- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Closed loop power cycle in...
Closed loop power cycle in OpenModelica not working
Closed loop power cycle in OpenModelica not working
I am modelling a concentrated solar thermal power plant using OpenModelica. I have created a model for a pump and a condenser, and they successfully calculate the outlet conditions when tested individually. However for testing purposes, when I connect the pump and condenser models in a closed loop the model will not simulate and I receive the following errors:
Code:
[1] 22:16:26 Translation Error
Internal error Circular Equalities Detected for Variables:
condenser2.o.mdot
condenser2.i.mdot
----------------------------------
pump2.i.mdot
condenser2.o.mdot
----------------------------------
pump2.o.mdot
pump2.i.mdot
----------------------------------
[2] 22:16:26 Symbolic Error
[PTC: 995:5-995:122]: Model is structurally singular, error found sorting equations
This most likely has something to do with the connectors and the mass flow rate in particular, however, I do not know what I need to change to solve this issue.
The system model is shown below:
Code:
model Pump_condenser
PTC.Pump2 pump2 annotation();
PTC.Condenser2 condenser2 annotation();
equation
connect(condenser2.o, pump2.i) annotation();
connect(pump2.o, condenser2.i) annotation();
end Pump_condenser;
The model for the pump is shown below:
Code:
model Pump2
extends PTC.PartialModels.PartialCSTComponentSISO;
// Imports
import Modelica.SIunits.*;
import ThermoCycle.Media.*;
import Modelica.Constants;
// Outlet isentropic state
Medium.ThermodynamicState state_isentropic;
// Parameters
parameter Length D = 2 "Diameter of pump";
parameter Length w = 1 "Width of pump";
parameter Real eta(unit = "1") = 0.7 "Isentropic efficiency of pump";
constant Real pi = 2 * Modelica.Math.asin(1.0) "3.14159265358979";
// Variables
Power Wdot "Power input to pump";
SpecificEntropy s_i "Specific entropy at inlet";
SpecificEnthalpy hs "Specific enthalpy after isentropic compression";
initial equation
medium_i.T = 363;
medium_i.p = 80000;
medium_o.T = 450;
medium_o.p = 800000;
i.h = Medium.specificEnthalpy(medium_i.state);
equation
// Energy balance
m * der(u) = (-Wdot) + i.mdot * actualStream(i.h) + o.mdot * actualStream(o.h);
// Isentropic efficiency
s_i = Medium.specificEntropy(medium_i.state) "Get inlet entropy";
state_isentropic = Medium.setState_ps(medium_o.p, s_i) "Isentropic state";
hs = Medium.specificEnthalpy(state_isentropic);
eta = (hs - medium_i.h) / (medium_o.h - medium_i.h) "Isentropic efficiency";
// Inlet pressure
medium_i.p = 80000;
// Mass
m = pi * D ^ 2 * w * d / 4 "Mass of fluid in control volume";
// Simulation parameters
annotation();
annotation();
end Pump2;
The model for the condenser is shown below:
Code:
model Condenser2
extends PTC.PartialModels.PartialCSTComponentSISO;
// Imports
import Modelica.SIunits.*;
// Parameters
parameter Length L = 5 "Length of one tube";
parameter Area A = 0.02 "Cross sectional area of tubes";
parameter Integer N(unit = "1") = 10 "Number of tubes";
parameter Temperature Tinf = 298 "Ambient temperature";
parameter CoefficientOfHeatTransfer k = 3000 "Convection coefficient";
// Variables
HeatFlowRate Qdot "Heat flow rate from power block to condenser fluid";
Temperature T "Average temp in CV";
initial equation
medium_i.T = 450;
medium_i.p = 8000000;
medium_o.T = 363;
medium_o.p = 80000;
i.h = Medium.specificEnthalpy(medium_i.state);
equation
// Energy balance
m * der(u) = Qdot + i.mdot * actualStream(i.h) + o.mdot * actualStream(o.h);
// Inlet pressure
medium_i.p = 8000000;
// Average temperature
T = (medium_i.T + medium_o.T) / 2;
// Heat flow rate
Qdot = -k * (T - Tinf) "Newtons law of cooling";
// Mass
m = N * L * A * d "Mass of fluid in CV";
// Simulation parameters
annotation();
annotation();
end Condenser2;
Both models extend the following partial model:
Code:
partial model PartialCSTComponentSISO
// Imports
import Modelica.SIunits.*;
// Fluid imports
replaceable package Medium = Modelica.Media.Water.StandardWater annotation(
choicesAllMatching = true);
// Set up inlet and outlet media
Medium.BaseProperties medium_i;
Medium.BaseProperties medium_o;
// Connectors
PTC.inlet i(redeclare package Medium = Medium) annotation();
PTC.outlet o(redeclare package Medium = Medium) annotation();
// Variables
SpecificInternalEnergy u "Average specific internal energy in CV (control volume)";
Mass m "Mass contained in CV";
Density d "Average density of fluid in CV";
// Parameters
parameter MassFlowRate mdotCV = 3.0 "Mass flow rate through CV";
equation
// Fluid equations
medium_i.h = i.h;
medium_i.p = i.p;
medium_o.p = o.p;
medium_o.h = o.h;
// Mass flow rate
i.mdot = mdotCV;
o.mdot + i.mdot = 0 "Mass balance";
// Internal energy
u = (medium_i.u + medium_o.u) / 2 "Internal energy in CV is average of inlet and outlet u";
// Miscellaneous
d = (medium_i.d + medium_o.d) / 2 "d in CV is average of inlet and outlet densities";
end PartialCSTComponentSISO;
The inlet and outlet connectors have the following structure:
Code:
connector inlet
// Imports //
import Modelica.SIunits.*;
// Fluid imports //
replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium model" annotation(
choicesAllMatching = true);
// Energy variables //
Medium.AbsolutePressure p;
stream Medium.SpecificEnthalpy h;
// Flow variables //
flow Medium.MassFlowRate mdot;
annotation();
end inlet;
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Closed loop power cycle in...