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

Stream variables in fluid connectors

Stream variables in fluid connectors

Hi

I’ve just started using Modelica, with the ThermoPower library, and would be very grateful if someone could help me understand the use of stream connectors in Modelica.

To simplify, I've tried to create a model with a PressureSource and a PressureSink only, where the enthalpy of the fluid entering the sink is set to be that of saturated steam at the input sink pressure, calculated using a function from the IF97 utilities.  I'm using the ThermoPower component PressureSource and have adapted a component for the pressure sink with the following:

model PressSink_SatSteam
  extends ThermoPower.Icons.Water.SourceP;
  replaceable package Medium = Modelica.Media.Water.StandardWater constrainedby
    Modelica.Media.Interfaces.PartialMedium "Medium model";
  parameter Modelica.SIunits.Pressure p0=1.01325e5 "Nominal pressure";

  parameter Boolean allowFlowReversal=system.allowFlowReversal ;
  outer ThermoPower.System system "System wide properties";

  Modelica.SIunits.Pressure p "Actual pressure";
  Modelica.SIunits.SpecificEnthalpy h_sat;
  Modelica.Media.Common.PhaseBoundaryProperties Props;

  ThermoPower.Water.FlangeA flange(redeclare package Medium = Medium, m_flow(min=if allowFlowReversal then -Modelica.Constants.inf else 0));

equation
  flange.p = p;
  p =  p0 "Pressure set by parameter";
  Props = Modelica.Media.Water.IF97_Utilities.BaseIF97.TwoPhase.waterVap_p(p0) "Find saturation properties at p0";
  h_sat = Props.h "Saturation enthallpy";
  inStream(flange.h_outflow) = h_sat;
end PressSink_SatSteam;


The complete model is as follows:

model Sat_steam_enthalpy

  ThermoPower.Water.SourcePressure sourcePressure(
    flange(m_flow(start=10, fixed=false)),
    h(start=398.5640641e3, fixed=false),
    p0(start=800000, fixed=true),
    p(start=800000, fixed=false));
  inner ThermoPower.System system(Dynamics=ThermoPower.Choices.System.Dynamics.DynamicFreeInitial);
  ThermoPower.Water.ThroughMassFlow throughMassFlow(w0=10);
  PressSink_SatSteam pressSink_SatSteam(p0=800000);
 
equation
  connect(sourcePressure.flange, throughMassFlow.inlet);
  connect(throughMassFlow.outlet, pressSink_SatSteam.flange);
 
end Sat_steam_enthalpy;


In OMEdit I receive an error telling me there is an imblanced number of equations and variables, but I cannot see why since I only want the enthalpy exiting the source to be set equal to the enthalpy entering the sink, calculated with the IF97 function.  I think I must be misunderstanding something basic about the stream definition of h_outflow and fluid connectors in general so would definitely appreciate any advice.

Many thanks in advance.

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