openmodelica

Modelica array of partial model

风格不统一 提交于 2019-12-12 06:10:01
问题 Let A be a partial model and C , D be models which extend A . Given a model partial model X A a[3]; end X; how can I instantiate X, e.g. something along the lines of A X.a = {C,D,C}; Update : I tried 2 variants. One is package P partial model A end A; model B extends A; end B; model C extends A; end C; partial model X A a[3]; end X; model Y extends X(a={c,b,c}); B b; C c; end Y; end P; which fails with the warning "May only set inputs, parameters, and variables with default, but modified a."

OpenModelica and JModelica deliver significantly different results

孤人 提交于 2019-12-11 15:34:43
问题 Following this question, I'm trying to compare the results of the simulation between JModelica and OpenModelica. The Modelica file is identical to the above-mentioned post and the JModelica wrapper is the corrected version: #%% from pymodelica import compile_fmu from pyfmi import load_fmu import matplotlib.pylab as plt #%% model_name = 'friction1D.fricexample_1' mofile = 'friction1D.mo' #%% fmu_name = compile_fmu(model_name, mofile) sim = load_fmu(fmu_name) #%% opts = sim.simulate_options()

Error due to delay operator in algorithm section

核能气质少年 提交于 2019-12-11 12:40:11
问题 I have implemented a delay operator in algorithm section of a class as shown in the test case below, but during the execution of the codes in Open modelica, I face the below error. how can I fix the problem? model test3 Real x=sin(377*time); Real z; parameter Real tau[:]={0.01,0.02}; equation algorithm for k in 1: 2 loop z:=delay(x,tau[k]); end for; end test3; 回答1: Looks like a tool issue. On the other hand, why would you calculate z for k=1 and never use it? 回答2: Like tbeu said in his answer

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 =

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) :=

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

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

Modelica output file during simulation

 ̄綄美尐妖づ 提交于 2019-12-11 01:19:23
问题 I am making simulations for long times and I need to check the output when the simulation is continuing. Another reason is that I am doing real-time simulation so I want to see the output in real-time as well. That would be perfect if OpenModelica creates an output file during the simulation so that I can read and plot it using 3rd party tools, maybe Python. So far as I know, OpenModelica creates output file only at the end of the simulation. Is there a way to create an output file using a

matrix singular under determined linear system not solvable

我的未来我决定 提交于 2019-12-11 00:59:07
问题 Following this question, I modified my code to: model test // types type Mass = Real(unit = "Kg", min = 0); type Length = Real(unit = "m"); type Area = Real(unit = "m2", min = 0); type Force = Real(unit = "Kg.m/s2"); type Pressure = Real(unit = "Kg/m/s2"); type Torque = Real(unit = "Kg.m2/s2"); type Velocity = Real(unit = "m/s"); type Time = Real(unit = "s"); // constants constant Real pi = 2 * Modelica.Math.asin(1.0); parameter Mass Mp = 0.01; parameter Length r1 = 0.010; parameter Length r3