Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » Briant
  • » Profile

Posts

Posts

Dec-15-20 11:13:11
Solutions for debugging the ThreeWayValve class within the Buildings library

Hello,

Using Buildings 7.0 and Modelica 3.2.3 libraries, I could not simulate the model Examples.ThreeWayValve. After some investigations, it appeared to me that the BaseClasses.ValveParameters are not being transferred into the res1.TwoWayValve and res3.TwoWayValve components. The TwoWayValve Class extends the PartialTwoWayValveKv class, which requires a Kv value that wasn't provided by the ThreeWayValve class.

To make it work, I duplicated the Buildings.Fluid.Actuators.Valves.ThreeWayLinear class and introduced the declarations
m_flow_nominal=m_flow_nominal, CvData = Buildings.Fluid.Types.CvTypes.Kv, Kv=Kv
as follows:

Code:


model ThreeWayLinear "Three way valve with linear characteristics"
  extends Buildings.Fluid.Actuators.BaseClasses.PartialThreeWayValve(
    redeclare Buildings.Fluid.Actuators.Valves.TwoWayLinear res1(
      m_flow_nominal=m_flow_nominal, CvData = Buildings.Fluid.Types.CvTypes.Kv, Kv=Kv, final l = l[1]),
    redeclare Buildings.Fluid.Actuators.Valves.TwoWayLinear res3(
      m_flow_nominal=m_flow_nominal, CvData = Buildings.Fluid.Types.CvTypes.Kv, Kv=Kv, final l = l[2]));
equation
  connect(inv.y, res3.y) annotation(
    Line(points = {{-62.6, 46}, {20, 46}, {20, -50}, {12, -50}}, color = {0, 0, 127}));
  connect(y_actual, inv.u2) annotation(
    Line(points = {{50, 70}, {88, 70}, {88, 34}, {-68, 34}, {-68, 41.2}}, color = {0, 0, 127}));
  connect(y_actual, res1.y) annotation(
    Line(points = {{50, 70}, {88, 70}, {88, 34}, {-50, 34}, {-50, 12}}, color = {0, 0, 127}));
  annotation(
    Icon(coordinateSystem(extent = {{-120, -100}, {70, 100}})));
end ThreeWayLinear;

Now I am wondering, if there is a better or cleaner way for debugging this component. Any ideas?
And what would be the process to include this change into the next release of the standard "Buildings" library.

Regards,

Stephan

------------------------------------------------------------------------------------------

Edit, 21.12.2020:
I ended up extending the declarations list even further to:

Code:


extends Buildings.Fluid.Actuators.BaseClasses.PartialThreeWayValve(
  redeclare Buildings.Fluid.Actuators.Valves.TwoWayLinear res1(
    deltaM = deltaM,
    rhoStd = rhoStd,
    dp(start = dpValve_nominal / 2),
    from_dp = from_dp,
    final linearized = linearized[1],
    final homotopyInitialization = homotopyInitialization,
    final dpFixed_nominal = dpFixed_nominal[1],
    final use_inputFilter = false,
    final m_flow_nominal = m_flow_nominal,
    final CvData = CvData,
    final y_start = y_start,
    final Kv = Kv,
    final l = l[1]),
  redeclare Buildings.Fluid.Actuators.Valves.TwoWayLinear res3(
    deltaM = deltaM,
    rhoStd = rhoStd,
    dp(start = dpValve_nominal / 2),
    from_dp = from_dp,
    final linearized = linearized[2],
    final homotopyInitialization = homotopyInitialization,
    final dpFixed_nominal = dpFixed_nominal[2],
    final use_inputFilter = false,
    final m_flow_nominal = m_flow_nominal,
    final CvData = CvData,
    final y_start = 1 - y_start,
    final Kv = Kv / fraK,
    final l = l[2]),
  final CvData = Buildings.Fluid.Types.CvTypes.Kv);

Jun-15-17 19:47:47
When trying to simulate my espresso machine model, it fails as soon as I add a pump.
Category: Programming

After a couple of weeks debugging, I managed to make the model work myself. The attached version however, uses a piston pump instead of the original centrifugal pump. For that reason I also had to create a check valve model (based on the GenericOrifice template). The downside of this real-life approach is that with a 50Hz AC source, the model simulates very very very slowly. Any suggestions on how to possibly speed up my model would be appreciated.

I am hoping this may be useful to anybody working on similar systems...
EspressoHydraulics.mo

Apr-27-17 17:59:00
Re: Modelica.Blocks.Logical.Edge / Modelica.Blocks.MathBoolean.RisingEdge
Category: Programming

Hello Hakan,

I assume that the function does work well, but it is not visible in the plot view. The output is only a "One Shot", which means that its change from 0 to 1 and back to 0 happens for a very short time only. Can you try to connect the output to the S port of a Modelica.Blocks.Logical.RSFlipFlop? If it works, you should see the output of the FlipFlop change to 1 permanently.

Apr-25-17 20:50:50
When trying to simulate my espresso machine model, it fails as soon as I add a pump.
Category: Programming

Hello,

I am doing a project to tune my espresso machine at home (PID and volume control). To make it even more exciting, I have modeled the whole machine including power circuits, control circuits, (Arduino) software and hydraulics in Openmodelica and in a second step want to connect the whole thing through OPC to an Ignition SCADA system.
Everything compiles and simulated well, except of course the hydraulics. Starting off from the Empty Tanks example, I built the model step by step successfully until the pump came into play. The pump is supposed to overcome the 5 bar back pressure of the boiler outlet valve, to get flow going. I would be glad to hearing your suggestions on how to make this model work. To me it seems, that with the pump in the loop, I cannot stick to the FixedInitial Initialization. I just have not found the right setting that fixes it.

The following simulation error occurs:


assert | warning | <p>The following assertion has been violated at time 0.000000<br>
waterPump.delta_head_init &gt;= 0.0</p>
assert | warning | <p>Variable violating min constraint: 0.0 &lt;= waterPump.delta_head_init, has value: -91.9394</p>

This is my model code:

Code:


model HW_Hydraulics_debug
  replaceable package Medium = Modelica.Media.Water.StandardWaterOnePhase
    constrainedby Modelica.Media.Interfaces.PartialMedium;
   
  inner Modelica.Fluid.System system(
    energyDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial,
    p_ambient = 100000)
    annotation(
    Placement(visible = true, transformation(extent = {{80, 80}, {100, 100}}, rotation = 0)));
  Modelica.Fluid.Vessels.OpenTank waterTank(
    redeclare package Medium = Medium,
     crossArea = 0.024,
     height = 0.15,
     level_start = 0.12,
     nPorts = 1,
     portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.005)})
     annotation(
    Placement(visible = true, transformation(extent = {{-80, -80}, {-40, -40}}, rotation = 0)));
  Modelica.Fluid.Pipes.StaticPipe pipe(
    redeclare package Medium = Medium,
    diameter = 0.005,
    length = 0.4)
    annotation(
    Placement(visible = true, transformation(origin = {-90, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  Modelica.Fluid.Vessels.ClosedVolume boiler(
    redeclare replaceable package Medium = Medium,
    redeclare model HeatTransfer = Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.IdealHeatTransfer(k = 10),
    V = 0.00025,
    nPorts = 3,
    portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.005),
    Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.005),
    Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.005)},
    use_HeatTransfer = true,
    use_portsData = true)
    annotation(
    Placement(visible = true, transformation(origin = {60, 30}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a a_boiler
    annotation(
    Placement(visible = true, transformation(origin = {90, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0),
      iconTransformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Fluid.Sensors.Pressure boilerPressure(redeclare replaceable package Medium = Medium)
      annotation(
    Placement(visible = true, transformation(origin = {0, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Logical.GreaterThreshold valveOpenThresh(threshold = 500000)
    annotation(
    Placement(visible = true, transformation(origin = {30, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Fluid.Valves.ValveDiscrete onOffValve(
    redeclare replaceable package Medium = Medium,
    dp_nominal = 900000,
    m_flow_nominal = 0.001)
    annotation(
    Placement(visible = true, transformation(origin = {60, -10}, extent = {{10, -10}, {-10, 10}}, rotation = 90)));
  Modelica.Fluid.Vessels.OpenTank coffeeCup(
    redeclare package Medium = Medium,
    crossArea = 0.0012,
    height = 0.15,
    level_start = 1.0e-8,
    nPorts = 1,
    portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.005)})
    annotation(
    Placement(visible = true, transformation(extent = {{40, -80}, {80, -40}}, rotation = 0)));
  Modelica.Fluid.Machines.ControlledPump waterPump(
    redeclare package Medium = Medium,
    N_nominal = 3000,
    V = 0.0000001,
    control_m_flow = false,
    energyDynamics = system.energyDynamics,
    m_flow_nominal = 0.002,
    m_flow_start = 0.002,
    massDynamics = system.massDynamics,
    p_a_nominal = 100000,
    p_b_nominal = 1000000,
    p_b_start = 100000)
    annotation(
    Placement(visible = true, transformation(origin = {-40, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

equation
  connect(pipe.port_b, waterPump.port_a) annotation(
    Line(points = {{-90, 0}, {-90, 0}, {-90, 20}, {-50, 20}, {-50, 20}}, color = {0, 127, 255}));
  connect(waterPump.port_b, boiler.ports[1]) annotation(
    Line(points = {{-30, 20}, {60, 20}, {60, 20}, {60, 20}}, color = {0, 127, 255}));
  connect(waterTank.ports[1], pipe.port_a) annotation(
    Line(points = {{-60, -80}, {-90, -80}, {-90, -20}, {-88, -20}}, color = {0, 127, 255}));
  connect(boiler.ports[3], boilerPressure.port) annotation(
    Line(points = {{60, 20}, {-20, 20}, {-20, -20}, {0, -20}}, color = {0, 127, 255}, thickness = 0.5));
  connect(boilerPressure.p, valveOpenThresh.u) annotation(
    Line(points = {{9, -10}, {18, -10}}, color = {0, 0, 127}));
  connect(valveOpenThresh.y, onOffValve.open) annotation(
    Line(points = {{42, -10}, {52, -10}, {52, -10}, {52, -10}}, color = {255, 0, 255}));
  connect(onOffValve.port_b, coffeeCup.ports[1]) annotation(
    Line(points = {{60, -20}, {60, -20}, {60, -80}, {60, -80}}, color = {0, 127, 255}));
  connect(boiler.ports[2], onOffValve.port_a) annotation(
    Line(points = {{60, 20}, {60, 20}, {60, 0}, {60, 0}}, color = {0, 127, 255}, thickness = 0.5));
  connect(a_boiler, boiler.heatPort) annotation(
    Line(points = {{88, 30}, {68, 30}, {68, 30}, {68, 30}}, color = {191, 0, 0}));
  annotation(
    Icon(coordinateSystem(grid = {2, 8})),
    experiment(StartTime = 0, StopTime = 30, Tolerance = 0.0001, Interval = 0.06),
    __OpenModelica_simulationFlags(jacobian = "coloredNumerical", s = "dassl", lv = "LOG_STATS"));
end HW_Hydraulics_debug;

  • Index
  • » Users
  • » Briant
  • » Profile
You are here: