1

I try to understand MSL Fluid and Media better and study the very basic example Modelica.Fluid.Examples.Tanks.EmptyTanks. Water flows simply from the upper tank to the lower tank.See code below, with T_start added for each tank to also work well with JModelica (as well as OpenModelica). I still stick to MSL 3.2.2 build 3 (and MSL 3.2.3 for OpenModelica).

encapsulated package MSL_FLUID_MEDIA_TEST

    import Modelica.Icons.Example;
    import Modelica.Fluid.Vessels.OpenTank;
    import Modelica.Fluid.Vessels.BaseClasses.VesselPortsData;
    import Modelica.Fluid.Pipes.StaticPipe;
    import Modelica.Media.Water;
    import Modelica.Fluid.System;
    import Modelica.Fluid.Types.Dynamics;

    model EmptyTanks4   
        extends Example;
        OpenTank tank1(
            redeclare package Medium = Water.StandardWaterOnePhase,
            T_start = 300,
            nPorts = 1,
            crossArea = 1,
            level_start = 1,
            portsData = {VesselPortsData(diameter = 0.1)},
            height = 1.1);
        StaticPipe pipe(
            redeclare package Medium = Water.StandardWaterOnePhase,
            length = 1,
            diameter = 0.1,
            height_ab =-1);
        OpenTank tank2(
            redeclare package Medium = Water.StandardWaterOnePhase,
            T_start = 300,
            nPorts = 1,
            crossArea = 1,
            level_start = 1.0e-10,
            portsData = {VesselPortsData(diameter = 0.1, height = 0.5)},
            height = 1.1);
        inner System system(energyDynamics = Dynamics.FixedInitial);        
    equation
        connect(tank1.ports[1], pipe.port_a);
        connect(pipe.port_b, tank2.ports[1]);
    end EmptyTanks4;                

end MSL_FLUID_MEDIA_TEST;

I would like to change to some other water medium that allows small concentrations of some material. The term often used is I think "trace substance". We should address concentrations of completely solvable substances and only liquid phase. I looked in MSL Fluid Users Guide but I do not understand. How do I change the medium for this?

The chosen medium StandardWaterOnePhase make the model have variables tank1.medium.X[1] and tank2.medium.X[1] that give the mass fraction of a substance. However, they do not show up when I for the fmu using PyFMI do model.get_states_list(). Here I only see the level and temperature for each tank. I guess something should be enabled in the model, likely at compilation time to have trace substance X[1] there as a state. What should be done?

janpeter
  • 681
  • 8
  • 22

0 Answers0