modelica

How do I gate a when statement in Modelica to limit time event generation?

强颜欢笑 提交于 2019-12-11 08:43:32
问题 Suppose that I'd like to model an alarm clock that produces 10 beeps (one per second) every morning at 01:00: model DailyBeep import SI = Modelica.SIunits; import Modelica.SIunits.Conversions.*; constant SI.Time oneDay = 86459.17808 "one day in seconds"; parameter SI.Time startTime = from_hour(1) "time to start beeping"; parameter Real numBeeps = 10 "the number of beeps to make"; Boolean beeping "true when we should beep every second"; Real beepsRemaining "the number of beeps remaining";

Limit tank flow when level <= 0 in Modelica

时光毁灭记忆、已成空白 提交于 2019-12-11 06:47:22
问题 I have a model of a tank that I am creating as follows: model Tank "Simple model of a tank" parameter Real volume=1 "tank volume (m^3)"; parameter Integer num_ports=1 "Number of ports"; parameter Real static_pressure=1 "Internal Tank Pressure"; parameter Real initial_level = 0; Stream[num_ports] ports "Stream Connectors"; Real level "Level in % 0-100"; protected Real vol "Volume of medium in the tank"; Real pressure(start=static_pressure) "Pressure inside the tank"; initial equation level =

FMU Variable Values Do Not Match Input

情到浓时终转凉″ 提交于 2019-12-11 06:42:34
问题 I'm getting some strange behavior in a simple co-simulation that I'm trying to configure. I setup a building energy model in EnergyPlus to test out an FMU generated from JModelica. However, the building energy model would get hung up at the co-simulation step. I then ran the FMU in JModelica and got some very strange results. The Modelica code is: model CallAdd input Real FirstInput(start=0); input Real SecondInput(start=0); output Real FMUOutput(start=0); function CAdd input Real x(start=0);

getting the Translation Error Class not found when tryin gto generate random variable

◇◆丶佛笑我妖孽 提交于 2019-12-11 06:28:10
问题 I'm trying to follow this example to generate a random function of time: model testData extends Modelica.Icons.Example; parameter Real k = 1.0; Real theta1; Real theta2; parameter Real tau = 1.0; parameter Modelica.SIunits.Period samplePeriod = 0.05; parameter Integer globalSeed = 30020; output Real omega1; algorithm when initial() then state1024 := Generators.Xorshift1024star.initialState(localSeed, globalSeed); omega1 := 0; elsewhen sample(0,samplePeriod) then (omega1,state1024) :=

Modelica: how to use replaceable components?

风流意气都作罢 提交于 2019-12-11 04:17:17
问题 I am trying to build a model that can use two different components (taken from an existing library) for the same scope: in particular a system with an heat exchanger; this heat exchanger can be based on different technologies, e.g. pipes or plates. I want then define a model with a default replaceable exchanger and say which other technologies may be used. This is a vey simple exemple of what I tried: package Test // Component 1 original definition in the library model COMP1 parameter Real p1

Why do q_nom & head_nom always give issues for models built from ThermoPower Library?

微笑、不失礼 提交于 2019-12-11 04:13:57
问题 I've been working within the ThermoPower Library of OpenModelica for a while now trying to build a Combined Power Cycle by first modeling the Brayton and Rankine Power Cycles first. Every time I attempt to use a pump, I always receive errors like: [1] 10:31:00 Translation Error [ThermoPower.Examples: 2523:70-2523:81]: Variable q_nom not found in scope ThermoPower.Examples.RankineCycle.Models. [2] 10:31:00 Translation Error [ThermoPower.Examples: 2531:21-2531:69]: Cyclically dependent

Dymola solving stationary equation systems for Media-Model

纵饮孤独 提交于 2019-12-11 03:59:28
问题 I'm building a Media-Library in Dymola similar to Helmholtz-Media but for Ammonia+Water, a mixture. You get a lot of not explicitly solvable equations. Because of the structure of the Media and Fluid libraries in Modelica I need to be able to get my thermodynamic state from p, h and x. The state-vector consists of d, T, and x. This is a simple example how to get the state-vector: model getState_phX parameter AbsolutePressure p = 500000 "pressure"; parameter SpecificEnthalpy h = 2500000

Extract Types/Classnames from flat Modelica code

北慕城南 提交于 2019-12-11 03:37:21
问题 I was wondering if there already exists a possibility to extract from flat Modelica code all variables AND their corresponding types (classnames respectively). For example: Given an extract from a flattened Modelica model: constant Integer nSurfaces = 8; constant Integer construction1.nLayers(min = 1.0) = 2 "Number of layers of the construction"; parameter Modelica.SIunits.Length construction1.thickness[construction1.nLayers]= {0.2, 0.1} "Thickness of each construction layer"; Here, the

Modelica Evaluation Order

无人久伴 提交于 2019-12-11 03:34:17
问题 I can't really find any answer in the Modelica specification so ill ask you guys. The specification states that A tool is free to solve equations, reorder expressions and to not evaluate expressions if their values do not influence the result (e.g. short-circuit evaluation of Boolean expressions). If-statements and if-expressions guarantee that their clauses are only evaluated if the appropriate condition is true, but relational operators generating state or time events will during continuous

Modelica arrays with unspecified dimension

柔情痞子 提交于 2019-12-11 03:19:03
问题 Given a model with an array x of connectors where its size is unspecified, e.g. connector con ... end con; model test con x[:]; end test; How can x be instantiated with a specific size, e.g. something like this? test t(x = ?); ... equation connect(t.x[1], a); connect(t.x[2], b); ... 回答1: Why do you need unspecified dimension? You can do something like this: connector con ... end con; model test constant Integer dim = 1; con x[dim]; end test; // usage test(dim = 10); ... equation connect(t.x[1