4.4. Dymola

To configure a Modelica model that will be simulated by Dymola, you may modify the files in the directory BCVTB/examples/dymola-room, or you may create a new Modelica model. This section describes how to create a new Modelica model using the Dymola modeling and simulation environment. The configuration consists of creating a Modelica model, a Modelica script and a Ptolemy II model.

To create a new Modelica model, proceed as follows: First, open Dymola and the Buildings library, which may be downloaded from http://simulationresearch.lbl.gov/modelica . From the Buildings library, add the block Buildings.Utilities.IO.BCVTB.BCVTB to your model. Next, connect the bcvtb block to your other Modelica models to create a system model that takes signals from the bcvtb block and writes signals to the bcvtb block. This may yield a system model as shown in Figure 4.9 , which is the model in the file bcvtb/examples/dymola-room/TwoRoomsTotal.mo.


To configure the bcvtb interface, double-click on the bcvtb block that is shown in the left of the figure. This will open the input form shown in Figure 4.10 .


In this example, a vector with two double values are obtained from the BCVTB and written to the BCVTB every 60 seconds of simulation time. Additional information about this block can be obtained by pressing the Info button.

To perform a simulation, the BCVTB will call a batch file (on Windows) or a shell script (on Linux), which in turn calls Dymola to execute a Modelica script that opens and simulates the model. The batch file or shell script is stored in the directory bcvtb/bin and need not be changed by the user. To create the Modelica script, adjust the following three lines as needed and save them in a file called simulateAndExit.mos:

openModel("TwoRoomsTotal.mo");
simulateModel("Buildings_Utilities_IO_BCVTB_Examples_TwoRooms", stopTime=21600);
exit();

To start Dymola from Ptolemy II, a Ptolemy II model will need to be created. The model BCVTB/examples/dymola-room/system-windows.xml shown in Figure 4.11 may be used as a starting point.


In this model, the Simulator actor that calls Dymola is configured as shown in Figure 4.12 .


The batch file runDymola.bat (on Windows) or the shell script runDymola.sh (on Linux) will copy the binary and header files that are required by Dymola. If either dymosim.exe (or dymosim on Linux) or dsin.txt do not exist in the current directory, then the batch file starts Dymola, translates and simulates the model. Otherwise, the batch file will call dymosim -s to simulate the model.