SharpProp 3.1.7
See the version list below for details.
dotnet add package SharpProp --version 3.1.7
NuGet\Install-Package SharpProp -Version 3.1.7
<PackageReference Include="SharpProp" Version="3.1.7" />
paket add SharpProp --version 3.1.7
#r "nuget: SharpProp, 3.1.7"
// Install SharpProp as a Cake Addin #addin nuget:?package=SharpProp&version=3.1.7 // Install SharpProp as a Cake Tool #tool nuget:?package=SharpProp&version=3.1.7
A simple, full-featured, lightweight, cross-platform CoolProp wrapper for C#.
Quick start
Fluid
class - for pure fluids and binary mixtures.Mixture
class - for mixtures with pure fluids components.FluidsList
enum - list of all available fluids.Input
record - inputs for theFluid
andMixture
classes.HumidAir
class - for humid air.InputHumidAir
record - inputs for theHumidAir
class.
Unit safety
All calculations of thermophysical properties are unit safe (thanks to UnitsNet). This allows you to avoid errors associated with incorrect dimensions of quantities, and will help you save a lot of time on their search and elimination. In addition, you will be able to convert all values to many other dimensions without the slightest difficulty.
List of properties
For instances of Fluid
and Mixture
:
Compressibility
- compressibility factor (dimensionless).Conductivity
- thermal conductivity (by default, W/m/K).CriticalPressure
- absolute pressure at the critical point (by default, kPa).CriticalTemperature
- temperature at the critical point (by default, °C).Density
- mass density (by default, kg/m3).DynamicViscosity
- dynamic viscosity (by default, mPa*s).Enthalpy
- mass specific enthalpy (by default, kJ/kg).Entropy
- mass specific entropy (by default, kJ/kg/K).FreezingTemperature
- temperature at freezing point (for incompressible fluids) (by default, °C).InternalEnergy
- mass specific internal energy (by default, kJ/kg).MaxPressure
- maximum pressure limit (by default, kPa).MaxTemperature
- maximum temperature limit (by default, °C).MinPressure
- minimum pressure limit (by default, kPa).MinTemperature
- minimum temperature limit (by default, °C).MolarMass
- molar mass (by default, g/mol).Phase
- phase state (enum).Prandtl
- Prandtl number (dimensionless).Pressure
- absolute pressure (by default, kPa).Quality
- mass vapor quality (by default, %).SoundSpeed
- sound speed (by default, m/s).SpecificHeat
- mass specific constant pressure specific heat (by default, kJ/kg/K).SurfaceTension
- surface tension (by default, N/m).Temperature
- temperature (by default, °C).TriplePressure
- absolute pressure at the triple point (by default, kPa).TripleTemperature
- temperature at the triple point (by default, °C).
For instances of HumidAir
:
Compressibility
- compressibility factor (dimensionless).Conductivity
- thermal conductivity (by default, W/m/K).Density
- mass density per humid air unit (by default, kg/m3).DewTemperature
- dew-point temperature (by default, °C).DynamicViscosity
- dynamic viscosity (by default, mPa*s).Enthalpy
- mass specific enthalpy per humid air (by default, kJ/kg).Entropy
- mass specific entropy per humid air (by default, kJ/kg/K).Humidity
- absolute humidity ratio (by default, g/kg d.a.).PartialPressure
- partial pressure of water vapor (by default, kPa).Pressure
- absolute pressure (by default, kPa).RelativeHumidity
- relative humidity ratio (by default, %).SpecificHeat
- mass specific constant pressure specific heat per humid air (by default, kJ/kg/K).Temperature
- dry-bulb temperature (by default, °C).WetBulbTemperature
- wet-bulb temperature (by default, °C).
NB. If the required property is not present in the instance of the fluid, then you can add it by extending
the Fluid
, Mixture
or HumidAir
classes.
Examples
Pure fluids
To calculate the specific heat of saturated water vapor at 1 atm:
using System;
using SharpProp;
using UnitsNet.NumberExtensions.NumberToPressure;
using UnitsNet.NumberExtensions.NumberToRatio;
using UnitsNet.Units;
var waterVapour = new Fluid(FluidsList.Water);
waterVapour.Update(Input.Pressure((1).Atmospheres()), Input.Quality((100).Percent()));
Console.WriteLine(waterVapour.SpecificHeat.JoulesPerKilogramKelvin); // 2079.937085633241
Console.WriteLine(waterVapour.SpecificHeat); // 2.08 kJ/kg.K
Console.WriteLine(waterVapour.SpecificHeat
.ToUnit(SpecificEntropyUnit.CaloriePerGramKelvin)); // 0.5 cal/g.K
Incompressible binary mixtures
To calculate the dynamic viscosity of propylene glycol aqueous solution with 60 % mass fraction at 100 kPa and -20 °C:
using System;
using SharpProp;
using UnitsNet.NumberExtensions.NumberToPressure;
using UnitsNet.NumberExtensions.NumberToRatio;
using UnitsNet.NumberExtensions.NumberToTemperature;
using UnitsNet.Units;
var propyleneGlycol = new Fluid(FluidsList.MPG, (60).Percent());
propyleneGlycol.Update(Input.Pressure((100).Kilopascals()), Input.Temperature((-20).DegreesCelsius()));
Console.WriteLine(propyleneGlycol.DynamicViscosity?.PascalSeconds); // 0.13907391053938878
Console.WriteLine(propyleneGlycol.DynamicViscosity); // 139.07 mPa·s
Console.WriteLine(propyleneGlycol.DynamicViscosity?
.ToUnit(DynamicViscosityUnit.Poise)); // 1.39 P
Mixtures
To calculate the density of ethanol aqueous solution (with ethanol 40 % mass fraction) at 200 kPa and 277.15 K:
using System;
using System.Collections.Generic;
using SharpProp;
using UnitsNet;
using UnitsNet.NumberExtensions.NumberToPressure;
using UnitsNet.NumberExtensions.NumberToRatio;
using UnitsNet.NumberExtensions.NumberToTemperature;
using UnitsNet.Units;
var mixture = new Mixture(new List<FluidsList> {FluidsList.Water, FluidsList.Ethanol},
new List<Ratio> {(60).Percent(), (40).Percent()});
mixture.Update(Input.Pressure((200).Kilopascals()), Input.Temperature((277.15).Kelvins()));
Console.WriteLine(mixture.Density.KilogramsPerCubicMeter); // 883.3922771627759
Console.WriteLine(mixture.Density); // 883.39 kg/m3
Console.WriteLine(mixture.Density.ToUnit(DensityUnit.GramPerDeciliter)); // 88.34 g/dl
Humid air
To calculate the wet bulb temperature of humid air at 99 kPa, 30 °C and 50 % relative humidity:
using System;
using SharpProp;
using UnitsNet.NumberExtensions.NumberToPressure;
using UnitsNet.NumberExtensions.NumberToRelativeHumidity;
using UnitsNet.NumberExtensions.NumberToTemperature;
using UnitsNet.Units;
var humidAir = new HumidAir();
humidAir.Update(InputHumidAir.Pressure((99).Kilopascals()),
InputHumidAir.Temperature((30).DegreesCelsius()), InputHumidAir.RelativeHumidity((50).Percent()));
// or use:
// var humidAir1 =
// HumidAir.WithState(InputHumidAir.Pressure((99).Kilopascals()),
// InputHumidAir.Temperature((30).DegreesCelsius()), InputHumidAir.RelativeHumidity((50).Percent()));
Console.WriteLine(humidAir.WetBulbTemperature.Kelvins); // 295.0965785590792
Console.WriteLine(humidAir.WetBulbTemperature); // 21.95 °C
Console.WriteLine(humidAir.WetBulbTemperature
.ToUnit(TemperatureUnit.DegreeFahrenheit)); // 71.5 °F
Equality of instances
You can simply determine the equality of Fluid
, Mixture
and HumidAir
instances by its state.
Just use the Equals
method or the equality operators (==
or !=
).
Exactly the same way you can compare inputs (Input
, InputHumidAir
or any IKeyedInput
record).
For example:
using System;
using SharpProp;
using UnitsNet.NumberExtensions.NumberToPressure;
using UnitsNet.NumberExtensions.NumberToRelativeHumidity;
using UnitsNet.NumberExtensions.NumberToTemperature;
var humidAir = HumidAir.WithState(InputHumidAir.Pressure((1).Atmospheres()),
InputHumidAir.Temperature((20).DegreesCelsius()), InputHumidAir.RelativeHumidity((50).Percent()));
var humidAirWithSameState = HumidAir.WithState(InputHumidAir.Pressure((101325).Pascals()),
InputHumidAir.Temperature((293.15).Kelvins()), InputHumidAir.RelativeHumidity((50).Percent()));
Console.WriteLine(humidAir == humidAirWithSameState); // true
Console.WriteLine(InputHumidAir.Pressure((1).Atmospheres()) ==
InputHumidAir.Pressure((101.325).Kilopascals())); // true
Converting to a JSON string
The Fluid
, Mixture
and HumidAir
classes have an extension method AsJson
,
which performs converting of instance to a JSON string.
For example, converting a Fluid
instance to an indented JSON string:
using System;
using SharpProp;
using SharpProp.Extensions;
using UnitsNet.NumberExtensions.NumberToRatio;
using UnitsNet.NumberExtensions.NumberToTemperature;
var refrigerant = new Fluid(FluidsList.R32);
refrigerant.Update(Input.Temperature((5).DegreesCelsius()), Input.Quality((100).Percent()));
Console.WriteLine(refrigerant.AsJson());
As a result:
{
"Name": "R32",
"Fraction": {
"Unit": "RatioUnit.Percent",
"Value": 100.0
},
"Compressibility": 0.8266625877210833,
"Conductivity": {
"Unit": "ThermalConductivityUnit.WattPerMeterKelvin",
"Value": 0.013435453854396475
},
"CriticalPressure": {
"Unit": "PressureUnit.Kilopascal",
"Value": 5782.0
},
"CriticalTemperature": {
"Unit": "TemperatureUnit.DegreeCelsius",
"Value": 78.10500000000002
},
"Density": {
"Unit": "DensityUnit.KilogramPerCubicMeter",
"Value": 25.89088151061046
},
"DynamicViscosity": {
"Unit": "DynamicViscosityUnit.MillipascalSecond",
"Value": 0.012606543144761657
},
"Enthalpy": {
"Unit": "SpecificEnergyUnit.KilojoulePerKilogram",
"Value": 516.1057800378023
},
"Entropy": {
"Unit": "SpecificEntropyUnit.KilojoulePerKilogramKelvin",
"Value": 2.1362654412978777
},
"FreezingTemperature": null,
"InternalEnergy": {
"Unit": "SpecificEnergyUnit.KilojoulePerKilogram",
"Value": 479.35739743435374
},
"MaxPressure": {
"Unit": "PressureUnit.Kilopascal",
"Value": 70000.0
},
"MaxTemperature": {
"Unit": "TemperatureUnit.DegreeCelsius",
"Value": 161.85000000000002
},
"MinPressure": {
"Unit": "PressureUnit.Kilopascal",
"Value": 0.04799989387605937
},
"MinTemperature": {
"Unit": "TemperatureUnit.DegreeCelsius",
"Value": -136.80999999999997
},
"MolarMass": {
"Unit": "MolarMassUnit.GramPerMole",
"Value": 52.024
},
"Phase": "TwoPhase",
"Prandtl": 1.2252282243443504,
"Pressure": {
"Unit": "PressureUnit.Kilopascal",
"Value": 951.448019691762
},
"Quality": {
"Unit": "RatioUnit.Percent",
"Value": 100.0
},
"SoundSpeed": {
"Unit": "SpeedUnit.MeterPerSecond",
"Value": 209.6337575990297
},
"SpecificHeat": {
"Unit": "SpecificEntropyUnit.KilojoulePerKilogramKelvin",
"Value": 1.3057899441785379
},
"SurfaceTension": {
"Unit": "ForcePerLengthUnit.NewtonPerMeter",
"Value": 0.010110117241546162
},
"Temperature": {
"Unit": "TemperatureUnit.DegreeCelsius",
"Value": 5.0
},
"TriplePressure": {
"Unit": "PressureUnit.Kilopascal",
"Value": 0.04799989387605937
},
"TripleTemperature": {
"Unit": "TemperatureUnit.DegreeCelsius",
"Value": -136.80999999999997
}
}
Deep cloning
The Fluid
, Mixture
and HumidAir
classes have an extension method Clone
,
which performs deep (full) copy of instance:
using System;
using SharpProp;
using SharpProp.Extensions;
using UnitsNet.NumberExtensions.NumberToPressure;
using UnitsNet.NumberExtensions.NumberToTemperature;
var water = new Fluid(FluidsList.Water);
water.Update(Input.Pressure((1).Atmospheres()), Input.Temperature((20).DegreesCelsius()));
var clone = water.Clone();
Console.WriteLine(water == clone); // true
water.Update(Input.Pressure((1).Atmospheres()), Input.Temperature((30).DegreesCelsius()));
Console.WriteLine(water == clone); // false
Adding other properties
Adding other inputs
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- DeepCloner (>= 0.10.3)
- Newtonsoft.Json (>= 13.0.1)
- UnitsNet (>= 4.107.0)
- UnitsNet.NumberExtensions (>= 4.107.0)
- UnitsNet.Serialization.JsonNet (>= 4.5.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SharpProp:
Package | Downloads |
---|---|
VCRC
Cross-platform vapor-compression refrigeration cycles analysis tool |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
7.3.0 | 764 | 10/3/2024 |
7.2.11 | 849 | 8/29/2024 |
7.2.10 | 790 | 7/2/2024 |
7.2.9 | 490 | 6/11/2024 |
7.2.8 | 930 | 3/19/2024 |
7.2.7 | 602 | 2/21/2024 |
7.2.6 | 313 | 1/19/2024 |
7.2.4 | 206 | 1/16/2024 |
7.2.3 | 307 | 12/27/2023 |
7.2.2 | 238 | 12/20/2023 |
7.2.1 | 306 | 12/10/2023 |
7.2.0 | 277 | 11/30/2023 |
7.1.0 | 318 | 11/15/2023 |
7.0.6 | 192 | 11/10/2023 |
7.0.5 | 368 | 10/11/2023 |
7.0.4 | 375 | 9/26/2023 |
7.0.3 | 354 | 9/6/2023 |
7.0.2 | 350 | 8/31/2023 |
7.0.1 | 229 | 8/30/2023 |
7.0.0 | 396 | 8/4/2023 |
6.0.4 | 1,154 | 3/18/2023 |
6.0.3 | 370 | 3/10/2023 |
6.0.2 | 411 | 3/5/2023 |
6.0.1 | 440 | 2/26/2023 |
6.0.0 | 496 | 2/18/2023 |
5.0.0 | 1,057 | 12/4/2022 |
4.4.1 | 5,304 | 11/21/2022 |
4.4.0 | 475 | 11/15/2022 |
4.3.3 | 641 | 11/7/2022 |
4.3.2 | 538 | 11/2/2022 |
4.3.1 | 692 | 9/12/2022 |
4.2.5 | 618 | 9/5/2022 |
4.2.4 | 648 | 8/17/2022 |
4.2.3 | 644 | 8/5/2022 |
4.2.2 | 637 | 7/22/2022 |
4.2.1 | 673 | 7/4/2022 |
4.2.0 | 669 | 6/29/2022 |
4.1.0 | 462 | 6/27/2022 |
4.0.3 | 874 | 6/22/2022 |
4.0.2 | 646 | 6/14/2022 |
4.0.1 | 665 | 6/7/2022 |
4.0.0 | 560 | 5/27/2022 |
3.2.4 | 582 | 5/7/2022 |
3.2.3 | 729 | 4/24/2022 |
3.2.2 | 866 | 4/6/2022 |
3.2.1 | 713 | 4/4/2022 |
3.2.0 | 737 | 3/22/2022 |
3.1.19 | 682 | 3/11/2022 |
3.1.18 | 687 | 3/4/2022 |
3.1.17 | 656 | 3/1/2022 |
3.1.16 | 672 | 2/17/2022 |
3.1.15 | 661 | 2/12/2022 |
3.1.14 | 731 | 1/29/2022 |
3.1.13 | 413 | 1/10/2022 |
3.1.11 | 563 | 12/8/2021 |
3.1.10 | 480 | 12/5/2021 |
3.1.9 | 1,539 | 11/28/2021 |
3.1.8 | 429 | 11/27/2021 |
3.1.7 | 3,314 | 11/25/2021 |
3.1.6 | 313 | 11/23/2021 |
3.1.4 | 366 | 11/16/2021 |
3.1.3 | 361 | 11/13/2021 |
3.1.2 | 429 | 11/6/2021 |
3.1.1 | 397 | 11/5/2021 |
3.1.0 | 407 | 10/29/2021 |
3.0.4 | 374 | 10/26/2021 |
3.0.3 | 488 | 10/24/2021 |
3.0.2 | 475 | 10/23/2021 |
3.0.1 | 380 | 10/22/2021 |
3.0.0 | 405 | 10/21/2021 |
2.0.4 | 384 | 10/18/2021 |
2.0.3 | 427 | 10/17/2021 |
2.0.2 | 367 | 10/15/2021 |
2.0.1 | 363 | 10/5/2021 |
2.0.0 | 358 | 9/27/2021 |
1.1.0 | 424 | 9/18/2021 |
1.0.6 | 347 | 9/18/2021 |
1.0.5 | 437 | 9/15/2021 |
1.0.4 | 373 | 9/15/2021 |
1.0.3 | 391 | 9/15/2021 |
1.0.2 | 370 | 9/15/2021 |
1.0.1 | 441 | 9/12/2021 |
Bump UnitsNet from 4.105.0 to 4.107.0. Bump UnitsNet.NumberExtensions from 4.105.0 to 4.107.0.