- Index
- » Users
- » Arne
- » Profile
Posts
Posts
Hello,
I want to perform some simple calculations concerning a CO2 heatpump. For this I will need to calculate the fluid properties of the CO2 medium. The Modelica standard library doesn't have this, has only ideal gas model. For the calculations the user has two specify two properties of the following list: temperature, pressure, density, enthalpy or entropy.
In what Open source Modelica library can I find such a media model?
Hello,
I am currently tasked with implementing the functionality of an Excel tool into a format which protects the intelectual property.
The model would basically entail the above roof piping of a solar thermal collector groep and beneath roof heat exchanger and thermal buffer. The user should be taken by the hand so as to be easily determine the number of collectors, piping lengths, pump needed etc... In the Excel tool this is done by asking the user to fill in properties spread over multiple tabs.
I am a huge fan of Modelica and would like to use it as the principal tool to implement the representative model. But it's not clear to me how to hide the implementation of this model.
Would it be an idea to export this model as an FMI model? But than how to preceed further? Can the UI be done in Phyton/C# which inputs and outputs are communicated to the FMI model. How to simulate the model?
Is there perhaps some example somewhere?
Thank you in advace,
Arne Sinnema
Hello,
I try to open the ThermoPower library package, but I get the following error:
[57] 11:45:36 Grammar Error
[D:/Documents/SUNRAIN/ModelicaCode/ThermoPower2.1-MSL2.2.2/ThermoPower/Choices.mo: 1:1-217:12]: Expected the package to have within ThermoPower; but got within ;.
[58] 11:45:36 Scripting Error
Failed to load package ThermoPower () using MODELICAPATH D:\Documents\SUNRAIN\ModelicaCode\ThermoPower2.1-MSL2.2.2\;C:/OpenModelica1.9.3Nightly/lib/omlibrary.
Not sure how I can open the package.
Okay added a new ticket.
https://trac.openmodelica.org/OpenModelica/ticket/3245
Actually this bug is preventing my model from running, say if I baked you guys a nice cake could you fix this one first .
Hello,
I already sent an email to Lennart's email, but I also put the bug report here.
OMEdit crashes when a record parameter is set in a function, it looks very similar to bug 3082 which is fixed.
PS I have difficulties uploading the .mo file so I pasted it below.
Regards, Arne
model TestRecord
function setRecordFunction
output Real[3] y;
protected
Rec[3] x;
algorithm
for i in 1:3 loop
x[i].r := i;
y[i] := x[i].r;
end for;
end setRecordFunction;
record Rec
Real r;
end Rec;
model CallRecordFunction
Real[3] y;
//Real[4] y2;
equation
y = setRecordFunction();
//y2 = setRecordFunction2(4);
end CallRecordFunction;
function setRecordFunction2
input Integer N;
output Real[N] y;
protected
Rec[N] x;
algorithm
for i in 1:N loop
x[i].r := i;
y[i] := x[i].r;
end for;
end setRecordFunction2;
end TestRecord;
Hello,
I got this error when I connected several block diagrams together including equation and algorithm sections.
Is there anything I can do here?
Below the Error message:
[1] 14:54:31 Translation Error
[CodegenC.tpl: 7200:11-7200:11]: Template error: tupleReturnVariableUpdates: Unhandled expression. {$TMP_otsg1$Pd$rB1$lB_1, $TMP_otsg1$Pd$rB2$lB_1, $TMP_otsg1$Pd$rB3$lB_1, $TMP_otsg1$Pd$rB4$lB_1, $TMP_otsg1$Pd$rB5$lB_1, $TMP_otsg1$Pd$rB6$lB_1, $TMP_otsg1$Pd$rB7$lB_1, $TMP_otsg1$Pd$rB8$lB_1, $TMP_otsg1$Pd$rB9$lB_1, $TMP_otsg1$Pd$rB10$lB_1, $TMP_otsg1$Pd$rB11$lB_1, $TMP_otsg1$Pd$rB12$lB_1, $TMP_otsg1$Pd$rB13$lB_1, $TMP_otsg1$Pd$rB14$lB_1, $TMP_otsg1$Pd$rB15$lB_1, $TMP_otsg1$Pd$rB16$lB_1, $TMP_otsg1$Pd$rB17$lB_1, $TMP_otsg1$Pd$rB18$lB_1, $TMP_otsg1$Pd$rB19$lB_1, $TMP_otsg1$Pd$rB20$lB_1, $TMP_otsg1$Pd$rB21$lB_1, $TMP_otsg1$Pd$rB22$lB_1, $TMP_otsg1$Pd$rB23$lB_1, $TMP_otsg1$Pd$rB24$lB_1, $TMP_otsg1$Pd$rB25$lB_1, $TMP_otsg1$Pd$rB26$lB_1, $TMP_otsg1$Pd$rB27$lB_1, $TMP_otsg1$Pd$rB28$lB_1, $TMP_otsg1$Pd$rB29$lB_1, $TMP_otsg1$Pd$rB30$lB_1, $TMP_otsg1$Pd$rB31$lB_1, $TMP_otsg1$Pd$rB32$lB_1, $TMP_otsg1$Pd$rB33$lB_1, $TMP_otsg1$Pd$rB34$lB_1, $TMP_otsg1$Pd$rB35$lB_1, $TMP_otsg1$Pd$rB36$lB_1, $TMP_otsg1$Pd$rB37$lB_1, $TMP_otsg1$Pd$rB38$lB_1, $TMP_otsg1$Pd$rB39$lB_1, $TMP_otsg1$Pd$rB40$lB_1, $TMP_otsg1$Pd$rB41$lB_1, $TMP_otsg1$Pd$rB42$lB_1, $TMP_otsg1$Pd$rB43$lB_1, $TMP_otsg1$Pd$rB44$lB_1, $TMP_otsg1$Pd$rB45$lB_1, $TMP_otsg1$Pd$rB46$lB_1, $TMP_otsg1$Pd$rB47$lB_1, $TMP_otsg1$Pd$rB48$lB_1, $TMP_otsg1$Pd$rB49$lB_1, $TMP_otsg1$Pd$rB50$lB_1, $TMP_otsg1$Pd$rB51$lB_1, $TMP_otsg1$Pd$rB52$lB_1, $TMP_otsg1$Pd$rB53$lB_1, $TMP_otsg1$Pd$rB54$lB_1, $TMP_otsg1$Pd$rB55$lB_1, $TMP_otsg1$Pd$rB56$lB_1, $TMP_otsg1$Pd$rB57$lB_1, $TMP_otsg1$Pd$rB58$lB_1, $TMP_otsg1$Pd$rB59$lB_1, $TMP_otsg1$Pd$rB60$lB_1, $TMP_otsg1$Pd$rB61$lB_1}
[2] 14:54:31 Translation Error
No system for the symbolic initialization was generated.
[3] 14:54:31 Translation Notification
The given system is mixed-determined. [index > 3]
[4] 14:54:31 Translation Notification
The given system is mixed-determined. [index > 2]
[5] 14:54:31 Translation Notification
The given system is mixed-determined. [index > 1]
[6] 14:54:31 Translation Notification
The given system is mixed-determined. [index > 0]
[7] 14:54:31 Translation Error
Internal error BackendDAEUtil.getAdjacencyMatrixEnhancedScalar failed
[8] 14:54:31 Translation Error
Internal error BackendDAE.adjacencyRowEnhanced failed for eqn: algorithm if otsg1.useM_flow then otsg1.m_flow := pipemodel1.p[1]; (otsg1.dp_total, pipemodel1.T[1], otsg1.p_out, otsg1.d) := SunrainModels.SolarSteamGenerator.OTSGfunction(0, 60, /*Real*/(otsg1.N_serie), /*Real*/(otsg1.N_branch), otsg1.A_col, otsg1.eta0, otsg1.a1, otsg1.a2, otsg1.b1, otsg1.b2, otsg1.m_flow, pipemodel2.T[21], pipemodel2.p[21], constant3.k, constant2.k); otsg1.p_outORm_flow := otsg1.p_out; else otsg1.p_out := pipemodel1.p[1]; otsg1.dp_total := pipemodel2.p[21] - otsg1.p_out; if initial() then otsg1.m_flow_g := otsg1.m_flow_start; else otsg1.m_flow_g := pre(otsg1.m_flow); end if; for i in 1:10 loop otsg1.count1 := 1 + otsg1.count1; (otsg1.dp_total_ref, pipemodel1.T[1], otsg1.p_out_calculated, otsg1.d) := SunrainModels.SolarSteamGenerator.OTSGfunction(0, 60, /*Real*/(otsg1.N_serie), /*Real*/(otsg1.N_branch), otsg1.A_col, otsg1.eta0, otsg1.a1, otsg1.a2, otsg1.b1, otsg1.b2, otsg1.m_flow_g, pipemodel2.T[21], pipemodel2.p[21], constant3.k, constant2.k); otsg1.a := 0.0; for i in 1:60 loop otsg1.a := otsg1.a + 1.0 / otsg1.d[i]; end for; otsg1.a := 0.01666666666666667 * otsg1.a * /*Real*/(otsg1.N_serie) / /*Real*/(otsg1.N_branch); otsg1.b := otsg1.b2 * otsg1.a / /*Real*/(otsg1.N_branch); otsg1.a := otsg1.b1 * otsg1.a; for k in 1:10 loop otsg1.count2 := 1 + otsg1.count2; otsg1.m_flow := (otsg1.dp_total - otsg1.m_flow_g * (otsg1.a + otsg1.b * abs(otsg1.m_flow_g))) / (otsg1.a + 2.0 * otsg1.b * abs(otsg1.m_flow_g)) + otsg1.m_flow_g; otsg1.eps2 := abs(otsg1.m_flow - otsg1.m_flow_g); otsg1.m_flow_g := otsg1.m_flow; end for; otsg1.count2ks := otsg1.count2; otsg1.count2 := 0; otsg1.eps1 := abs(otsg1.dp_total - otsg1.m_flow * (otsg1.a + otsg1.b * abs(otsg1.m_flow))); end for; otsg1.count1ks := otsg1.count1; otsg1.count1 := 0; otsg1.p_outORm_flow := otsg1.m_flow; end if;
TestForLoop.mo
Sorry to bother your tennis game again... ;-)
If I 'wrap' the working code into a function and then call this function from the model than it does run as it should.
Aha, okay yes that works. Thanks for the (very) quick reply. Don't you guys sleep in Sweden? ;-)
WhileLoopBug.mo
Hello,
The following code fragment runs but I do not understand the result. I would expect countks to be constant 10 and count to be constant 0. Instead countks is 11 at the beginning and end and zero everywhere else.
model WhileLoopBug
Real count;
Real countks;
algorithm
count := 0;
while count < 10 loop
count := count + 1;
end while;
countks := count;
count := 0;
end WhileLoopBug;
ForLoopBug.mo
Hello,
If I'm not very mistaken this should just run:
model ForLoopBug
parameter Integer N = 1;
parameter Real p_in = 2e5;
Real[N + 1] p;
Real[N] dp;
algorithm
p[1] := p_in;
for i in 1:N loop
dp[i] := 10;
p[i + 1] := p[i] - dp[i];
end for;
end ForLoopBug;
I get the following error:
error: 'INTEGER_ATTRIBUTE' has no member named 'nominal'
Can someone tell me what this means? Two block models alone run fine, but then when I interconnect these two block models I get this error message.
Below is the complete error message.
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.2Nightly//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o MyProblem.Test_03lsy.o MyProblem.Test_03lsy.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.2Nightly//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o MyProblem.Test_04set.o MyProblem.Test_04set.c
MyProblem.Test_02nls.c: In function 'initializeStaticNLSData171':
MyProblem.Test_02nls.c:2905: error: 'INTEGER_ATTRIBUTE' has no member named 'nominal'
MyProblem.Test_02nls.c:2989: error: 'INTEGER_ATTRIBUTE' has no member named 'nominal'
MyProblem.Test_02nls.c:3045: error: 'INTEGER_ATTRIBUTE' has no member named 'nominal'
MyProblem.Test_02nls.c:3381: error: 'INTEGER_ATTRIBUTE' has no member named 'nominal'
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.2Nightly//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o MyProblem.Test_05evt.o MyProblem.Test_05evt.c
MyProblem.Test_02nls.c: In function 'initializeStaticNLSData336':
MyProblem.Test_02nls.c:9229: error: 'INTEGER_ATTRIBUTE' has no member named 'nominal'
MyProblem.Test_02nls.c:9285: error: 'INTEGER_ATTRIBUTE' has no member named 'nominal'
MyProblem.Test_02nls.c:9393: error: 'INTEGER_ATTRIBUTE' has no member named 'nominal'
MyProblem.Test_02nls.c:9501: error: 'INTEGER_ATTRIBUTE' has no member named 'nominal'
mingw32-make: *** [MyProblem.Test_02nls.o] Error 1
mingw32-make: *** Waiting for unfinished jobs....
Compilation process exited with code 2
Hello,
I have a probably quite basic question. That is how to obtain the value of a continuous time variable in the previous state-event (for a variable time integration algorithm). I.e. how to obtain the last calculated value for a continuous time variable?
See below for the explanation and an example code.
See in the accompanying code the ImplicitExplicit model for a rough outline of my problem. In this code the pressure drop over one branch is determined as a function of the mass-flow rates in N pipe-segments. If the Boolean value calcExplicit is set to true then the friction pressure drop dp_f depens on der(M) which in turn depends on der(U). Therefore the entering mass-flow rate mflows[1] needs to be determined iteratively. When there are multiple branches than computational times increase even more. Since also the flow distribution over multiple branches needs to be determined.
Now I’m planning to reduce computational time by disconnecting the mass and energy balances from the pressure drop calculation (by setting the Boolean value calcExplicit to false).
However I’m puzzled how to implement this. I would appreciate some pointers in the right direction.
Regards, Arne
model ImplicitExplicit
parameter Boolean calcExplicit
"if true than dp_f is no longer influenced by the mass and energy balances";
parameter Integer N = 10;
parameter Real L = 1;
parameter Real D = 0.025;
parameter Real T_in = 300;
//parameter Real m_flow_in = 1;
parameter Real p_in = 1e6;
parameter Real p_out = 0;
parameter Real Q_flow = 1000;
parameter Real R = 1e6;
Real[N+1] T(each start=500);
Real[N+1] rho;
Real[N+1] h;
Real[N] M;
Real[N] U;
Real[N] dMdt;
//Real h_A;
Real[N+1] m_flows;
Real[N] dp_f;
Real[N+1] m_flows_exp "approximated mass flow rates";
Real[N+1] rho_exp "density in the previous event";
Real[N] dMdt_exp "derivate of the mass flow rates in the previous time instant";
protected
parameter Real A = 0.25*Modelica.Constants.pi*D^2;
parameter Real V = A*L;
equation
// boundary conditions
T[1] = T_in;
// EXTRA CODE
m_flows_exp[1]=m_flows[1];
rho_exp[1] = rho[1];
for i in 1:N loop
dMdt_exp[i] = m_flows_exp[i] - m_flows_exp[i+1];
if calcExplicit then
dMdt_exp[i] = der(M[i]); // How to obtain the value of dMdt as calculated in the previous time event
rho_exp[i+1] = rho[i+1]; // ...
else
dMdt_exp[i] = pre(dMdt[i]); // THIS DOES NOT WORK ?????????;
rho_exp[i+1] = pre(rho[i]); // THIS DOES NOT WORK ?????????;
end if;
end for;
// calculations
dMdt = der(M);
for i in 1:N+1 loop
rho[i] = 2090 - 0.636*T[i];
h[i] = 1443*T[i] + 0.172/2*T[i]^2;
end for;
for i in 1:N loop
M[i] = rho[i+1]*V;
U[i] = M[i]*h[i+1];
der(M[i]) = m_flows[i] - m_flows[i+1];
der(U[i]) = m_flows[i]*h[i] - m_flows[i+1]*h[i+1] + Q_flow;
dp_f[i] = Modelica.Fluid.Pipes.BaseClasses.WallFriction.Detailed.pressureLoss_m_flow(
m_flows_exp[i],
rho_exp[i],
rho_exp[i],
0.035,
0.035,
L,
D,
0.04/1000);
//dp_f[i] = sign(m_flows[i+1])*R*m_flows[i+1]^2;
end for;
p_out = p_in - sum(dp_f);
annotation ();
end ImplicitExplicit;
Thanks, indeed the latest version of OpenModelica compiles the model.
Hello,
I'm trying to run a rather large model (with aproximately 11000 equations.), after a while the compiler runs out of the 4GB of memory and quits, in the log file the following message is shown.
cc1.exe: out of memory allocating 16008 bytes
mingw32-make: *** [MyModels.someModel.o] Error 1
Is there a way to get the model running other than installing more memory?
Regards,
Arne Sinnema
Hello Adrian Pop,
I've changed the code slightly and fixed the start values all test models now run in Dymola and all initial conditions (according to Dymola are specified) nevertheless the test models do not run (correctly) in OpenModelica. Can I send you my models (what is your email adress?), it is (somewhat) confidential therefore I would like to send it to you personally.
Regards,
Arne Sinnema
Hello,
I have diffuculties running a discrete model with OpenModelica (Version 2013-09-16 1.9.0), the model is basically a translation from a Simulink model which is completely explicit. Therefore I would not expect initialization difficulties however OpenModelica using the Euler integration scheme, gives the following warning.
LOG_INIT | Warning | try -ils to activate start value homotopy.
The model is basically characterized by a algorithm section which is the main body and a small equation body.
initial equation
h_out_new = NEM_models.Functions.ms_propertyies.ms_property_h_T(T_0);
equation
sampleTrigger = sample(t_start, dt);
when sampleTrigger then
h_out = pre(h_out_new);
firstTrigger = time <= t_start + dt/2;
end when;
algorithm
... rest of the code
The model runs in Dymola.
I’ve tried to help the solver by setting h_out(start=...) but this doesn't help.
I would very much appreciate it if someone can give me some pointers how to help the solver to find the initial solution.
That's a bummer
Today I downloaded the latest OpenModelica (revision 13047) and removed the older version (which had the same problem).
When I create a new Model in a package it doesn't get saved. I have tried to save everything (select the model, press save, select the package which contains the model, press save, etc...) but. When I close OpenModelica and restart it the model is gone. Everytime I press save I get the message: The Model '......' is contained inside a package. It is automatically saved when you save the package.
For example we have the following code:
package PleaseDontThrowAway
model Test1
parameter Real aVariable;
end Test1;
end PleaseDontThrowAway;
Then after closing and reopening we get:
package PleaseDontThrowAway
end PleaseDontThrowAway;
Sometimes however the save does work, then OpenModelica will also ask with what name to save and then I don't get the previous message.
I performed the following action
- I deinstalled Dymola, still the same problem.
- I restarted the computer
- I removed and reinstalled the latest version of OpenModelica (revision 13047)
Hope this is helpfull.
Regards Arne
Well it originates from Europe of course and it seems that it only very slowly spreads around. In Holland for example, at least at my university the TUDelft they still don't teach it (Although there were plans.). So still questionable if Modelica will really break through and become the new standard altough I think it should.
Hi,
My model uses inputs which constitute measured temperatures. These measured temperatures (of the real system) are samples every 30s which means that the temperature is average over 30s. This however poses some problem since the highest peak temperature and lowest valley temperature are needed (to trigger an on/off controller).
Thus I have to somehow un-average the temperature input signals, i.e. the dT/dt of the sampled signal should be incorporated.
This can probably be done with an PID controller but what values for the P, I and D?
Arne
Yes solvers often have difficulties whith these instanteneous switches, best is to use smooth switches such as the Modelica.Fluid.Utilities.regStep function or the spliceFunction from the Buildings library (http://simulationresearch.lbl.gov/modelica).
Good luck with it.
Arne
function spliceFunction
input Real pos "Argument of x > 0";
input Real neg "Argument of x < 0";
input Real x "Independent value";
input Real deltax "Half width of transition interval";
output Real out "Smoothed value";
protected
Real scaledX;
Real scaledX1;
Real y;
algorithm
scaledX1 := x/deltax;
scaledX := scaledX1*Modelica.Math.asin(1);
if scaledX1 <= -0.999999999 then
y := 0;
elseif scaledX1 >= 0.999999999 then
y := 1;
else
y := (Modelica.Math.tanh(Modelica.Math.tan(scaledX)) + 1)/2;
end if;
out := pos*y + (1 - y)*neg;
annotation (smoothOrder=1,derivative=BaseClasses.der_spliceFunction);
end spliceFunction;
- Index
- » Users
- » Arne
- » Profile