How to connect input connectors from the outside?

61 Views Asked by At

I am quite new to Modelica, so perhaps my question is a basic one.

I do have a model for a combustion chamber, with 3 ports (or connectors):

1- AirPort (which provides the model with the Medium (in which the mass fractions of air are specified), P, h, and f (=massflow)). 2- ExhaustPort which connects the same variables (but also the mass fractions), but leaving the combustion chamber 3- A real input that provides the combustor with a unitless value that dictates the value of the massflow.

Now this model works, but I wanted to replace the third port with another port that allows actual variables being transported (so mass flow, enthalpy, and pressure) instead of just a unitless value.

Doing this, I get the following error:

The input connector p of prop is not connected from the outside.
It is likely that it should have been connected, and recursive check assumes this.
The missing connection is a likely cause of errors in the model.

The input connector Xi of prop is not connected from the outside.
It is likely that it should have been connected, and recursive check assumes this.
The missing connection is a likely cause of errors in the model.

The input connector h of prop is not connected from the outside.
It is likely that it should have been connected, and recursive check assumes this.
The missing connection is a likely cause of errors in the model.

The input connector p of propFuel is not connected from the outside.
It is likely that it should have been connected, and recursive check assumes this.
The missing connection is a likely cause of errors in the model.

The input connector h of propFuel is not connected from the outside.
It is likely that it should have been connected, and recursive check assumes this.
The missing connection is a likely cause of errors in the model.

The lines where 'prop' and 'propFuel' are defined:

  BasicAeroEngines.Media.ExhaustGas.BaseProperties prop "Properties of exhaust gas";
  BasicAeroEngines.Media.Hydrogen.BaseProperties propFuel "Properties of fuel";

and where these are used in the same model:

  prop.T = T;
  prop.X = X_L;
  h_L = prop.h;
  cp_gas = ExhaustGas.specificHeatCapacityCp(prop.state);

  propFuel.p = P;
  propFuel.T = T;
  h_L = propFuel.h;
  propFuel.X = {1};

And these are the lines for the connectors:

    BasicAeroEngines.Interfaces.AirPort airInlet;
    BasicAeroEngines.Interfaces.ExhaustPort exhaust;

    ThermoPower.Water.FlangeC fuelFlow

In which FlanceC is defined as follows:

    connector FlangeC
    extends ThermoPower.Water.Flange_NEW;
    end FlangeC;

In which 'ThermoPower.Water.Flange_NEW' is defined as follows:

    connector Flange_NEW
    "Flange connector for water/steam flows TEST FOR NEW COMBUSTOR"
    replaceable package Medium = ExternalMedia.Media.CoolPropMedium (mediumName="Hydrogen", substanceNames={"H2"}, ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.ph);
    flow Medium.MassFlowRate m_flow
    "Mass flow rate from the connection point into the component";
    Medium.AbsolutePressure p "Thermodynamic pressure in the connection point";
    stream Medium.SpecificEnthalpy h_outflow
    "Specific thermodynamic enthalpy close to the connection point if m_flow < 0";
   stream Medium.MassFraction Xi_outflow[Medium.nXi]
   "Independent mixture mass fractions m_i/m close to the connection point if m_flow < 0";
   stream Medium.ExtraProperty C_outflow[Medium.nC]
    "Properties c_i/m close to the connection point if m_flow < 0";

    end Flange_NEW;

Help would be very much appreciated!

Firstly I thought, perhaps the error comes from an undetermined system, but then I closed the system with these lines:

  propFuel.p = P;
  propFuel.T = T;
  h_L = propFuel.h;
  propFuel.X = {1};

But I still get the same error.

Edit:

This is the code in its entirety:

model CombustionChamberEnthalpies_C
 "Model of combustion chamber with given fuel LHV"
 //   import Modelica.Media.Interfaces.Choices.ReferenceEnthalpy;
 //   constant ReferenceEnthalpy referenceChoice=ReferenceEnthalpy.ZeroAt25C
 //     "Choice of reference enthalpy";
 package ExhaustGas = BasicAeroEngines.Media.ExhaustGas;
 package InletFuel = ExternalMedia.Media.CoolPropMedium (mediumName="Hydrogen", substanceNames={"H2"}, ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.ph);

 outer BasicAeroEngines.Components.Environment environment;

 parameter Modelica.SIunits.SpecificEnergy LHV = 42.8e6 "Lower heating value of fuel";
 Modelica.SIunits.MassFraction X_L[ExhaustGas.nX] "Composition of exhaust gases";
 //ExhaustGas.reference_Xfu
 parameter Modelica.SIunits.Volume V "Internal volume of combustion chamber";
 parameter Modelica.SIunits.Pressure P_start "Start value of pressure";
 parameter Modelica.SIunits.Temperature T_start "Start value of temperature";
 parameter Boolean steadyStateInit = false "Initialize in steady state if true";
 parameter Real ZC "number of carbon atoms in fuel equivalent chemical formula";
 parameter Real ZH "number of hydrogen atoms in fuel equivalent chemical formula";
 final parameter Real a_stoich = ZC + ZH / 4 "stoichiometric ratio of the fuel combustion reaction";
 final parameter Modelica.SIunits.MolarMass MMfuel = ZC * 12 + ZH "Eq. molar mass of the fuel";
 parameter Real eta_comb = 0.995 "Combustion chamber efficiency";
 parameter Real P_Loss = 4 "Relative pressure loss in percentage";
 BasicAeroEngines.Interfaces.AirPort airInlet annotation (Placement(
     visible=true,
     transformation(
       origin={-100,0},
       extent={{-10,-10},{10,10}},
       rotation=0),
     iconTransformation(
       origin={-100,3.55271e-15},
       extent={{-20,-20},{20,20}},
       rotation=0)));
 BasicAeroEngines.Interfaces.ExhaustPort exhaust annotation (Placement(
     visible=true,
     transformation(
       origin={100,2},
       extent={{-10,-10},{10,10}},
       rotation=0),
     iconTransformation(
       origin={100,7.10543e-15},
       extent={{-20,-20},{20,20}},
       rotation=0)));
 BasicAeroEngines.Media.ExhaustGas.BaseProperties prop "Properties of exhaust gas";
 BasicAeroEngines.Media.Hydrogen.BaseProperties propFuel "Properties of fuel (linked to the BaseProperties in CoolPropMedium as this allows a two-phase hydrogen to be used at temperatures below 200K)";

 Modelica.SIunits.MassFlowRate f_E "Entering mass flow rate";
 Modelica.SIunits.MassFlowRate f_L "Leaving mass flow rate";
 Modelica.SIunits.MassFlowRate f_E_fuel "Leaving mass flow rate";
 Modelica.SIunits.SpecificEnthalpy h_E "Entering specific enthalpy";
 Modelica.SIunits.SpecificEnthalpy h_L "Leaving specific enthalpy";
 Modelica.SIunits.SpecificEnthalpy h_E_fuel "Leaving specific enthalpy";
 Modelica.SIunits.Pressure P(start = P_start, stateSelect = StateSelect.prefer) "Exhaust gas pressure";
 Modelica.SIunits.Pressure P_fuel "fuel pressure";
 Modelica.SIunits.Temperature T(start = T_start, stateSelect = StateSelect.prefer) "Exhaust gas temperature";
 Modelica.SIunits.Mass M(stateSelect = StateSelect.avoid) "Total mass";
 Modelica.SIunits.Energy E(stateSelect = StateSelect.avoid) "Total internal energy";
 Modelica.SIunits.Power Q "Thermal power released by combustion";
 Modelica.SIunits.MassFraction X_E[BasicAeroEngines.Media.Air.nX]
   "Composition of air";
 Modelica.SIunits.SpecificHeatCapacity cp_gas "Cp of the flue gas";

 ThermoPower.Water.FlangeC fuelFlow annotation (Placement(transformation(extent=
          {{-10,90},{10,110}}), iconTransformation(extent={{-10,90},{10,110}})));
initial equation 
 if steadyStateInit or environment.onDesignInit then
   der(M) = 0;
   der(E) = 0;
   der(X_L[2:4]) = zeros(ExhaustGas.nX - 1);
 else
   T = T_start;
   P = P_start;
   X_L[2:4] = ExhaustGas.reference_X[2:4];
 end if;
equation 
 // Conservation equations
 der(M) = f_E +  f_E_fuel - f_L;
 der(E) = f_E * h_E - f_L * h_L + f_E_fuel * h_E_fuel + Q;
 //"Nitrogen","Oxygen","Water", "Carbondioxide"
 X_L[1] = 1 - X_L[2] - X_L[3] - X_L[4];
 der(M * X_L[2]) = f_E * X_E[2] - f_L * X_L[2] - a_stoich *  f_E_fuel / MMfuel * ExhaustGas.data[2].MM * 1000 "oxygen";
 der(M * X_L[3]) = (-f_L * X_L[3]) + ZH / 2 *  f_E_fuel / MMfuel * ExhaustGas.data[3].MM * 1000 "water";
 der(M * X_L[4]) = (-f_L * X_L[4]) + ZC *  f_E_fuel / MMfuel * ExhaustGas.data[4].MM * 1000 "carbondioxide";
 // Constitutive equations and fluid properties
 M = prop.d * V;
 E = prop.u * M;
 Q = LHV *  f_E_fuel * eta_comb 
 prop.p = P;
 prop.T = T;
 prop.X = X_L;
 h_L = prop.h;
 cp_gas = ExhaustGas.specificHeatCapacityCp(prop.state);

 propFuel.p = P;
 propFuel.T = T;
 h_L = propFuel.h;
 propFuel.X = {1};


 // Boundary conditions
 P = airInlet.P;
 P * (1 - P_Loss / 100) = exhaust.P;
 f_E = airInlet.f;
 f_L = -exhaust.f;
 h_E = inStream(airInlet.h_L);
 exhaust.h_L = h_L;
 exhaust.X_L = X_L;
 X_E = BasicAeroEngines.Media.Air.reference_X;
 airInlet.h_L = 0 "Unused, no flow reversal";

 f_E_fuel = fuelFlow.m_flow;
 h_E_fuel = inStream(fuelFlow.h_outflow);
 P_fuel = fuelFlow.p;

 annotation (
   Icon(graphics={  Ellipse(origin = {0, -1}, fillColor = {129, 170, 194},
           fillPattern =                                                                 FillPattern.Solid, extent = {{-100, 101}, {100, -99}}, endAngle = 360), Polygon(origin = {-2, 19}, fillColor = {218, 74, 25}, pattern = LinePattern.None,
           fillPattern =                                                                                                                                                                                                        FillPattern.Solid, points = {{0, 75}, {-82, 3}, {-14, 35}, {-64, -55}, {-12, -1}, {4, -75}, {16, 1}, {62, -67}, {34, 31}, {82, 17}, {0, 75}})}));
end CombustionChamberEnthalpies_C;

I hope this helps to find the problem!

1

There are 1 best solutions below

2
On

The input connectors in the medium-models should be used in a bit odd way, so the diagnostics is not helpful. Unfortunately that prevents other diagnostics from being generated.

In Dymola set:

Advanced.ReportEquationsForSingular=0

and you will get additional information about the problem. Without the complete model it will be difficult to give more help.