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
  • » sdaix
  • » Profile

Posts

Posts

Hello

I ask myself a question about the possibility of carrying out under openmodelica the inerting of piping.
For example, I have natural gas and I inject an inert gas like nitrogen to replace it. The piping would be quite long and I would like to see the propagation of nitrogen within this piping.
This piping could be considered the filling.
You could advise me to do this model ?

Thank you
Steven

Hi Carlos

So I think it's going to be complicated to use openmodelica for my project with hydrogen pure without coolprop or the helmhotlz library.

Thank you anyway for your help

I come back to you I tried to check the coefficient that you entered for the equation of state. Looks good for all settings. I just didn't check HCRIT0 and SCRIT0.

I am doing some time step testing to see if it can improve things.

I test with helium medium, I don't have the same problem. The time step has no influence

Steven

Hi Carlos,

Well seen for the volume, I had stayed on the volume of the container. It corresponds better to what is presented in the document.

Yes I agree with you on the physical properties. But when you're done re-adjusting your conversion file for transport properties, I'm in for it.

For the convergence problem, it's a bit more annoying. Do you think this comes from the helmholtzfluid module? I have the impression that it gets better when you increase the inlet temperature. It may be necessary to adjust the time step?

Thank you anyway for your help

Regards
STeven

Hello

I have a problem with a following equation (I think).
When I run the calculation, openmodelica warns me of a division by zero when calculating a reynolds.
So I think that this comes from the mu_in variable which is not initialized during the launch of the computation at t = 0s.

ReynoldsNumber = (if Vdot <> 0 then d_in * abs (Vdot / A) * Diameter / mu_in else 1);

Can I define an initialization in the first part of the code? I have to reconsider the calculation of the reynolds?

I put part of the code attached to this post.
problem-divided-0.zip

I update this post.
The problem was with the if.
It is necessary to modify the structure of the if
       if portA.m_flow> = 0 then
         mediumA = Medium.setState_ph (portA.p, inStream (portA.h_outflow));
       else
         mediumA = Medium.setState_ph (portA.p, portA.h_outflow);
       end if;

in :
      mediumA = (if portA.m_flow> = 0 then Medium.setState_ph (portA.p, inStream (portA.h_outflow)) else Medium.setState_ph (portA.p, portA.h_outflow));

Hello

I currently have a problem when I try to run a calculation with this attached module.
I have a feeling that the problem is located on the if loop is not performing properly on initialization.
I get this error:
Internal error - BackendDAEOptimize.makeEquationToResidualExp failed to transform equation: tank1_4.mediumStream = test_model.Models.TestPressurelosses.tank1_4.Medium.setState_phX(tank1_4.p, tank1_4.h, {}, 0) to residual form!

Should I change the shape of the loop?


model-tank.zip


Thank you for your help
Steven

Hi Carlos

I come back to you after some tests, The model I sent you does not work. I tried to put several thermal resistance and inertia with finally a convetive exchange.
The exchange between the tank and the first layer is too large, I should add a resistance related to the fluid and the second inertia remains too cold.
I am looking to adapt a multilayer model for use. I found a law of convection in a cylinder which will allow me to model an exchange in the reservoir.

        //calculation of rayleighs number taken from 'Natural convection cooling of
        //rectangular and cylindrical containers' by Wenxian Lin, S.W. Armfield
        Ra=g*beta*d^3*Medium.specificHeatCapacityCp(medium)*
        Medium.density(medium)^2*abs(portA.T-T)/(v*k);
        beta=1/portA.T;
        Tau=time/(d^2/(a*Ra^(1/2)));
        Nu=0.104*Ra^(0.352);

Thank you for your help
Steven

Hi Carlos

Thank you for your reply

I have currently coded this model which serves as a basis for the subject.
I used the valve which is available in the fluid package and I added the properties according to helmholtz as you had thought also I took the parameters of the helium to start which was available.
I think that the shape will be important in the thermal but in a second step, because it will surely be necessary to adjust the heat exchange surface.
I have a lot of discrepancy between my current model and the results of the document.
I'm looking at where the problem could be coming from and thought it was from the valve. Possibly the absence of transport properties depending on the equation of state.


valve-cas-3.zip

Hi Carlos

Yes you right the thermocycle library works. I made a mistake on the module of helmholtz.


in fact, I am using this document as validation of the module. In it there is a "simple" case compose of :
*  a source of pressure with a ramp on 600s
* a valve with some parameter followng the pressure gradient.
          if sonic : Pin > 2Pout
                    dm/dt=C kv Pin (rho_nominal / Temperature_in)^1/2
          if subsonic Pin <=2Pout
                    dm/dt= 2 C kv (rho_nom (Pin - Pout) * Pout / Temperature_in)^1/2
C is a constant equal at 257
* a closed tank 

Source <-->  valve <--> tank

This system is carried out with hydrogen gas and for initial pressure at 100bar and final pressure at 437 bar at 600s at the level of source

Once the module is validated I could develop an entire filling line for several tanks and different sizes of pipes / tanks.

Thank you for your help
Steven

I thinh there are a problem

Following link :
https://prhyde-cdn.s3-accelerate.amazon … vision.pdf

Hi Carlos

Perfect I understand. Thank you for your help.
I Have two adding questions :

    I try to test the thermocycle library with helmholtzlibrary but I have an extra equation (20 instead of 19 for the valve model). Have you ever used this bookstore? You would know the difference between coolprop and helmholtz library to explain this problem.

    I try also to code these following equations (figure 3 and 4) for my training and I want to be sure that it is possible with this library. I have some difficulties to code theses equations.

    equation

    Hi Carlos,

    Yes I am very insterested by this file for hydrogen.

    I was doing by hand the passage of an fld file in helhmotzfluid. It takes a long time to find the right value.

    if you want to complete your file I can provide you with the hydrogen fld file

    Thank you 

    In any case, thank you for your help

    I am going to work on your two solutions :

    Carlos, I find apublication with helmholtz coefficient for hydrogen used by refprop but I don't understand for the moment how can helmholtz coefficient inside helmholtz media to work. I compare the model for helium that is already in library and the theory of coefficient to understand the working of module.

    Adrpo, I test your version of externalmedia with my configuration. I have two differents behavior :

      ExternalMedia/Examples/CO2RefProp : I have an error on the function og getMolarMass

        ExternalMedia/Test/Pentane_hs : The verification is good but I have this error :
        ExternalMedia.Test.CoolProp.Pentane_hs_functions.c: In function 'omc_ExternalMedia_Test_CoolProp_Pentane__hs_wf_setBubbleState':
        ExternalMedia.Test.CoolProp.Pentane_hs_functions.c:228:40: warning: passing argument 1 of 'TwoPhaseMedium_setBubbleState_C_impl' from incompatible pointer type [-Wincompatible-pointer-types]
           TwoPhaseMedium_setBubbleState_C_impl(_sat_ext, _phase_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));

        Thank you for your help
        Steven

        Ok it is a good news for me this work on coolprop.
        I hope that it's going to work

        I find the hydrogen library linked at https://backend.orbit.dtu.dk/ws/portalf … ations.pdf

        i thought it would work
        Maybe, there are some errors insides this code but this library will be used like a base.

        Thank you for your help. You give me hope

        Hi

        Thank you for quick answer

        Ok I give up to use this library to calculate the behavior of hydrogen.
        I try since one week but I find any solution to use corretly coolprop library with openmodelica (same in recompiling)

        Thank you for your help

        In testing other module, I have always a problem with  setState__pT.
        I think this function don't return the right parameter.

        function setState_pT
            "Return thermodynamic state record from p and T"
            extends Modelica.Icons.Function;
            input AbsolutePressure p "pressure";
            input Temperature T "temperature";
            input FixedPhase phase = 0
              "2 for two-phase, 1 for one-phase, 0 if not known";
            output ThermodynamicState state;
          external "C" TwoPhaseMedium_setState_pT_C_impl(p, T, state, mediumName, libraryName, substanceName)
            annotation(Include="#include \"externalmedialib.h\"", Library="ExternalMediaLib", IncludeDirectory="modelica://ExternalMedia/Resources/Include", LibraryDirectory="modelica://ExternalMedia/Resources/Library");
          end setState_pT;

        I think my problem is principally on this function

        Thank you for your quick answer

        I try to run models verification of componentes.
        For example, I run HydrogenFuelingStationLibrary/Models/Tanks

        Hello

        I have a problem to use thermocyle module added at openmodelica with externalmedia.
        The problem is located on the calculation of sound velocity with the function of setState_pT.
        In searching on google, I think that the problem from to evaluate pure /impure function.

        Is it possible to add test loop on pure function ?
        Modelica.SIunits.Velocity C_thr(start=Medium.velocityOfSound(Medium.setState_pT(p_choked_start, T_su_start)));

        When I change this function in constant, the problem appears on this following function :
        CheckCoolPropOptions

        Can you advise me to modify this line ?

        Thank you for your help
        Steven

        Hello

        I search to convert dymola model to openmodelica model.
        My base model is https://github.com/DTU-TES/Hydrogen-Fuelling-Station

        When I run the test model, I have this error :


        [10] 18:25:47 Traduction Erreur
        Internal error - BackendDAEOptimize.makeEquationToResidualExp failed to transform equation: pressureLoss.mediumB = HydrogenFuelingStationLibrary.Models.VerificationOfComponents.Valves.pressureLoss.Medium.setState_ph(pressureLoss.portB.p, tank1_2.portA.h_outflow, 0) to residual form!

        [11] 18:25:47 Traduction Erreur
        Internal error - BackendDAEOptimize.makeEquationToResidualExp failed to transform equation: tank1_2.mediumStream = HydrogenFuelingStationLibrary.Models.VerificationOfComponents.Valves.tank1_2.Medium.setState_ph(tank1_2.p, tank1_2.h, 0) to residual form!

        [12] 18:25:47 Traduction Erreur
        Internal error - BackendDAEOptimize.makeEquationToResidualExp failed to transform equation: tank1_1.mediumStream = HydrogenFuelingStationLibrary.Models.VerificationOfComponents.Valves.tank1_1.Medium.setState_ph(tank1_1.p, tank1_1.h, 0) to residual form!


        Can you advise me to modify this part ?

        Thank you for your help
        Steven

        Hi

        Thank you very much for your help

        I find my problem. An error of beginner. I forget the time of my valve.

        Hello

        I am beginner on openmodelica and I want to model a simple system in transient:

        pressure source --> valve (with kv coefficient) --> pipe --> closedvolume.

        This model is composed only hydrogen gas with very high pressure (between 100 and 700bar)
        I build my model step by step.

        When I run my model, I have problem inside my valve and I don't understand why.

        following it's my little model

        model valve_cas

          replaceable package Medium =
              Modelica.Media.Incompressible.Examples.Glycol47
            constrainedby Modelica.Media.Interfaces.PartialMedium;
           
          inner Modelica.Fluid.System system(T_ambient(displayUnit = "K") = -15, energyDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial) 
          annotation(
            Placement(visible = true, transformation(origin = {-160, 76}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
            Modelica.Fluid.Sources.FixedBoundary boundary(
            redeclare package Medium = Medium, T = Modelica.SIunits.Conversions.from_degC(-15), p = 2000000, use_p = true) 
            annotation(
            Placement(visible = true, transformation(origin = {-64, -26}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Fluid.Vessels.ClosedVolume reservoir(
            redeclare package Medium = Medium,V = 0.35, massDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial, nPorts = 1, p_start = system.p_ambient, use_HeatTransfer = false, use_portsData = false) 
            annotation(
            Placement(visible = true, transformation(origin = {130, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
          Modelica.Fluid.Valves.ValveIncompressible valveIncompressible(
            redeclare package Medium = Medium,CvData = Modelica.Fluid.Types.CvTypes.Kv, Kv = 0.11, allowFlowReversal = false, checkValve = false, dp(displayUnit = "Pa", start = 10), dp_nominal(displayUnit = "Pa") = 1e6, m_flow_nominal = 0.04579, opening_nominal = 1, show_T = false) 
            annotation(
            Placement(visible = true, transformation(origin = {28, -14}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        Modelica.Fluid.Pipes.DynamicPipe pipe(
            redeclare package Medium = Medium,
          allowFlowReversal = false,diameter = 0.005, length = 1)  annotation(
            Placement(visible = true, transformation(origin = {86, -16}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        equation
          connect(boundary.ports[1], valveIncompressible.port_a) annotation(
            Line(points = {{-54, -26}, {-15, -26}, {-15, -14}, {18, -14}}, color = {0, 127, 255}));
          connect(valveIncompressible.port_b, pipe.port_a) annotation(
            Line(points = {{38, -14}, {52, -14}, {52, -16}, {76, -16}}, color = {0, 127, 255}));
          connect(pipe.port_b, reservoir.ports[1]) annotation(
            Line(points = {{96, -16}, {130, -16}, {130, 10}}, color = {0, 127, 255}));
          annotation(
            Diagram(coordinateSystem(extent = {{-200, -100}, {200, 100}})),
            Icon(coordinateSystem(extent = {{-200, -100}, {200, 100}})),
            version = "",
            uses(Modelica(version = "3.2.3")));
        end valve_cas;

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