modelica

Abstract switch in Modelica

青春壹個敷衍的年華 提交于 2019-12-12 16:07:29
问题 I would like to motivate a question I asked before about a Modelica array of partial model. Consider the following model of a switch between 2 controllers. model Switch input Real u; input Integer sel; output Real y; protected Real x; equation if sel == 1 then y = 0.1 * (0 - u); der(x) = 0; else y = 0.1 * (0 - u) + 0.2 * x; der(x) = 0 - u; end if; end Switch; Let's ignore the fact that the PI controller may break when it is not selected for some time due to divergence of x . This can be fixed

Setting up Jupyter Notebook for JModelica

你。 提交于 2019-12-12 09:43:13
问题 I would like to use Jupyter Notebook for editing JModelica python scripts; however after installing, the Jupyter notebook cannot locate key libraries, such as pymodelica. Here is the process I followed to install Jupyter Notebook for JModelica Version 2.1: In the IPython terminal: !pip install jupyter In windows CMD I navigate using cd C:\JModelica.org-2.1\Python27\Scripts I then open using jupyter notebook Within the notebook I create a Python 2 file and attempt to import the pymodelica

Modelica Flow Simulation says divide by zero

故事扮演 提交于 2019-12-12 06:55:44
问题 I am trying to simulate the flow in a pipe that starts out partially full, and gradually fills up. Once it is full, the flow equation needs to change. I have tried the following code, but I get a divide by zero error once the pipe is full. TestTrap1 is a demo that shows the problem. It seems that some equation is not correct once the pipe is full. I am using openmodelica to run this. package FlowPackage package Interfaces extends Modelica.Icons.InterfacesPackage; //Use this for a inlet outlet

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."

When and If in Modelica

扶醉桌前 提交于 2019-12-12 04:43:51
问题 Hi I have some puzzles about event and when in Modelica. Below is my code: model test Integer bar(start=5, fixed=true); equation when (time < 2) then bar = 1; end when; annotation(experiment(StopTime=3)); end test; My question is why I got 5 instead of 1 when time is less than 2? How can I understand the event(time < 2) in this case? What is the difference of when clause in Modelica and other programming language, like c. 回答1: Tobias' answer is correct. But I think for beginners it might be 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()

Assignment problems with simple random number generation in Modelica

守給你的承諾、 提交于 2019-12-11 12:41:26
问题 I am relatively new to Modelica (Dymola-environment) and I am getting very desperate/upset that I cannot solve such a simple problem as a random number generation in Modelica and I hope that you can help me out. The simple function random produces a random number between 0 and 1 with an input seed seedIn[3] and produces the output seed seedOut[3] for the next time step or event. The call (z,seedOut) = random(seedIn); works perfectly fine. The problem is that I cannot find a way in Modelica to

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

pyFMI parameter change don't change the simulation output

▼魔方 西西 提交于 2019-12-11 12:25:52
问题 I'm changing the initial 2 parameter values (over the range of possible values) with pyFMI and simulate the model response I can see that my response is affected only by 1 variable change and not by the other but if I simulate the model only with the second variable (that is not changing in inital simulations) I can clearly see the effect on the model response. model.reset() model=load_fmu('Series_0Resistance.fmu') tstart = model.get_default_experiment_start_time() #### start time of the

Update Modelica standard Library in Dymola in Linux

痴心易碎 提交于 2019-12-11 08:58:10
问题 I am using Dymola in Linux. Recently I find I need to update the Modelica standard library from 3.2 to 3.2.1(Got from github). Anyone knows what I need to set up such that Dymola starts with Modelica 3.2.1? Thanks a lot 来源: https://stackoverflow.com/questions/23792259/update-modelica-standard-library-in-dymola-in-linux