modelica

conditional component declaration and a following if equation

风格不统一 提交于 2019-12-30 08:31:14
问题 I am trying to build a model that will have slightly different equations based on whether or not certain components exist (in my case, fluid ports). A code like the following will not work: parameter Boolean use_component=false; Component component if use_component; equation if use_component then component.x = 0; end if; How can I work around this? 回答1: If you want to use condition components, there are some restrictions you need to be aware of. Section 4.4.5 of the Modelica 3.3 specification

Two-Phase Modelica Media example

こ雲淡風輕ζ 提交于 2019-12-30 07:18:06
问题 I am trying to develop a simulation in OpenModelica of a flow that has a single substance that will be liquid or vapor. The Modelica.Media.Water models do have two phases, but are extremely complicated, and would be very hard to reproduce for a completely different substance. I would like to find a simple example of a two phase medium that I can work from. There is a partial package TemplateMedium and a partial package PartialTwoPhaseMedium, but I don't see any examples of how to write a

How are the data types in dsin.txt defined?

自闭症网瘾萝莉.ら 提交于 2019-12-24 12:26:30
问题 I am currently developing a python interface for running Modelica simulations using Dymola and I can't find any documentation on the data types used in the dsin.txt file : ... 0 0 0 0 4 328 # timeToEmpty -1 0 0 100 2 272 # level 0 0 0 0 3 256 # der(level) -1 10 0 0 1 280 # initialFlowRate 0 0 0 0 6 320 # flowRate ... There is some documentation inside the file itself, but it's not very helpful : ... # column 6: Data type of variable. # = 0: real. # = 1: boolean. # = 2: integer. ... As you can

Switch between two flanges

拥有回忆 提交于 2019-12-24 08:56:07
问题 I am currently working with multibody mechanical systems using the MultiBody library included in the standard Modelica distribution. I need to implement a switch between flanges, in order to select position or force control for a given joint. model FlangeSwitch "Switch between flanges" Modelica.Mechanics.Translational.Interfaces.Flange_a flange_a_1; Modelica.Mechanics.Translational.Interfaces.Flange_b flange_b_1; Modelica.Mechanics.Translational.Interfaces.Flange_a flange_a_2; Modelica

N-dimensional (linear) interpolation on external table in Modelica

泪湿孤枕 提交于 2019-12-24 00:14:47
问题 I would like to extend the functionality provided by Modelica Standard Library's types ExternalCombiTable1D and ExternalCombiTable2D , to implement an N-dimensional (linear) interpolation (with "N" up to at least 4, possibly getting up to 8) on external data tables (saved on txt data files). What would be the best way to do that? 回答1: You might wanna have a look at the current list of ideas for future extensions: https://github.com/modelica/Modelica/issues/1153 回答2: Dassault Systems has

use asserts for debugging Modelica

自古美人都是妖i 提交于 2019-12-23 05:11:20
问题 In Modelica, one could define a protected final constant Boolean debug and then use that in an assert statement to print out some values while debugging, similar to the code shown below (or as seen on github). In the final version, debug would then be set to false. Would that slow down the simulation or does the assert get eliminated, because debug is a constant? model debugexample parameter Real a; parameter Real b; Real sum; protected final constant Boolean debug = false "set to true while

OpenModelica: “Warning: maximal number of iteration reached but no root found” with conditional equation

天大地大妈咪最大 提交于 2019-12-20 05:32:58
问题 I am an OpenModelica beginner trying to model a DC/DC converter with constant voltage and current limiting. Basically the output is supposed to give a constant voltage until the maximum current is reached and then hold that current by reducing voltage. This is the equation part of my code so far: model DC_DC "Voltage source with current limiting" import SI = Modelica.SIunits; parameter SI.Voltage Vnom(start=1) "Value of nominal output voltage"; parameter SI.Current Inom(start=1) "Value for

OpenModelica: “Warning: maximal number of iteration reached but no root found” with conditional equation

只谈情不闲聊 提交于 2019-12-20 05:31:13
问题 I am an OpenModelica beginner trying to model a DC/DC converter with constant voltage and current limiting. Basically the output is supposed to give a constant voltage until the maximum current is reached and then hold that current by reducing voltage. This is the equation part of my code so far: model DC_DC "Voltage source with current limiting" import SI = Modelica.SIunits; parameter SI.Voltage Vnom(start=1) "Value of nominal output voltage"; parameter SI.Current Inom(start=1) "Value for

External Functions: Alternative Method to use .dll from a C-script

强颜欢笑 提交于 2019-12-20 04:16:26
问题 This is a companion question to External Functions: Reference headers in C-script to compiled dll. That stack overflow question is using a Modelica external function call to a c-script. That c-script then uses c-functions contained within a .dll. Below is the initial preferred method I had attempted and a working attempt that I do not prefer. Initial Attempt: The following code would not work. My assumption was since I loaded the .dll Library libgsl in Modelica I could then simply use headers

External Functions: Reference headers in C-script to compiled dll

倾然丶 夕夏残阳落幕 提交于 2019-12-20 02:01:18
问题 Using Dymola 2017. Case A) Calling an external c-script I have had success implementing simple external c functions that have no “# include <-->” statements: Modelica Function: function chirp input Modelica.SIunits.AngularVelocity w_start; input Modelica.SIunits.AngularVelocity w_end; input Real A; input Real M; input Real t; output Real u "output signal"; external "C" u=chirp(w_start,w_end,A,M,t) annotation(IncludeDirectory="modelica://ExternalFuncTest/Resources/Source/", Include="#include \