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

Initialization of a espresso machine fluid model

Initialization of a espresso machine fluid model

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;

Edited by: Briant - Apr-25-17 21:07:17

Re: Initialization of a espresso machine fluid model

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

Edited by: Briant - Jun-15-17 19:49:19

Re: Initialization of a espresso machine fluid model

The solenoid of your solenoid pump has no inductance, which is unreal. I've added an inductor L=tau*R_Resistor with tau being the time constant. I suppose a realistic tau is 1s, which means L=R_Resistor.
Moreover the output step should be changed from 10ms to 1ms.
With this addition simulation is faster and, I believe, more realistic.

There are 0 guests and 0 other users also viewing this topic
You are here: