- Index
- » Users
- » Sover1
- » Profile
Posts
Posts
Hi everybody, I am using OpenModelica for months. I just want to know how can I move right and left on my model by using the mouse, because I can only zoom but I can't move right and left.
Thanks
Lorenzo
Hi everybody
I would like to know if ther was a way to move a component in a model through OMPython, without doing it in openmodelica. Is there any command in OMPython to do so?
Thanks
Hi,
I have a probelm with a simulation in OMPython. When I simulate the model in Openmodelica "the simulation finished successfully" but when I simulate in OMPython (the same model) I have these warnings: "while solving non-linear system am assertion failed during initialization", the non-linear solver tries to solve the problem that could take some time", "it could help to provide better better start-values for the iteration variables". Why this happens? I also try to set new start-values but I always have these warnings and until I have these warnings I cannot set new parameters with OMPython.
Thank you
Hi everybody
I have this model in OpenModelica:
model BranchA
inner Modelica.Fluid.System system annotation(
Placement(visible = true, transformation(origin = {-152, 148}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.MassFlowSource_T boundary(redeclare package Medium =
Modelica.Media.Water.StandardWater, m_flow = 2.376, nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {6, 190}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 2.79e-2, length = 15.35) annotation(
Placement(visible = true, transformation(origin = {-36, 138}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe1(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 2.79e-2, length = 15.35) annotation(
Placement(visible = true, transformation(origin = {44, 138}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe2(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 2.79e-2, length = 1) annotation(
Placement(visible = true, transformation(origin = {6, 162}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 50000, m_flow_nominal = 1.188, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {-36, 112}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice1(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 50000, m_flow_nominal = 1.188, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {44, 112}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Sensors.MassFlowRate massFlowRate (redeclare package Medium =
Modelica.Media.Water.StandardWater) annotation(
Placement(visible = true, transformation(origin = {-36, 82}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Sensors.MassFlowRate massFlowRate1 (redeclare package Medium =
Modelica.Media.Water.StandardWater) annotation(
Placement(visible = true, transformation(origin = {44, 82}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe3(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 13.8e-3, length = 12.8) annotation(
Placement(visible = true, transformation(origin = {-60, 46}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe4(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 13.8e-3, length = 12.8) annotation(
Placement(visible = true, transformation(origin = {-44, 46}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe5(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 13.8e-3, length = 12.8) annotation(
Placement(visible = true, transformation(origin = {-14, 46}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe6(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 13.8e-3, length = 12.8) annotation(
Placement(visible = true, transformation(origin = {-28, 46}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe7(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 13.8e-3, length = 12.8) annotation(
Placement(visible = true, transformation(origin = {48, 46}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe8(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 13.8e-3, length = 12.8) annotation(
Placement(visible = true, transformation(origin = {64, 46}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe9(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 13.8e-3, length = 12.8) annotation(
Placement(visible = true, transformation(origin = {32, 46}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe10(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 13.8e-3, length = 12.8) annotation(
Placement(visible = true, transformation(origin = {16, 46}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Sensors.MassFlowRate massFlowRate2 (redeclare package Medium =
Modelica.Media.Water.StandardWater) annotation(
Placement(visible = true, transformation(origin = {-36, -76}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Sensors.MassFlowRate massFlowRate3 (redeclare package Medium =
Modelica.Media.Water.StandardWater) annotation(
Placement(visible = true, transformation(origin = {44, -76}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice2(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 50000, m_flow_nominal = 1.188, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {-36, -106}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice3(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 50000, m_flow_nominal = 1.188, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {44, -106}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe11(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 2.79e-2, length = 15.35) annotation(
Placement(visible = true, transformation(origin = {-36, -134}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe12(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 2.79e-2, length = 15.35) annotation(
Placement(visible = true, transformation(origin = {44, -134}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Pipes.StaticPipe pipe13(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 2.79e-2, length = 1) annotation(
Placement(visible = true, transformation(origin = {6, -196}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Sources.FixedBoundary boundary1(redeclare package Medium =
Modelica.Media.Water.StandardWater,nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {6, -228}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice4(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 207833, m_flow_nominal = 2.376, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {6, -166}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice5(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 94200, m_flow_nominal = 0.297, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {-60, 14}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice6(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 94200, m_flow_nominal = 0.297, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {-44, 14}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice7(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 94200, m_flow_nominal = 0.297, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {-12, 12}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice8(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 94200, m_flow_nominal = 0.297, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {-28, 12}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice9(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 94200, m_flow_nominal = 0.297, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {48, 12}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice10(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 94200, m_flow_nominal = 0.297, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {64, 12}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice11(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 94200, m_flow_nominal = 0.297, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {32, 14}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice12(redeclare package Medium =
Modelica.Media.Water.StandardWater,diameter = 0.2, dp_nominal = 94200, m_flow_nominal = 0.297, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {16, 14}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
equation
connect(boundary.ports[1], pipe2.port_a) annotation(
Line(points = {{6, 180}, {6, 172}}, color = {0, 127, 255}));
connect(pipe2.port_b, pipe1.port_a) annotation(
Line(points = {{6, 152}, {44, 152}, {44, 148}}, color = {0, 127, 255}));
connect(pipe2.port_b, pipe.port_a) annotation(
Line(points = {{6, 152}, {-36, 152}, {-36, 148}}, color = {0, 127, 255}));
connect(pipe.port_b, orifice.port_a) annotation(
Line(points = {{-36, 128}, {-36, 122}}, color = {0, 127, 255}));
connect(pipe1.port_b, orifice1.port_a) annotation(
Line(points = {{44, 128}, {44, 122}}, color = {0, 127, 255}));
connect(orifice.port_b, massFlowRate.port_a) annotation(
Line(points = {{-36, 102}, {-36, 92}}, color = {0, 127, 255}));
connect(orifice1.port_b, massFlowRate1.port_a) annotation(
Line(points = {{44, 102}, {44, 92}}, color = {0, 127, 255}));
connect(massFlowRate.port_b, pipe3.port_a) annotation(
Line(points = {{-36, 72}, {-60, 72}, {-60, 56}}, color = {0, 127, 255}));
connect(massFlowRate.port_b, pipe4.port_a) annotation(
Line(points = {{-36, 72}, {-44, 72}, {-44, 56}}, color = {0, 127, 255}));
connect(massFlowRate.port_b, pipe6.port_a) annotation(
Line(points = {{-36, 72}, {-28, 72}, {-28, 56}}, color = {0, 127, 255}));
connect(massFlowRate.port_b, pipe5.port_a) annotation(
Line(points = {{-36, 72}, {-14, 72}, {-14, 56}}, color = {0, 127, 255}));
connect(massFlowRate1.port_b, pipe10.port_a) annotation(
Line(points = {{44, 72}, {16, 72}, {16, 56}}, color = {0, 127, 255}));
connect(massFlowRate1.port_b, pipe9.port_a) annotation(
Line(points = {{44, 72}, {32, 72}, {32, 56}}, color = {0, 127, 255}));
connect(massFlowRate1.port_b, pipe7.port_a) annotation(
Line(points = {{44, 72}, {48, 72}, {48, 56}}, color = {0, 127, 255}));
connect(massFlowRate1.port_b, pipe8.port_a) annotation(
Line(points = {{44, 72}, {64, 72}, {64, 56}}, color = {0, 127, 255}));
connect(massFlowRate2.port_b, orifice2.port_a) annotation(
Line(points = {{-36, -86}, {-36, -96}}, color = {0, 127, 255}));
connect(massFlowRate3.port_b, orifice3.port_a) annotation(
Line(points = {{44, -86}, {44, -96}}, color = {0, 127, 255}));
connect(orifice2.port_b, pipe11.port_a) annotation(
Line(points = {{-36, -116}, {-36, -124}}, color = {0, 127, 255}));
connect(orifice3.port_b, pipe12.port_a) annotation(
Line(points = {{44, -116}, {44, -124}}, color = {0, 127, 255}));
connect(pipe13.port_b, boundary1.ports[1]) annotation(
Line(points = {{6, -206}, {6, -218}}, color = {0, 127, 255}));
connect(pipe11.port_b, orifice4.port_a) annotation(
Line(points = {{-36, -144}, {-36, -156}, {6, -156}}, color = {0, 127, 255}));
connect(pipe12.port_b, orifice4.port_a) annotation(
Line(points = {{44, -144}, {23, -144}, {23, -156}, {6, -156}}, color = {0, 127, 255}));
connect(orifice4.port_b, pipe13.port_a) annotation(
Line(points = {{6, -176}, {6, -186}}, color = {0, 127, 255}));
connect(pipe3.port_b, orifice5.port_a) annotation(
Line(points = {{-60, 36}, {-60, 36}, {-60, 24}, {-60, 24}}, color = {0, 127, 255}));
connect(pipe4.port_b, orifice6.port_a) annotation(
Line(points = {{-44, 36}, {-44, 36}, {-44, 24}, {-44, 24}}, color = {0, 127, 255}));
connect(pipe6.port_b, orifice8.port_a) annotation(
Line(points = {{-28, 36}, {-28, 36}, {-28, 22}, {-28, 22}}, color = {0, 127, 255}));
connect(pipe5.port_b, orifice7.port_a) annotation(
Line(points = {{-14, 36}, {-14, 36}, {-14, 22}, {-12, 22}, {-12, 22}}, color = {0, 127, 255}));
connect(pipe10.port_b, orifice12.port_a) annotation(
Line(points = {{16, 36}, {16, 36}, {16, 24}, {16, 24}}, color = {0, 127, 255}));
connect(pipe9.port_b, orifice11.port_a) annotation(
Line(points = {{32, 36}, {32, 36}, {32, 24}, {32, 24}}, color = {0, 127, 255}));
connect(pipe7.port_b, orifice9.port_a) annotation(
Line(points = {{48, 36}, {48, 36}, {48, 22}, {48, 22}}, color = {0, 127, 255}));
connect(pipe8.port_b, orifice10.port_a) annotation(
Line(points = {{64, 36}, {64, 36}, {64, 22}, {64, 22}}, color = {0, 127, 255}));
connect(orifice5.port_b, massFlowRate2.port_a) annotation(
Line(points = {{-60, 4}, {-60, -66}, {-36, -66}}, color = {0, 127, 255}));
connect(orifice6.port_b, massFlowRate2.port_a) annotation(
Line(points = {{-44, 4}, {-46, 4}, {-46, -66}, {-36, -66}}, color = {0, 127, 255}));
connect(orifice8.port_b, massFlowRate2.port_a) annotation(
Line(points = {{-28, 2}, {-28, -66}, {-36, -66}}, color = {0, 127, 255}));
connect(orifice7.port_b, massFlowRate2.port_a) annotation(
Line(points = {{-12, 2}, {-14, 2}, {-14, -66}, {-36, -66}}, color = {0, 127, 255}));
connect(orifice12.port_b, massFlowRate3.port_a) annotation(
Line(points = {{16, 4}, {16, -66}, {44, -66}}, color = {0, 127, 255}));
connect(orifice11.port_b, massFlowRate3.port_a) annotation(
Line(points = {{32, 4}, {32, -66}, {44, -66}}, color = {0, 127, 255}));
connect(orifice9.port_b, massFlowRate3.port_a) annotation(
Line(points = {{48, 2}, {48, -66}, {44, -66}}, color = {0, 127, 255}));
connect(orifice10.port_b, massFlowRate3.port_a) annotation(
Line(points = {{64, 2}, {62, 2}, {62, -66}, {44, -66}}, color = {0, 127, 255}));
annotation(
uses(Modelica(version = "3.2.3")));
end BranchA;
I want to simulate this model with OMPython with this code:
import OMPython
from OMPython import OMCSessionZMQ
from OMPython import ModelicaSystem
omc = OMCSessionZMQ()
omc.sendExpression("instantiateModel(BranchA)")
omc.sendExpression("loadFile(\"C:/Users/loren/Documents/OpenModelica/BranchA.mo\")")
omc.sendExpression("loadModel(BranchA)")
model_path = omc.sendExpression("getInstallationDirectoryPath()")
mod = ModelicaSystem("C:/Users/loren/Documents/OpenModelica/BranchA.mo", "BranchA")
quantities = mod.getQuantities()
parameters = mod.getParameters()
continuous = mod.getContinuous()
setting = mod.setParameters("boundary.m_flow=5")
gettingParameters = mod.getParameters(["orifice5.dp_nominal"])
mod.simulate()
pipeMassFlow = mod.getSolutions(["pipe.port_a.m_flow"])
pipe1MassFlow = mod.getSolutions(["pipe1.port_a.m_flow"])
pipe2MassFlow = mod.getSolutions(["pipe2.port_a.m_flow"])
pipe3MassFlow = mod.getSolutions(["pipe3.port_a.m_flow"])
pipe4MassFlow = mod.getSolutions(["pipe4.port_a.m_flow"])
pipe5MassFlow = mod.getSolutions(["pipe5.port_a.m_flow"])
pipe6MassFlow = mod.getSolutions(["pipe6.port_a.m_flow"])
pipe7MassFlow = mod.getSolutions(["pipe7.port_a.m_flow"])
pipe8MassFlow = mod.getSolutions(["pipe8.port_a.m_flow"])
pipe9MassFlow = mod.getSolutions(["pipe9.port_a.m_flow"])
pipe10MassFlow = mod.getSolutions(["pipe10.port_a.m_flow"])
pipe11MassFlow = mod.getSolutions(["pipe11.port_a.m_flow"])
pipe12MassFlow = mod.getSolutions(["pipe12.port_a.m_flow"])
pipe13MassFlow = mod.getSolutions(["pipe13.port_a.m_flow"])
inletPressurePipe3 = mod.getSolutions(["pipe3.port_a.p"])
outletPressureOrifice5 = mod.getSolutions(["orifice5.port_b.p"])
inletPressurePipe = mod.getSolutions(["pipe.port_a.p"])
outletPressureMassFlowRate = mod.getSolutions(["massFlowRate.port_b.p"])
m_flow = pipeMassFlow.flat[0]
m_flow1 = pipe1MassFlow.flat[0]
m_flow2 = pipe2MassFlow.flat[0]
m_flow3 = pipe3MassFlow.flat[0]
m_flow4 = pipe4MassFlow.flat[0]
m_flow5 = pipe5MassFlow.flat[0]
m_flow6 = pipe6MassFlow.flat[0]
m_flow7 = pipe7MassFlow.flat[0]
m_flow8 = pipe8MassFlow.flat[0]
m_flow9 = pipe9MassFlow.flat[0]
m_flow10 = pipe10MassFlow.flat[0]
m_flow11 = pipe11MassFlow.flat[0]
m_flow12 = pipe12MassFlow.flat[0]
m_flow13 = pipe13MassFlow.flat[0]
inletPressureBeam = inletPressurePipe3.flat[0]
outletPressureBeam = outletPressureOrifice5.flat[0]
PressureDropBeam = inletPressureBeam-outletPressureBeam
inletPressureLosses = inletPressurePipe.flat[0]
outletPressureLosses = outletPressureMassFlowRate.flat[0]
BranchLosses = (inletPressureLosses-outletPressureLosses)*2
print(parameters)
print("\n")
print("m_flowInlet =", m_flow2, "[kg/s]")
print("\n")
print("m_flowInletBranchA2 =", m_flow1, "[kg/s]")
print("\n")
print("m_flowInletBranchA1 =", m_flow, "[kg/s]")
print("\n")
#print("m_flowBeam =", m_flow3, "[kg/s]")
#print("\n")
#print("m_flow4 =", m_flow4, "[kg/s]")
#print("\n")
#print("m_flow5 =", m_flow5, "[kg/s]")
#print("\n")
#print("m_flow6 =", m_flow6, "[kg/s]")
#print("\n")
#print("m_flow7 =", m_flow7, "[kg/s]")
#print("\n")
#print("m_flow8 =", m_flow8, "[kg/s]")
#print("\n")
#print("m_flow9 =", m_flow9, "[kg/s]")
#print("\n")
#print("m_flow10 =", m_flow10, "[kg/s]")
#print("\n")
print("m_flowOutletBranchA1 =", m_flow11, "[kg/s]")
print("\n")
print("m_flowOutletBranchA2 =", m_flow12, "[kg/s]")
print("\n")
print("m_flowOutlet =", m_flow13, "[kg/s]")
print("\n")
print("PressureDropBeam =", PressureDropBeam, "[Pa]")
print("\n")
print("BranchLosses =", BranchLosses, "[Pa]")
I want to set a new parameter but after the simulation the results are the same. How can I set a paramater??? Thanks
Hi everybody. I created a simple model:
model MFR
inner Modelica.Fluid.System system annotation(
Placement(visible = true, transformation(origin = {-102, 88}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Pipes.StaticPipe pipe(redeclare package Medium =
Modelica.Media.Water.StandardWater, diameter = 2.25e-2, length = 10) annotation(
Placement(visible = true, transformation(origin = {-38, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.FixedBoundary boundary(redeclare package Medium =
Modelica.Media.Water.StandardWater, nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {112, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
Modelica.Fluid.Sources.MassFlowSource_T boundary1(redeclare package Medium =
Modelica.Media.Water.StandardWater, m_flow = 10, nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sensors.MassFlowRate massFlowRate (redeclare package Medium =
Modelica.Media.Interfaces.PartialMedium) annotation(
Placement(visible = true, transformation(origin = {28, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(boundary1.ports[1], pipe.port_a) annotation(
Line(points = {{-90, 0}, {-48, 0}, {-48, 0}, {-48, 0}}, color = {0, 127, 255}));
connect(pipe.port_b, massFlowRate.port_a) annotation(
Line(points = {{-28, 0}, {18, 0}, {18, 0}, {18, 0}}, color = {0, 127, 255}));
connect(massFlowRate.port_b, boundary.ports[1]) annotation(
Line(points = {{38, 0}, {102, 0}, {102, 0}, {102, 0}}, color = {0, 127, 255}));
annotation(
uses(Modelica(version = "3.2.3")));
end MFR;
I tried to simulate the model on OMPython but it gave me this error: Error: component massFlowRate contains the definition of a partial class Medium.
Please redeclare it to any package compatible with Modelica.Media.Interfaces.PartialMedium.
Error: Error occurred while flattening model MFR
How can I solve this problem?
Thank you.
Hello everybody, I have this simple example:
model Ex
inner Modelica.Fluid.System system annotation(
Placement(visible = true, transformation(origin = {-172, 90}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.MassFlowSource_T boundary(redeclare package Medium =
Modelica.Media.Water.StandardWater, m_flow = 10, nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {-130, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.FixedBoundary boundary1(redeclare package Medium =
Modelica.Media.Water.StandardWater, nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {4, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
Modelica.Fluid.Fittings.SimpleGenericOrifice orifice(redeclare package Medium =
Modelica.Media.Water.StandardWater, diameter = 0.2, dp_nominal = 50000, m_flow_nominal = 10, use_zeta = false) annotation(
Placement(visible = true, transformation(origin = {-64, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(boundary.ports[1], orifice.port_a) annotation(
Line(points = {{-120, 0}, {-74, 0}, {-74, 0}, {-74, 0}}, color = {0, 127, 255}));
connect(orifice.port_b, boundary1.ports[1]) annotation(
Line(points = {{-54, 0}, {-6, 0}, {-6, 0}, {-6, 0}}, color = {0, 127, 255}));
annotation(
uses(Modelica(version = "3.2.3")));
end Ex;
I'd like to simulate this model in OMPython: how can I do? I downloaded OMPython and imported it with import OMPython. Help me, thanks.
Hi
I'm trying to creating a new medium model using the TemplateMedium package. I've created this simple model:
model Example
inner Modelica.Fluid.System system annotation(
Placement(visible = true, transformation(origin = {-270, 84}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.MassFlowSource_T boundary( m_flow = 10, nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {-224, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.FixedBoundary boundary1(nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {44, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
Modelica.Fluid.Pipes.StaticPipe pipe(diameter = 5e-2, length = 10) annotation(
Placement(visible = true, transformation(origin = {-96, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(boundary.ports[1], pipe.port_a) annotation(
Line(points = {{-214, 0}, {-108, 0}, {-108, 0}, {-106, 0}}, color = {0, 127, 255}));
connect(pipe.port_b, boundary1.ports[1]) annotation(
Line(points = {{-86, 0}, {34, 0}, {34, -2}, {34, -2}}, color = {0, 127, 255}));
annotation(
uses(Modelica(version = "3.2.2")));
end Example;
I want to use a medium with specific properties so I've created a new package from the TemplateMedium package, copying the TemplateMedium package in the new one (removing the "partial" keyword from the package, as suggested by OpenModelica). This is the new Medium package:
package TemplateMedium "Template for media models"
extends Modelica.Media.Interfaces.PartialMedium(
final mediumName="NameOfMedium",
final substanceNames={mediumName},
final singleState=true,
final reducedX=true,
final fixedX=true,
Temperature(
min=273,
max=450,
start=323),
pressure(min=1e5,
max=3e5,
start=2e5));
constant SpecificHeatCapacity cp_const
"Constant specific heat capacity at constant pressure";
redeclare model extends BaseProperties(final standardOrderComponents=true)
"Base properties of medium"
equation
d = 1;
h = cp_const*298.15;
u = h - 2e5/d;
MM = 0.024;
R = 8.3144/MM;
state.p = p;
state.T = T;
end BaseProperties;
redeclare replaceable record ThermodynamicState
"A selection of variables that uniquely defines the thermodynamic state"
extends Modelica.Icons.Record;
AbsolutePressure p "Absolute pressure of medium";
Temperature T "Temperature of medium";
annotation (Documentation(info="<html>
</html>"));
end ThermodynamicState;
redeclare function extends dynamicViscosity "Return dynamic viscosity"
algorithm
eta := 10 - state.T*0.3 + state.p*0.2;
annotation (Documentation(info="<html>
</html>"));
end dynamicViscosity;
redeclare function extends thermalConductivity
"Return thermal conductivity"
algorithm
lambda := 1;
annotation (Documentation(info="<html>
</html>"));
end thermalConductivity;
redeclare function extends specificEntropy "Return specific entropy"
algorithm
s := 2;
annotation (Documentation(info="<html>
</html>"));
end specificEntropy;
redeclare function extends specificHeatCapacityCp
"Return specific heat capacity at constant pressure"
algorithm
cp := 4;
annotation (Documentation(info="<html>
</html>"));
end specificHeatCapacityCp;
redeclare function extends specificHeatCapacityCv
"Return specific heat capacity at constant volume"
algorithm
cv := 4.2;
annotation (Documentation(info="<html>
</html>"));
end specificHeatCapacityCv;
redeclare function extends isentropicExponent "Return isentropic exponent"
extends Modelica.Icons.Function;
algorithm
gamma := 1;
annotation (Documentation(info="<html>
</html>"));
end isentropicExponent;
redeclare function extends velocityOfSound "Return velocity of sound"
extends Modelica.Icons.Function;
algorithm
a := 3;
annotation (Documentation(info="<html>
</html>"));
end velocityOfSound;
annotation (Documentation(info="<html>
<p>
This package is a <b>template</b> for <b>new medium</b> models. For a new
medium model just make a copy of this package, remove the
\"partial\" keyword from the package and provide
the information that is requested in the comments of the
Modelica source.
</p>
</html>"));
end TemplateMedium;
Before simulating the model I've redeclared the package in the model:
model Example
inner Modelica.Fluid.System system annotation(
Placement(visible = true, transformation(origin = {-270, 84}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.MassFlowSource_T boundary(redeclare package Medium =
Modelica.Media.Interfaces.TemplateMedium, m_flow = 10, nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {-224, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.FixedBoundary boundary1(redeclare package Medium =
Modelica.Media.Interfaces.TemplateMedium,nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {44, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
Modelica.Fluid.Pipes.StaticPipe pipe(redeclare package Medium =
Modelica.Media.Interfaces.TemplateMedium,diameter = 5e-2, length = 10) annotation(
Placement(visible = true, transformation(origin = {-96, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(boundary.ports[1], pipe.port_a) annotation(
Line(points = {{-214, 0}, {-108, 0}, {-108, 0}, {-106, 0}}, color = {0, 127, 255}));
connect(pipe.port_b, boundary1.ports[1]) annotation(
Line(points = {{-86, 0}, {34, 0}, {34, -2}, {34, -2}}, color = {0, 127, 255}));
annotation(
uses(Modelica(version = "3.2.2")));
end Example;
When I check the model I have this error:
Cannot resolve type of expression Example.pipe.flowModel.Medium.pressure(BOX(pipe.flowModel.states[i + 1])) -
Example.pipe.flowModel.Medium.pressure(BOX(pipe.flowModel.states[i])). The operands have types #Real, #Real in component <NO_COMPONENT>.
What is wrong in my model? How can I create a new medium model in OpenModelica? Please help me!!!!
Hi everybody, I just want to know how I can create a new medium model using the template medium package. I create an easy model with a mass flow source, a pipe and a fixed boundary:
model Fluid
inner Modelica.Fluid.System system annotation(
Placement(visible = true, transformation(origin = {-106, 86}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Pipes.StaticPipe pipe(redeclare package NewMedium =
Modelica.Media.Interfaces.PartialMedium, diameter = 5e-2, length = 10) annotation(
Placement(visible = true, transformation(origin = {-90, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.MassFlowSource_T boundary(nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {-154, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Sources.FixedBoundary boundary1(nPorts = 1) annotation(
Placement(visible = true, transformation(origin = {-30, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
equation
connect(boundary.ports[1], pipe.port_a) annotation(
Line(points = {{-144, 10}, {-100, 10}, {-100, 10}, {-100, 10}}, color = {0, 127, 255}));
connect(pipe.port_b, boundary1.ports[1]) annotation(
Line(points = {{-80, 10}, {-40, 10}, {-40, 10}, {-40, 10}}, color = {0, 127, 255}));
annotation(
uses(Modelica(version = "3.2.2")));
end Fluid;
I want to use a fluid with prescribed density, dynamic viscosity ecc... What do I have to use for creating this new medium?
Thanks
Hi, I am a new user on openmodelica. I just wanted to know how can I work with constant density because if I use Modelica.Media.Water.StandardWater the density is a function of temperature and pressure. Using Modelica.Media.Water.ConstantPropertyLiquidWater openmodelica gives this error: Class Medium.ExtraProperty not found in scope FluidPort.
Thank you
Tearing is skipped for strong component 3 because system size of 344 exceeds maximum system size for tearing of linear systems (200).
To adjust the maximum system size for tearing use --maxSizeLinearTearing=<size> and --maxSizeNonlinearTearing=<size>.
After my simulation I saw this message: what can I do to solve the problem? Help me
Thank you
I created 7 model but I need to create a bigger one, containing the previous 7. I can only copy and paste the 7 models into the bigger one? Does it exist a way to compress a model into something smaller in order to keep from becoming blind? Because if I can only copy and paste, I need to zoom a lot and it becomes difficult to connect an element to another. And what is the composite model? How and when I can use it? Thanks
I have six models and I have to connect each model to create a new bigger one. I can create a composite model, can I? But creating a composite model I can't connect the models, so how can I create a composite model or connect each model?
How can I compress 6 models to create a bigger one? Because if I paste the 6 models in a new one, I have not enough space on the grid. Thanks
Hi
I'd like to know which formula is used to calculate the pressure drop in a valve. I can't find it anywhere otherwise I found the formula for the calculation of the pressure drop in an orifice. Help me
- Index
- » Users
- » Sover1
- » Profile