This package contains some models of gaseous CVs, gaseous mixtures TP (e.g., gas-flow by convection and diffusion, valves, pumps, etc.) and boundary conditions (i.e., gas-flow and pressure sources).
The mixtures of gases are considered ideal and they can be composed of an arbitrary number of components.
.
| Name | Description |
|---|---|
| Partial model - Convective flow of gas. | |
| Diffusion of an ideal, binary gas | |
| Gas flowing through a pipe | |
| Gas flowing through a pipe | |
| Partial model - Gas pump | |
| Gas pump. Setpoint: total mass-flow | |
| Gas pump. Setpoint: total molar-flow | |
| Gas pump. Setpoint: total volumetric-flow | |
| Homogeneous mixture of semi-perfect gases. | |
| Homogeneous mixture of semi-perfect gases inside a vessel. | |
| Gas-flow source | |
| Gas-flow source. Setpoint: total mass-flow, flow molar-fraction and flow temperature. | |
| Gas-flow source. Setpoint: total molar-flow, flow molar-fraction and flow temperature. | |
| Partial model - Pressure source. The across variables should be a funcion of time and state variables. | |
| Gas-flow source. Setpoint: total volume-flow, flow molar-fraction and flow temperature | |
| Vessel with a constant volume. |
JARA2i.gas.convecGasFlowB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6 | |
| Real | eps | 1.E-10 | Small constant to avoid by-zero division |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy of the components at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for enthalpy [T] |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive. |
| cutGasR | outMol | Gas flow - Connector Resistive. |
| cutHeatFC | inHeat | Heat flow - Connector F-C. Connector for the heat convection. |
partial model convecGasFlowB
"Partial model - Convective flow of gas."
extends interf.gasFlow2qI;
parameter Real CpCoefN[nComp,7] "Coefficients of the molar heat capacity at constant pressure
CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6";
parameter Real eps( unit="") = 1.E-10
"Small constant to avoid by-zero division";
parameter Real molEnthalpyRef[nComp]( unit="M.L2.t-2.mol-1") = zeros(nComp)
"Molar enthalpy of the components at the reference temperature";
parameter Real tempRef( unit="T") = 298
"Reference temperature for enthalpy";
Real totalMolF( unit="mol.t-1") "Total molar flow";
Boolean flowIsPosit( start=true) "Flow direction";
Real totalMolI( unit="mol") "Total number of mols";
Real totalMolO( unit="mol") "Total number of mols";
Real molEnthalpy[nComp]( unit="M.L2.t-2.mol-1")
"Molar enthalpy of the components";
equation
// Relationship among the interface variables
outMol.energyGF + inMol.energyGF + inHeat.heatF = 0;
inMol.molGF = - outMol.molGF;
inMol.molGF = inHeat.matterF;
// Flow direction
flowIsPosit = totalMolF > 0;
// Flow molar-fraction
if nComp > 1 then
for i in 1:(nComp-1) loop
inHeat.matterF[i] = if flowIsPosit then
totalMolF * inMol.molG[i] / ( totalMolI + eps) else
totalMolF * outMol.molG[i] / ( totalMolO + eps);
end for;
end if;
// Flujo molar total
totalMolF = sum(inHeat.matterF[i] for i in 1:nComp);
// Mols
totalMolI = sum(inMol.molG[i] for i in 1:nComp);
totalMolO = sum(outMol.molG[i] for i in 1:nComp);
// Flow temperature
inHeat.tempF = if flowIsPosit then inMol.tempG else outMol.tempG;
// Relationship between the molar enthalpy of the components and the temperature
for i in 1:nComp loop
molEnthalpy[i] = molEnthalpyRef[i] +
CpCoefN[i,1] * ( inHeat.tempF - tempRef) +
CpCoefN[i,2] * 1/2 * ( inHeat.tempF^ 2 - tempRef^ 2) +
CpCoefN[i,3] * 1/3 * ( inHeat.tempF^ 3 - tempRef^ 3) +
CpCoefN[i,4] * 1/4 * ( inHeat.tempF^ 4 - tempRef^ 4) +
CpCoefN[i,5] * 1/5 * ( inHeat.tempF^ 5 - tempRef^ 5) +
CpCoefN[i,6] * 1/6 * ( inHeat.tempF^ 6 - tempRef^ 6) +
CpCoefN[i,7] * 1/7 * ( inHeat.tempF^ 7 - tempRef^ 7);
end for;
// Total flow of energy
sum(inHeat.matterF[i]*molEnthalpy[i] for i in 1:nComp) = if flowIsPosit then inMol.energyGF else -outMol.energyGF;
end convecGasFlowB;
JARA2i.gas.diffSemiPerfGasBinCp6B
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | molEnthalpyRef[2] | 0 | Molar enthalpy at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature [T] |
| Real | CpCoefN[2, 7] | Coefficients of the molar heat capacity at constant pressure Cp[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6 | |
| Real | diffLength | Distance between the control volumes [L] | |
| Real | eps | 1.E-10 | Small constant to avoid by-zero division |
| Real | perfGasConst | Constant of the perfect gases [M.L2.t-2.T-1] |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive |
| cutGasR | outMol | Gas flow - Connector Resistive |
model diffSemiPerfGasBinCp6B "Diffusion of an ideal, binary gas"
extends interf.gasFlow2I(nComp=2);
parameter Real molEnthalpyRef[ 2]( unit="M.L2.t-2.mol-1") = 0
"Molar enthalpy at the reference temperature";
parameter Real tempRef( unit="T") = 298
"Reference temperature";
parameter Real CpCoefN[ 2,7] "Coefficients of the molar heat capacity at constant pressure
Cp[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6";
parameter Real diffLength( unit="L")
"Distance between the control volumes";
parameter Real eps( unit="") = 1.E-10
"Small constant to avoid by-zero division";
parameter Real perfGasConst( unit="M.L2.t-2.T-1")
"Constant of the perfect gases";
protected
Real diffArea( unit="L2")
"Diffusion section between the control volumes";
Real diffCoefI( unit="L2.t-1") "Diffusion coefficient";
Real diffCoefO( unit="L2.t-1") "Diffusion coefficient";
Real gasIVolume( unit="L3") "Volume of the gas mixture";
Real gasOVolume( unit="L3") "Volume of the gas mixture";
Real molEnthalpyTempI[ 2]( unit="M.L2.t-2.mol-1")
"Molar enthalpy of the flow from inMass to outMass";
Real molEnthalpyTempO[ 2]( unit="M.L2.t-2.mol-1")
"Molar enthalpy of the flow from outMass to inMass";
equation
// Relationship among the interface variables
inMol.molGF = - outMol.molGF;
inMol.energyGF + outMol.energyGF = 0;
// State equation of the perfect gases
( inMol.pressG + eps) * gasIVolume = (inMol.molG[1] + inMol.molG[2]) * perfGasConst * inMol.tempG;
( outMol.pressG + eps) * gasOVolume = (outMol.molG[1] + outMol.molG[2]) * perfGasConst * outMol.tempG;
// Fick law
inMol.molGF = diffArea * ( diffCoefI * inMol.molG / ( gasIVolume + eps) -
diffCoefO * outMol.molG / ( gasOVolume + eps)) / diffLength;
// Molar-enthalpy flow from inMass to outMass
molEnthalpyTempI = molEnthalpyRef + CpCoefN * [ inMol.tempG - tempRef;
1/2 * ( inMol.tempG^ 2 - tempRef^ 2);
1/3 * ( inMol.tempG^ 3 - tempRef^ 3);
1/4 * ( inMol.tempG^ 4 - tempRef^ 4);
1/5 * ( inMol.tempG^ 5 - tempRef^ 5);
1/6 * ( inMol.tempG^ 6 - tempRef^ 6);
1/7 * ( inMol.tempG^ 7 - tempRef^ 7)];
// Molar-enthalpy flow from outMass to inMass
molEnthalpyTempO = molEnthalpyRef + CpCoefN * [ outMol.tempG - tempRef;
1/2 * ( outMol.tempG^ 2 - tempRef^ 2);
1/3 * ( outMol.tempG^ 3 - tempRef^ 3);
1/4 * ( outMol.tempG^ 4 - tempRef^ 4);
1/5 * ( outMol.tempG^ 5 - tempRef^ 5);
1/6 * ( outMol.tempG^ 6 - tempRef^ 6);
1/7 * ( outMol.tempG^ 7 - tempRef^ 7)];
// Enthalpy flow
inMol.energyGF = diffArea * ( diffCoefI * sum(inMol.molG[i]*molEnthalpyTempI[i] for i in 1:2) /
( gasIVolume + eps) -
diffCoefO * sum(outMol.molG[i]* molEnthalpyTempO[i] for i in 1:2) /
( gasOVolume + eps)) / diffLength;
end diffSemiPerfGasBinCp6B;
JARA2i.gas.pipeDynGasB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6 | |
| Real | eps | 1.E-10 | Small constant to avoid by-zero division |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy of the components at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for enthalpy [T] |
| Real | length | Pipe length [L] | |
| Real | section | Pipe cross-section [L2] | |
| Real | wettedArea | Wetted area of the pipe [L2] | |
| Real | perfGasConst | Constant of the perfect gases [M.L2.t-2.T-1] | |
| Real | molecWeigth[nComp] | Molecular weight of the components [M.mol-1] | |
| Real | epsMomentum | 1 | Dynamic balance of linear momentum. = small value. Steady-state balance. |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive. |
| cutGasR | outMol | Gas flow - Connector Resistive. |
| cutHeatFC | inHeat | Heat flow - Connector F-C. Connector for the heat convection. |
| cutReceiver | setPointSignal | Setpoint signal |
model pipeDynGasB "Gas flowing through a pipe"
extends convecGasFlowB;
cutsB.cutReceiver setPointSignal( dim=1, signal={valveOpeningSP})
"Setpoint signal";
Real valveOpeningSP( unit="") "Setpoint of the valve opening";
parameter Real length( unit="L") "Pipe length";
parameter Real section( unit="L2") "Pipe cross-section";
parameter Real wettedArea( unit="L2") "Wetted area of the pipe";
parameter Real perfGasConst( unit="M.L2.t-2.T-1")
"Constant of the perfect gases";
parameter Real molecWeigth[nComp]( unit="M.mol-1")
"Molecular weight of the components";
parameter Real epsMomentum( unit="") = 1 "Dynamic balance of linear momentum.
= small value. Steady-state balance.";
protected
Real veloc( unit="L.t-1") "Velocity of the flow";
Real linMomentum( unit="M.L.t-1") "Lineal momentum";
Real pressForce( unit="M.L.t-2") "Pressure-diference force";
Real fricForce( unit="M.L.t-2") "Friction force";
Real gasDensity( unit="M.L-3") "Gas density";
Real fanning( unit="") "Fanning's adimensional coeficient";
Real totalMassF( unit="M.t-1") "Total mass-flow";
Real totalForce( unit="M.L.t-2") "Total force";
Real valveOpening( unit="", min=0, max=1) "Valve opening. Bounded value";
equation
// Density of the gas flow
gasDensity = if linMomentum > 0 then
sum(molecWeigth[i]*inMol.molG[i] for i in 1:nComp) * inMol.pressG /
( totalMolI * perfGasConst * inMol.tempG + eps) else
sum(molecWeigth[i]*outMol.molG[i] for i in 1:nComp) * outMol.pressG /
( totalMolO * perfGasConst * outMol.tempG + eps);
// Pressure-difference force
pressForce = section * ( inMol.pressG - outMol.pressG);
// Friction force
fricForce = if linMomentum > 0 then
-wettedArea * 0.5 * gasDensity * veloc^ 2 * fanning else
wettedArea * 0.5 * gasDensity * veloc^ 2 * fanning;
// Bounding of the valve-opening signal
valveOpening = if valveOpeningSP > 1 then
1 else
if valveOpeningSP < 0 then
0 else
valveOpeningSP;
// Linear momentum balance
totalForce = fricForce + valveOpening^ 2 * pressForce;
epsMomentum * der(linMomentum) = totalForce;
when linMomentum > 0 and not ( sum(inMol.molG[i] for i in 1:nComp) > 0) or
linMomentum < 0 and not ( sum(outMol.molG[i] for i in 1:nComp) > 0) or
not valveOpeningSP > 0 then
reinit(linMomentum,0);
end when;
linMomentum = totalMassF * length;
totalMassF = sum(molecWeigth[i]*inHeat.matterF[i] for i in 1:nComp);
totalMassF = section * ( gasDensity + eps) * veloc;
end pipeDynGasB;
JARA2i.gas.pressEqGasB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6 | |
| Real | eps | 1.E-10 | Small constant to avoid by-zero division |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy of the components at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for enthalpy [T] |
| Real | Kprop | 1E3 | Coefficient [mol.t.L.M-1] |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive. |
| cutGasR | outMol | Gas flow - Connector Resistive. |
| cutHeatFC | inHeat | Heat flow - Connector F-C. Connector for the heat convection. |
model pressEqGasB "Gas flowing through a pipe" extends convecGasFlowB; parameter Real Kprop( unit="mol.t.L.M-1") = 1E3 "Coefficient"; protected Real pressDif( unit="M.L-1.t-2") "Pressure difference"; Real relatError( unit="") "Relative error"; equation // Pressure difference // It has been arbitrary defined that the molar flow is proportional to the pressure gradient. pressDif = inMol.pressG - outMol.pressG; // The molar flow is proportional to the pressure difference totalMolF = Kprop * pressDif; // Relative error of assuming zero pressure-difference relatError = abs(pressDif) / ( 0.5 * ( inMol.pressG + outMol.pressG + eps)); end pressEqGasB;
JARA2i.gas.pumpGasB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6 | |
| Real | eps | 1.E-10 | Small constant to avoid by-zero division |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy of the components at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for enthalpy [T] |
| Real | pmax | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | pmin | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | pcodo | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | peps | Parameter of the pump constitutive relation [M.L-1.t-2] |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive. |
| cutGasR | outMol | Gas flow - Connector Resistive. |
| cutHeatFC | inHeat | Heat flow - Connector F-C. Connector for the heat convection. |
partial model pumpGasB "Partial model - Gas pump"
extends convecGasFlowB;
Real totalMolFSP( unit="mol.t-1") "Setpoint of the total molar-flow";
// Parameters of the pump constitutive relation: pmax > pcodo , pmin > peps
parameter Real pmax( unit="M.L-1.t-2")
"Parameter of the pump constitutive relation";
parameter Real pmin( unit="M.L-1.t-2")
"Parameter of the pump constitutive relation";
parameter Real pcodo( unit="M.L-1.t-2")
"Parameter of the pump constitutive relation";
parameter Real peps( unit="M.L-1.t-2")
"Parameter of the pump constitutive relation";
protected
Real pressTo( unit="M.L-1.t-2") "Load pressure";
Real pressFrom( unit="M.L-1.t-2") "Source pressure";
Real coefPressTo;
Real coefPressFrom;
equation
// Load pressure
pressTo = if totalMolFSP > 0 then outMol.pressG else inMol.pressG;
// Source pressure
pressFrom = if totalMolFSP > 0 then inMol.pressG else outMol.pressG;
// Constitutive relation of the pump
coefPressTo = if pressTo < pcodo then
1 else
if pressTo < pmax then
(pmax-pressTo) / (pmax-pcodo) else
0;
coefPressFrom = if pressFrom > pmin then
1 else
if pressFrom > peps then
(pressFrom-peps) / (pmin-peps) else
0;
totalMolF = coefPressTo * coefPressFrom * totalMolFSP;
end pumpGasB;
JARA2i.gas.pumpMassGasB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6 | |
| Real | eps | 1.E-10 | Small constant to avoid by-zero division |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy of the components at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for enthalpy [T] |
| Real | pmax | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | pmin | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | pcodo | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | peps | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | molecWeigth[nComp] | Molecular weigth of the components [M.moles-1] |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive. |
| cutGasR | outMol | Gas flow - Connector Resistive. |
| cutHeatFC | inHeat | Heat flow - Connector F-C. Connector for the heat convection. |
| cutReceiver | setPointSignal | Set.point signal |
model pumpMassGasB "Gas pump. Setpoint: total mass-flow"
extends pumpGasB;
cutsB.cutReceiver setPointSignal( dim=1, signal={totalMassFSP})
"Set.point signal";
Real totalMassFSP( unit="M.t-1") "Setpoint of the total mass-flow";
parameter Real molecWeigth[nComp]( unit="M.moles-1")
"Molecular weigth of the components";
equation
totalMolFSP = if totalMassFSP > 0 then
totalMolI * totalMassFSP / ( sum(molecWeigth[i]*inMol.molG[i] for i in 1:nComp) + eps) else
totalMolO * totalMassFSP / ( sum(molecWeigth[i]*outMol.molG[i] for i in 1:nComp) + eps);
end pumpMassGasB;
JARA2i.gas.pumpMolGasB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6 | |
| Real | eps | 1.E-10 | Small constant to avoid by-zero division |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy of the components at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for enthalpy [T] |
| Real | pmax | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | pmin | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | pcodo | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | peps | Parameter of the pump constitutive relation [M.L-1.t-2] |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive. |
| cutGasR | outMol | Gas flow - Connector Resistive. |
| cutHeatFC | inHeat | Heat flow - Connector F-C. Connector for the heat convection. |
| cutReceiver | setPointSignal | Set.point signal |
model pumpMolGasB "Gas pump. Setpoint: total molar-flow"
extends pumpGasB;
cutsB.cutReceiver setPointSignal( dim=1, signal={totalMolFSP})
"Set.point signal";
equation
end pumpMolGasB;
JARA2i.gas.pumpVolGasB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6 | |
| Real | eps | 1.E-10 | Small constant to avoid by-zero division |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy of the components at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for enthalpy [T] |
| Real | pmax | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | pmin | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | pcodo | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | peps | Parameter of the pump constitutive relation [M.L-1.t-2] | |
| Real | perfGasConst | Perfect-gas constant [M.L2.t-2.T-1] |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive. |
| cutGasR | outMol | Gas flow - Connector Resistive. |
| cutHeatFC | inHeat | Heat flow - Connector F-C. Connector for the heat convection. |
| cutReceiver | setPointSignal | Set-point signal |
model pumpVolGasB "Gas pump. Setpoint: total volumetric-flow"
extends pumpGasB;
cutsB.cutReceiver setPointSignal( dim=1, signal={totalVolFSP})
"Set-point signal";
Real totalVolFSP( unit="L3.t-1") "Setpoint of the volumetric flow";
parameter Real perfGasConst( unit="M.L2.t-2.T-1") "Perfect-gas constant";
equation
0 = if totalVolFSP > 0 then
inMol.pressG * totalVolFSP - totalMolFSP * perfGasConst * ( inMol.tempG + eps) else
outMol.pressG * totalVolFSP - totalMolFSP * perfGasConst * ( outMol.tempG + eps);
end pumpVolGasB;
JARA2i.gas.semiPerfGasCp6B
Homogeneous mixture of semi-perfect gases.
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | molGinitial[nComp] | Number of gas moles - Initial condition [mol] | |
| Real | tempGinitial | Gas temperature - Initial condition [T] | |
| Real | perfGasConst | Constant of the perfect gases [M.L2.t-2.T-1] | |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6 | |
| Real | eps | 1.E-10 | Small constant to avoid by-zero division |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy of the components at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for enthalpy [T] |
| Type | Name | Description |
|---|---|---|
| cutGasC | inMol | Gas flow - Connector Capacitive |
| cutHeatMC | inHeat | Heat flow - Connector M-C |
| cutVolConstrGas | constraintV | Volume constraint - Gas |
model semiPerfGasCp6B "Homogeneous mixture of semi-perfect gases."
extends interf.gasV1I;
parameter Real molGinitial[nComp]( unit="mol")
"Number of gas moles - Initial condition";
parameter Real tempGinitial( unit="T")
"Gas temperature - Initial condition";
parameter Real perfGasConst( unit="M.L2.t-2.T-1")
"Constant of the perfect gases";
parameter Real CpCoefN[nComp,7] "Coefficients of the molar heat capacity at constant pressure
CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6";
parameter Real eps( unit="") = 1.E-10
"Small constant to avoid by-zero division";
parameter Real molEnthalpyRef[nComp]( unit="M.L2.t-2.mol-1") = zeros(nComp)
"Molar enthalpy of the components at the reference temperature";
parameter Real tempRef( unit="T") = 298
"Reference temperature for enthalpy";
Real molG[ nComp]( unit="mol", start=molGinitial, fixed=true)
"Number of gas moles"; //CCC
Real tempG( unit="K", start=tempGinitial, fixed=true)
" Gas temperature";
Real fluidV( unit="m^3") "Gas volume";
protected
Real dIntEnergy( unit="M.L2.t-3")
"Derivative of the total internal energy";
Real molIntEnergy[ nComp]( unit="M.L2.t-2.mol-1")
"Molar internal energy of the components";
Real aux[ nComp];
Real vesselV;
equation
// Variable of the volume constraint connector
vesselV = constraintV.vcF;
// Relationship among the interface variables
inHeat.matter = molG;
inMol.molG = molG;
inHeat.temp = tempG;
inMol.tempG = tempG;
// constraintV.press = inMol.pressG;
constraintV.vcE[3] = inMol.pressG;
// Molar balance
der(molG) = inMol.molGF;
// Energy balance
dIntEnergy = inMol.energyGF + inHeat.heatF;
// The gas volume is equal to the control-volume volume
fluidV = vesselV;
// State equation of the perfect gases
inMol.pressG * ( fluidV + eps) = sum(inMol.molG[i] for i in 1:nComp) * perfGasConst * inMol.tempG;
// Relationship between the molar internal energy and the temperature
for i in 1:nComp loop
molIntEnergy[i] = molEnthalpyRef[i] - perfGasConst * inMol.tempG +
CpCoefN[i,1] * ( (inMol.tempG+eps) - tempRef) +
CpCoefN[i,2] * 1/2 * ( (inMol.tempG+eps)^ 2 - tempRef^ 2) +
CpCoefN[i,3] * 1/3 * ( (inMol.tempG+eps)^ 3 - tempRef^ 3) +
CpCoefN[i,4] * 1/4 * ( (inMol.tempG+eps)^ 4 - tempRef^ 4) +
CpCoefN[i,5] * 1/5 * ( (inMol.tempG+eps)^ 5 - tempRef^ 5) +
CpCoefN[i,6] * 1/6 * ( (inMol.tempG+eps)^ 6 - tempRef^ 6) +
CpCoefN[i,7] * 1/7 * ( (inMol.tempG+eps)^ 7 - tempRef^ 7);
end for;
for i in 1:nComp loop
aux[i] = CpCoefN[i,1] +
CpCoefN[i,2] * inMol.tempG +
CpCoefN[i,3] * inMol.tempG^ 2 +
CpCoefN[i,4] * inMol.tempG^ 3 +
CpCoefN[i,5] * inMol.tempG^ 4 +
CpCoefN[i,6] * inMol.tempG^ 5 +
CpCoefN[i,7] * inMol.tempG^ 6 -
perfGasConst;
end for;
dIntEnergy = sum(inMol.molGF[i]*molIntEnergy[i] for i in 1:nComp) +
sum(( inMol.molG[i] + eps) * aux[i] for i in 1:nComp) * der(tempG);
end semiPerfGasCp6B;
JARA2i.gas.semiPerfGasCp6VB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | perfGasConst | Constant of the perfect gases [M.L2.t-2.T-1] | |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6 | |
| Real | eps | 1.E-10 | Small constant to avoid by-zero division |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy of the components at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for enthalpy [T] |
| Real | vesselVolumeInitial | Vessel volume [L3] | |
| Real | molGinitial[nComp] | Initial condition [mol] | |
| Real | tempGinitial | Initial condition [T] |
| Type | Name | Description |
|---|---|---|
| cutGasC | inMol | Gas flow - Connector Capacitive |
| cutHeatMC | inHeat | Heat flow - Connector M-C |
model semiPerfGasCp6VB
"Homogeneous mixture of semi-perfect gases inside a vessel."
extends interf.gas1I;
parameter Real perfGasConst( unit="M.L2.t-2.T-1")
"Constant of the perfect gases";
parameter Real CpCoefN[nComp,7] "Coefficients of the molar heat capacity at constant pressure
CpMol[i] = CpCoefN[i,1] + CpCoefN[i,2]*T + ... + CpCoefN[i,7]*T**6";
parameter Real eps( unit="") = 1.E-10
"Small constant to avoid by-zero division";
parameter Real molEnthalpyRef[nComp]( unit="M.L2.t-2.mol-1") = zeros(nComp)
"Molar enthalpy of the components at the reference temperature";
parameter Real tempRef( unit="T") = 298
"Reference temperature for enthalpy";
parameter Real vesselVolumeInitial( unit="L3") "Vessel volume";
parameter Real molGinitial[nComp]( unit="mol") "Initial condition";
parameter Real tempGinitial( unit="T") "Initial condition";
semiPerfGasCp6B semiPerfGas( nComp=nComp,perfGasConst=perfGasConst,CpCoefN=CpCoefN,eps=eps,
molEnthalpyRef=molEnthalpyRef,tempRef=tempRef,
molGinitial=molGinitial, tempGinitial=tempGinitial);
vesselGasB vessel( vesselVolumeInitial=vesselVolumeInitial);
equation
connect( semiPerfGas.constraintV, vessel.constraintV);
connect( semiPerfGas.inMol, inMol);
connect( semiPerfGas.inHeat, inHeat);
end semiPerfGasCp6VB;
JARA2i.gas.sourceGasFB

| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure Cp[i] = CpCoef[i,1] + CpCoef[i,2]*T + ... + CpCoef[i,7]*T**6 | |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for the enthalpy [T] |
| Real | pmax | 1.0E6 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | pcodo | 9.5E5 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | pmin | 1 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | peps | 0.2 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | eps | 1.E-8 | Small constant to avoid by-zero division |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive |
model sourceGasFB "Gas-flow source"
extends interf.gasFlow1I;
Real molFractSP[ nComp]( unit="") "Setpoint of the molar fraction";
Real tempFSP( unit="T") "Setpoint of the flow temperature";
Real totalMolFSP( unit="mol.t-1")
"Setpoint of the total molar-flow";
parameter Real CpCoefN[nComp,7] "Coefficients of the molar heat capacity at constant pressure
Cp[i] = CpCoef[i,1] + CpCoef[i,2]*T + ... + CpCoef[i,7]*T**6";
parameter Real molEnthalpyRef[nComp]( unit="M.L2.t-2.mol-1") = zeros(nComp)
"Molar enthalpy at the reference temperature";
parameter Real tempRef( unit="T") = 298
"Reference temperature for the enthalpy";
parameter Real pmax( unit="M.L-1.t-2") = 1.0E6
"Parameter of the source constitutive relation";
parameter Real pcodo( unit="M.L-1.t-2") = 9.5E5
"Parameter of the source constitutive relation";
parameter Real pmin( unit="M.L-1.t-2") = 1
"Parameter of the source constitutive relation";
parameter Real peps( unit="M.L-1.t-2") = 0.2
"Parameter of the source constitutive relation";
parameter Real eps( unit="") = 1.E-8
"Small constant to avoid by-zero division";
Real tempF( unit="T") "Flow temperature";
protected
Boolean flowIsPosit( start = true) "Flow direction";
Real totalMolF( unit="mol.t-1") "Total molar flow";
Real totalMol( unit="mol") "Total mols";
Real molFract[ nComp]( unit="") "Molar fraction";
Real aux[ nComp];
equation
// Constitutive relation of the gas source
flowIsPosit = totalMolFSP > 0;
totalMolF = if flowIsPosit and inMol.pressG > pmin then
totalMolFSP else
if flowIsPosit and inMol.pressG > peps then
totalMolFSP * ( inMol.pressG - peps) / ( pmin - peps) else
if flowIsPosit then
0 else
if inMol.pressG < pcodo then
totalMolFSP else
if inMol.pressG < pmax then
totalMolFSP * ( pmax - inMol.pressG) / ( pmax - pcodo) else
0;
// Total mols
totalMol = sum(inMol.molG[i] for i in 1:nComp);
// Molar fraction
molFract = inMol.molG / ( totalMol + eps);
// Composition of the mass flow
if nComp > 1 then
for i in 1:(nComp-1) loop
inMol.molGF[i] = if flowIsPosit then
molFract[i] * totalMolF else
molFractSP[i] * totalMolF;
end for;
end if;
// Total molar flow
totalMolF = sum(inMol.molGF[i] for i in 1:nComp);
// Flow temperature
tempF = if flowIsPosit then inMol.tempG else tempFSP;
// Enthalpy flow
for i in 1:nComp loop
aux[i] = molEnthalpyRef[i] +
CpCoefN[i,1] * ( tempF - tempRef) +
CpCoefN[i,2] * 1/2 * ( tempF^ 2 - tempRef^ 2) +
CpCoefN[i,3] * 1/3 * ( tempF^ 3 - tempRef^ 3) +
CpCoefN[i,4] * 1/4 * ( tempF^ 4 - tempRef^ 4) +
CpCoefN[i,5] * 1/5 * ( tempF^ 5 - tempRef^ 5) +
CpCoefN[i,6] * 1/6 * ( tempF^ 6 - tempRef^ 6) +
CpCoefN[i,7] * 1/7 * ( tempF^ 7 - tempRef^ 7);
end for;
inMol.energyGF = sum(inMol.molGF[i] * aux[i] for i in 1:nComp);
end sourceGasFB;
JARA2i.gas.sourceMassGasFB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure Cp[i] = CpCoef[i,1] + CpCoef[i,2]*T + ... + CpCoef[i,7]*T**6 | |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for the enthalpy [T] |
| Real | pmax | 1.0E6 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | pcodo | 9.5E5 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | pmin | 1 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | peps | 0.2 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | eps | 1.E-8 | Small constant to avoid by-zero division |
| Real | molecWeigth[nComp] | Molecular weigth of the components [M.mol-1] |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive |
| cutReceiver | setPointSignal | Setpoint signals {totalMassFSP, massFractSP[:], tempFSP} |
model sourceMassGasFB
"Gas-flow source. Setpoint: total mass-flow, flow molar-fraction and flow temperature."
extends sourceGasFB;
cutsB.cutReceiver setPointSignal( dim=nComp+2)
"Setpoint signals {totalMassFSP, massFractSP[:], tempFSP}";
Real totalMassFSP( unit="M.t-1")
"Setpoint of the total mass flow";
Real massFractSP[ nComp]( unit="") "Setpoint of the mass fraction";
parameter Real molecWeigth[ nComp]( unit="M.mol-1")
"Molecular weigth of the components";
protected
Real auxMW;
equation
setPointSignal.signal[1] = totalMassFSP;
setPointSignal.signal[2:(nComp+1)] = massFractSP[:];
setPointSignal.signal[nComp+2] = tempFSP;
auxMW = sum(massFractSP[i]/molecWeigth[i] for i in 1:nComp);
for i in 1:nComp loop
molFractSP[i] = massFractSP[i] / ( molecWeigth[i] * auxMW);
end for;
totalMolFSP = auxMW * totalMassFSP;
end sourceMassGasFB;
JARA2i.gas.sourceMolGasFB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure Cp[i] = CpCoef[i,1] + CpCoef[i,2]*T + ... + CpCoef[i,7]*T**6 | |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for the enthalpy [T] |
| Real | pmax | 1.0E6 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | pcodo | 9.5E5 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | pmin | 1 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | peps | 0.2 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | eps | 1.E-8 | Small constant to avoid by-zero division |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive |
| cutReceiver | setPointSignal | Setpoint signals {totalMolFSP, molFractSP[:], tempFSP} |
model sourceMolGasFB
"Gas-flow source. Setpoint: total molar-flow, flow molar-fraction and flow temperature."
extends sourceGasFB;
cutsB.cutReceiver setPointSignal( dim=nComp+2)
"Setpoint signals {totalMolFSP, molFractSP[:], tempFSP}";
equation
setPointSignal.signal[1] = totalMolFSP;
setPointSignal.signal[2:(nComp+1)] = molFractSP[:];
setPointSignal.signal[nComp+2] = tempFSP;
end sourceMolGasFB;
JARA2i.gas.sourcePressGasB
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Type | Name | Description |
|---|---|---|
| cutGasC | inMol | Gas flow - Connector Capacitive |
| cutHeatMC | inHeat | Heat flow - Connector M-C |
partial model sourcePressGasB "Partial model - Pressure source. The across variables should be a funcion of time and state variables." extends interf.gas1I; equation // Relationship among the interface variables inMol.molG = inHeat.matter; inMol.tempG = inHeat.temp; end sourcePressGasB;
JARA2i.gas.sourceVolGasFB
Gas-flow source. Setpoint: total volume-flow, flow molar-fraction and flow temperature
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nComp | 1 | Number of components |
| Real | CpCoefN[nComp, 7] | Coefficients of the molar heat capacity at constant pressure Cp[i] = CpCoef[i,1] + CpCoef[i,2]*T + ... + CpCoef[i,7]*T**6 | |
| Real | molEnthalpyRef[nComp] | zeros(nComp) | Molar enthalpy at the reference temperature [M.L2.t-2.mol-1] |
| Real | tempRef | 298 | Reference temperature for the enthalpy [T] |
| Real | pmax | 1.0E6 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | pcodo | 9.5E5 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | pmin | 1 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | peps | 0.2 | Parameter of the source constitutive relation [M.L-1.t-2] |
| Real | eps | 1.E-8 | Small constant to avoid by-zero division |
| Real | perfGasConst | Constant of the perfect gases |
| Type | Name | Description |
|---|---|---|
| cutGasR | inMol | Gas flow - Connector Resistive |
| cutReceiver | setPointSignal | Setpoint signal: { totalVolFSP, molFractSP[:], tempFSP, pressFSP} |
model sourceVolGasFB
"Gas-flow source. Setpoint: total volume-flow, flow molar-fraction and flow temperature"
extends sourceGasFB;
cutsB.cutReceiver setPointSignal( dim=nComp+3)
"Setpoint signal: { totalVolFSP, molFractSP[:], tempFSP, pressFSP}";
Real totalVolFSP "Setpoint of the total volume flow";
Real pressFSP "Setpoint of the gas flow pressure";
parameter Real perfGasConst "Constant of the perfect gases";
equation
setPointSignal.signal[1] = totalVolFSP;
setPointSignal.signal[2:(nComp+1)] = molFractSP[:];
setPointSignal.signal[nComp+2] = tempFSP;
setPointSignal.signal[nComp+3] = pressFSP;
0 = if totalVolFSP > 0 then
inMol.pressG * totalVolFSP - totalMolFSP * perfGasConst * inMol.tempG else
pressFSP * totalVolFSP - totalMolFSP * perfGasConst * tempFSP;
end sourceVolGasFB;
JARA2i.gas.vesselGasB
| vesselVolume | Recipient volume. |
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | Ejs | false | Global parameter - Runtime interactive simulation |
| Boolean | Sysquake | false | Global parameter - Batch interactive simulation |
| Real | vesselVolumeInitial | Vessel volume - Initial condition [L3] |
| Type | Name | Description |
|---|---|---|
| cutVolConstrVessel | constraintV | Volume constraint - Vessel. |
model vesselGasB "Vessel with a constant volume."
extends interf.vesselI;
outer parameter Boolean Ejs=false
"Global parameter - Runtime interactive simulation";
outer parameter Boolean Sysquake=false
"Global parameter - Batch interactive simulation";
parameter Real vesselVolumeInitial(unit="L3")
"Vessel volume - Initial condition";
Real vesselVolume(start=vesselVolumeInitial)
"Vessel volume - Interactive Variable";
equation
// Interactive parameter for Ejs
if Ejs then
der(vesselVolume) = 0;
end if;
// Sysquake
if Sysquake then
vesselVolume = vesselVolumeInitial;
end if;
// The vessel volume is a constant
// constraintV.vesselV = vesselVolume;
constraintV.vcE[1] = vesselVolume;
end vesselGasB;