Index: branches/gui/eml/pressure_changers/compressor.mso
===================================================================
 branches/gui/eml/pressure_changers/compressor.mso (revision 597)
+++ branches/gui/eml/pressure_changers/compressor.mso (revision 598)
@@ 30,29 +30,36 @@
PARAMETERS
outer PP as Plugin (Brief = "External Physical Properties", Type="PP");
outer NComp as Integer (Brief = "Number of chemical components", Lower = 1);
 R as positive (Brief = "Constant of Gases", Unit= 'kJ/kmol/K', Default = 8.31451,Hidden=true);
+outer PP as Plugin (Brief = "External Physical Properties", Type="PP");
+outer NComp as Integer (Brief = "Number of chemical components", Lower = 1);
+ Rgas as positive (Brief = "Constant of Gases", Unit= 'kJ/kmol/K', Default = 8.31451,Hidden=true);
Mw(NComp) as molweight (Brief = "Molar Weight");
+ CompressorType as Switcher (Brief = "Compressor Model Type",Valid=["Polytropic Operation","Isentropic Operation"], Default="Isentropic Operation");
VARIABLES
 n as positive (Brief = "Politropic Coefficient", Lower=0);
 k as positive (Brief = "Isentropic Coefficient", Lower=1e3);
 Cp as cp_mol (Brief = "Heat Capacity");
 Cv as cv_mol (Brief = "Heat Capacity");
+ PolyCoeff as positive (Brief = "Polytropic Coefficient", Lower=0);
+ IseCoeff as positive (Brief = "Isentropic Coefficient", Lower=1e3);
+ Cp as cp_mol (Brief = "Heat Capacity");
+ Cv as cv_mol (Brief = "Heat Capacity");
Pratio as positive (Brief = "Pressure Ratio", Symbol ="P_{ratio}");
Pdrop as press_delta (Brief = "Pressure Drop", DisplayUnit = 'kPa', Symbol ="\Delta P");
 Wp as energy_mol (Brief = "Politropic Head");
 Ws as energy_mol (Brief = "Isentropic Head");
 Tiso as temperature (Brief = "Isentropic Temperature");
 Effp as positive (Brief = "Politropic efficiency");
 Effs as efficiency (Brief = "Isentropic efficiency");
 FPower as power (Brief = "Fluid Power");
 Mwm as molweight (Brief = "Mixture Molar Weight");
in Inlet as stream (Brief = "Inlet stream", PosX=0.35, PosY=1, Symbol="_{in}");
out Outlet as streamPH (Brief = "Outlet stream", PosX=1, PosY=0.0, Symbol="_{out}");
+ Head as energy_mass (Brief = "Isentropic Head");
+ Tiso as temperature (Brief = "Isentropic Temperature");
+
+ PolytropicEff as efficiency (Brief = "Polytropic efficiency");
+ IsentropicEff as efficiency (Brief = "Isentropic efficiency");
+ MechanicalEff as efficiency (Brief = "Mechanical efficiency");
+
+ FluidPower as power (Brief = "Fluid Power");
+ Mwm as molweight (Brief = "Mixture Molar Weight");
+ rho as dens_mass (Brief = "Mass Density");
+ Zfac_in as fraction (Brief = "Compressibility factor at inlet");
+ Zfac_out as fraction (Brief = "Compressibility factor at outlet");
in WorkIn as power (Brief = "Work Inlet", PosX=0, PosY=0.46);
+in Inlet as stream (Brief = "Inlet stream", PosX=0.437, PosY=1, Symbol="_{in}");
+out Outlet as streamPH (Brief = "Outlet stream", PosX=0.953, PosY=0.0, Symbol="_{out}");
+
+in WorkIn as power (Brief = "Work Inlet", PosX=0, PosY=0.45);
SET
@@ 60,9 +67,15 @@
Mw = PP.MolecularWeight();
 R = 8.31451*'kJ/kmol/K';
+ Rgas = 8.31451*'kJ/kmol/K';
EQUATIONS
"Calculate Mwm for Inlet Mixture"
+"Overall Molar Balance"
+ Outlet.F = Inlet.F;
+
+"Component Molar Balance"
+ Outlet.z = Inlet.z;
+
+"Average Molecular Weight"
Mwm = sum(Mw*Inlet.z);
@@ 73,45 +86,57 @@
Outlet.P = Inlet.P  Pdrop;
"Calculate Cp Using a External Physical Properties Routine"
+"Mass Density"
+ rho = PP.VapourDensity(Inlet.T, Inlet.P, Inlet.z);
+
+"Heat Capacity at Constant Pressure"
Cp = PP.VapourCp(Inlet.T,Inlet.P,Inlet.z);
"Calculate Cv Using a External Physical Properties Routine"
+"Heat Capacity at Constant Volume"
Cv = PP.VapourCv(Inlet.T,Inlet.P,Inlet.z);
"Calculate Isentropic Coeficient"
 k * Cv = Cp;
+"Compressibility factor at Inlet Conditions"
+ Zfac_in = PP.VapourCompressibilityFactor(Inlet.T,Inlet.P,Inlet.z);
"Calculate Isentropic Head"
 Ws = (k/(k1))*R*Inlet.T*((Outlet.P/Inlet.P)^((k1)/k)  1);
+"Compressibility factor at Outlet Conditions"
+ Zfac_out = PP.VapourCompressibilityFactor(Outlet.T,Outlet.P,Outlet.z);
"Calculate Isentropic Outlet Temperature"
# Tiso = Inlet.T * (Outlet.P/Inlet.P)^((k1)/k);
+"Isentropic Coeficient"
+ IseCoeff * Cv = Cp;
+
+#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+switch CompressorType
+
+ case "Isentropic Operation":
+
+"Isentropic Head"
+ Head = (0.5*Zfac_in+0.5*Zfac_out)*(1/Mwm)*(IseCoeff/(IseCoeff1))*Rgas*Inlet.T*((Outlet.P/Inlet.P)^((IseCoeff1)/IseCoeff)  1);
+
+"Fluid Power"
+ FluidPower*IsentropicEff = Head*sum(Mw*Inlet.z)*Inlet.F;
+
+ case "Polytropic Operation":
+
+"Polytropic Head"
+ Head = (0.5*Zfac_in+0.5*Zfac_out)*(1/Mwm)*(PolyCoeff/(PolyCoeff1))*Rgas*Inlet.T*((Outlet.P/Inlet.P)^((PolyCoeff1)/PolyCoeff)  1);
+
+"Fluid Power"
+ FluidPower*PolytropicEff = Head*sum(Mw*Inlet.z)*Inlet.F;
+
+end
+
+"Isentropic Outlet Temperature"#Mollier Method ?
PP.VapourEntropy(Tiso, Outlet.P, Outlet.z) = PP.VapourEntropy(Inlet.T, Inlet.P, Inlet.z);
"Calculate Real Outlet Temperature"
 Effs * (Outlet.T Inlet.T) = (Tiso  Inlet.T);

+"Discharge Temperature"
+ IsentropicEff * (Outlet.T Inlet.T) = (Tiso  Inlet.T);
+
"Calculate Politropic Coefficient"
 n*(ln(Outlet.T/Inlet.T)) = (n1)*(ln(Outlet.P/Inlet.P));

"Calculate Politropic Efficiency"
 Effp * (n1) * k = n * (k1);

"Calculate Politropic Head"
 Ws*Effp = Wp*Effs;
+ PolyCoeff*(ln(Outlet.T/Inlet.T)) = (PolyCoeff1)*(ln(Outlet.P/Inlet.P));
"Overall Molar Balance"
 Outlet.F = Inlet.F;

"Component Molar Balance"
 Outlet.z = Inlet.z;

# Testing Equations
+#"Polytropic Efficiency"
+ #PolytropicEff * (PolyCoeff1) * IseCoeff = PolyCoeff * (IseCoeff1);
"Fluid Power"
 FPower*Effs = Inlet.F*Ws;

"Fluid Power"
 FPower = WorkIn;
+ FluidPower = WorkIn;
end