FCSys.Conditions.Adapters.MSL.Junctions

Modelica junctions between pure substances and their mixtures

Information

Extends from Modelica.Icons.Package (Icon for standard packages).

Package Content

NameDescription
FCSys.Conditions.Adapters.MSL.Junctions.Junction2 Junction2 Junction between two pure substances and their mixture
FCSys.Conditions.Adapters.MSL.Junctions.Junction3 Junction3 Junction between three pure substances and their mixture
FCSys.Conditions.Adapters.MSL.Junctions.PartialJunction PartialJunction Base model for a junction between pure substances and their mixture

FCSys.Conditions.Adapters.MSL.Junctions.Junction2 FCSys.Conditions.Adapters.MSL.Junctions.Junction2

Junction between two pure substances and their mixture FCSys.Conditions.Adapters.MSL.Junctions.Junction2

Information

Assumptions:

  1. The mixing is ideal. If the pure substances are being combined, then the massic enthalpy of the mixture is the mass-weighted sum of the pure substances. If the mixture is being split, then each of the pure substances receives fluid at the same massic enthalpy.
  2. The mixture observes Dalton's law. The pressure of the mixture is the sum of the pressures of the pure substances.
Extends from PartialJunction (Base model for a junction between pure substances and their mixture).

Parameters

TypeNameDefaultDescription
Material properties
replaceable package MixtureMediumMedia.AnodeGasMedium model for the mixture
replaceable package Medium1Modelica.Media.IdealGases.Si…Medium model for the 1st pure substance
replaceable package Medium2Modelica.Media.IdealGases.Si…Medium model for the 2nd pure substance

Connectors

TypeNameDescription
FluidPort_amixturePortFluid port for the mixture
FluidPort_bpurePort1Fluid port for the 1st pure substance
FluidPort_bpurePort2Fluid port for the 2nd pure substance
Material properties
replaceable package Medium1Medium model for the 1st pure substance
replaceable package Medium2Medium model for the 2nd pure substance

Modelica definition

model Junction2 
  "Junction between two pure substances and their mixture"
  import assert = FCSys.Utilities.assertEval;
  extends PartialJunction;

  replaceable package Medium1 = Modelica.Media.IdealGases.SingleGases.H2 
    constrainedby Modelica.Media.Interfaces.PartialPureSubstance 
    "Medium model for the 1st pure substance";
  replaceable package Medium2 = Modelica.Media.IdealGases.SingleGases.H2O 
    constrainedby Modelica.Media.Interfaces.PartialPureSubstance 
    "Medium model for the 2nd pure substance";

  Modelica.Fluid.Interfaces.FluidPort_b purePort1(redeclare final package
      Medium = Medium1) "Fluid port for the 1st pure substance";
  Modelica.Fluid.Interfaces.FluidPort_b purePort2(redeclare final package
      Medium = Medium2) "Fluid port for the 2nd pure substance";

initial equation 
  // Check the number and names of substances
  assert(MixtureMedium.nS == 2, "The mixture medium must have exactly two substances.");
  assert(MixtureMedium.substanceNames[1] == Medium1.substanceNames[1], "The first substance of the mixture medium (MixtureMedium) is \""
     + MixtureMedium.substanceNames[1] + "\",
but the first pure substance is \"" + Medium1.substanceNames[1] + "\".");
  assert(MixtureMedium.substanceNames[2] == Medium2.substanceNames[1], "The second substance of the mixture medium (MixtureMedium) is \""
     + MixtureMedium.substanceNames[2] + "\",
but the second pure substance is \"" + Medium2.substanceNames[1] + "\".");

  // Check the extra properties.
  assert(MixtureMedium.nC == Medium1.nC and MixtureMedium.nC == Medium2.nC, "The media must all have the same number of extra properties.");
  for i in 1:MixtureMedium.nC loop
    assert(MixtureMedium.extraPropertiesNames[i] == Medium1.extraPropertiesNames[
      i], "Extra property #" + String(i) + " of the mixture medium (MixtureMedium) is \""
       + MixtureMedium.extraPropertiesNames[i] + "\",
but that of the first pure substance (Medium1) is \"" + Medium1.extraPropertiesNames[
      i] + "\".");
    assert(MixtureMedium.extraPropertiesNames[i] == Medium2.extraPropertiesNames[
      i], "Extra property #" + String(i) + " of the mixture medium (MixtureMedium) is \""
       + MixtureMedium.extraPropertiesNames[i] + "\",
but that of the second pure substance (Medium2) is \"" + Medium2.extraPropertiesNames[
      i] + "\".");
  end for;

equation 
  // Dalton's law (additivity of pressure)
  mixturePort.p = purePort1.p + purePort2.p;

  // Streams
  // -------
  // Enthalpy
  purePort1.h_outflow = inStream(mixturePort.h_outflow);
  purePort2.h_outflow = inStream(mixturePort.h_outflow);
  mixturePort.h_outflow = X*{inStream(purePort1.h_outflow),inStream(purePort2.h_outflow)};
  // 
  // Extra properties
  purePort1.C_outflow = inStream(mixturePort.C_outflow);
  purePort2.C_outflow = inStream(mixturePort.C_outflow);
  mixturePort.C_outflow = X*{inStream(purePort1.C_outflow),inStream(purePort2.C_outflow)};

  // Mass conservation (no storage)
  0 = X[1]*mixturePort.m_flow + purePort1.m_flow "Substance 1";
  0 = X[2]*mixturePort.m_flow + purePort2.m_flow "Substance 2";
end Junction2;

FCSys.Conditions.Adapters.MSL.Junctions.Junction3 FCSys.Conditions.Adapters.MSL.Junctions.Junction3

Junction between three pure substances and their mixture FCSys.Conditions.Adapters.MSL.Junctions.Junction3

Information

Assumptions:

  1. The mixing is ideal. If the pure substances are being combined, then the massic enthalpy of the mixture is the mass-weighted sum of the pure substances. If the mixture is being split, then each of the pure substances receives fluid at the same massic enthalpy.
  2. The mixture observes Dalton's law. The pressure of the mixture is the sum of the pressures of the pure substances.
Extends from PartialJunction (Base model for a junction between pure substances and their mixture).

Parameters

TypeNameDefaultDescription
Material properties
replaceable package MixtureMediumMedia.CathodeGasMedium model for the mixture
replaceable package Medium1Modelica.Media.IdealGases.Si…Medium model for the 1st pure substance
replaceable package Medium2Modelica.Media.IdealGases.Si…Medium model for the 2nd pure substance
replaceable package Medium3Modelica.Media.IdealGases.Si…Medium model for the 3rd pure substance

Connectors

TypeNameDescription
FluidPort_amixturePortFluid port for the mixture
FluidPort_bpurePort1Fluid port for the 1st pure substance
FluidPort_bpurePort2Fluid port for the 2nd pure substance
FluidPort_bpurePort3Fluid port for the 3rd pure substance
Material properties
replaceable package MixtureMediumMedium model for the mixture
replaceable package Medium1Medium model for the 1st pure substance
replaceable package Medium2Medium model for the 2nd pure substance
replaceable package Medium3Medium model for the 3rd pure substance

Modelica definition

model Junction3 
  "Junction between three pure substances and their mixture"
  import assert = FCSys.Utilities.assertEval;
  extends PartialJunction(redeclare replaceable package MixtureMedium = Media.CathodeGas);

  replaceable package Medium1 = Modelica.Media.IdealGases.SingleGases.H2O 
    constrainedby Modelica.Media.Interfaces.PartialPureSubstance 
    "Medium model for the 1st pure substance";
  replaceable package Medium2 = Modelica.Media.IdealGases.SingleGases.N2 
    constrainedby Modelica.Media.Interfaces.PartialPureSubstance 
    "Medium model for the 2nd pure substance";
  replaceable package Medium3 = Modelica.Media.IdealGases.SingleGases.O2 
    constrainedby Modelica.Media.Interfaces.PartialPureSubstance 
    "Medium model for the 3rd pure substance";

  Modelica.Fluid.Interfaces.FluidPort_b purePort1(redeclare final package
      Medium = Medium1) "Fluid port for the 1st pure substance";
  Modelica.Fluid.Interfaces.FluidPort_b purePort2(redeclare final package
      Medium = Medium2) "Fluid port for the 2nd pure substance";
  Modelica.Fluid.Interfaces.FluidPort_b purePort3(redeclare final package
      Medium = Medium3) "Fluid port for the 3rd pure substance";

initial equation 
  // Check the number and names of substances
  assert(MixtureMedium.nS == 3, "The mixture medium must have exactly three substances.");
  assert(MixtureMedium.substanceNames[1] == Medium1.substanceNames[1], "The first substance of the mixture medium (MixtureMedium) is \""
     + MixtureMedium.substanceNames[1] + "\",
but the first pure substance is \"" + Medium1.substanceNames[1] + "\".");
  assert(MixtureMedium.substanceNames[2] == Medium2.substanceNames[1], "The second substance of the mixture medium (MixtureMedium) is \""
     + MixtureMedium.substanceNames[2] + "\",
but the second pure substance is \"" + Medium2.substanceNames[1] + "\".");
  assert(MixtureMedium.substanceNames[3] == Medium3.substanceNames[1], "The second substance of the mixture medium (MixtureMedium) is \""
     + MixtureMedium.substanceNames[3] + "\",
but the third pure substance is \"" + Medium2.substanceNames[1] + "\".");

  // Check the extra properties.
  assert(MixtureMedium.nC == Medium1.nC and MixtureMedium.nC == Medium2.nC and 
    MixtureMedium.nC == Medium3.nC, "The media must all have the same number of extra properties.");
  for i in 1:MixtureMedium.nC loop
    assert(MixtureMedium.extraPropertiesNames[i] == Medium1.extraPropertiesNames[
      i], "Extra property #" + String(i) + " of the mixture medium (MixtureMedium) is \""
       + MixtureMedium.extraPropertiesNames[i] + "\",
but that of the first pure substance (Medium1) is \"" + Medium1.extraPropertiesNames[
      i] + "\".");
    assert(MixtureMedium.extraPropertiesNames[i] == Medium2.extraPropertiesNames[
      i], "Extra property #" + String(i) + " of the mixture medium (MixtureMedium) is \""
       + MixtureMedium.extraPropertiesNames[i] + "\",
but that of the second pure substance (Medium2) is \"" + Medium2.extraPropertiesNames[
      i] + "\".");
    assert(MixtureMedium.extraPropertiesNames[i] == Medium3.extraPropertiesNames[
      i], "Extra property #" + String(i) + " of the mixture medium (MixtureMedium) is \""
       + MixtureMedium.extraPropertiesNames[i] + "\",
but that of the third pure substance (Medium3) is \"" + Medium3.extraPropertiesNames[
      i] + "\".");
  end for;

equation 
  // Dalton's law (additivity of pressure)
  mixturePort.p = purePort1.p + purePort2.p + purePort3.p;

  // Streams
  // -------
  // Enthalpy
  purePort1.h_outflow = inStream(mixturePort.h_outflow);
  purePort2.h_outflow = inStream(mixturePort.h_outflow);
  purePort3.h_outflow = inStream(mixturePort.h_outflow);
  mixturePort.h_outflow = X*{inStream(purePort1.h_outflow),inStream(purePort2.h_outflow),
    inStream(purePort3.h_outflow)};
  // 
  // Extra properties
  purePort1.C_outflow = inStream(mixturePort.C_outflow);
  purePort2.C_outflow = inStream(mixturePort.C_outflow);
  purePort3.C_outflow = inStream(mixturePort.C_outflow);
  mixturePort.C_outflow = X*{inStream(purePort1.C_outflow),inStream(purePort2.C_outflow),
    inStream(purePort3.C_outflow)};

  // Mass conservation (no storage)
  0 = X[1]*mixturePort.m_flow + purePort1.m_flow "Substance 1";
  0 = X[2]*mixturePort.m_flow + purePort2.m_flow "Substance 2";
  0 = X[3]*mixturePort.m_flow + purePort3.m_flow "Substance 3";
end Junction3;

FCSys.Conditions.Adapters.MSL.Junctions.PartialJunction FCSys.Conditions.Adapters.MSL.Junctions.PartialJunction

Base model for a junction between pure substances and their mixture FCSys.Conditions.Adapters.MSL.Junctions.PartialJunction

Information

Extends from FCSys.Icons.Names.Top3.

Parameters

TypeNameDefaultDescription
Material properties
replaceable package MixtureMediumMedia.AnodeGasMedium model for the mixture

Connectors

TypeNameDescription
FluidPort_amixturePortFluid port for the mixture
Material properties
replaceable package MixtureMediumMedium model for the mixture

Modelica definition

partial model PartialJunction 
  "Base model for a junction between pure substances and their mixture"
  extends FCSys.Icons.Names.Top3;

  replaceable package MixtureMedium = Media.AnodeGas constrainedby 
    Modelica.Media.Interfaces.PartialMedium "Medium model for the mixture";

  Modelica.Fluid.Interfaces.FluidPort_a mixturePort(redeclare final package
      Medium = MixtureMedium) "Fluid port for the mixture";

  Modelica.SIunits.MassFraction X[MixtureMedium.nX] 
    "Mass fractions within the mixture";

equation 
  // Mass fractions
  X = if MixtureMedium.fixedX then MixtureMedium.reference_X else if 
    MixtureMedium.reducedX then cat(
    1,
    inStream(mixturePort.Xi_outflow),
    1 - sum(X[1:MixtureMedium.nXi])) else inStream(mixturePort.Xi_outflow);
  X = if MixtureMedium.reducedX then cat(
    1,
    mixturePort.Xi_outflow,
    1 - sum(X[1:MixtureMedium.nXi])) else mixturePort.Xi_outflow;
end PartialJunction;