public static double getMolarWeight(Resources res) { double MW = 0; switch (res) { case Resources.CO2: MW = CoolProp.PropsSI("M", "", 0, "", 0, "CO2"); return(MW); case Resources.O2: MW = CoolProp.PropsSI("M", "", 0, "", 0, "Oxygen"); return(MW); case Resources.N2: MW = CoolProp.PropsSI("M", "", 0, "", 0, "Nitrogen"); return(MW); case Resources.CH4: MW = CoolProp.PropsSI("M", "", 0, "", 0, "Methane"); return(MW); case Resources.Humidity: MW = CoolProp.PropsSI("M", "", 0, "", 0, "Water"); return(MW); default: throw new Exception("Cannot get molar weight for unknown resource"); } }
//static void Main(string[] args) //{ // Console.WriteLine(GetH20BoilingPoint(7500)); // //Console.Write("**************** INFORMATION ***************" + "\n"); // //Console.Write("This example was auto-generated by the language-agnostic dev/scripts/example_generator.py script written by Ian Bell" + "\n"); // //Console.Write("CoolProp version:" + " " + CoolProp.get_global_param_string("version") + "\n"); // //Console.Write("CoolProp gitrevision:" + " " + CoolProp.get_global_param_string("gitrevision") + "\n"); // //Console.Write("CoolProp Fluids:" + " " + CoolProp.get_global_param_string("FluidsList") + "\n"); // //var FluidString = CoolProp.get_global_param_string("FluidsList"); // //List<string> Fluids = FluidString.Split(',').ToList(); // //foreach (string Fluid in Fluids) // //{ // // try { // // Console.Write("Boiling temperature of " + Fluid + " at 101325 Pa:" + " " + (Math.Round(CoolProp.PropsSI("T", "P", 10000, "Q", 0, Fluid), 2) - 273.15) + " " + "C" + "\n"); // // } // // catch { } // //} // //// See http://www.coolprop.org/coolprop/HighLevelAPI.html#table-of-string-inputs-to-propssi-function for a list of inputs to high-level interface; // //Console.Write("*********** HIGH LEVEL INTERFACE *****************" + "\n"); // //Console.Write("Critical temperature of water:" + " " + CoolProp.Props1SI("Water", "Tcrit") + " " + "K" + "\n"); // //Console.Write("Boiling temperature of water at 101325 Pa:" + " " + CoolProp.PropsSI("T", "P", 101325, "Q", 0, "Water") + " " + "K" + "\n"); //} public static decimal GetWaterBoilingPoint(decimal PressureInPa) { decimal BoilingPoint = 0; if (PressureInPa >= 612 && PressureInPa <= 500000) { BoilingPoint = Math.Round(Convert.ToDecimal(CoolProp.PropsSI("T", "P", Convert.ToDouble(PressureInPa), "Q", 0, "Water") - 273.15), 2); } return(BoilingPoint); }
static void Main(string[] args) { Console.Write("**************** INFORMATION ***************" + "\n"); Console.Write("This example was auto-generated by the language-agnostic dev/scripts/example_generator.py script written by Ian Bell" + "\n"); Console.Write("CoolProp version:" + " " + CoolProp.get_global_param_string("version") + "\n"); Console.Write("CoolProp gitrevision:" + " " + CoolProp.get_global_param_string("gitrevision") + "\n"); Console.Write("CoolProp Fluids:" + " " + CoolProp.get_global_param_string("FluidsList") + "\n"); // See http://www.coolprop.org/coolprop/HighLevelAPI.html#table-of-string-inputs-to-propssi-function for a list of inputs to high-level interface; Console.Write("*********** HIGH LEVEL INTERFACE *****************" + "\n"); Console.Write("Critical temperature of water:" + " " + CoolProp.Props1SI("Water", "Tcrit") + " " + "K" + "\n"); Console.Write("Boiling temperature of water at 101325 Pa:" + " " + CoolProp.PropsSI("T", "P", 101325, "Q", 0, "Water") + " " + "K" + "\n"); Console.Write("Phase of water at 101325 Pa and 300 K:" + " " + CoolProp.PhaseSI("P", 101325, "T", 300, "Water") + "\n"); Console.Write("c_p of water at 101325 Pa and 300 K:" + " " + CoolProp.PropsSI("C", "P", 101325, "T", 300, "Water") + " " + "J/kg/K" + "\n"); Console.Write("c_p of water (using derivatives) at 101325 Pa and 300 K:" + " " + CoolProp.PropsSI("d(H)/d(T)|P", "P", 101325, "T", 300, "Water") + " " + "J/kg/K" + "\n"); Console.Write("*********** HUMID AIR PROPERTIES *****************" + "\n"); Console.Write("Humidity ratio of 50% rel. hum. air at 300 K, 101325 Pa:" + " " + CoolProp.HAPropsSI("W", "T", 300, "P", 101325, "R", 0.5) + " " + "kg_w/kg_da" + "\n"); Console.Write("Relative humidity from last calculation:" + " " + CoolProp.HAPropsSI("R", "T", 300, "P", 101325, "W", CoolProp.HAPropsSI("W", "T", 300, "P", 101325, "R", 0.5)) + " " + "(fractional)" + "\n"); Console.Write("*********** INCOMPRESSIBLE FLUID AND BRINES *****************" + "\n"); Console.Write("Density of 50% (mass) ethylene glycol/water at 300 K, 101325 Pa:" + " " + CoolProp.PropsSI("D", "T", 300, "P", 101325, "INCOMP::MEG-50%") + " " + "kg/m^3" + "\n"); Console.Write("Viscosity of Therminol D12 at 350 K, 101325 Pa:" + " " + CoolProp.PropsSI("V", "T", 350, "P", 101325, "INCOMP::TD12") + " " + "Pa-s" + "\n"); // If you don't have REFPROP installed, disable the following lines; Console.Write("*********** REFPROP *****************" + "\n"); Console.Write("REFPROP version:" + " " + CoolProp.get_global_param_string("REFPROP_version") + "\n"); Console.Write("Critical temperature of water:" + " " + CoolProp.Props1SI("REFPROP::WATER", "Tcrit") + " " + "K" + "\n"); Console.Write("Boiling temperature of water at 101325 Pa:" + " " + CoolProp.PropsSI("T", "P", 101325, "Q", 0, "REFPROP::WATER") + " " + "K" + "\n"); Console.Write("c_p of water at 101325 Pa and 300 K:" + " " + CoolProp.PropsSI("C", "P", 101325, "T", 300, "REFPROP::WATER") + " " + "J/kg/K" + "\n"); Console.Write("*********** TABULAR BACKENDS *****************" + "\n"); AbstractState TAB = AbstractState.factory("BICUBIC&HEOS", "R245fa"); TAB.update(input_pairs.PT_INPUTS, 101325, 300); Console.Write("Mass density of refrigerant R245fa at 300 K, 101325 Pa:" + " " + TAB.rhomass() + " " + "kg/m^3" + "\n"); Console.Write("*********** SATURATION DERIVATIVES (LOW-LEVEL INTERFACE) ***************" + "\n"); AbstractState AS_SAT = AbstractState.factory("HEOS", "R245fa"); AS_SAT.update(input_pairs.PQ_INPUTS, 101325, 0); Console.Write("First saturation derivative:" + " " + AS_SAT.first_saturation_deriv(parameters.iP, parameters.iT) + " " + "Pa/K" + "\n"); Console.Write("*********** LOW-LEVEL INTERFACE *****************" + "\n"); AbstractState AS = AbstractState.factory("HEOS", "Water&Ethanol"); DoubleVector z = new DoubleVector(new double[] { 0.5, 0.5 }); AS.set_mole_fractions(z); AS.update(input_pairs.PQ_INPUTS, 101325, 1); Console.Write("Normal boiling point temperature of water and ethanol:" + " " + AS.T() + " " + "K" + "\n"); // If you don't have REFPROP installed, disable the following block; Console.Write("*********** LOW-LEVEL INTERFACE (REFPROP) *****************" + "\n"); AbstractState AS2 = AbstractState.factory("REFPROP", "METHANEÐANE"); DoubleVector z2 = new DoubleVector(new double[] { 0.2, 0.8 }); AS2.set_mole_fractions(z2); AS2.update(input_pairs.QT_INPUTS, 1, 120); Console.Write("Vapor molar density:" + " " + AS2.keyed_output(parameters.iDmolar) + " " + "mol/m^3" + "\n"); }
public ThermoState getStateFromInternDensity(double internalenergy, double dens) { StringVector outputs = new StringVector(new string[] { "T", "P", "H", "L", "V", "C" }); DoubleVector umass = new DoubleVector(new double[] { internalenergy * 1000 }); DoubleVector dmass = new DoubleVector(new double[] { dens }); double[] result = CoolProp.PropsSImulti(outputs, "U", umass, "D", dmass, propsDatabase, new StringVector(new string[] { FluidName }), new DoubleVector(new double[] { 1 }))[0].ToArray(); return(new ThermoState(result[0] - 273.15, result[1] * 0.001, result[2] * 0.001, dens, internalenergy, result[3], result[4], result[5])); }
public ThermoState getStateFromTempDensity(double tmp, double dens) { StringVector outputs = new StringVector(new string[] { "P", "U", "H", "L", "V", "C" }); DoubleVector temps = new DoubleVector(new double[] { tmp + 273.15 }); DoubleVector dmass = new DoubleVector(new double[] { dens }); double[] result = CoolProp.PropsSImulti(outputs, "T", temps, "D", dmass, propsDatabase, new StringVector(new string[] { FluidName }), new DoubleVector(new double[] { 1 }))[0].ToArray(); return(new ThermoState(tmp, result[0] * 0.001, result[2] * 0.001, dens, result[1] * 0.001, result[3], result[4], result[5])); }
static void Main(string[] args) { double T, rho, h; T = CoolProp.Props("R410A", "Tcrit"); Console.Write("The critical temperature of R410A is: " + T + " K\n"); rho = CoolProp.Props('D', 'T', 298.15, 'P', 101.325, "Air"); Console.Write("Density of air at STP is " + rho + " kg/m3\n"); h = CoolProp.Props('D', 'T', 275, 'Q', 1.0, "R290"); Console.Write("The saturated vapor enthalpy of Propane at 275 K is: " + h + " kJ/kg\n"); Console.Write("Enter to quit"); Console.ReadLine(); }
parameters ICoolProp.get_parameter_index(string param_name) { return(CoolProp.get_parameter_index(param_name)); }
string ICoolProp.get_input_pair_short_desc(input_pairs pair) { return(CoolProp.get_input_pair_short_desc(pair)); }
string ICoolProp.get_global_param_string(string ParamName) { return(CoolProp.get_global_param_string(ParamName)); }
int ICoolProp.get_debug_level() { return(CoolProp.get_debug_level()); }
string ICoolProp.get_config_string(configuration_keys key) { return(CoolProp.get_config_string(key)); }
bool ICoolProp.get_config_bool(configuration_keys key) { return(CoolProp.get_config_bool(key)); }
void ICoolProp.set_mixture_binary_pair_data(string CAS1, string CAS2, string param, double val) { CoolProp.set_mixture_binary_pair_data(CAS1, CAS2, param, val); }
void ICoolProp.set_error_string(string error) { CoolProp.set_error_string(error); }
void ICoolProp.set_debug_level(int level) { CoolProp.set_debug_level(level); }
string ICoolProp.config_key_to_string(configuration_keys keys) { return(CoolProp.config_key_to_string(keys)); }
string ICoolProp.get_config_as_json_string() { return(CoolProp.get_config_as_json_string()); }
void ICoolProp.set_reference_stateD(string FluidName, double T, double rhomolar, double h0, double s0) { CoolProp.set_reference_stateD(FluidName, T, rhomolar, h0, s0); }
double ICoolProp.get_config_double(configuration_keys key) { return(CoolProp.get_config_double(key)); }
string ICoolProp.config_key_description(string key) { return(CoolProp.config_key_description(key)); }
string ICoolProp.get_csv_parameter_list() { return(CoolProp.get_csv_parameter_list()); }
void ICoolProp.set_reference_stateS(string FluidName, string reference_state) { CoolProp.set_reference_stateS(FluidName, reference_state); }
string ICoolProp.get_fluid_param_string(string FluidName, string ParamName) { return(CoolProp.get_fluid_param_string(FluidName, ParamName)); }
void ICoolProp.set_warning_string(string warning) { CoolProp.set_warning_string(warning); }
input_pairs ICoolProp.get_input_pair_index(string input_pair_name) { return(CoolProp.get_input_pair_index(input_pair_name)); }
void ICoolProp.UseIdealGasEnthalpyCorrelations(int flag) { CoolProp.UseIdealGasEnthalpyCorrelations(flag); }
string ICoolProp.get_mixture_binary_pair_data(string CAS1, string CAS2, string param) { return(CoolProp.get_mixture_binary_pair_data(CAS1, CAS2, param)); }
void ICoolProp.UseIsothermCompressCorrelation(int flag) { CoolProp.UseIsothermCompressCorrelation(flag); }
static void Main(string[] args) { AbstractState State = AbstractState.factory("HEOS", "Water"); State.update(input_pairs.PT_INPUTS, 1e5, 300); double hmol = State.hmolar(); Console.Write("Hmol: " + hmol + " J/kg" + "\n"); double T, h, p, D; //Console.Write("CoolProp version: " + CoolProp.get_global_param_string("version") + "\n"); //Console.Write("CoolProp gitrevision: " + CoolProp.get_global_param_string("gitrevision") + "\n"); //Console.Write("CoolProp fluids: " + CoolProp.get_global_param_string("FluidsList") + "\n"); Console.Write(" " + "\n"); Console.Write("************ USING EOS *************" + "\n"); Console.Write(" " + "\n"); Console.Write("FLUID STATE INDEPENDENT INPUTS" + "\n"); //Console.Write("Critical Density Propane: " + CoolProp.Props1SI("Propane", "rhocrit") + " kg/m^3" + "\n"); Console.Write("TWO PHASE INPUTS (Pressure)" + "\n"); Console.Write("Density of saturated liquid Propane at 101325 Pa: " + CoolProp.PropsSI("D", "P", 101325, "Q", 0, "Propane") + " kg/m^3" + "\n"); Console.Write("Density of saturated vapor R290 at 101325 Pa: " + CoolProp.PropsSI("D", "P", 101325, "Q", 1, "R290") + " kg/m^3" + "\n"); Console.Write("TWO PHASE INPUTS (Temperature)" + "\n"); Console.Write("Density of saturated liquid Propane at 300 K: " + CoolProp.PropsSI("D", "T", 300, "Q", 0, "Propane") + " kg/m^3" + "\n"); Console.Write("Density of saturated vapor R290 at 300 K: " + CoolProp.PropsSI("D", "T", 300, "Q", 1, "R290") + " kg/m^3" + "\n"); Console.Write("SINGLE PHASE CYCLE (propane)" + "\n"); p = CoolProp.PropsSI("P", "T", 300, "D", 1, "Propane"); h = CoolProp.PropsSI("H", "T", 300, "D", 1, "Propane"); Console.Write("T,D -> P,H " + 300 + "," + 1 + " --> " + p + "," + h + "\n"); T = CoolProp.PropsSI("T", "P", p, "H", h, "Propane"); D = CoolProp.PropsSI("D", "P", p, "H", h, "Propane"); Console.Write("P,H -> T,D " + p + "," + h + " --> " + T + "," + D + "\n"); //~ Console.Write(" " + "\n"); //~ Console.Write("************ USING TTSE ***************" + "\n"); //~ Console.Write(" " + "\n"); //~ //CoolProp.enable_TTSE_LUT("Propane"); //~ Console.Write("TWO PHASE INPUTS (Pressure)" + "\n"); //~ Console.Write("Density of saturated liquid Propane at 101325 Pa: " + CoolProp.PropsSI("D", "P", 101325, "Q", 0, "Propane") + " kg/m^3" + "\n"); //~ Console.Write("Density of saturated vapor R290 at 101325 Pa: " + CoolProp.PropsSI("D", "P", 101325, "Q", 1, "R290") + " kg/m^3" + "\n"); //~ Console.Write("TWO PHASE INPUTS (Temperature)" + "\n"); //~ Console.Write("Density of saturated liquid Propane at 300 K: " + CoolProp.PropsSI("D", "T", 300, "Q", 0, "Propane") + " kg/m^3" + "\n"); //~ Console.Write("Density of saturated vapor R290 at 300 K: " + CoolProp.PropsSI("D", "T", 300, "Q", 1, "R290") + " kg/m^3" + "\n"); //~ Console.Write("SINGLE PHASE CYCLE (propane)" + "\n"); //~ p = CoolProp.PropsSI("P", "T", 300, "D", 1, "Propane"); //~ h = CoolProp.PropsSI("H", "T", 300, "D", 1, "Propane"); //~ Console.Write("T,D -> P,H " + 300 + ","+ 1+ " --> " + p + "," + h + "\n"); //~ T = CoolProp.PropsSI("T", "P", p, "H", h, "Propane"); //~ D = CoolProp.PropsSI("D", "P", p, "H", h, "Propane"); //~ Console.Write("P,H -> T,D " + p + "," + h + " --> " + T + "," + D + "\n"); //CoolProp.disable_TTSE_LUT("Propane"); try { Console.Write(" " + "\n"); Console.Write("************ USING REFPROP ***************" + "\n"); Console.Write(" " + "\n"); Console.Write("TWO PHASE INPUTS (Pressure)" + "\n"); Console.Write("Density of saturated liquid Propane at 101325 Pa: " + CoolProp.PropsSI("D", "P", 101325, "Q", 0, "REFPROP::Propane") + " kg/m^3" + "\n"); Console.Write("TWO PHASE INPUTS (Temperature)" + "\n"); Console.Write("Density of saturated liquid Propane at 300 K: " + CoolProp.PropsSI("D", "T", 300, "Q", 0, "REFPROP::Propane") + " kg/m^3" + "\n"); Console.Write("SINGLE PHASE CYCLE (propane)" + "\n"); p = CoolProp.PropsSI("P", "T", 300, "D", 1, "REFPROP::Propane"); h = CoolProp.PropsSI("H", "T", 300, "D", 1, "REFPROP::Propane"); Console.Write("T,D -> P,H " + 300 + "," + 1 + " --> " + p + "," + h + "\n"); T = CoolProp.PropsSI("T", "P", p, "H", h, "REFPROP::Propane"); D = CoolProp.PropsSI("D", "P", p, "H", h, "REFPROP::Propane"); Console.Write("P,H -> T,D " + p + "," + h + " --> " + T + "," + D + "\n"); } catch { Console.Write(" " + "\n"); Console.Write("************ CANT USE REFPROP ************" + "\n"); Console.Write(" " + "\n"); } Console.Write(" " + "\n"); Console.Write("************ BRINES AND SECONDARY WORKING FLUIDS *************" + "\n"); Console.Write(" " + "\n"); Console.Write("Density of 50% (mass) ethylene glycol/water at 300 K, 101325 Pa: " + CoolProp.PropsSI("D", "T", 300, "P", 101325, "EG-50%") + " kg/m^3" + "\n"); Console.Write("Viscosity of Therminol D12 at 350 K, 101325 kPa: " + CoolProp.PropsSI("V", "T", 350, "P", 101325, "INCOMP::TD12") + " Pa-s" + "\n"); Console.Write(" " + "\n"); Console.Write("************ HUMID AIR PROPERTIES *************" + "\n"); Console.Write(" " + "\n"); //Console.Write("Humidity ratio of 50% rel. hum. air at 300 K, 101.325 kPa: " + CoolProp.HAProps("W", "T", 300, "P", 101.325, "R", 0.5) + " kg_w/kg_da" + "\n"); //Console.Write("Relative humidity from last calculation: " + CoolProp.HAProps("R", "T", 300, "P", 101.325, "W", CoolProp.HAProps("W", "T", 300, "P", 101.325, "R", 0.5)) + "(fractional)" + "\n"); //Console.Write("Enter to quit"); //Console.ReadLine(); }
void ICoolProp.UseVirialCorrelations(int flag) { CoolProp.UseVirialCorrelations(flag); }