matplotlib

Table Of Contents

Previous topic

Example Code for Octave

Next topic

Example Code for Java

This Page

Example Code for C#

Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; 

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            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.Props1("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, "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");
            }
            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, "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();
        }
    }
}

Output

CoolProp version: 4.2.5
CoolProp gitrevision: b'7fd51d2f3821338fb4c27d2cd1ffad52d3efc23e'
CoolProp fluids: Water,R134a,Helium,Oxygen,Hydrogen,ParaHydrogen,OrthoHydrogen,Argon,CarbonDioxide,Nitrogen,n-Propane,Ammonia,R1234yf,R1234ze(E),R32,R22,SES36,Ethylene,SulfurHexafluoride,Ethanol,DimethylEther,DimethylCarbonate,R143a,R23,n-Dodecane,Propylene,Cyclopentane,R236FA,R236EA,R227EA,R365MFC,R161,HFE143m,Benzene,n-Undecane,R125,CycloPropane,Neon,R124,Propyne,Fluorine,Methanol,RC318,R21,R114,R13,R14,R12,R113,R1234ze(Z),R1233zd(E),AceticAcid,R245fa,R41,CarbonMonoxide,CarbonylSulfide,n-Decane,HydrogenSulfide,Isopentane,Neopentane,Isohexane,Krypton,n-Nonane,Toluene,Xenon,R116,Acetone,NitrousOxide,SulfurDioxide,R141b,R142b,R218,Methane,Ethane,n-Butane,IsoButane,n-Pentane,n-Hexane,n-Heptane,n-Octane,CycloHexane,R152A,R123,R11,MDM,MD2M,MD3M,D6,MM,MD4M,D4,D5,1-Butene,IsoButene,cis-2-Butene,trans-2-Butene,MethylPalmitate,MethylStearate,MethylOleate,MethylLinoleate,MethylLinolenate,o-Xylene,m-Xylene,p-Xylene,EthylBenzene,Deuterium,ParaDeuterium,OrthoDeuterium,Air,R404A,R410A,R407C,R507A,R407F
 
************ USING EOS *************
 
FLUID STATE INDEPENDENT INPUTS
Critical Density Propane: 220.4781 kg/m^3
TWO PHASE INPUTS (Pressure)
Density of saturated liquid Propane at 101325 Pa: 580.88295195482 kg/m^3
Density of saturated vapor R290 at 101325 Pa: 2.41613600878816 kg/m^3
TWO PHASE INPUTS (Temperature)
Density of saturated liquid Propane at 300 K: 489.447375251959 kg/m^3
Density of saturated vapor R290 at 300 K: 21.6295320184622 kg/m^3
SINGLE PHASE CYCLE (propane)
T,D -> P,H 300,1 --> 56072.7627482929,634733.625928477
P,H -> T,D 56072.7627482929,634733.625928477 --> 300,0.999999999999999
 
************ USING TTSE ***************
 
TWO PHASE INPUTS (Pressure)
0.249 to build both two phase tables
3.41 to build single phase table with p,h
16.91 to build single phase table for T,rho
write time: 0.05
Density of saturated liquid Propane at 101325 Pa: 580.882952265689 kg/m^3
Density of saturated vapor R290 at 101325 Pa: 2.41613600655144 kg/m^3
TWO PHASE INPUTS (Temperature)
Density of saturated liquid Propane at 300 K: 489.44737744117 kg/m^3
Density of saturated vapor R290 at 300 K: 21.629531877304 kg/m^3
SINGLE PHASE CYCLE (propane)
T,D -> P,H 300,1 --> 56072.7644058219,634733.625854333
P,H -> T,D 56072.7644058219,634733.625854333 --> 299.999999906753,0.999999979733272
 
************ USING REFPROP ***************
 
TWO PHASE INPUTS (Pressure)
Density of saturated liquid Propane at 101325 Pa: 580.88295195482 kg/m^3
Density of saturated vapor R290 at 101325 Pa: 2.41613600878816 kg/m^3
TWO PHASE INPUTS (Temperature)
Density of saturated liquid Propane at 300 K: 489.447375251959 kg/m^3
Density of saturated vapor R290 at 300 K: 21.6295320184622 kg/m^3
SINGLE PHASE CYCLE (propane)
T,D -> P,H 300,1 --> 56072.7627482929,634733.625928477
P,H -> T,D 56072.7627482929,634733.625928477 --> 300,0.999999999999999
 
************ BRINES AND SECONDARY WORKING FLUIDS *************
 
Density of 50% (mass) ethylene glycol/water at 300 K, 101325 Pa: 1061.17930772046kg/m^3
Viscosity of Therminol D12 at 350 K, 101325 kPa: 0.000522884941050795Pa-s
 
************ HUMID AIR PROPERTIES *************
 
Humidity ratio of 50% rel. hum. air at 300 K, 101.325 kPa: 0.0110962237500952 kg_w/kg_da
Relative humidity from last calculation: 0.5(fractional)