- Index
- » Users
- » Makumazan
- » Profile
Posts
Posts
Is it possible to set the outputInterval in OMEdit? outputInterval is in the document http://www.ida.liu.se/labs/pelab/modeli … System.pdf (page 24).
I have a very large output file, and I want to reduce it. Perhaps there is an alternative outputInterval in OMEdit?
Thank you in advance
sjoelund.se wrote:
Post the model (mos-script, not onb) to https://trac.openmodelica.org/OpenModelica/newticket
It seems even with Inline=false, in this instance the function is inlined and this causes a bad equation to be generated:
x := $_signNoNull($TMP$VAR$3$0X$ABS) * abs(y ^ 0.5)
Should probably have been abs(y)^0.5 that should have been automatically generated...
Many thanks, sjoelund.se
sjoelund.se wrote:
No, there really is an error in your original post. You have x_to_y mapping y:=x and y_to_x mapping x:=-y. So it is not an inverse function.
When I try your other functions, OM also solves them just fine.
Yes, if in Test x > 0 OM solves it, but if x < 0 no:
reverseTest.onb
If I wrote in x_to_y() y := x, I would not have understood that inverse not working.
sjoelund.se wrote:
The inverse annotation is not used by OpenModelica. It solves the function numerically instead (your x_to_y function has the error; fix it and you get the expected result). If you use Inline=true, the generated code does not contain any non-linear system to solve at run-time.
Thank you sjoelund.se!
No error in the function x_to_y(x). Realy I need something like what:
Code:
function x_to_y
input Real x;
output Real y;
annotation(inline = false, inverse(x = y_to_x(y)));
algorithm
y := x ^ 2;
y := sign(x) * y;
end x_to_y;
function y_to_x
input Real y;
output Real x;
algorithm
x := sqrt(abs(y));
x := sign(y) * x;
end y_to_x;
Without inverse() I'll get error: "Argument of sqrt(y) was -5 should be >= 0".
A pity that the inverse annotation is not used by OpenModelica
I'm trying to start this test code with inverse()operator in OMNotebook:
Code:
function x_to_y
input Real x;
output Real y;
[b] annotation(inverse(x = y_to_x(y)));[/b]
algorithm
y := x;
end x_to_y;
function y_to_x
input Real y;
output Real x;
algorithm
x := -y;
end y_to_x;
model Test
parameter Real y = 5;
Real x;
equation
y = x_to_y(x);
end Test;
simulate(Test)
val(x, 1.)
And result = 5, but i'd like to get -5.
Similarly inverse() doesn't work in OMedit.
I use OpenModelica v1.12.0-dev-36-g9ba9c3d (64-bit).
Thanks in advance.
Sorry. How to reduce the data recording step to the results file without decreasing the simulation step? Perhaps there is a flag?
Can I in the model use: stoptime, startime etc? Is it possible to implement such a line: parameter Real timeStep = (stopTime-startTime) / numberOfIntervals?
Hi again.
I replaced der(p_flow[i, j + 1]) to (p_flow[i, j + 1] - delay(p_flow[i, j + 1], 0.2)) / 0.2, (where 0.2 - time interval), and it works. But I'm not sure that this replacing is tantamount .
I have the piece of code:
Code:
Medium_F.AbsolutePressure p_flow[numberOfFlueSections, numberOfTubeSections + 1](start = p_startFlow);
...
for i in 1:numberOfFlueSections loop
for j in 1:numberOfTubeSections loop
...
C2[i, j] = deltaVFlow * drdp_flow[i, j] ;
...
p_flow[i, j + 1] = p_flow[i, j] - Dpfric[i, j];
...
stateFlow[i, j] = Medium_F.setState_ph(p_flow[i, j + 1], h_flow[i, j + 1]);
...
...
it is compiled and calculated normal.
But if I add to the code * der(p_flow[i, j + 1])
Code:
...
C2[i, j] = deltaVFlow * drdp_flow[i, j] * der(p_flow[i, j + 1]);
...
I have "Compilation process failed".
"C:\OpenModelica1.9.3\\MinGW\bin\mingw32-make.exe" -j4 -f MyHRSG.TestOnlyFlowHE.makefile
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o MyHRSG.TestOnlyFlowHE.o MyHRSG.TestOnlyFlowHE.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o MyHRSG.TestOnlyFlowHE_functions.o MyHRSG.TestOnlyFlowHE_functions.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o MyHRSG.TestOnlyFlowHE_records.o MyHRSG.TestOnlyFlowHE_records.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o MyHRSG.TestOnlyFlowHE_01exo.o MyHRSG.TestOnlyFlowHE_01exo.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o MyHRSG.TestOnlyFlowHE_02nls.o MyHRSG.TestOnlyFlowHE_02nls.c
gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.3//include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o MyHRSG.TestOnlyFlowHE_03lsy.o MyHRSG.TestOnlyFlowHE_03lsy.c
MyHRSG.TestOnlyFlowHE_03lsy.c: In function 'MyHRSG_TestOnlyFlowHE_initialLinearSystem':
MyHRSG.TestOnlyFlowHE_03lsy.c:167: error: 'MyHRSG_TestOnlyFlowHE_functionJacNLSJac7_column' undeclared (first use in this function)
MyHRSG.TestOnlyFlowHE_03lsy.c:167: error: (Each undeclared identifier is reported only once
MyHRSG.TestOnlyFlowHE_03lsy.c:167: error: for each function it appears in.)
MyHRSG.TestOnlyFlowHE_03lsy.c:168: error: 'MyHRSG_TestOnlyFlowHE_initialAnalyticJacobianNLSJac7' undeclared (first use in this function)
MyHRSG.TestOnlyFlowHE_03lsy.c:180: error: 'MyHRSG_TestOnlyFlowHE_functionJacNLSJac8_column' undeclared (first use in this function)
MyHRSG.TestOnlyFlowHE_03lsy.c:181: error: 'MyHRSG_TestOnlyFlowHE_initialAnalyticJacobianNLSJac8' undeclared (first use in this function)
mingw32-make: *** [MyHRSG.TestOnlyFlowHE_03lsy.o] Error 1
mingw32-make: *** Waiting for unfinished jobs....
Compilation process failed. Exited with code 2.
Why is this happening? Can I calculate the derivative without der()?
Perhaps in my previous post, I did not accurately explain the problem. Therefore, I attach to this letter a package with the models in the format ".mo". The problem is that I do not understand why the model "WaterSourceSink" does not work. I just started to deal with OpenModelica, so really hope to help. Thanks in advance for your help.
Hello
Please help me with Modelica.Fluid.Interfaces.FluidPort. I'm trying to create two models "WaterSource" and "WaterSink" and connect them (the final model is named WaterSourceSink) . The following code in OpenModelica:
Code:
model WaterSource
replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium model" annotation(choicesAllMatching = true);
parameter Medium.MassFlowRate w0 = 0;
parameter Medium.Temperature t0 = 0;
Modelica.Fluid.Interfaces.FluidPort_a port_a annotation(Placement(visible = true, transformation(origin = {98, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {98, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
port_a.m_flow = -w0;
port_a.h_outflow = Modelica.Media.Water.WaterIF97_base.specificEnthalpy_pT(port_a.p, t0);
annotation(Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics = {Polygon(origin = {-14.04, 0}, fillColor = {0, 0, 255}, fillPattern = FillPattern.CrossDiag, points = {{-67.956, 0}, {-67.956, 20}, {50.044, 20}, {50.044, 40}, {68.044, 0}, {50.044, -40}, {50.044, -20}, {-67.956, -20}, {-67.956, -20}, {-67.956, 0}})}));
end WaterSource;
Code:
model WaterSink
replaceable package Medium = Modelica.Media.Water.StandardWater constrainedby Modelica.Media.Interfaces.PartialMedium "Medium model" annotation(choicesAllMatching = true);
parameter Medium.AbsolutePressure p = 1e5;
Modelica.Fluid.Interfaces.FluidPort_b port_b annotation(Placement(visible = true, transformation(origin = {-98, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-98, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
port_b.p = p;
annotation(Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics = {Ellipse(origin = {0, -40}, fillColor = {0, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-66, 32}, {66, -32}}, endAngle = 360), Polygon(origin = {-36.15, -16}, fillColor = {0, 0, 255}, fillPattern = FillPattern.CrossDiag, points = {{-53.8536, 22}, {-31.8536, 22}, {-11.8536, 18}, {12.1464, 10}, {30.1464, 0}, {48.1464, -16}, {54.1464, -22}, {-3.85355, -22}, {-5.85355, -12}, {-9.85355, -2}, {-15.8536, 4}, {-27.8536, 10}, {-41.8536, 14}, {-53.8536, 16}, {-53.8536, 22}})}));
end WaterSink;
Code:
model WaterSourceSink
MyPowerPlant.Simple.WaterSource watersource1 annotation(Placement(visible = true, transformation(origin = {-52, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
MyPowerPlant.Simple.WaterSink watersink1 annotation(Placement(visible = true, transformation(origin = {10, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(watersource1.port_a, watersink1.port_b) annotation(Line(points = {{-42, 0}, {0, 0}, {0, 0}, {0, 0}}, color = {0, 127, 255}));
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})));
end WaterSourceSink;
When the "Check of MyPowerPlant.Simple.Examples.WaterSourceSink completed successfully. Class MyPowerPlant.Simple.Examples.WaterSourceSink has 5 equation(s) and 6 variable(s). 4 of these are trivial equation(s)". And such a code in the "InstantiateModel":
Code:
class MyPowerPlant.Simple.Examples.WaterSourceSink
parameter Real watersource1.w0(quantity = "MassFlowRate.unusablePartialMedium", unit = "kg/s", min = -100000.0, max = 100000.0) = 0.0 "Массовый расход";
parameter Real watersource1.t0(quantity = "ThermodynamicTemperature", unit = "K", displayUnit = "degC", min = 1.0, max = 10000.0, start = 300.0, nominal = 300.0) = 0.0;
Real watersource1.port_a.m_flow(quantity = "MassFlowRate.unusablePartialMedium", unit = "kg/s", min = -100000.0, max = 100000.0) "Mass flow rate from the connection point into the component";
Real watersource1.port_a.p(quantity = "Pressure", unit = "Pa", displayUnit = "bar", min = 0.0, max = 100000000.0, start = 100000.0, nominal = 100000.0) "Thermodynamic pressure in the connection point";
Real watersource1.port_a.h_outflow(quantity = "SpecificEnergy", unit = "J/kg", min = -10000000000.0, max = 10000000000.0, nominal = 1000000.0) "Specific thermodynamic enthalpy close to the connection point if m_flow < 0";
parameter Real watersink1.p(quantity = "Pressure", unit = "Pa", displayUnit = "bar", min = 611.657, max = 100000000.0, start = 5000000.0, nominal = 1000000.0) = 100000.0 "Давление";
Real watersink1.port_b.m_flow(quantity = "MassFlowRate.unusablePartialMedium", unit = "kg/s", min = -100000.0, max = 100000.0) "Mass flow rate from the connection point into the component";
Real watersink1.port_b.p(quantity = "Pressure", unit = "Pa", displayUnit = "bar", min = 0.0, max = 100000000.0, start = 100000.0, nominal = 100000.0) "Thermodynamic pressure in the connection point";
Real watersink1.port_b.h_outflow(quantity = "SpecificEnergy", unit = "J/kg", min = -10000000000.0, max = 10000000000.0, nominal = 1000000.0) "Specific thermodynamic enthalpy close to the connection point if m_flow < 0";
equation
watersource1.port_a.m_flow = -watersource1.w0;
watersource1.port_a.h_outflow = Modelica.Media.Water.WaterIF97_base.specificEnthalpy_pT(watersource1.port_a.p, watersource1.t0, 0);
watersink1.port_b.p = watersink1.p;
watersource1.port_a.m_flow + watersink1.port_b.m_flow = 0.0;
watersink1.port_b.p = watersource1.port_a.p;
end MyPowerPlant.Simple.Examples.WaterSourceSink;
Thus in the model is not equation for enthalpy "watersource1.port_a.h_outflow = watersink1.port_b.h_outflow".
Sorry for my bad english
- Index
- » Users
- » Makumazan
- » Profile