Skip to content

Quick Tips

Scott G edited this page Dec 19, 2022 · 12 revisions

Beginner TRANSFORM Modeling Tips

  1. Connecting Components Together: "Flow" vs "States"(i.e., "non-flows")

    • Make sure you are alternating flows and states
    • A “flow” is usually indicated by a filled circle. Flows are valves, resistances, velocities, mass flow rates, etc.
    • A “state” is usually indicated by an open circle (or a filled circle with another circle around it for GenericPipes). States are, well, states like pressure, enthalpy, temperature, etc.
    • You may be familiar with pressure-velocity coupling numeric schemes like SIMPLE, SIMPLER or SIMPLEC and others that appear in other dynamic fluid systems codes. If you aren’t, I would suggest you read about the reasons behind state/flow alternation.
    • If your model is having problems, check for state/flow alternation. You can determine whether a port is a state or flow by floating over it in the GUI, or doing a right-click “Open Class in New Tab”.
    • This open/closed circle alternation also applies to other types of systems (notably heat transfer systems). You will now be on the lookout for it. It’s not just for aesthetics, there is a numerical purpose.
  2. Small Volumes and Resistances for Numerical Assistance to the Solver

    • When having problems try adding small volumes or resistances. This helps break non-linear terms (see below).
  3. Non-Linearities and Numerical Jacobians

    • Avoid non-linear terms and numerical Jacobians. You can see how many non-linear terms you have when doing a Translation. Check the Logs>Translation>Statistics. You want to see something like:

      Sizes of linear systems of equations: {​​​​​​​​​2, 2}​​​​​​​​​
      Sizes after manipulation of the linear systems: {​​​​​​​​​0, 0}​​​​​​​​​
      Sizes of nonlinear systems of equations: {​​​​​​​​​ }​​
      Sizes after manipulation of the nonlinear systems: {​​​​​​​​​ }​​​​​​​​​
      Number of numerical Jacobians: 0
      
    • If you have non-linear terms there will be another drop down thing that tells you which variables are part of the non-linear systems.

    • You may also see a separate set of “sizes” for the initialization problem.

    • Sometimes non-linear terms are inevitable/desirable. For example, when using steady-state initialization, non-linear terms are often a necessity. You can still use these diagnostics to minimize the number of non-linear terms in your initialization problem.

    • If you have non-linear terms and you cannot see what they are, you may need to turn on Simulation>Setup>Translation>List non-linear iteration variables.

  4. Check the initial conditions.

    • Default initial conditions can be quite bad.
    • The DynamicFreeInitial choice mostly uses your input. However, it sometimes will change things if it determines some kind of numeric conflict (like what I mentioned earlier about the reason for your crashing).
    • You can try using the SteadyState initialization options. These can be quite handy, however they often only work for smaller models.
  5. Learn how to use a PID controller and the Parameter Sweep feature to help you tune models

    • PID controller combined with SteadyState initialization can help you determine where your model will settle and can be quite useful and time-saving.
    • Parameter Sweep (available in Simulation>Sweep Parameters) allows you to quickly explore things. Note you can only sweep “parameter”s which are specific type of time-invariant data. Sometimes you can need to go to the text view to see what things are parameters. You can also make dummy parameters and put them in as the value for an Input (“input” is a keyword for a time-dependent variable that is provided by the user).

Dymola Flags

  • If Dymola models with lots of components are slowing the GUI down: Hidden.CachedImagePaint=true

  • Simulations with large RAM requirements may be handled with: Advanced.CompileWith64 = 2

  • Dark Mode: On the shortcut to Dymola, right click and got to "Properties". Then enter - dark at the end of "Target".

    image

Dymola Python Interface

List of Commands

  • Found in your Dymola installation folder.
    • e.g., C:\Program Files\Dymola 2021\Modelica\Library\python_interface\doc\genindex.html

Installation

Anaconda

Windows

  • In Explorer, go to your Anaconda path. Open the Anaconda prompt and enter where python to locate.
    • e.g., C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\Lib\site-packages
    • AppData is a "hidden" folder and can be seen by going to View and checking Hidden Items
  • Create a text file and rename to a reasonable name
    • e.g., dymola-python-interface.pth
    • When changing the text file extension you should see .txt. If that is not visible go to View and check File name extensions.
  • Open up dymola-python-interface.pth and add the path to the dymola.egg file. Save and close.
    • e.g., C:\Program Files\Dymola 2021\Modelica\Library\python_interface\dymola.egg
  • Open a new anaconda tool (e.g., jupyter notebook, terminal, or spyder) and dymola should now be able to be loaded.
    • import dymola

Dymola Scripting

Looping

d={.2,.4,.6,.8};
openModel("TRANSFORM.Blocks.Examples.EasingRamp_Test");
for i in 1:4 loop
  easingRamp.duration = d[i];
  translateModel("TRANSFORM.Blocks.Examples.EasingRamp_Test");
  simulate();
  //simulateExtendedModel("TRANSFORM.Blocks.Examples.EasingRamp_Test",initialNames={"easingRamp.duration"},initialValues={d[i]},finalNames={"easingRamp.y"});
  system("copy dsres.mat results"+String(i) +".mat");
end for;