Search code examples
modelicaopenmodelica

Closed Volume - Initialization Error - Modelica


I try to model a simplified case which consists of a SweptVolume and a ClosedVolume. When piston moves downwards then closedvolume should fill with water, when piston move upwards the fluid will flow into the piston. But I get initialization errors. Could you help me to handle this error? Thanks in advance!

Residual function evaluation failed at initial point for "1" From Hochdruckreiniger4_1: Jacobian evaluation failed at initial point for "1" From Hochdruckreiniger4_1: Failed to find a consistent solution in event iteration in "1", 0 at 0.0000000000000000E+000 From Hochdruckreiniger4_1: Residual function evaluation failed at initial point for "2" "#r108#" From Hochdruckreiniger4_1: Initialization failed.

model Hochdruckreiniger4
    //Declaration(s)
    Real V_max = 0.000003;
    Real V_tod = 0.000002;
    Real N = 2800;
    replaceable package medium = Modelica.Media.Water.StandardWater( );
    //Component(s)
    inner Modelica.Fluid.System system;
    Modelica.Fluid.Vessels.ClosedVolume volume (nPorts = 1, redeclare package Medium = medium, V = 0.05);
    Modelica.Fluid.Machines.SweptVolume Swept1 (
        pistonCrossArea = 0.0001131,
        clearance = 0.00000250621,
        redeclare package Medium = Modelica.Media.Water.StandardWater,
        nPorts = 1,
        use_portsData = false,
        massDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial,
        energyDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial,
        p_start = 1e5,
        use_T_start = true,
        T_start = 293.15,
        V(start = 0.005),
        m(start = 0.005));
    Modelica.Mechanics.Translational.Sources.Position Posit1 (exact = true, useSupport = false);
    Modelica.Blocks.Sources.Sine Sine1 (
        amplitude = 0.005567,
        freqHz = 46.66,
        offset = 0.005567,
        phase = -Modelica.Constants.pi/4);


equation
    //Connection(s)
    connect(Sine1.y, Posit1.s_ref);
    connect(Posit1.flange, Swept1.flange);
    connect(Swept1.ports, volume.ports);
end  Hochdruckreiniger4;

enter image description here


Solution

  • After changing the volume's parameters (adding a diameter to the port) the model seems to work. This results in the following code for the volume model:

    Modelica.Fluid.Vessels.ClosedVolume volume(nPorts = 1, redeclare package Medium = medium, V = 0.05, portsData={Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter=0.001)}); 
    

    The simulation still gives some warnings regarding pressure (probably because the estimated diameter of 1mm does not make a lot of sense), but the pressure in the volume does not look totally off.

    Some background (though I'm not very experienced with the Fluid package): For use_portsData = true the diameter needs to be specified as it does not have any start or default value. In Dymola the simulation would not even start without a value for it. Actually there should be at least a warning if there is no value set. Assuming that it takes 0 as value for the diameter it would be reasonable that the model brakes, as there cannot be any flow into the volume.

    As an alternative it could be possible to set use_portsData to false. I think this will result in no resistance at the volumes connector. Still it good practice to not connect volume-type models directly, but always have a resistance-type model in between. Actually it is best to have volume- and resistance-type models in alternating order.