SMath Wrapper refactoring (#1365)

* Full update to latest SS 0.98 APIs

- SS: switched to LowLevelEvaluationFast interface;
- SS: fixed compiler warnings for deprecated methods/properties;
- refactoring;

* refactoring

- removed not useful try/catch from unit manager;
- refactoring of not used methods;

* Fix for SMath bug SS-2414

* minor changes

* Added folder for Test files

* Added test file

IF97 test file from CoolProp/CoolProp issue #1249

* changed filename

* added script for batch testing

* Review of dynamic assistant tootltip

* New layout for README.md

* Updated README.md

* Updated README.md

* Fixed combined emphasis in README.md
This commit is contained in:
Davide Carpi
2016-12-02 16:41:19 +01:00
committed by Ian Bell
parent 091a4893a2
commit b371b75aaf
20 changed files with 3384 additions and 1398 deletions

View File

@@ -0,0 +1,172 @@
using System.Collections.Generic;
using System.Reflection;
using SMath.Manager;
namespace coolprop_wrapper
{
public class coolpropPlugin : SMath.Math.IPluginLowLevelEvaluationFast
{
AssemblyInfo[] asseblyInfos = new []
{
new AssemblyInfo("SMath Studio", new System.Version(0, 98), new System.Guid("a37cba83-b69c-4c71-9992-55ff666763bd"))
};
TermInfo[] termInfos = new TermInfo[] {};
List<IFunction> functions = new List<IFunction>();
static string AssemblyDirectory
{
get
{
var filepath = new System.Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
return System.IO.Path.GetDirectoryName(filepath);
}
}
static string LogFile
{
get { return System.IO.Path.Combine(AssemblyDirectory, "log.txt"); }
}
public static void LogInfo(string Category, string Text, params object[] args)
{
#if DEBUG
var method = new System.Diagnostics.StackFrame(1).GetMethod();
System.IO.File.AppendAllText(
LogFile,
string.Format(
"{0} {1} {2} [{3}.{4}] {5}{6}",
System.DateTime.Now.ToShortDateString(),
System.DateTime.Now.ToLongTimeString(),
Category,
method.DeclaringType.Name,
method.Name.Substring(method.Name.LastIndexOf('.')+1),
string.Format(Text, args),
System.Environment.NewLine),
System.Text.Encoding.UTF8);
#endif
}
public static SMath.Math.Numeric.TNumber GetNumberParam(Entry arg, SMath.Math.Store context)
{
// var arg1 = SMath.Math.Decision.Preprocessing(arg, ref context);
// return SMath.Math.Numeric.Expression.Calculate(arg1, context).obj as SMath.Math.Numeric.TDouble;
return SMath.Math.Decision.NumericCalculation(arg, context);
}
public static void CoolPropError(string message = "")
{
string errStr;
if (!Functions.CoolProp_get_global_param_string.CoolPropDLLfunc("errstring", out errStr))
{
// Call it second time - most probably will get something like "buffer too small"
Functions.CoolProp_get_global_param_string.CoolPropDLLfunc("errstring", out errStr);
errStr = "Error message couldn't be retrieved from CoolProp library (buffer size issue?); the second try returned: " + errStr;
}
throw new System.Exception(message + errStr);
}
public static string GetStringParam(Entry arg, SMath.Math.Store context)
{
var dbl = GetNumberParam(arg, context).obj as SMath.Math.Numeric.TDouble;
if (!dbl.isText)
throw new SMath.Manager.MathException(Errors.ArgumentMustBeString);
return dbl.ToString().Trim(Symbols.StringChar[0]);
}
public static Entry MakeDoubleResult(double result, SMath.Math.Symbolic.MItem unit)
{
if (double.IsInfinity(result))
{
CoolPropError();
}
var d = new SMath.Math.Numeric.TDouble(result);
d.Units = unit;
return Entry.Create(d.ToTerms());
}
public static Entry MakeStringResult(string result)
{
return new Entry(Symbols.StringChar + result + Symbols.StringChar, TermType.Operand, new Entry[0]);
}
TermInfo[] IPluginHandleEvaluation.TermsHandled { get { return termInfos; } }
void System.IDisposable.Dispose()
{
try
{
if (System.IO.File.Exists(LogFile))
System.IO.File.Delete(LogFile);
}
catch (System.Exception) {}
}
AssemblyInfo[] IPlugin.Dependences { get { return asseblyInfos; } }
void IPlugin.Initialize()
{
var info = new List<TermInfo>();
try
{
foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) {
if (!(type.IsClass && typeof(IFunction).IsAssignableFrom(type)))
continue;
var arguments = type.GetField("Arguments", BindingFlags.GetField | BindingFlags.Static | BindingFlags.Public);
if (arguments == null)
continue;
var args = arguments.GetValue(null) as int[];
foreach (var arg in args)
functions.Add((IFunction)System.Activator.CreateInstance(type, new object[] {arg}));
}
foreach (var func in functions)
{
var item = func.GetTermInfo(GlobalParams.CurLang3Letter);
info.Add(item);
LogInfo("[INFO]", "{0}({1}) - {2}", item.Text, item.ArgsCount, item.Description);
}
}
catch (System.Exception ex)
{
LogInfo("[ERROR]", "{0}", ex.Message);
}
termInfos = info.ToArray();
LogInfo("[INFO]", "Successfully. {0} functions loaded.", termInfos.Length);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
result = null;
if (value.Type != TermType.Function)
return false;
foreach (var func in functions)
{
if (!func.Info.Equals(value.ToTerm()))
continue;
try
{
return func.TryEvaluateExpression(value, context, out result);
}
catch (System.Exception ex)
{
LogInfo("[ERROR]", "{0}({1}) {2}", value.Text, value.ArgsCount, ex.Message);
throw;
}
}
return false;
}
}
}

View File

@@ -3,136 +3,136 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_HAProps : IFunction
{
// double HAPropsSI(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char *Name3, double Prop3);
[DllImport(
"CoolProp_x86", EntryPoint = "HAPropsSI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x86(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string Name3,
double Prop3);
[DllImport(
"CoolProp_x64", EntryPoint = "HAPropsSI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x64(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string Name3,
double Prop3);
internal static double CoolPropDLLfunc(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string Name3,
double Prop3)
class CoolProp_HAProps : IFunction
{
switch (System.IntPtr.Size) {
case 4:
return CoolPropDLLfunc_x86(Output, Name1, Prop1, Name2, Prop2, Name3, Prop3);
case 8:
return CoolPropDLLfunc_x64(Output, Name1, Prop1, Name2, Prop2, Name3, Prop3);
}
throw new System.Exception("Unknown platform!");
// double HAPropsSI(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char *Name3, double Prop3);
[DllImport(
"CoolProp_x86", EntryPoint = "HAPropsSI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x86(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string Name3,
double Prop3);
[DllImport(
"CoolProp_x64", EntryPoint = "HAPropsSI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x64(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string Name3,
double Prop3);
internal static double CoolPropDLLfunc(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string Name3,
double Prop3)
{
switch (System.IntPtr.Size) {
case 4:
return CoolPropDLLfunc_x86(Output, Name1, Prop1, Name2, Prop2, Name3, Prop3);
case 8:
return CoolPropDLLfunc_x64(Output, Name1, Prop1, Name2, Prop2, Name3, Prop3);
}
throw new System.Exception("Unknown platform!");
}
Term inf;
public static int[] Arguments = new[] { 7 };
public CoolProp_HAProps(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(Output, Name1, Prop1, Name2, Prop2, Name3, Prop3) Return a humid air property\r\n" +
"Output: The output parameter, one of \"T\", \"D\", \"H\", etc...\r\n" +
"Name1: The first state variable name, one of \"T\", \"D\", \"H\", etc...\r\n" +
"Prop1: The first state variable value\r\n" +
"Name2: The second state variable name, one of \"T\", \"D\", \"H\", etc...\r\n" +
"Prop2: The second state variable value\r\n" +
"Name3: The third state variable name, one of \"T\", \"D\", \"H\", etc...\r\n" +
"Prop3: The third state variable value";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
// Possible inputs:
// "Omega"="HumRat"="W" = Humidity ratio
// "Tdp"="T_dp"="DewPoint"="D" = Dewpoint temperature
// "Twb"="T_wb"="WetBulb"="B" = Wet bulb temperature
// "Enthalpy"="H" = Enthalpy
// "Entropy"="S" = Entropy
// "RH"="RelHum"="R" = Relative humidity
// "Tdb"="T_db"="T" = Dry-bulb temperature
// "P" = Pressure
// "V"="Vda" = Volume of dry air
// "mu"="Visc"="M" = Viscosity
// "k"="Conductivity"="K" = Conductivity
// Output:
// "Vda"="V"[m^3/kg_da]
// "Vha"[m^3/kg_ha]
// "Y"[mol_w/mol]
// "Hda"="H"
// "Hha"[kJ/kg_ha]
// "S"="Entropy"[kJ/kg_da]
// "C"="cp"[kJ/kg_da]
// "Cha"="cp_ha"[kJ/kg_da]
// "Tdp"="D"[K]
// "Twb"="T_wb"="WetBulb"="B"[K]
// "Omega"="HumRat"="W"
// "RH"="RelHum"="R"
// "mu"="Visc"="M"
// "k"="Conductivity"="K"
var Output = coolpropPlugin.GetStringParam(value.Items[0], context);
var Name1 = coolpropPlugin.GetStringParam(value.Items[1], context);
var Prop1 = coolpropPlugin.GetNumberParam(value.Items[2], context);
Unit.matchHA(Name1, Prop1, context);
var Name2 = coolpropPlugin.GetStringParam(value.Items[3], context);
var Prop2 = coolpropPlugin.GetNumberParam(value.Items[4], context);
Unit.matchHA(Name2, Prop2, context);
var Name3 = coolpropPlugin.GetStringParam(value.Items[5], context);
var Prop3 = coolpropPlugin.GetNumberParam(value.Items[6], context);
Unit.matchHA(Name3, Prop3, context);
var Result = CoolPropDLLfunc(Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), Name3, Prop3.obj.ToDouble());
coolpropPlugin.LogInfo("[INFO]",
"Output = {0}, Name1 = {1}, Prop1 = {2}, Name2 = {3}, Prop2 = {4}, Name3 = {5}, Prop3 = {6}, Result = {7}",
Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), Name3, Prop3.obj.ToDouble(), Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.FindHA(Output));
return true;
}
}
Term inf;
public static int[] Arguments = new[] { 7 };
public CoolProp_HAProps(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(Output, Name1, Prop1, Name2, Prop2, Name3, Prop3) Return a humid air property\r\n" +
"Output The output parameter, one of \"T\",\"D\",\"H\",etc.\r\n" +
"Name1 The first state variable name, one of \"T\",\"D\",\"H\",etc.\r\n" +
"Prop1 The first state variable value\r\n" +
"Name2 The second state variable name, one of \"T\",\"D\",\"H\",etc.\r\n" +
"Prop2 The second state variable value\r\n" +
"Name3 The third state variable name, one of \"T\",\"D\",\"H\",etc.\r\n" +
"Prop3 The third state variable value";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
// Possible inputs:
// "Omega"="HumRat"="W" = Humidity ratio
// "Tdp"="T_dp"="DewPoint"="D" = Dewpoint temperature
// "Twb"="T_wb"="WetBulb"="B" = Wet bulb temperature
// "Enthalpy"="H" = Enthalpy
// "Entropy"="S" = Entropy
// "RH"="RelHum"="R" = Relative humidity
// "Tdb"="T_db"="T" = Dry-bulb temperature
// "P" = Pressure
// "V"="Vda" = Volume of dry air
// "mu"="Visc"="M" = Viscosity
// "k"="Conductivity"="K" = Conductivity
// Output:
// "Vda"="V"[m^3/kg_da]
// "Vha"[m^3/kg_ha]
// "Y"[mol_w/mol]
// "Hda"="H"
// "Hha"[kJ/kg_ha]
// "S"="Entropy"[kJ/kg_da]
// "C"="cp"[kJ/kg_da]
// "Cha"="cp_ha"[kJ/kg_da]
// "Tdp"="D"[K]
// "Twb"="T_wb"="WetBulb"="B"[K]
// "Omega"="HumRat"="W"
// "RH"="RelHum"="R"
// "mu"="Visc"="M"
// "k"="Conductivity"="K"
var Output = coolpropPlugin.GetStringParam(args[0], ref context);
var Name1 = coolpropPlugin.GetStringParam(args[1], ref context);
var Prop1 = coolpropPlugin.GetNumberParam(args[2], ref context);
Unit.matchHA(Name1, Prop1, context);
var Name2 = coolpropPlugin.GetStringParam(args[3], ref context);
var Prop2 = coolpropPlugin.GetNumberParam(args[4], ref context);
Unit.matchHA(Name2, Prop2, context);
var Name3 = coolpropPlugin.GetStringParam(args[5], ref context);
var Prop3 = coolpropPlugin.GetNumberParam(args[6], ref context);
Unit.matchHA(Name3, Prop3, context);
var Result = CoolPropDLLfunc(Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), Name3, Prop3.obj.ToDouble());
coolpropPlugin.LogInfo("[INFO ]",
"Output = {0}, Name1 = {1}, Prop1 = {2}, Name2 = {3}, Prop2 = {4}, Name3 = {5}, Prop3 = {6}, Result = {7}",
Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), Name3, Prop3.obj.ToDouble(), Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.FindHA(Output));
return true;
}
}
}

View File

@@ -3,104 +3,104 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_Phase : IFunction
{
// long PhaseSI(const char *Name1, double Prop1, const char *Name2, double Prop2, const char *Ref, char *phase, int n);
[DllImport(
"CoolProp_x86", EntryPoint="PhaseSI",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName,
System.Text.StringBuilder phase,
int n);
[DllImport(
"CoolProp_x64", EntryPoint = "PhaseSI",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName,
System.Text.StringBuilder phase,
int n);
internal static long CoolPropDLLfunc(
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName,
System.Text.StringBuilder phase,
int n)
class CoolProp_Phase : IFunction
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(Name1, Prop1, Name2, Prop2, FluidName, phase, n);
case 8:
return CoolPropDLLfunc_x64(Name1, Prop1, Name2, Prop2, FluidName, phase, n);
}
throw new System.Exception("Unknown platform!");
// long PhaseSI(const char *Name1, double Prop1, const char *Name2, double Prop2, const char *Ref, char *phase, int n);
[DllImport(
"CoolProp_x86", EntryPoint="PhaseSI",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName,
System.Text.StringBuilder phase,
int n);
[DllImport(
"CoolProp_x64", EntryPoint = "PhaseSI",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName,
System.Text.StringBuilder phase,
int n);
internal static long CoolPropDLLfunc(
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName,
System.Text.StringBuilder phase,
int n)
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(Name1, Prop1, Name2, Prop2, FluidName, phase, n);
case 8:
return CoolPropDLLfunc_x64(Name1, Prop1, Name2, Prop2, FluidName, phase, n);
}
throw new System.Exception("Unknown platform!");
}
Term inf;
public static int[] Arguments = new [] {5};
public CoolProp_Phase(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(Name1, Prop1, Name2, Prop2, FluidName) Return a string representation of the phase\r\n" +
"Name1: The first state variable name, one of \"T\", \"D\", \"H\", etc...\r\n" +
"Prop1: The first state variable value\r\n" +
"Name2: The second state variable name, one of \"T\", \"D\", \"H\", etc...\r\n" +
"Prop2: The second state variable value\r\n" +
"FluidName: The fluid name";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
var Name1 = coolpropPlugin.GetStringParam(value.Items[0], context);
var Prop1 = coolpropPlugin.GetNumberParam(value.Items[1], context);
Unit.match(Name1, Prop1, context);
var Name2 = coolpropPlugin.GetStringParam(value.Items[2], context);
var Prop2 = coolpropPlugin.GetNumberParam(value.Items[3], context);
Unit.match(Name2, Prop2, context);
var FluidName = coolpropPlugin.GetStringParam(value.Items[4], context);
var phase = new System.Text.StringBuilder(10000);
var Result = CoolPropDLLfunc(Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, phase, phase.Capacity);
coolpropPlugin.LogInfo("[INFO]",
"Name1 = {0}, Prop1 = {1}, Name2 = {2}, Prop2 = {3}, FluidName = {4}, phase = {5}, Result = {6}",
Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, phase.ToString(), Result);
if (Result != 1)
coolpropPlugin.CoolPropError();
result = coolpropPlugin.MakeStringResult(phase.ToString());
return true;
}
}
Term inf;
public static int[] Arguments = new [] {5};
public CoolProp_Phase(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(Name1, Prop1, Name2, Prop2, FluidName) Return a string representation of the phase\r\n" +
"Name1 The first state variable name, one of \"T\",\"D\",\"H\",etc.\r\n" +
"Prop1 The first state variable value\r\n" +
"Name2 The second state variable name, one of \"T\",\"D\",\"H\",etc.\r\n" +
"Prop2 The second state variable value\r\n" +
"FluidName The fluid name";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
var Name1 = coolpropPlugin.GetStringParam(args[0], ref context);
var Prop1 = coolpropPlugin.GetNumberParam(args[1], ref context);
Unit.match(Name1, Prop1, context);
var Name2 = coolpropPlugin.GetStringParam(args[2], ref context);
var Prop2 = coolpropPlugin.GetNumberParam(args[3], ref context);
Unit.match(Name2, Prop2, context);
var FluidName = coolpropPlugin.GetStringParam(args[4], ref context);
var phase = new System.Text.StringBuilder(10000);
var Result = CoolPropDLLfunc(Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, phase, phase.Capacity);
coolpropPlugin.LogInfo("[INFO ]",
"Name1 = {0}, Prop1 = {1}, Name2 = {2}, Prop2 = {3}, FluidName = {4}, phase = {5}, Result = {6}",
Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, phase.ToString(), Result);
if (Result != 1)
coolpropPlugin.CoolPropError();
result = coolpropPlugin.MakeStringResult(phase.ToString());
return true;
}
}
}

View File

@@ -3,100 +3,101 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_Props : IFunction
{
// double PropsSI(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char *Ref);
[DllImport(
"CoolProp_x86", EntryPoint = "PropsSI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x86(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName);
[DllImport(
"CoolProp_x64", EntryPoint = "PropsSI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x64(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName);
internal static double CoolPropDLLfunc(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName)
class CoolProp_Props : IFunction
{
switch (System.IntPtr.Size) {
case 4:
return CoolPropDLLfunc_x86(Output, Name1, Prop1, Name2, Prop2, FluidName);
case 8:
return CoolPropDLLfunc_x64(Output, Name1, Prop1, Name2, Prop2, FluidName);
}
throw new System.Exception("Unknown platform!");
// double PropsSI(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char *Ref);
[DllImport(
"CoolProp_x86", EntryPoint = "PropsSI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x86(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName);
[DllImport(
"CoolProp_x64", EntryPoint = "PropsSI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x64(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName);
internal static double CoolPropDLLfunc(
string Output,
string Name1,
double Prop1,
string Name2,
double Prop2,
string FluidName)
{
switch (System.IntPtr.Size) {
case 4:
return CoolPropDLLfunc_x86(Output, Name1, Prop1, Name2, Prop2, FluidName);
case 8:
return CoolPropDLLfunc_x64(Output, Name1, Prop1, Name2, Prop2, FluidName);
}
throw new System.Exception("Unknown platform!");
}
Term inf;
public static int[] Arguments = new[] { 6 };
public CoolProp_Props(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(Output, Name1, Prop1, Name2, Prop2, FluidName) Return a value that depends on the thermodynamic state\r\n" +
"Output: The output parameter, one of \"T\", \"D\", \"H\", etc...\r\n" +
"Name1: The first state variable name, one of \"T\", \"D\", \"H\", etc...\r\n" +
"Prop1: The first state variable value\r\n" +
"Name2: The second state variable name, one of \"T\", \"D\", \"H\", etc...\r\n" +
"Prop2: The second state variable value\r\n" +
"FluidName: The fluid name";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
var Output = coolpropPlugin.GetStringParam(value.Items[0], context);
var Name1 = coolpropPlugin.GetStringParam(value.Items[1], context);
var Prop1 = coolpropPlugin.GetNumberParam(value.Items[2], context);
Unit.match(Name1, Prop1, context);
var Name2 = coolpropPlugin.GetStringParam(value.Items[3], context);
var Prop2 = coolpropPlugin.GetNumberParam(value.Items[4], context);
Unit.match(Name2, Prop2, context);
var FluidName = coolpropPlugin.GetStringParam(value.Items[5], context);
var Result = CoolPropDLLfunc(Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName);
coolpropPlugin.LogInfo("[INFO]",
"Output = {0}, Name1 = {1}, Prop1 = {2}, Name2 = {3}, Prop2 = {4}, FluidName = {5}, Result = {6}",
Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.Find(Output));
return true;
}
}
Term inf;
public static int[] Arguments = new[] { 6 };
public CoolProp_Props(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(Output, Name1, Prop1, Name2, Prop2, FluidName) Return a value that depends on the thermodynamic state\r\n" +
"Output The output parameter, one of \"T\",\"D\",\"H\",etc.\r\n" +
"Name1 The first state variable name, one of \"T\",\"D\",\"H\",etc.\r\n" +
"Prop1 The first state variable value\r\n" +
"Name2 The second state variable name, one of \"T\",\"D\",\"H\",etc.\r\n" +
"Prop2 The second state variable value\r\n" +
"FluidName The fluid name";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
var Output = coolpropPlugin.GetStringParam(args[0], ref context);
var Name1 = coolpropPlugin.GetStringParam(args[1], ref context);
var Prop1 = coolpropPlugin.GetNumberParam(args[2], ref context);
Unit.match(Name1, Prop1, context);
var Name2 = coolpropPlugin.GetStringParam(args[3], ref context);
var Prop2 = coolpropPlugin.GetNumberParam(args[4], ref context);
Unit.match(Name2, Prop2, context);
var FluidName = coolpropPlugin.GetStringParam(args[5], ref context);
var Result = CoolPropDLLfunc(Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName);
coolpropPlugin.LogInfo("[INFO ]",
"Output = {0}, Name1 = {1}, Prop1 = {2}, Name2 = {3}, Prop2 = {4}, FluidName = {5}, Result = {6}",
Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.Find(Output));
return true;
}
}
}
}

View File

@@ -3,77 +3,77 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_Props1 : IFunction
{
// double Props1SI(const char *FluidName, const char* Output);
[DllImport(
"CoolProp_x86", EntryPoint = "Props1SI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x86(
string FluidName,
string Output);
[DllImport(
"CoolProp_x64", EntryPoint = "Props1SI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x64(
string FluidName,
string Output);
internal static double CoolPropDLLfunc(
string FluidName,
string Output)
class CoolProp_Props1 : IFunction
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(FluidName, Output);
case 8:
return CoolPropDLLfunc_x64(FluidName, Output);
}
throw new System.Exception("Unknown platform!");
// double Props1SI(const char *FluidName, const char* Output);
[DllImport(
"CoolProp_x86", EntryPoint = "Props1SI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x86(
string FluidName,
string Output);
[DllImport(
"CoolProp_x64", EntryPoint = "Props1SI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x64(
string FluidName,
string Output);
internal static double CoolPropDLLfunc(
string FluidName,
string Output)
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(FluidName, Output);
case 8:
return CoolPropDLLfunc_x64(FluidName, Output);
}
throw new System.Exception("Unknown platform!");
}
Term inf;
public static int[] Arguments = new[] { 2 };
public CoolProp_Props1(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(FluidName, Output) Return a value that does not depends on the thermodynamic state\r\n" +
"FluidName: The fluid name\r\n" +
"Output: The output parameter, one of \"Tcrit\", \"D\", \"H\", etc...";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
string FluidName = coolpropPlugin.GetStringParam(value.Items[0], context),
Output = coolpropPlugin.GetStringParam(value.Items[1], context);
var Result = CoolPropDLLfunc(FluidName, Output);
coolpropPlugin.LogInfo("[INFO]", "FluidName = {0}, Output = {1}, Result = {2}", FluidName, Output, Result);
var ResUnit = Unit.Find(Output);
// Props1SI may take parameters in either order; so, Output may actually be in FluidName
if (ResUnit == Unit.unitless)
ResUnit = Unit.Find(FluidName);
result = coolpropPlugin.MakeDoubleResult(Result, ResUnit);
return true;
}
}
Term inf;
public static int[] Arguments = new[] { 2 };
public CoolProp_Props1(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(FluidName, Output) Return a value that does not depend on the thermodynamic state\r\n" +
"FluidName The fluid name\r\n" +
"Output The output parameter, one of \"Tcrit\",\"D\",\"H\",etc.";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
string FluidName = coolpropPlugin.GetStringParam(args[0], ref context),
Output = coolpropPlugin.GetStringParam(args[1], ref context);
var Result = CoolPropDLLfunc(FluidName, Output);
coolpropPlugin.LogInfo("[INFO ]", "FluidName = {0}, Output = {1}, Result = {2}", FluidName, Output, Result);
var ResUnit = Unit.Find(Output);
// Props1SI may take parameters in either order; so, Output may actually be in FluidName
if (ResUnit == Unit.unitless)
ResUnit = Unit.Find(FluidName);
result = coolpropPlugin.MakeDoubleResult(Result, ResUnit);
return true;
}
}
}

View File

@@ -3,82 +3,82 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_get_fluid_param_string : IFunction
{
// long get_fluid_param_string(const char *fluid, const char *param, char *Output, int n);
[DllImport(
"CoolProp_x86", EntryPoint = "get_fluid_param_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string fluid,
string param,
System.Text.StringBuilder Output,
int n);
[DllImport(
"CoolProp_x64", EntryPoint = "get_fluid_param_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string fluid,
string param,
System.Text.StringBuilder Output,
int n);
internal static long CoolPropDLLfunc(
string fluid,
string param,
System.Text.StringBuilder Output,
int n)
class CoolProp_get_fluid_param_string : IFunction
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(fluid, param, Output, n);
case 8:
return CoolPropDLLfunc_x64(fluid, param, Output, n);
}
throw new System.Exception("Unknown platform!");
// long get_fluid_param_string(const char *fluid, const char *param, char *Output, int n);
[DllImport(
"CoolProp_x86", EntryPoint = "get_fluid_param_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string fluid,
string param,
System.Text.StringBuilder Output,
int n);
[DllImport(
"CoolProp_x64", EntryPoint = "get_fluid_param_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string fluid,
string param,
System.Text.StringBuilder Output,
int n);
internal static long CoolPropDLLfunc(
string fluid,
string param,
System.Text.StringBuilder Output,
int n)
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(fluid, param, Output, n);
case 8:
return CoolPropDLLfunc_x64(fluid, param, Output, n);
}
throw new System.Exception("Unknown platform!");
}
Term inf;
public static int[] Arguments = new [] {2};
public CoolProp_get_fluid_param_string(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
public TermInfo GetTermInfo(string lang)
{
string funcInfo = "(FluidName, ParamName) Get a string for a value from a fluid\r\n" +
"FluidName: The name of the fluid that is part of CoolProp, for instance \"n-Propane\"\r\n" +
"ParamName: A string, can be in one of \"aliases\", \"CAS\", \"CAS_number\", \"ASHRAE34\", \"REFPROPName\", \"REFPROP_name\"";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
var fluid = coolpropPlugin.GetStringParam(value.Items[0], context);
var param = coolpropPlugin.GetStringParam(value.Items[1], context);
var output = new System.Text.StringBuilder(10000);
var Result = CoolPropDLLfunc(fluid, param, output, output.Capacity);
coolpropPlugin.LogInfo("[INFO]", "fluid = {0} param = {1} output = {2} Result = {3}", fluid, param, output.ToString(), Result);
if (Result != 1)
coolpropPlugin.CoolPropError();
result = coolpropPlugin.MakeStringResult(output.ToString());
return true;
}
}
Term inf;
public static int[] Arguments = new [] {2};
public CoolProp_get_fluid_param_string(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
public TermInfo GetTermInfo(string lang)
{
string funcInfo = "(FluidName, ParamName) Get a string for a value from a fluid\r\n" +
"FluidName The name of the fluid that is part of CoolProp, for instance \"n-Propane\"\r\n" +
"ParamName A string, can be in one of \"aliases\", \"CAS\", \"CAS_number\", \"ASHRAE34\", \"REFPROPName\", \"REFPROP_name\"";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
var fluid = coolpropPlugin.GetStringParam(args[0], ref context);
var param = coolpropPlugin.GetStringParam(args[1], ref context);
var output = new System.Text.StringBuilder(10000);
var Result = CoolPropDLLfunc(fluid, param, output, output.Capacity);
coolpropPlugin.LogInfo("[INFO ]", "fluid = {0} param = {1} output = {2} Result = {3}", fluid, param, output.ToString(), Result);
if (Result != 1)
coolpropPlugin.CoolPropError();
result = coolpropPlugin.MakeStringResult(output.ToString());
return true;
}
}
}

View File

@@ -3,77 +3,77 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_get_global_param_string : IFunction
{
// long get_global_param_string(const char *param, char *Output, int n);
[DllImport(
"CoolProp_x86", EntryPoint = "get_global_param_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string param,
System.Text.StringBuilder Output,
int n);
[DllImport(
"CoolProp_x64", EntryPoint = "get_global_param_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string param,
System.Text.StringBuilder Output,
int n);
internal static bool CoolPropDLLfunc(string param, out string resultStr)
class CoolProp_get_global_param_string : IFunction
{
var output = new System.Text.StringBuilder(10000);
long Result = 0;
switch (System.IntPtr.Size)
{
case 4:
Result = CoolPropDLLfunc_x86(param, output, output.Capacity);
break;
case 8:
Result = CoolPropDLLfunc_x64(param, output, output.Capacity);
break;
default:
throw new System.Exception("Unknown platform!");
}
coolpropPlugin.LogInfo("[INFO ]", "param = {0} output = {1} Result = {2}", param, resultStr = output.ToString(), Result);
return (Result == 1);
// long get_global_param_string(const char *param, char *Output, int n);
[DllImport(
"CoolProp_x86", EntryPoint = "get_global_param_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string param,
System.Text.StringBuilder Output,
int n);
[DllImport(
"CoolProp_x64", EntryPoint = "get_global_param_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string param,
System.Text.StringBuilder Output,
int n);
internal static bool CoolPropDLLfunc(string param, out string resultStr)
{
var output = new System.Text.StringBuilder(10000);
long Result = 0;
switch (System.IntPtr.Size)
{
case 4:
Result = CoolPropDLLfunc_x86(param, output, output.Capacity);
break;
case 8:
Result = CoolPropDLLfunc_x64(param, output, output.Capacity);
break;
default:
throw new System.Exception("Unknown platform!");
}
coolpropPlugin.LogInfo("[INFO]", "param = {0} output = {1} Result = {2}", param, resultStr = output.ToString(), Result);
return (Result == 1);
}
Term inf;
public static int[] Arguments = new [] {1};
public CoolProp_get_global_param_string(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(ParamName) Get a globally-defined string\r\n" +
"ParamName: A string, one of \"version\", \"errstring\", \"warnstring\", \"gitrevision\", \"FluidsList\", \"fluids_list\", \"parameter_list\",\"predefined_mixtures\"";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
var param = coolpropPlugin.GetStringParam(value.Items[0], context);
string resultStr;
if (!CoolPropDLLfunc(param, out resultStr))
coolpropPlugin.CoolPropError();
result = coolpropPlugin.MakeStringResult(resultStr);
return true;
}
}
Term inf;
public static int[] Arguments = new [] {1};
public CoolProp_get_global_param_string(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(ParamName) Get a globally-defined string\r\n" +
"ParamName A string, one of \"version\", \"errstring\", \"warnstring\", \"gitrevision\", \"FluidsList\", \"fluids_list\", \"parameter_list\",\"predefined_mixtures\"";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
var param = coolpropPlugin.GetStringParam(args[0], ref context);
string resultStr;
if (!CoolPropDLLfunc(param, out resultStr))
coolpropPlugin.CoolPropError();
result = coolpropPlugin.MakeStringResult(resultStr);
return true;
}
}
}

View File

@@ -3,68 +3,67 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_get_param_index : IFunction
{
// long get_param_index(const char *param);
[DllImport(
"CoolProp_x86", EntryPoint = "get_param_index",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string param);
[DllImport(
"CoolProp_x64", EntryPoint = "get_param_index",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string param);
internal static long CoolPropDLLfunc(
string param)
class CoolProp_get_param_index : IFunction
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(param);
case 8:
return CoolPropDLLfunc_x64(param);
}
throw new System.Exception("Unknown platform!");
// long get_param_index(const char *param);
[DllImport(
"CoolProp_x86", EntryPoint = "get_param_index",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string param);
[DllImport(
"CoolProp_x64", EntryPoint = "get_param_index",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string param);
internal static long CoolPropDLLfunc(
string param)
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(param);
case 8:
return CoolPropDLLfunc_x64(param);
}
throw new System.Exception("Unknown platform!");
}
Term inf;
public static int[] Arguments = new[] { 1 };
public CoolProp_get_param_index(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(Name) Returns the index of a parameter\r\n" +
"Name: The parameter name, one of \"Tcrit\", \"D\", \"H\", etc...";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
var param = coolpropPlugin.GetStringParam(value.Items[0], context);
var Result = CoolPropDLLfunc(param);
coolpropPlugin.LogInfo("[INFO]", "param = {0}, Result = {1}", param, Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);
return true;
}
}
Term inf;
public static int[] Arguments = new[] { 1 };
public CoolProp_get_param_index(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(FluidName, Output) Return a value that does not depend on the thermodynamic state\r\n" +
"FluidName The fluid name\r\n" +
"Output The output parameter, one of \"Tcrit\",\"D\",\"H\",etc.";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
var param = coolpropPlugin.GetStringParam(args[0], ref context);
var Result = CoolPropDLLfunc(param);
coolpropPlugin.LogInfo("[INFO ]", "param = {0}, Result = {1}", param, Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);
return true;
}
}
}

View File

@@ -3,81 +3,81 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_get_parameter_information_string : IFunction
{
// long get_parameter_information_string(const char *key, char *Output, int n);
[DllImport(
"CoolProp_x86", EntryPoint = "get_parameter_information_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string key,
System.Text.StringBuilder Output,
int n);
[DllImport(
"CoolProp_x64", EntryPoint = "get_parameter_information_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string key,
System.Text.StringBuilder Output,
int n);
internal static long CoolPropDLLfunc(
string key,
System.Text.StringBuilder Output,
int n)
class CoolProp_get_parameter_information_string : IFunction
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(key, Output, n);
case 8:
return CoolPropDLLfunc_x64(key, Output, n);
}
throw new System.Exception("Unknown platform!");
// long get_parameter_information_string(const char *key, char *Output, int n);
[DllImport(
"CoolProp_x86", EntryPoint = "get_parameter_information_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string key,
System.Text.StringBuilder Output,
int n);
[DllImport(
"CoolProp_x64", EntryPoint = "get_parameter_information_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string key,
System.Text.StringBuilder Output,
int n);
internal static long CoolPropDLLfunc(
string key,
System.Text.StringBuilder Output,
int n)
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(key, Output, n);
case 8:
return CoolPropDLLfunc_x64(key, Output, n);
}
throw new System.Exception("Unknown platform!");
}
Term inf;
public static int[] Arguments = new [] {2};
public CoolProp_get_parameter_information_string(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
public TermInfo GetTermInfo(string lang)
{
string funcInfo = "(Key, Output) Get a parameter information string\r\n" +
"Key: A string\r\n" +
"Output: A string, one of \"IO\", \"short\", \"long\", \"units\"";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
var key = coolpropPlugin.GetStringParam(value.Items[0], context);
var Output = coolpropPlugin.GetStringParam(value.Items[1], context);
var output = new System.Text.StringBuilder(Output, 10000);
var Result = CoolPropDLLfunc(key, output, output.Capacity);
coolpropPlugin.LogInfo("[INFO]",
"key = {0} output(in) = {1} output(out) = {2} Result = {3}",
key, Output, output.ToString(), Result);
if (Result != 1)
coolpropPlugin.CoolPropError();
result = coolpropPlugin.MakeStringResult(output.ToString());
return true;
}
}
Term inf;
public static int[] Arguments = new [] {2};
public CoolProp_get_parameter_information_string(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
public TermInfo GetTermInfo(string lang)
{
string funcInfo = "(key, Output) Get a parameter information string\r\n" +
"key A string\r\n" +
"Output A string (one of \"IO\", \"short\", \"long\", \"units\")";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
var key = coolpropPlugin.GetStringParam(args[0], ref context);
var Output = coolpropPlugin.GetStringParam(args[1], ref context);
var output = new System.Text.StringBuilder(Output, 10000);
var Result = CoolPropDLLfunc(key, output, output.Capacity);
coolpropPlugin.LogInfo("[INFO ]",
"key = {0} output(in) = {1} output(out) = {2} Result = {3}",
key, Output, output.ToString(), Result);
if (Result != 1)
coolpropPlugin.CoolPropError();
result = coolpropPlugin.MakeStringResult(output.ToString());
return true;
}
}
}

View File

@@ -3,93 +3,93 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_saturation_ancillary : IFunction
{
// double saturation_ancillary(const char *fluid_name, const char *output, int Q, const char *input, double value);
[DllImport(
"CoolProp_x86", EntryPoint = "saturation_ancillary",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x86(
string fluid_name,
string output,
int Q,
string input,
double value);
[DllImport(
"CoolProp_x64", EntryPoint = "saturation_ancillary",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x64(
string fluid_name,
string output,
int Q,
string input,
double value);
internal static double CoolPropDLLfunc(
string fluid_name,
string output,
int Q,
string input,
double value)
class CoolProp_saturation_ancillary : IFunction
{
switch (System.IntPtr.Size) {
case 4:
return CoolPropDLLfunc_x86(fluid_name, output, Q, input, value);
case 8:
return CoolPropDLLfunc_x64(fluid_name, output, Q, input, value);
}
throw new System.Exception("Unknown platform!");
// double saturation_ancillary(const char *fluid_name, const char *output, int Q, const char *input, double value);
[DllImport(
"CoolProp_x86", EntryPoint = "saturation_ancillary",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x86(
string fluid_name,
string output,
int Q,
string input,
double value);
[DllImport(
"CoolProp_x64", EntryPoint = "saturation_ancillary",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x64(
string fluid_name,
string output,
int Q,
string input,
double value);
internal static double CoolPropDLLfunc(
string fluid_name,
string output,
int Q,
string input,
double value)
{
switch (System.IntPtr.Size) {
case 4:
return CoolPropDLLfunc_x86(fluid_name, output, Q, input, value);
case 8:
return CoolPropDLLfunc_x64(fluid_name, output, Q, input, value);
}
throw new System.Exception("Unknown platform!");
}
Term inf;
public static int[] Arguments = new[] { 5 };
public CoolProp_saturation_ancillary(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(FluidName, output, Q, input, value) Extract a value from the saturation ancillary\r\n" +
"FluidName: The name of the fluid to be used - HelmholtzEOS backend only\r\n" +
"output: The desired output variable (\"P\" for instance for pressure)\r\n" +
"Q: The mass vapor quality, 0 or 1\r\n" +
"input: The input variable name, one of \"T\", \"D\", \"H\", etc...\r\n" +
"value: The input value";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
var fluid_name = coolpropPlugin.GetStringParam(value.Items[0], context);
var output = coolpropPlugin.GetStringParam(value.Items[1], context);
var Q = (int)coolpropPlugin.GetNumberParam(value.Items[2], context).obj.ToDouble();
var inputVar = coolpropPlugin.GetStringParam(value.Items[3], context);
var inputVal = coolpropPlugin.GetNumberParam(value.Items[4], context);
Unit.match(inputVar, inputVal, context);
var Result = CoolPropDLLfunc(fluid_name, output, Q, inputVar, inputVal.obj.ToDouble());
coolpropPlugin.LogInfo("[INFO]",
"fluid_name = {0}, output = {1}, Q = {2}, input = {3}, value = {4}, Result = {5}",
fluid_name, output, Q, inputVar, inputVal.obj.ToDouble(), Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.Find(output));
return true;
}
}
Term inf;
public static int[] Arguments = new[] { 5 };
public CoolProp_saturation_ancillary(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
TermInfo IFunction.GetTermInfo(string lang)
{
string funcInfo = "(fluid_name, output, Q, input, value) Extract a value from the saturation ancillary\r\n" +
"fluid_name The name of the fluid to be used - HelmholtzEOS backend only\r\n" +
"output The desired output variable (\"P\" for instance for pressure)\r\n" +
"Q The quality, 0 or 1\r\n" +
"input The input variable (\"T\")\r\n" +
"value The input value";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
var fluid_name = coolpropPlugin.GetStringParam(args[0], ref context);
var output = coolpropPlugin.GetStringParam(args[1], ref context);
var Q = (int)coolpropPlugin.GetNumberParam(args[2], ref context).obj.ToDouble();
var input = coolpropPlugin.GetStringParam(args[3], ref context);
var value = coolpropPlugin.GetNumberParam(args[4], ref context);
Unit.match(input, value, context);
var Result = CoolPropDLLfunc(fluid_name, output, Q, input, value.obj.ToDouble());
coolpropPlugin.LogInfo("[INFO ]",
"fluid_name = {0}, output = {1}, Q = {2}, input = {3}, value = {4}, Result = {5}",
fluid_name, output, Q, input, value.obj.ToDouble(), Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.Find(output));
return true;
}
}
}

View File

@@ -3,93 +3,93 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_set_reference_stateD : IFunction
{
// int set_reference_stateD(const char *Ref, double T, double rho, double h0, double s0);
[DllImport(
"CoolProp_x86", EntryPoint = "set_reference_stateD",
CharSet = CharSet.Ansi)]
internal static extern int CoolPropDLLfunc_x86(
string Ref,
double T,
double rho,
double h0,
double s0);
[DllImport(
"CoolProp_x64", EntryPoint = "set_reference_stateD",
CharSet = CharSet.Ansi)]
internal static extern int CoolPropDLLfunc_x64(
string Ref,
double T,
double rho,
double h0,
double s0);
internal static int CoolPropDLLfunc(
string Ref,
double T,
double rho,
double h0,
double s0)
class CoolProp_set_reference_stateD : IFunction
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(Ref, T, rho, h0, s0);
case 8:
return CoolPropDLLfunc_x64(Ref, T, rho, h0, s0);
}
throw new System.Exception("Unknown platform!");
// int set_reference_stateD(const char *Ref, double T, double rho, double h0, double s0);
[DllImport(
"CoolProp_x86", EntryPoint = "set_reference_stateD",
CharSet = CharSet.Ansi)]
internal static extern int CoolPropDLLfunc_x86(
string Ref,
double T,
double rho,
double h0,
double s0);
[DllImport(
"CoolProp_x64", EntryPoint = "set_reference_stateD",
CharSet = CharSet.Ansi)]
internal static extern int CoolPropDLLfunc_x64(
string Ref,
double T,
double rho,
double h0,
double s0);
internal static int CoolPropDLLfunc(
string Ref,
double T,
double rho,
double h0,
double s0)
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(Ref, T, rho, h0, s0);
case 8:
return CoolPropDLLfunc_x64(Ref, T, rho, h0, s0);
}
throw new System.Exception("Unknown platform!");
}
Term inf;
public static int[] Arguments = new [] {5};
public CoolProp_set_reference_stateD(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
public TermInfo GetTermInfo(string lang)
{
string funcInfo = "(FluidName, T, RhoMolar, h0, s0) Set the reference state based on a thermodynamic state point specified by temperature and molar density\r\n" +
"FluidName: The name of the fluid\r\n" +
"T: Temperature at reference state [K]\r\n" +
"RhoMolar: Density at reference state [mol/m^3]\r\n" +
"h0: Enthalpy at reference state [J/mol]\r\n" +
"s0: Entropy at references state [J/mol/K]";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.RealNumber),
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
var Ref = coolpropPlugin.GetStringParam(value.Items[0], context);
var T = coolpropPlugin.GetNumberParam(value.Items[1], context);
var rho = coolpropPlugin.GetNumberParam(value.Items[2], context);
var h0 = coolpropPlugin.GetNumberParam(value.Items[3], context);
var s0 = coolpropPlugin.GetNumberParam(value.Items[4], context);
var Result = CoolPropDLLfunc(Ref, T.obj.ToDouble(), rho.obj.ToDouble(), h0.obj.ToDouble(), s0.obj.ToDouble());
coolpropPlugin.LogInfo("[INFO]",
"Ref = {0} T = {1} rho = {2} h0 = {3} s0 = {4} Result = {5}",
Ref, T.obj.ToDouble(), rho.obj.ToDouble(), h0.obj.ToDouble(), s0.obj.ToDouble(), Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);
return true;
}
}
Term inf;
public static int[] Arguments = new [] {5};
public CoolProp_set_reference_stateD(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
public TermInfo GetTermInfo(string lang)
{
string funcInfo = "(FluidName, T, rhomolar, h0, s0) Set the reference state based on a thermodynamic state point specified by temperature and molar density\r\n" +
"FluidName The name of the fluid\r\n" +
"T Temperature at reference state [K]\r\n" +
"rhomolar Density at reference state [mol/m^3]\r\n" +
"h0 Enthalpy at reference state [J/mol]\r\n" +
"s0 Entropy at references state [J/mol/K]";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.RealNumber),
new ArgumentInfo(ArgumentSections.RealNumber),
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
var Ref = coolpropPlugin.GetStringParam(args[0], ref context);
var T = coolpropPlugin.GetNumberParam(args[1], ref context);
var rho = coolpropPlugin.GetNumberParam(args[2], ref context);
var h0 = coolpropPlugin.GetNumberParam(args[3], ref context);
var s0 = coolpropPlugin.GetNumberParam(args[4], ref context);
var Result = CoolPropDLLfunc(Ref, T.obj.ToDouble(), rho.obj.ToDouble(), h0.obj.ToDouble(), s0.obj.ToDouble());
coolpropPlugin.LogInfo("[INFO ]",
"Ref = {0} T = {1} rho = {2} h0 = {3} s0 = {4} Result = {5}",
Ref, T.obj.ToDouble(), rho.obj.ToDouble(), h0.obj.ToDouble(), s0.obj.ToDouble(), Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);
return true;
}
}
}

View File

@@ -3,73 +3,73 @@ using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_set_reference_stateS : IFunction
{
// int set_reference_stateS(const char *Ref, const char *reference_state);
[DllImport(
"CoolProp_x86", EntryPoint = "set_reference_stateS",
CharSet = CharSet.Ansi)]
internal static extern int CoolPropDLLfunc_x86(
string Ref,
string reference_state);
[DllImport(
"CoolProp_x64", EntryPoint = "set_reference_stateS",
CharSet = CharSet.Ansi)]
internal static extern int CoolPropDLLfunc_x64(
string Ref,
string reference_state);
internal static int CoolPropDLLfunc(
string Ref,
string reference_state)
class CoolProp_set_reference_stateS : IFunction
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(Ref, reference_state);
case 8:
return CoolPropDLLfunc_x64(Ref, reference_state);
}
throw new System.Exception("Unknown platform!");
// int set_reference_stateS(const char *Ref, const char *reference_state);
[DllImport(
"CoolProp_x86", EntryPoint = "set_reference_stateS",
CharSet = CharSet.Ansi)]
internal static extern int CoolPropDLLfunc_x86(
string Ref,
string reference_state);
[DllImport(
"CoolProp_x64", EntryPoint = "set_reference_stateS",
CharSet = CharSet.Ansi)]
internal static extern int CoolPropDLLfunc_x64(
string Ref,
string reference_state);
internal static int CoolPropDLLfunc(
string Ref,
string reference_state)
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(Ref, reference_state);
case 8:
return CoolPropDLLfunc_x64(Ref, reference_state);
}
throw new System.Exception("Unknown platform!");
}
Term inf;
public static int[] Arguments = new [] {2};
public CoolProp_set_reference_stateS(int argsCount)
{
inf = new Term(this.GetType().Name, TermType.Function, argsCount);
}
Term IFunction.Info { get { return inf; } }
public TermInfo GetTermInfo(string lang)
{
string funcInfo = "(FluidName, ReferenceState) Set the reference state based on a string representation\r\n" +
"FluidName: The name of the fluid\r\n" +
"ReferenceState: The reference state to use, one of \"IIR\", \"ASHRAE\", \"NBP\", \"DEF\", \"RESET\"";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
{
var Ref = coolpropPlugin.GetStringParam(value.Items[0], context);
var reference_state = coolpropPlugin.GetStringParam(value.Items[1], context);
var Result = CoolPropDLLfunc(Ref, reference_state);
coolpropPlugin.LogInfo("[INFO]", "Ref = {0}, reference_state = {1} Result = {2}", Ref, reference_state, Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);
return true;
}
}
Term inf;
public static int[] Arguments = new [] {2};
public CoolProp_set_reference_stateS(int childCount)
{
inf = new Term(this.GetType().Name, TermType.Function, childCount);
}
Term IFunction.Info { get { return inf; } }
public TermInfo GetTermInfo(string lang)
{
string funcInfo = "(FluidName, reference_state) Set the reference state based on a string representation\r\n" +
"FluidName The name of the fluid\r\n" +
"reference_state The reference state to use, one of \"IIR\", \"ASHRAE\", \"NBP\", \"DEF\", \"RESET\"";
var argsInfos = new [] {
new ArgumentInfo(ArgumentSections.String),
new ArgumentInfo(ArgumentSections.String)
};
return new TermInfo(inf.Text,
inf.Type,
funcInfo,
FunctionSections.Unknown,
true,
argsInfos);
}
bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
var Ref = coolpropPlugin.GetStringParam(args[0], ref context);
var reference_state = coolpropPlugin.GetStringParam(args[1], ref context);
var Result = CoolPropDLLfunc(Ref, reference_state);
coolpropPlugin.LogInfo("[INFO ]", "Ref = {0}, reference_state = {1} Result = {2}", Ref, reference_state, Result);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);
return true;
}
}
}

View File

@@ -1,15 +1,14 @@
namespace coolprop_wrapper
{
interface IFunction
{
SMath.Manager.Term Info { get; }
interface IFunction
{
SMath.Manager.Term Info { get; }
SMath.Manager.TermInfo GetTermInfo(string lang);
SMath.Manager.TermInfo GetTermInfo(string lang);
bool ExpressionEvaluation(
SMath.Manager.Term root,
SMath.Manager.Term[][] args,
ref SMath.Math.Store context,
ref SMath.Manager.Term[] result);
}
bool TryEvaluateExpression(
SMath.Manager.Entry value,
SMath.Math.Store context,
out SMath.Manager.Entry result);
}
}

View File

@@ -0,0 +1,107 @@
# List of functions
Below there is the list of all the functions provided by this plugin inside [SMath Studio](http://en.smath.info).
****
```
CoolProp_get_fluid_param_string(FluidName, ParamName)
```
*Get a string for a value from a fluid.*
* `FluidName` The name of the fluid that is part of CoolProp, for instance `"n-Propane"`
* `ParamName` A string, can be in one of `"aliases"`, `"CAS"`, `"CAS_number"`, `"ASHRAE34"`, `"REFPROPName"`, `"REFPROP_name"`
****
```
CoolProp_get_global_param_string(ParamName)
```
*Get a globally-defined string.*
* `ParamName` A string, one of `"version"`, `"errstring"`, `"warnstring"`, `"gitrevision"`, `"FluidsList"`, `"fluids_list"`, `"parameter_list"`, `"predefined_mixtures"`
****
```
CoolProp_get_param_index(Name)
```
*Return the index of a parameter.*
* `Name`: The parameter name, one of `"Tcrit"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
****
```
CoolProp_get_parameter_information_string(Key, Output)
```
*Get a parameter information string.*
* `Key` A string
* `Output` A string, one of `"IO"`, `"short"`, `"long"`, `"units"`
****
```
CoolProp_HAProps(Output, Name1, Prop1, Name2, Prop2, Name3, Prop3)
```
*Return a humid air property.*
* `Output` The output parameter, one of `"T"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
* `Name1` The first state variable name, one of `"T"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
* `Prop1` The first state variable value
* `Name2` The second state variable name, one of `"T"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
* `Prop2` The second state variable value
* `Name3` The third state variable name, one of `"T"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
* `Prop3` The third state variable value
****
```
CoolProp_Phase(Name1, Prop1, Name2, Prop2, FluidName)
```
*Return a string representation of the phase.*
* `Name1` The first state variable name, one of `"T"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
* `Prop1` The first state variable value
* `Name2` The second state variable name, one of `"T"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
* `Prop2` The second state variable value
* `FluidName` The fluid name
****
```
CoolProp_Props(Output, Name1, Prop1, Name2, Prop2, FluidName)
```
*Return a value that __depends__ on the thermodynamic state.*
* `Output` The output parameter, one of `"T"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
* `Name1` The first state variable name, one of `"T"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
* `Prop1` The first state variable value
* `Name2` The second state variable name, one of `"T"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
* `Prop2` The second state variable value
* `FluidName` The fluid name
****
```
CoolProp_Props1(FluidName, Output)
```
*Return a value that does __not depends__ on the thermodynamic state.*
* `FluidName` The fluid name
* `Output` The output parameter, one of `"Tcrit"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
****
```
CoolProp_saturation_ancillary(FluidName, output, Q, input, value)
```
*Extract a value from the saturation ancillary.*
* `FluidName` The name of the fluid to be used - HelmholtzEOS backend only
* `output` The desired output variable (\"P\" for instance for [pressure](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table))
* `Q` The mass vapor quality, 0 or 1
* `input` The input variable name, one of `"T"`, `"D"`, `"H"`, [etc...](http://www.coolprop.org/coolprop/HighLevelAPI.html#parameter-table)
* `value` The second state variable value
****
```
CoolProp_set_reference_stateD(FluidName, T, RhoMolar, h0, s0)
```
*Set the reference state based on a thermodynamic state point specified by temperature and molar density.*
* `FluidName` The name of the fluid
* `T` Temperature at reference state [K]
* `RhoMolar` Density at reference state [mol/m^3]
* `h0` Enthalpy at reference state [J/mol]
* `s0` Entropy at references state [J/mol/K]
****
```
CoolProp_set_reference_stateS(FluidName, ReferenceState)
```
*Set the reference state based on a string representation*
* `FluidName` The name of the fluid
* `ReferenceState` The reference state to use, one of `"IIR"`, `"ASHRAE"`, `"NBP"`, `"DEF"`, `"RESET"`

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,687 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?application progid="SMath Studio Desktop" version="0.98.6128.10018"?>
<regions>
<settings>
<identity>
<id>5dac1d59-6181-4c08-9279-eb0d09d3f36d</id>
<revision>11</revision>
</identity>
<calculation>
<precision>6</precision>
<exponentialThreshold>9</exponentialThreshold>
<fractions>decimal</fractions>
</calculation>
<pageModel active="true" printAreas="true" simpleEqualsOnly="false" printBackgroundImages="true">
<paper id="9" orientation="Landscape" width="1169" height="827" />
<margins left="39" right="39" top="39" bottom="39" />
<header alignment="Center" color="#a9a9a9">&amp;[DATE] &amp;[TIME] - &amp;[FILENAME]</header>
<footer alignment="Center" color="#a9a9a9">&amp;[PAGENUM] / &amp;[COUNT]</footer>
<backgrounds />
</pageModel>
<dependencies>
<assembly name="SMath Studio Desktop" version="0.98.6128.10018" guid="a37cba83-b69c-4c71-9992-55ff666763bd" />
<assembly name="Math Region" version="0.98.6128.10018" guid="02f1ab51-215b-466e-a74d-5d8b1cf85e8d" />
<assembly name="Text Region" version="1.10.6128.10025" guid="485d28c5-349a-48b6-93be-12a35a1c1e39" />
<assembly name="CoolProp Wrapper" version="6.1.0.0" guid="ca92ef03-c7da-4888-98ad-528482733e2f" />
</dependencies>
</settings>
<region id="0" left="261" top="9" width="209" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<text lang="eng">
<p bold="true" underline="true">CoolProp IAPWS IF97 Test</p>
</text>
</region>
<region id="1" left="639" top="9" width="445" height="26" color="#000000" bgColor="#91c8ff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">version</e>
<e type="function" preserve="true" args="1">CoolProp_get_global_param_string</e>
</input>
<result action="numeric">
<e type="operand" style="string">6.1.0</e>
</result>
</math>
</region>
<region id="2" left="0" top="54" width="114" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p1</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="3" left="153" top="54" width="106" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">T1</e>
<e type="operand">308.15</e>
<e type="operand" style="unit">K</e>
<e type="operator" args="2">*</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="4" left="0" top="99" width="168" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<text lang="eng">
<p underline="true">1.0 Saturation Test</p>
</text>
</region>
<region id="5" left="9" top="135" width="324" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<text lang="eng">
<p underline="true">1.1 Saturation ancillary function test</p>
</text>
</region>
<region id="6" left="18" top="171" width="527" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">T</e>
<e type="function" args="1">p_sat</e>
<e type="operand" style="string">water</e>
<e type="operand" style="string">P</e>
<e type="operand">0</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="function" preserve="true" args="5">CoolProp_saturation_ancillary</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="7" left="630" top="171" width="184" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">T1</e>
<e type="function" args="1">p_sat</e>
</input>
<contract>
<e type="operand" style="unit">Pa</e>
</contract>
<result action="numeric">
<e type="operand">5.63</e>
<e type="operand">10</e>
<e type="operand">3</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="8" left="18" top="207" width="576" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">T</e>
<e type="function" args="1">p_sat</e>
<e type="operand" style="string">IF97::water</e>
<e type="operand" style="string">P</e>
<e type="operand">0</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="function" preserve="true" args="5">CoolProp_saturation_ancillary</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="9" left="630" top="207" width="124" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="9" decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">T1</e>
<e type="function" args="1">p_sat</e>
</input>
<contract>
<e type="operand" style="unit">Pa</e>
</contract>
<result action="numeric">
<e type="operand">#</e>
</result>
</math>
</region>
<region id="10" left="828" top="207" width="737" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">lastError</e>
</input>
<result action="numeric">
<e type="operand" style="string">key [IF97::water] was not found in string_to_index_map in JSONFluidLibrary</e>
</result>
</math>
</region>
<region id="11" left="18" top="243" width="527" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="function" args="1">T_sat</e>
<e type="operand" style="string">water</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">T</e>
<e type="operand">0</e>
<e type="function" preserve="true" args="5">CoolProp_saturation_ancillary</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="12" left="630" top="243" width="124" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="9" decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="function" args="1">T_sat</e>
</input>
<contract>
<e type="operand" style="unit">°C</e>
</contract>
<result action="numeric">
<e type="operand">#</e>
</result>
</math>
</region>
<region id="13" left="828" top="243" width="540" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">lastError</e>
</input>
<result action="numeric">
<e type="operand" style="string">Q [101325] is invalid in calc_saturation_ancillary</e>
</result>
</math>
</region>
<region id="14" left="18" top="279" width="576" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="function" args="1">T_sat</e>
<e type="operand" style="string">IF97::water</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">T</e>
<e type="operand">0</e>
<e type="function" preserve="true" args="5">CoolProp_saturation_ancillary</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="15" left="630" top="279" width="124" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="9" decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="function" args="1">T_sat</e>
</input>
<contract>
<e type="operand" style="unit">°C</e>
</contract>
<result action="numeric">
<e type="operand">#</e>
</result>
</math>
</region>
<region id="16" left="828" top="279" width="737" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">lastError</e>
</input>
<result action="numeric">
<e type="operand" style="string">key [IF97::water] was not found in string_to_index_map in JSONFluidLibrary</e>
</result>
</math>
</region>
<region id="17" left="9" top="324" width="201" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<text lang="eng">
<p underline="true">1.2 Props function test</p>
</text>
</region>
<region id="18" left="18" top="360" width="444" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">T</e>
<e type="function" args="1">p_sat</e>
<e type="operand" style="string">P</e>
<e type="operand" style="string">Q</e>
<e type="operand">0</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="19" left="630" top="360" width="184" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">T1</e>
<e type="function" args="1">p_sat</e>
</input>
<contract>
<e type="operand" style="unit">Pa</e>
</contract>
<result action="numeric">
<e type="operand">5.63</e>
<e type="operand">10</e>
<e type="operand">3</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="20" left="18" top="396" width="493" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">T</e>
<e type="function" args="1">p_sat</e>
<e type="operand" style="string">P</e>
<e type="operand" style="string">Q</e>
<e type="operand">0</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="operand" style="string">IF97::water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="21" left="630" top="396" width="124" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="9" decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">T1</e>
<e type="function" args="1">p_sat</e>
</input>
<contract>
<e type="operand" style="unit">Pa</e>
</contract>
<result action="numeric">
<e type="operand">#</e>
</result>
</math>
</region>
<region id="22" left="828" top="396" width="622" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">lastError</e>
</input>
<result action="numeric">
<e type="operand" style="string">bad input_pair : PropsSI('P','Q',0,'T',308.15,'IF97::water')</e>
</result>
</math>
</region>
<region id="23" left="18" top="432" width="444" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="function" args="1">T_sat</e>
<e type="operand" style="string">T</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">Q</e>
<e type="operand">0</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="24" left="630" top="432" width="157" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="function" args="1">T_sat</e>
</input>
<contract>
<e type="operand" style="unit">°C</e>
</contract>
<result action="numeric">
<e type="operand">99.97</e>
</result>
</math>
</region>
<region id="25" left="18" top="468" width="493" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="function" args="1">T_sat</e>
<e type="operand" style="string">T</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">Q</e>
<e type="operand">0</e>
<e type="operand" style="string">IF97::water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="26" left="630" top="468" width="124" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="9" decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="function" args="1">T_sat</e>
</input>
<contract>
<e type="operand" style="unit">°C</e>
</contract>
<result action="numeric">
<e type="operand">#</e>
</result>
</math>
</region>
<region id="27" left="828" top="468" width="622" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">lastError</e>
</input>
<result action="numeric">
<e type="operand" style="string">bad input_pair : PropsSI('T','P',101325,'Q',0,'IF97::water')</e>
</result>
</math>
</region>
<region id="28" left="0" top="522" width="357" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<text lang="eng">
<p underline="true">2.0 Subcooled or superheated function Test</p>
</text>
</region>
<region id="29" left="18" top="567" width="509" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="operand">T</e>
<e type="function" args="2">h_pT</e>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="operand" style="string">IF97::water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="30" left="630" top="567" width="193" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="operand">T1</e>
<e type="function" args="2">h_pT</e>
</input>
<contract>
<e type="operand" style="unit">kJ</e>
<e type="operand" style="unit">kg</e>
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">146.73</e>
</result>
</math>
</region>
<region id="31" left="18" top="612" width="525" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="operand">T</e>
<e type="function" args="2">rho_pT</e>
<e type="operand" style="string">D</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="operand" style="string">IF97::water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="32" left="630" top="612" width="213" height="50" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="operand">T1</e>
<e type="function" args="2">rho_pT</e>
</input>
<contract>
<e type="operand" style="unit">kg</e>
<e type="operand" style="unit">m</e>
<e type="operand">3</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">994.04</e>
</result>
</math>
</region>
<region id="33" left="18" top="657" width="517" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="operand">T</e>
<e type="function" args="2">Cp_pT</e>
<e type="operand" style="string">C</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="operand" style="string">IF97::water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="34" left="630" top="657" width="216" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="operand">T1</e>
<e type="function" args="2">Cp_pT</e>
</input>
<contract>
<e type="operand" style="unit">kJ</e>
<e type="operand" style="unit">kg</e>
<e type="operand" style="unit">Δ°C</e>
<e type="operator" args="2">*</e>
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">4.18</e>
</result>
</math>
</region>
<region id="35" left="18" top="702" width="517" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="operand">T</e>
<e type="function" args="2">Cv_pT</e>
<e type="operand" style="string">O</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="operand" style="string">IF97::water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="36" left="630" top="702" width="216" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="operand">T1</e>
<e type="function" args="2">Cv_pT</e>
</input>
<contract>
<e type="operand" style="unit">kJ</e>
<e type="operand" style="unit">kg</e>
<e type="operand" style="unit">Δ°C</e>
<e type="operator" args="2">*</e>
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">4.10</e>
</result>
</math>
</region>
<region id="37" left="18" top="756" width="517" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="operand">T</e>
<e type="function" args="2">mu_pT</e>
<e type="operand" style="string">V</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="operand" style="string">IF97::water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="38" left="630" top="756" width="170" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="9" decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="operand">T1</e>
<e type="function" args="2">mu_pT</e>
</input>
<contract>
<e type="operand" style="unit">s</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
</contract>
<result action="numeric">
<e type="operand">#</e>
</result>
</math>
</region>
<region id="39" left="837" top="756" width="960" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">lastError</e>
</input>
<result action="numeric">
<e type="operand" style="string">calc_viscosity is not implemented for this backend : PropsSI('V','P',101325,'T',308.15,'IF97::water')</e>
</result>
</math>
</region>
<region id="40" left="18" top="801" width="468" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="operand">T</e>
<e type="function" args="2">mu_pT</e>
<e type="operand" style="string">V</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="41" left="630" top="801" width="239" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="operand">T1</e>
<e type="function" args="2">mu_pT</e>
</input>
<contract>
<e type="operand" style="unit">s</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
</contract>
<result action="numeric">
<e type="operand">7.19</e>
<e type="operand">10</e>
<e type="operand">4</e>
<e type="operator" args="1">-</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="42" left="18" top="846" width="509" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="operand">T</e>
<e type="function" args="2">k_pT</e>
<e type="operand" style="string">L</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="operand" style="string">IF97::water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="43" left="630" top="846" width="175" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="9" decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="operand">T1</e>
<e type="function" args="2">k_pT</e>
</input>
<contract>
<e type="operand" style="unit">W</e>
<e type="operand" style="unit">m</e>
<e type="operand" style="unit">Δ°C</e>
<e type="operator" args="2">*</e>
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">#</e>
</result>
</math>
</region>
<region id="44" left="837" top="855" width="985" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">lastError</e>
</input>
<result action="numeric">
<e type="operand" style="string">calc_conductivity is not implemented for this backend : PropsSI('L','P',101325,'T',308.15,'IF97::water')</e>
</result>
</math>
</region>
<region id="45" left="18" top="891" width="460" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">p</e>
<e type="operand">T</e>
<e type="function" args="2">k_pT</e>
<e type="operand" style="string">L</e>
<e type="operand" style="string">P</e>
<e type="operand">p</e>
<e type="operand" style="string">T</e>
<e type="operand">T</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="46" left="630" top="891" width="200" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="2" exponentialThreshold="3" trailingZeros="true">
<input>
<e type="operand">p1</e>
<e type="operand">T1</e>
<e type="function" args="2">k_pT</e>
</input>
<contract>
<e type="operand" style="unit">W</e>
<e type="operand" style="unit">m</e>
<e type="operand" style="unit">Δ°C</e>
<e type="operator" args="2">*</e>
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">0.62</e>
</result>
</math>
</region>
</regions>

View File

@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?application progid="SMath Studio Desktop" version="0.97.5346.24640"?>
<?application progid="SMath Studio Desktop" version="0.98.6128.10018"?>
<regions>
<settings>
<identity>
<id>4a35301a-4a4d-4f4c-8963-6e6d56d24ef4</id>
<revision>52</revision>
<revision>54</revision>
</identity>
<calculation>
<precision>4</precision>
<exponentialThreshold>5</exponentialThreshold>
<precision>6</precision>
<exponentialThreshold>9</exponentialThreshold>
<fractions>decimal</fractions>
</calculation>
<pageModel active="true" printAreas="true" simpleEqualsOnly="false" printBackgroundImages="true">
@@ -18,27 +18,28 @@
<footer alignment="Center" color="#a9a9a9">&amp;[PAGENUM] / &amp;[COUNT]</footer>
<backgrounds />
</pageModel>
<dependences>
<assembly name="SMath Studio Desktop" version="0.97.5346.24640" guid="a37cba83-b69c-4c71-9992-55ff666763bd" />
<assembly name="CoolPropWrapper" version="1.0.5526.20489" guid="ca92ef03-c7da-4888-98ad-528482733e2f" />
<assembly name="Math Region" version="0.97.5346.24640" guid="02f1ab51-215b-466e-a74d-5d8b1cf85e8d" />
<assembly name="Text Region" version="1.10.5346.31409" guid="485d28c5-349a-48b6-93be-12a35a1c1e39" />
<assembly name="Plot Region" version="1.9.5346.32570" guid="c451c2b5-798b-4f08-b9ec-b90963d1ddaa" />
</dependences>
<dependencies>
<assembly name="SMath Studio Desktop" version="0.98.6128.10018" guid="a37cba83-b69c-4c71-9992-55ff666763bd" />
<assembly name="Math Region" version="0.98.6128.10018" guid="02f1ab51-215b-466e-a74d-5d8b1cf85e8d" />
<assembly name="Special Functions" version="1.11.6128.10019" guid="2814e667-4e12-48b1-8d51-194e480eabc5" />
<assembly name="Text Region" version="1.10.6128.10025" guid="485d28c5-349a-48b6-93be-12a35a1c1e39" />
<assembly name="Plot Region" version="1.9.6128.10033" guid="c451c2b5-798b-4f08-b9ec-b90963d1ddaa" />
<assembly name="CoolProp Wrapper" version="6.1.6143.14019" guid="ca92ef03-c7da-4888-98ad-528482733e2f" />
</dependencies>
</settings>
<region id="0" left="0" top="0" width="445" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<math decimalPlaces="4">
<input>
<e type="operand" style="string">version</e>
<e type="function" preserve="true" args="1">CoolProp_get_global_param_string</e>
</input>
<result action="numeric">
<e type="operand" style="string">5.0.7</e>
<e type="operand" style="string">6.1.0</e>
</result>
</math>
</region>
<region id="1" left="0" top="27" width="456" height="28" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<math decimalPlaces="4">
<input>
<e type="operand" style="string">version</e>
<e type="function" preserve="true" args="1">CoolProp_get_global_param_string</e>
@@ -50,7 +51,7 @@
</math>
</region>
<region id="2" left="0" top="72" width="428" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<math decimalPlaces="4">
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">RESET</e>
@@ -61,8 +62,8 @@
</result>
</math>
</region>
<region id="3" left="0" top="126" width="488" height="28" color="#000000" bgColor="#ff8080" fontSize="10">
<math>
<region id="3" left="0" top="126" width="438" height="28" color="#000000" bgColor="#ff8080" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">P</e>
<e type="operand">1</e>
@@ -78,7 +79,7 @@
<e type="function" preserve="true" args="5">CoolProp_Phase</e>
</input>
<result action="numeric">
<e type="operand" style="string">liquid</e>
<e type="operand" style="string" />
</result>
</math>
</region>
@@ -88,7 +89,7 @@
</text>
</region>
<region id="5" left="0" top="171" width="377" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<math decimalPlaces="4">
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">Tcrit</e>
@@ -102,7 +103,7 @@
</math>
</region>
<region id="6" left="0" top="198" width="373" height="26" color="#000000" bgColor="#80ff80" fontSize="10">
<math>
<math decimalPlaces="4">
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">Tcrit</e>
@@ -116,26 +117,22 @@
</result>
</math>
</region>
<region id="7" left="0" top="243" width="411" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="7" left="0" top="243" width="393" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">Pcrit</e>
<e type="function" preserve="true" args="2">CoolProp_Props1</e>
</input>
<result action="numeric">
<e type="operand">2.2064</e>
<e type="operand">10</e>
<e type="operand">7</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
<e type="operand">22064000</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="8" left="0" top="279" width="365" height="26" color="#000000" bgColor="#ffff80" fontSize="10">
<math>
<math decimalPlaces="4">
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">Pcrit</e>
@@ -149,8 +146,8 @@
</result>
</math>
</region>
<region id="9" left="0" top="333" width="603" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="9" left="0" top="333" width="618" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
@@ -163,18 +160,14 @@
<e type="function" preserve="true" args="6">CoolProp_Props</e>
</input>
<result action="numeric">
<e type="operand">2.6756</e>
<e type="operand">10</e>
<e type="operand">6</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
<e type="operand">2594387.0356</e>
<e type="operand" style="unit">Gy</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="10" left="0" top="369" width="612" height="41" color="#000000" bgColor="#ffff80" fontSize="10">
<math>
<region id="10" left="0" top="369" width="595" height="41" color="#000000" bgColor="#ffff80" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
@@ -192,13 +185,15 @@
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">2675.5828</e>
<e type="operand">2594.387</e>
</result>
</math>
</region>
<region id="11" left="0" top="414" width="644" height="239" color="#000000" bgColor="#ffffff" fontSize="10">
<plot type="2d" render="lines" scale_x="0.00375710212613637" scale_y="0.135085171767299" scale_z="0.00375710212613637" rotate_x="0" rotate_y="0" rotate_z="0" transpose_x="-250" transpose_y="-86" transpose_z="0">
<region id="11" left="0" top="423" width="541" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">x</e>
<e type="function" args="1">props</e>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
<e type="operand">1</e>
@@ -215,11 +210,20 @@
<e type="operator" args="1">-</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="12" left="0" top="459" width="644" height="239" color="#000000" bgColor="#ffffff" fontSize="10">
<plot type="2d" render="lines" scale_x="0.00360905731152912" scale_y="0.129762277009832" scale_z="0.00360905731152912" rotate_x="0" rotate_y="0" rotate_z="0" transpose_x="-250" transpose_y="-86" transpose_z="0">
<input>
<e type="operand">x</e>
<e type="function" args="1">props</e>
</input>
</plot>
</region>
<region id="12" left="648" top="486" width="565" height="43" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="13" left="648" top="531" width="556" height="43" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">Q</e>
<e type="operand" style="string">P</e>
@@ -240,8 +244,8 @@
</result>
</math>
</region>
<region id="13" left="648" top="531" width="519" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="14" left="648" top="576" width="519" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="9" decimalPlaces="4">
<input>
<e type="operand" style="string">Phase</e>
<e type="operand" style="string">P</e>
@@ -256,12 +260,12 @@
<e type="function" preserve="true" args="6">CoolProp_Props</e>
</input>
<result action="numeric">
<e type="operand">0</e>
<e type="operand">#</e>
</result>
</math>
</region>
<region id="14" left="648" top="558" width="544" height="28" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="43">
<region id="15" left="648" top="603" width="544" height="28" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="9" decimalPlaces="4">
<input>
<e type="operand" style="string">Phase</e>
<e type="operand" style="string">P</e>
@@ -282,8 +286,8 @@
</result>
</math>
</region>
<region id="15" left="648" top="585" width="536" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="16" left="648" top="630" width="536" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">Phase</e>
<e type="operand" style="string">P</e>
@@ -302,7 +306,7 @@
</result>
</math>
</region>
<region id="16" left="0" top="684" width="655" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<region id="17" left="0" top="729" width="655" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">W</e>
@@ -328,11 +332,11 @@
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">1.606200912602</e>
<e type="operand">1.606200912578</e>
</result>
</math>
</region>
<region id="17" left="0" top="729" width="630" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<region id="18" left="0" top="774" width="638" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">W</e>
@@ -356,11 +360,11 @@
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">7.66274517334</e>
<e type="operand">7.662649153197</e>
</result>
</math>
</region>
<region id="18" left="0" top="774" width="642" height="43" color="#000000" bgColor="#ffffff" fontSize="10">
<region id="19" left="0" top="819" width="642" height="43" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">W</e>
@@ -386,13 +390,15 @@
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">7.615829321156</e>
<e type="operand">7.615734473192</e>
</result>
</math>
</region>
<region id="19" left="0" top="819" width="644" height="239" color="#000000" bgColor="#ffffff" fontSize="10">
<plot type="2d" render="lines" scale_x="0.170043645322544" scale_y="0.75106238530508" scale_z="0.170043645322544" rotate_x="0" rotate_y="0" rotate_z="0" transpose_x="-250" transpose_y="-86" transpose_z="0">
<region id="20" left="0" top="873" width="589" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand">x</e>
<e type="function" args="1">haprops</e>
<e type="operand" style="string">W</e>
<e type="operand" style="string">T</e>
<e type="operand">x</e>
@@ -409,11 +415,20 @@
<e type="operand">3</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
<e type="operator" args="2">:</e>
</input>
</math>
</region>
<region id="21" left="0" top="909" width="644" height="239" color="#000000" bgColor="#ffffff" fontSize="10">
<plot type="2d" render="lines" scale_x="0.170043645322544" scale_y="0.75106238530508" scale_z="0.170043645322544" rotate_x="0" rotate_y="0" rotate_z="0" transpose_x="-250" transpose_y="-86" transpose_z="0">
<input>
<e type="operand">x</e>
<e type="function" args="1">haprops</e>
</input>
</plot>
</region>
<region id="20" left="0" top="1107" width="411" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="22" left="0" top="1197" width="411" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">NBP</e>
@@ -424,7 +439,7 @@
</result>
</math>
</region>
<region id="21" left="0" top="1134" width="686" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<region id="23" left="0" top="1224" width="651" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">H</e>
@@ -438,18 +453,14 @@
<e type="function" preserve="true" args="6">CoolProp_Props</e>
</input>
<result action="numeric">
<e type="operand">2.33771983066259</e>
<e type="operand">10</e>
<e type="operand">6</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
<e type="operand">2256525.05386013</e>
<e type="operand" style="unit">Gy</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="22" left="0" top="1170" width="411" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="24" left="0" top="1260" width="411" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">DEF</e>
@@ -460,7 +471,7 @@
</result>
</math>
</region>
<region id="23" left="0" top="1197" width="686" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<region id="25" left="0" top="1287" width="643" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">H</e>
@@ -474,18 +485,14 @@
<e type="function" preserve="true" args="6">CoolProp_Props</e>
</input>
<result action="numeric">
<e type="operand">2.67558278695418</e>
<e type="operand">10</e>
<e type="operand">6</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
<e type="operand">2675582.7869542</e>
<e type="operand" style="unit">Gy</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="24" left="0" top="1233" width="428" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="26" left="0" top="1323" width="428" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">RESET</e>
@@ -496,7 +503,7 @@
</result>
</math>
</region>
<region id="25" left="0" top="1260" width="686" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<region id="27" left="0" top="1350" width="643" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">H</e>
@@ -510,18 +517,14 @@
<e type="function" preserve="true" args="6">CoolProp_Props</e>
</input>
<result action="numeric">
<e type="operand">2.67558278695418</e>
<e type="operand">10</e>
<e type="operand">6</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
<e type="operand">2675582.7869542</e>
<e type="operand" style="unit">Gy</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="26" left="0" top="1296" width="531" height="52" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="28" left="0" top="1386" width="523" height="52" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">water</e>
<e type="operand">10</e>
@@ -543,7 +546,7 @@
</result>
</math>
</region>
<region id="27" left="0" top="1350" width="686" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<region id="29" left="0" top="1440" width="651" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">H</e>
@@ -557,18 +560,14 @@
<e type="function" preserve="true" args="6">CoolProp_Props</e>
</input>
<result action="numeric">
<e type="operand">2.59438801015181</e>
<e type="operand">10</e>
<e type="operand">6</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
<e type="operand">2594387.03555534</e>
<e type="operand" style="unit">Gy</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="28" left="0" top="1413" width="897" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="30" left="0" top="1503" width="897" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">n-Propane</e>
<e type="operand" style="string">aliases</e>
@@ -579,30 +578,30 @@
</result>
</math>
</region>
<region id="29" left="0" top="1440" width="8423" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="31" left="0" top="1530" width="9256" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">FluidsList</e>
<e type="function" preserve="true" args="1">CoolProp_get_global_param_string</e>
</input>
<result action="numeric">
<e type="operand" style="string">1-Butene,Acetone,Air,Ammonia,Argon,Benzene,CarbonDioxide,CarbonMonoxide,CarbonylSulfide,cis-2-Butene,CycloHexane,Cyclopentane,CycloPropane,D4,D5,D6,Deuterium,DimethylCarbonate,DimethylEther,Ethane,Ethanol,EthylBenzene,Ethylene,Fluorine,Helium,HFE143m,Hydrogen,HydrogenSulfide,IsoButane,IsoButene,Isohexane,Isopentane,Krypton,m-Xylene,MD2M,MD3M,MD4M,MDM,Methane,Methanol,MethylLinoleate,MethylLinolenate,MethylOleate,MethylPalmitate,MethylStearate,MM,n-Butane,n-Decane,n-Dodecane,n-Heptane,n-Hexane,n-Nonane,n-Octane,n-Pentane,n-Propane,n-Undecane,Neon,Neopentane,Nitrogen,NitrousOxide,o-Xylene,OrthoDeuterium,OrthoHydrogen,Oxygen,p-Xylene,ParaDeuterium,ParaHydrogen,Propylene,Propyne,R11,R113,R114,R116,R12,R123,R1233zd(E),R1234yf,R1234ze(E),R1234ze(Z),R124,R125,R13,R134a,R14,R141b,R142b,R143a,R152A,R161,R21,R218,R22,R227EA,R23,R236EA,R236FA,R245fa,R32,R365MFC,R404A,R407C,R41,R410A,R507A,RC318,SES36,SulfurDioxide,SulfurHexafluoride,Toluene,trans-2-Butene,Water,Xenon</e>
<e type="operand" style="string">1-Butene,Acetone,Air,Ammonia,Argon,Benzene,CarbonDioxide,CarbonMonoxide,CarbonylSulfide,cis-2-Butene,CycloHexane,Cyclopentane,CycloPropane,D4,D5,D6,Deuterium,Dichloroethane,DiethylEther,DimethylCarbonate,DimethylEther,Ethane,Ethanol,EthylBenzene,Ethylene,EthyleneOxide,Fluorine,HeavyWater,Helium,HFE143m,Hydrogen,HydrogenChloride,HydrogenSulfide,IsoButane,IsoButene,Isohexane,Isopentane,Krypton,m-Xylene,MD2M,MD3M,MD4M,MDM,Methane,Methanol,MethylLinoleate,MethylLinolenate,MethylOleate,MethylPalmitate,MethylStearate,MM,n-Butane,n-Decane,n-Dodecane,n-Heptane,n-Hexane,n-Nonane,n-Octane,n-Pentane,n-Propane,n-Undecane,Neon,Neopentane,Nitrogen,NitrousOxide,Novec649,o-Xylene,OrthoDeuterium,OrthoHydrogen,Oxygen,p-Xylene,ParaDeuterium,ParaHydrogen,Propylene,Propyne,R11,R113,R114,R115,R116,R12,R123,R1233zd(E),R1234yf,R1234ze(E),R1234ze(Z),R124,R125,R13,R134a,R13I1,R14,R141b,R142b,R143a,R152A,R161,R21,R218,R22,R227EA,R23,R236EA,R236FA,R245ca,R245fa,R32,R365MFC,R40,R404A,R407C,R41,R410A,R507A,RC318,SES36,SulfurDioxide,SulfurHexafluoride,Toluene,trans-2-Butene,Water,Xenon</e>
</result>
</math>
</region>
<region id="30" left="0" top="1467" width="288" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="32" left="0" top="1557" width="288" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">H</e>
<e type="function" preserve="true" args="1">CoolProp_get_param_index</e>
</input>
<result action="numeric">
<e type="operand">32</e>
<e type="operand">35</e>
</result>
</math>
</region>
<region id="31" left="0" top="1494" width="535" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="33" left="0" top="1584" width="535" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">units</e>
@@ -613,8 +612,8 @@
</result>
</math>
</region>
<region id="32" left="0" top="1521" width="621" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="34" left="0" top="1611" width="628" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">P</e>
@@ -626,18 +625,14 @@
<e type="function" preserve="true" args="5">CoolProp_saturation_ancillary</e>
</input>
<result action="numeric">
<e type="operand">1.0141</e>
<e type="operand">10</e>
<e type="operand">5</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
<e type="operand">101413.7297</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="33" left="0" top="1566" width="354" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<region id="35" left="0" top="1656" width="354" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="4">
<input>
<e type="operand" style="string">n-Propane</e>
<e type="operand" style="string">GWP100</e>

View File

@@ -0,0 +1,16 @@
@echo off
:: path to test
SET testPath="."
:: launch batch test
"%ProgramFiles(x86)%\SMath Studio\SMathStudio_Desktop.exe" -silent -t %testPath%
::"%ProgramFiles%\SMath Studio\SMathStudio_Desktop.exe" -silent -t %testPath%
::"C:\Program Files (x86)\SMath Studio\SMathStudio_Desktop.exe" -silent -t %testPath%
ECHO.
ECHO Tested files in: %testPath%
ECHO.
:: prevents auto-close
pause

View File

@@ -2,208 +2,208 @@
namespace coolprop_wrapper
{
class Unit
{
static MItem unit(string Format, params string[] units)
class Unit
{
var lUnits = new System.Collections.Generic.List<string>(units.Length);
foreach (var unit in units)
lUnits.Add(SMath.Manager.UnitsManager.GetCurrentUnitName(unit));
return Converter.ToMItem(string.Format(Format, lUnits.ToArray()));
static MItem unit(string Format, params string[] units)
{
var lUnits = new System.Collections.Generic.List<string>(units.Length);
foreach (var unit in units)
lUnits.Add(SMath.Manager.UnitsManager.GetCurrentUnitName(unit));
return Converter.ToMItem(string.Format(Format, lUnits.ToArray()));
}
public static MItem K { get { return unit("{0}", "'K"); } }
// [Pa] = [kg/{m*s^2}]
public static MItem Pa { get { return unit("{0}", "'Pa"); } }
// [J] = [kg*m^2/s^2]
public static MItem J_kg { get { return unit("{0}/{1}", "'J", "'kg"); } } // J/kg
public static MItem mol_m3 { get { return unit("{0}/{{{1}^3}}", "'mol","'m"); } } // mol/m^3
public static MItem kg_m3 { get { return unit("{0}/{{{1}^3}}", "'kg", "'m"); } } // kg/m^3
public static MItem J_mol { get { return unit("{0}/{1}", "'J", "'mol"); } } // J/mol
public static MItem J_mol_K { get { return unit("{0}/{{{1}*{2}}}", "'J", "'mol", "'K"); } } // J/mol/K
public static MItem J_kg_K { get { return unit("{0}/{{{1}*{2}}}", "'J", "'kg", "'K"); } } // J/kg/K
public static MItem m_s { get { return unit("{0}/{1}", "'m", "'s"); } } // m/s
// [W]=[{kg*m^2}/{s^3}]
public static MItem W_m_K { get { return unit("{0}/{{{1}*{2}}}", "'W", "'m", "'K"); } } // W/m/K
public static MItem _K { get { return unit("1/{0}", "'K"); } } // 1/K
public static MItem _Pa { get { return unit("1/{0}", "'Pa"); } } // 1/Pa
// [N]=[{kg*m}/{s^2}]
public static MItem N_m { get { return unit("{0}/{1}", "'N", "'m"); } } // N/m
public static MItem kg_mol { get { return unit("{0}/{1}", "'kg", "'mol"); } } // kg/mol
public static MItem Pa_s { get { return unit("{0}*{1}", "'Pa", "'s"); } } // Pa*s
public static MItem m3_kg { get { return unit("{{{0}^3}}/{1}", "'m", "'kg"); } } // m^3/kg
public static MItem unitless { get { return unit("1"); } }
static void AddUnits(ref System.Collections.Generic.Dictionary<string, MItem> dic, MItem unit, params string[] names)
{
foreach (var name in names)
dic.Add(name, unit);
}
static System.Collections.Generic.Dictionary<string, MItem> InitUnitsDictionary()
{
var dic = new System.Collections.Generic.Dictionary<string, MItem>(160);
AddUnits(ref dic, unitless,
"DELTA", "Delta", // IO Reduced density (rho/rhoc)
"Q", // [mol/mol] IO Mass vapor quality
"TAU", "Tau", // IO Reciprocal reduced temperature (Tc/T)
"ACENTRIC", "acentric", // O Acentric factor
"ALPHA0", "alpha0", // O Ideal Helmholtz energy
"ALPHAR", "alphar", // O Residual Helmholtz energy
"BVIRIAL", "Bvirial", // O Second virial coefficient
"CVIRIAL", "Cvirial", // O Third virial coefficient
"DALPHA0_DDELTA_CONSTTAU", "dalpha0_ddelta_consttau", // O Derivative of ideal Helmholtz energy with delta
"DALPHA0_DTAU_CONSTDELTA", "dalpha0_dtau_constdelta", // O Derivative of ideal Helmholtz energy with tau
"DALPHAR_DDELTA_CONSTTAU", "dalphar_ddelta_consttau", // O Derivative of residual Helmholtz energy with delta
"DALPHAR_DTAU_CONSTDELTA", "dalphar_dtau_constdelta", // O Derivative of residual Helmholtz energy with tau
"DBVIRIAL_DT", "dBvirial_dT", // O Derivative of second virial coefficient with respect to T
"DCVIRIAL_DT", "dCvirial_dT", // O Derivative of third virial coefficient with respect to T
"FH", // O Flammability hazard
"FRACTION_MAX", "fraction_max", // O Fraction (mole, mass, volume) maximum value for incompressible solutions
"FRACTION_MIN", "fraction_min", // O Fraction (mole, mass, volume) minimum value for incompressible solutions
"FUNDAMENTAL_DERIVATIVE_OF_GAS_DYNAMICS", "fundamental_derivative_of_gas_dynamics", // O Fundamental_derivative_of_gas_dynamics
"GWP100", // O 100-year gobal warming potential
"GWP20", // O 20-year gobal warming potential
"GWP500", // O 500-year gobal warming potential
"HH", // O Health hazard
"ODP", // O Ozone depletion potential
"PHASE", "Phase", // O Phase index as a float
"PH", // O Physical hazard
"PRANDTL", "Prandtl", // O Prandtl number
"Z"); // O Compressibility factor
AddUnits(ref dic, mol_m3,
"DMOLAR", "Dmolar", // [mol/m^3] IO Molar density
"RHOMOLAR_CRITICAL", "rhomolar_critical", // [mol/m^3] O Molar density at critical point
"RHOMOLAR_REDUCING", "rhomolar_reducing"); // [mol/m^3] O Molar density at reducing point
AddUnits(ref dic, kg_m3,
"D", "DMASS", "Dmass", // [kg/m^3] IO Mass density
"RHOCRIT", "RHOMASS_CRITICAL", "rhocrit", "rhomass_critical", // [kg/m^3] O Mass density at critical point
"RHOMASS_REDUCING", "rhomass_reducing"); // [kg/m^3] O Mass density at reducing point
AddUnits(ref dic, J_mol,
"HMOLAR", "Hmolar", // [J/mol] IO Molar specific enthalpy
"UMOLAR", "Umolar", // [J/mol] IO Molar specific internal energy
"GMOLAR", "Gmolar"); // [J/mol] O Molar specific Gibbs energy
AddUnits(ref dic, J_kg,
"H", "HMASS", "Hmass", // [J/kg] IO Mass specific enthalpy
"U", "UMASS", "Umass", // [J/kg] IO Mass specific internal energy
"G", "GMASS", "Gmass"); // [J/kg] O Mass specific Gibbs energy
AddUnits(ref dic, Pa,
"P", // [Pa] IO Pressure
"PCRIT", "P_CRITICAL", "Pcrit", "p_critical", "pcrit", // [Pa] O Pressure at the critical point
"PMAX", "P_MAX", "P_max", "pmax", // [Pa] O Maximum pressure limit
"PMIN", "P_MIN", "P_min", "pmin", // [Pa] O Minimum pressure limit
"PTRIPLE", "P_TRIPLE", "p_triple", "ptriple", // [Pa] O Pressure at the triple point (pure only)
"P_REDUCING", "p_reducing"); // [Pa] O Pressure at the reducing point
AddUnits(ref dic, J_mol_K,
"SMOLAR", "Smolar", // [J/mol/K] IO Molar specific entropy
"CP0MOLAR", "Cp0molar", // [J/mol/K] O Ideal gas molar specific constant presssure specific heat
"CPMOLAR", "Cpmolar", // [J/mol/K] O Molar specific constant presssure specific heat
"CVMOLAR", "Cvmolar", // [J/mol/K] O Molar specific constant volume specific heat
"GAS_CONSTANT", "gas_constant", // [J/mol/K] O Molar gas constant
"SMOLAR_RESIDUAL", "Smolar_residual"); // [J/mol/K] O Residual molar entropy (sr/R = tau*dar_dtau-ar)
AddUnits(ref dic, J_kg_K,
"S", "SMASS", "Smass", // [J/kg/K] IO Mass specific entropy
"CVMASS", "Cvmass", "O", // [J/kg/K] O Mass specific constant volume specific heat
"CP0MASS", "Cp0mass", // [J/kg/K] O Ideal gas mass specific constant presssure specific heat
"C", "CPMASS", "Cpmass"); // [J/kg/K] O Mass specific constant presssure specific heat
AddUnits(ref dic, K,
"T", // [K] IO Temperature
"TCRIT", "T_CRITICAL", "T_critical", "Tcrit", // [K] O Temperature at the critical point
"TMAX", "T_MAX", "T_max", "Tmax", // [K] O Maximum temperature limit
"TMIN", "T_MIN", "T_min", "Tmin", // [K] O Minimum temperature limit
"TTRIPLE", "T_TRIPLE", "T_triple", "Ttriple", // [K] O Temperature at the triple point
"T_FREEZE", "T_freeze", // [K] O Freezing temperature for incompressible solutions
"T_REDUCING", "T_reducing"); // [K] O Temperature at the reducing point
AddUnits(ref dic, m_s,
"A", "SPEED_OF_SOUND", "speed_of_sound"); // [m/s] O Speed of sound
AddUnits(ref dic, W_m_K,
"CONDUCTIVITY", "L", "conductivity"); // [W/m/K] O Thermal conductivity
AddUnits(ref dic, _K,
"ISOBARIC_EXPANSION_COEFFICIENT", "isobaric_expansion_coefficient"); // [1/K] O Isobaric expansion coefficient
AddUnits(ref dic, _Pa,
"ISOTHERMAL_COMPRESSIBILITY", "isothermal_compressibility"); // [1/Pa] O Isothermal compressibility
AddUnits(ref dic, N_m,
"I", "SURFACE_TENSION", "surface_tension"); // [N/m] O Surface tension
AddUnits(ref dic, kg_mol,
"M", "MOLARMASS", "MOLAR_MASS", "MOLEMASS", "molar_mass", "molarmass", "molemass"); // kg/mol O Molar mass
AddUnits(ref dic, Pa_s,
"V", "VISCOSITY", "viscosity"); // [Pa s] O Viscosity
return dic;
}
static System.Collections.Generic.Dictionary<string, MItem> dic = InitUnitsDictionary();
public static MItem Find(string param)
{
if (!dic.ContainsKey(param))
return unitless;
// HACK: fix for SS-2414
return SMath.Math.Decision.SymbolicCalculation(dic[param].ToEntry(), new SMath.Math.Store());
//return dic[param];
}
static System.Collections.Generic.Dictionary<string, MItem> InitHAUnitsDictionary()
{
var dic = new System.Collections.Generic.Dictionary<string, MItem>(50);
AddUnits(ref dic, unitless,
"Omega", "HumRat", "W", // Humidity Ratio [kg water/kg dry air]
"RH", "RelHum", "R", // Relative humidity in (0,1) [-]
"psi_w", "Y", // Mole fraction of water [mol_w/mol]
"Z"); // Compressibility factor (Z=pv/(RT)) [-]
AddUnits(ref dic, K,
"Tdb", "T_db", "T", // Dry-Bulb Temperature [K]
"Tdp", "T_dp", "DewPoint", "D", // Dew-Point Temperature [K]
"Twb", "T_wb", "WetBulb", "B"); // Wet-Bulb Temperature [K]
AddUnits(ref dic, J_kg,
"Enthalpy", "H", "Hda", // Mixture enthalpy per dry air [J/kg dry air]
"Hha"); // Mixture enthalpy per humid air [J/kg humid air]
AddUnits(ref dic, J_kg_K,
"Entropy", "S", "Sda", // Mixture entropy per unit dry air [J/kg dry air/K]
"Sha", // Mixture entropy per unit humid air [J/kg humid air/K]
"C", "cp", // Mixture specific heat per unit dry air [J/kg dry air/K]
"Cha", "cp_ha"); // Mixture specific heat per unit humid air [J/kg humid air/K]
AddUnits(ref dic, Pa,
"P", // Pressure [Pa]
"P_w"); // Partial pressure of water vapor [Pa]
AddUnits(ref dic, m3_kg,
"V", "Vda", // Mixture volume per unit dry air [m^3/kg dry air]
"Vha"); // Mixture volume per unit humid air [m^3/kg humid air]
AddUnits(ref dic, Pa_s,
"mu", "Visc", "M"); // Mixture viscosity [Pa-s]
AddUnits(ref dic, W_m_K,
"k", "Conductivity", "K"); // Mixture thermal conductivity [W/m/K]
return dic;
}
static System.Collections.Generic.Dictionary<string, MItem> HAdic = InitHAUnitsDictionary();
public static MItem FindHA(string param)
{
if (!HAdic.ContainsKey(param))
return unitless;
// HACK: fix for SS-2414
return SMath.Math.Decision.SymbolicCalculation(HAdic[param].ToEntry(), new SMath.Math.Store());
//return HAdic[param];
}
static void matchInternal(MItem unit, SMath.Math.Numeric.TNumber val, ref SMath.Math.Store context)
{
// First, reduce our units to basic representation to allow MathEqual()
var t = SMath.Math.Decision.Preprocessing(unit.ToEntry(), context);
var u = Expression.SimplifyEx(Converter.ToMItem(t), context);
if (!val.obj.Units.MathEqual(u) && !val.obj.Units.MathEqual(unitless))
throw new SMath.Manager.MathException(SMath.Manager.Errors.UnitsDontMatch);
}
public static void match(string param, SMath.Math.Numeric.TNumber val, SMath.Math.Store context)
{
matchInternal(Find(param), val, ref context);
}
public static void matchHA(string param, SMath.Math.Numeric.TNumber val, SMath.Math.Store context)
{
matchInternal(FindHA(param), val, ref context);
}
}
public static MItem K { get { return unit("{0}", "'K"); } }
// [Pa] = [kg/{m*s^2}]
public static MItem Pa { get { return unit("{0}", "'Pa"); } }
// [J] = [kg*m^2/s^2]
public static MItem J_kg { get { return unit("{0}/{1}", "'J", "'kg"); } } // J/kg
public static MItem mol_m3 { get { return unit("{0}/{{{1}^3}}", "'mol","'m"); } } // mol/m^3
public static MItem kg_m3 { get { return unit("{0}/{{{1}^3}}", "'kg", "'m"); } } // kg/m^3
public static MItem J_mol { get { return unit("{0}/{1}", "'J", "'mol"); } } // J/mol
public static MItem J_mol_K { get { return unit("{0}/{{{1}*{2}}}", "'J", "'mol", "'K"); } } // J/mol/K
public static MItem J_kg_K { get { return unit("{0}/{{{1}*{2}}}", "'J", "'kg", "'K"); } } // J/kg/K
public static MItem m_s { get { return unit("{0}/{1}", "'m", "'s"); } } // m/s
// [W]=[{kg*m^2}/{s^3}]
public static MItem W_m_K { get { return unit("{0}/{{{1}*{2}}}", "'W", "'m", "'K"); } } // W/m/K
public static MItem _K { get { return unit("1/{0}", "'K"); } } // 1/K
public static MItem _Pa { get { return unit("1/{0}", "'Pa"); } } // 1/Pa
// [N]=[{kg*m}/{s^2}]
public static MItem N_m { get { return unit("{0}/{1}", "'N", "'m"); } } // N/m
public static MItem kg_mol { get { return unit("{0}/{1}", "'kg", "'mol"); } } // kg/mol
public static MItem Pa_s { get { return unit("{0}*{1}", "'Pa", "'s"); } } // Pa*s
public static MItem m3_kg { get { return unit("{{{0}^3}}/{1}", "'m", "'kg"); } } // m^3/kg
public static MItem unitless { get { return unit("1"); } }
static void AddUnits(ref System.Collections.Generic.Dictionary<string, MItem> dic, MItem unit, params string[] names)
{
foreach (var name in names)
dic.Add(name, unit);
}
static System.Collections.Generic.Dictionary<string, MItem> InitUnitsDictionary()
{
var dic = new System.Collections.Generic.Dictionary<string, MItem>(160);
AddUnits(ref dic, unitless,
"DELTA", "Delta", // IO Reduced density (rho/rhoc)
"Q", // [mol/mol] IO Mass vapor quality
"TAU", "Tau", // IO Reciprocal reduced temperature (Tc/T)
"ACENTRIC", "acentric", // O Acentric factor
"ALPHA0", "alpha0", // O Ideal Helmholtz energy
"ALPHAR", "alphar", // O Residual Helmholtz energy
"BVIRIAL", "Bvirial", // O Second virial coefficient
"CVIRIAL", "Cvirial", // O Third virial coefficient
"DALPHA0_DDELTA_CONSTTAU", "dalpha0_ddelta_consttau", // O Derivative of ideal Helmholtz energy with delta
"DALPHA0_DTAU_CONSTDELTA", "dalpha0_dtau_constdelta", // O Derivative of ideal Helmholtz energy with tau
"DALPHAR_DDELTA_CONSTTAU", "dalphar_ddelta_consttau", // O Derivative of residual Helmholtz energy with delta
"DALPHAR_DTAU_CONSTDELTA", "dalphar_dtau_constdelta", // O Derivative of residual Helmholtz energy with tau
"DBVIRIAL_DT", "dBvirial_dT", // O Derivative of second virial coefficient with respect to T
"DCVIRIAL_DT", "dCvirial_dT", // O Derivative of third virial coefficient with respect to T
"FH", // O Flammability hazard
"FRACTION_MAX", "fraction_max", // O Fraction (mole, mass, volume) maximum value for incompressible solutions
"FRACTION_MIN", "fraction_min", // O Fraction (mole, mass, volume) minimum value for incompressible solutions
"FUNDAMENTAL_DERIVATIVE_OF_GAS_DYNAMICS", "fundamental_derivative_of_gas_dynamics", // O Fundamental_derivative_of_gas_dynamics
"GWP100", // O 100-year gobal warming potential
"GWP20", // O 20-year gobal warming potential
"GWP500", // O 500-year gobal warming potential
"HH", // O Health hazard
"ODP", // O Ozone depletion potential
"PHASE", "Phase", // O Phase index as a float
"PH", // O Physical hazard
"PRANDTL", "Prandtl", // O Prandtl number
"Z"); // O Compressibility factor
AddUnits(ref dic, mol_m3,
"DMOLAR", "Dmolar", // [mol/m^3] IO Molar density
"RHOMOLAR_CRITICAL", "rhomolar_critical", // [mol/m^3] O Molar density at critical point
"RHOMOLAR_REDUCING", "rhomolar_reducing"); // [mol/m^3] O Molar density at reducing point
AddUnits(ref dic, kg_m3,
"D", "DMASS", "Dmass", // [kg/m^3] IO Mass density
"RHOCRIT", "RHOMASS_CRITICAL", "rhocrit", "rhomass_critical", // [kg/m^3] O Mass density at critical point
"RHOMASS_REDUCING", "rhomass_reducing"); // [kg/m^3] O Mass density at reducing point
AddUnits(ref dic, J_mol,
"HMOLAR", "Hmolar", // [J/mol] IO Molar specific enthalpy
"UMOLAR", "Umolar", // [J/mol] IO Molar specific internal energy
"GMOLAR", "Gmolar"); // [J/mol] O Molar specific Gibbs energy
AddUnits(ref dic, J_kg,
"H", "HMASS", "Hmass", // [J/kg] IO Mass specific enthalpy
"U", "UMASS", "Umass", // [J/kg] IO Mass specific internal energy
"G", "GMASS", "Gmass"); // [J/kg] O Mass specific Gibbs energy
AddUnits(ref dic, Pa,
"P", // [Pa] IO Pressure
"PCRIT", "P_CRITICAL", "Pcrit", "p_critical", "pcrit", // [Pa] O Pressure at the critical point
"PMAX", "P_MAX", "P_max", "pmax", // [Pa] O Maximum pressure limit
"PMIN", "P_MIN", "P_min", "pmin", // [Pa] O Minimum pressure limit
"PTRIPLE", "P_TRIPLE", "p_triple", "ptriple", // [Pa] O Pressure at the triple point (pure only)
"P_REDUCING", "p_reducing"); // [Pa] O Pressure at the reducing point
AddUnits(ref dic, J_mol_K,
"SMOLAR", "Smolar", // [J/mol/K] IO Molar specific entropy
"CP0MOLAR", "Cp0molar", // [J/mol/K] O Ideal gas molar specific constant presssure specific heat
"CPMOLAR", "Cpmolar", // [J/mol/K] O Molar specific constant presssure specific heat
"CVMOLAR", "Cvmolar", // [J/mol/K] O Molar specific constant volume specific heat
"GAS_CONSTANT", "gas_constant", // [J/mol/K] O Molar gas constant
"SMOLAR_RESIDUAL", "Smolar_residual"); // [J/mol/K] O Residual molar entropy (sr/R = tau*dar_dtau-ar)
AddUnits(ref dic, J_kg_K,
"S", "SMASS", "Smass", // [J/kg/K] IO Mass specific entropy
"CVMASS", "Cvmass", "O", // [J/kg/K] O Mass specific constant volume specific heat
"CP0MASS", "Cp0mass", // [J/kg/K] O Ideal gas mass specific constant presssure specific heat
"C", "CPMASS", "Cpmass"); // [J/kg/K] O Mass specific constant presssure specific heat
AddUnits(ref dic, K,
"T", // [K] IO Temperature
"TCRIT", "T_CRITICAL", "T_critical", "Tcrit", // [K] O Temperature at the critical point
"TMAX", "T_MAX", "T_max", "Tmax", // [K] O Maximum temperature limit
"TMIN", "T_MIN", "T_min", "Tmin", // [K] O Minimum temperature limit
"TTRIPLE", "T_TRIPLE", "T_triple", "Ttriple", // [K] O Temperature at the triple point
"T_FREEZE", "T_freeze", // [K] O Freezing temperature for incompressible solutions
"T_REDUCING", "T_reducing"); // [K] O Temperature at the reducing point
AddUnits(ref dic, m_s,
"A", "SPEED_OF_SOUND", "speed_of_sound"); // [m/s] O Speed of sound
AddUnits(ref dic, W_m_K,
"CONDUCTIVITY", "L", "conductivity"); // [W/m/K] O Thermal conductivity
AddUnits(ref dic, _K,
"ISOBARIC_EXPANSION_COEFFICIENT", "isobaric_expansion_coefficient"); // [1/K] O Isobaric expansion coefficient
AddUnits(ref dic, _Pa,
"ISOTHERMAL_COMPRESSIBILITY", "isothermal_compressibility"); // [1/Pa] O Isothermal compressibility
AddUnits(ref dic, N_m,
"I", "SURFACE_TENSION", "surface_tension"); // [N/m] O Surface tension
AddUnits(ref dic, kg_mol,
"M", "MOLARMASS", "MOLAR_MASS", "MOLEMASS", "molar_mass", "molarmass", "molemass"); // kg/mol O Molar mass
AddUnits(ref dic, Pa_s,
"V", "VISCOSITY", "viscosity"); // [Pa s] O Viscosity
return dic;
}
static System.Collections.Generic.Dictionary<string, MItem> dic = InitUnitsDictionary();
public static MItem Find(string param)
{
try {
return dic[param];
}
catch (System.Exception) {
return unitless;
}
}
static System.Collections.Generic.Dictionary<string, MItem> InitHAUnitsDictionary()
{
var dic = new System.Collections.Generic.Dictionary<string, MItem>(50);
AddUnits(ref dic, unitless,
"Omega", "HumRat", "W", // Humidity Ratio [kg water/kg dry air]
"RH", "RelHum", "R", // Relative humidity in (0,1) [-]
"psi_w", "Y", // Mole fraction of water [mol_w/mol]
"Z"); // Compressibility factor (Z=pv/(RT)) [-]
AddUnits(ref dic, K,
"Tdb", "T_db", "T", // Dry-Bulb Temperature [K]
"Tdp", "T_dp", "DewPoint", "D", // Dew-Point Temperature [K]
"Twb", "T_wb", "WetBulb", "B"); // Wet-Bulb Temperature [K]
AddUnits(ref dic, J_kg,
"Enthalpy", "H", "Hda", // Mixture enthalpy per dry air [J/kg dry air]
"Hha"); // Mixture enthalpy per humid air [J/kg humid air]
AddUnits(ref dic, J_kg_K,
"Entropy", "S", "Sda", // Mixture entropy per unit dry air [J/kg dry air/K]
"Sha", // Mixture entropy per unit humid air [J/kg humid air/K]
"C", "cp", // Mixture specific heat per unit dry air [J/kg dry air/K]
"Cha", "cp_ha"); // Mixture specific heat per unit humid air [J/kg humid air/K]
AddUnits(ref dic, Pa,
"P", // Pressure [Pa]
"P_w"); // Partial pressure of water vapor [Pa]
AddUnits(ref dic, m3_kg,
"V", "Vda", // Mixture volume per unit dry air [m^3/kg dry air]
"Vha"); // Mixture volume per unit humid air [m^3/kg humid air]
AddUnits(ref dic, Pa_s,
"mu", "Visc", "M"); // Mixture viscosity [Pa-s]
AddUnits(ref dic, W_m_K,
"k", "Conductivity", "K"); // Mixture thermal conductivity [W/m/K]
return dic;
}
static System.Collections.Generic.Dictionary<string, MItem> HAdic = InitHAUnitsDictionary();
public static MItem FindHA(string param)
{
try {
return HAdic[param];
}
catch (System.Exception) {
return unitless;
}
}
static void matchInternal(MItem unit, SMath.Math.Numeric.TNumber val, ref SMath.Math.Store context)
{
// First, reduce our units to basic representation to allow MathEqual()
var t = SMath.Math.Decision.Preprocessing(unit.ToTerms(), ref context);
var u = Expression.SimplifyEx(Converter.ToMItem(t), context);
if (!val.obj.Units.MathEqual(u) && !val.obj.Units.MathEqual(unitless))
throw new SMath.Manager.EvaluationException(SMath.Manager.Errors.UnitsDontMatch);
}
public static void match(string param, SMath.Math.Numeric.TNumber val, SMath.Math.Store context)
{
matchInternal(Find(param), val, ref context);
}
public static void matchHA(string param, SMath.Math.Numeric.TNumber val, SMath.Math.Store context)
{
matchInternal(FindHA(param), val, ref context);
}
}
}

View File

@@ -1,159 +0,0 @@
using System.Collections.Generic;
using System.Reflection;
using SMath.Manager;
namespace coolprop_wrapper
{
public class coolpropPlugin : SMath.Math.IPluginLowLevelEvaluation
{
AssemblyInfo[] asseblyInfos = new [] {
new AssemblyInfo("SMath Studio", new System.Version(0, 97), new System.Guid("a37cba83-b69c-4c71-9992-55ff666763bd"))
};
TermInfo[] termInfos = new TermInfo[] {};
List<IFunction> functions = new List<IFunction>();
static string AssemblyDirectory {
get
{
var filepath = new System.Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
return System.IO.Path.GetDirectoryName(filepath);
}
}
static string LogFile {
get { return System.IO.Path.Combine(AssemblyDirectory, "log.txt"); }
}
public static void LogInfo(string Category, string Text, params object[] args)
{
#if DEBUG
var method = new System.Diagnostics.StackFrame(1).GetMethod();
System.IO.File.AppendAllText(
LogFile,
string.Format(
"{0} {1} {2} [{3}.{4}] {5}{6}",
System.DateTime.Now.ToShortDateString(),
System.DateTime.Now.ToLongTimeString(),
Category,
method.DeclaringType.Name,
method.Name.Substring(method.Name.LastIndexOf('.')+1),
string.Format(Text, args),
System.Environment.NewLine),
System.Text.Encoding.UTF8);
#endif
}
public static SMath.Math.Numeric.TNumber GetNumberParam(Term[] arg, ref SMath.Math.Store context)
{
// var arg1 = SMath.Math.Decision.Preprocessing(arg, ref context);
// return SMath.Math.Numeric.Expression.Calculate(arg1, context).obj as SMath.Math.Numeric.TDouble;
return SMath.Math.Decision.NumericCalculation(arg, ref context);
}
public static void CoolPropError(string message = "")
{
string errStr;
if (!Functions.CoolProp_get_global_param_string.CoolPropDLLfunc("errstring", out errStr))
{
// Call it second time - most probably will get something like "buffer too small"
Functions.CoolProp_get_global_param_string.CoolPropDLLfunc("errstring", out errStr);
errStr = "Error message couldn't be retrieved from CoolProp library (buffer size issue?); the second try returned: " + errStr;
}
throw new System.Exception(message+errStr);
}
public static string GetStringParam(Term[] arg, ref SMath.Math.Store context)
{
var dbl = GetNumberParam(arg, ref context).obj as SMath.Math.Numeric.TDouble;
if (!dbl.isText)
throw new SMath.Manager.EvaluationException(Errors.ArgumentMustBeString);
return dbl.ToString().Trim('"');
}
public static Term[] MakeDoubleResult(double result, SMath.Math.Symbolic.MItem unit)
{
if (double.IsInfinity(result))
{
CoolPropError();
}
var d = new SMath.Math.Numeric.TDouble(result);
d.Units = unit;
return d.ToTerms();
}
public static Term[] MakeStringResult(string result)
{
return new SMath.Math.Numeric.TDouble("\"" + result + "\"").ToTerms();
}
TermInfo[] IPluginHandleEvaluation.TermsHandled { get { return termInfos; } }
void System.IDisposable.Dispose()
{
try {
if (System.IO.File.Exists(LogFile))
System.IO.File.Delete(LogFile);
}
catch (System.Exception) {}
}
AssemblyInfo[] IPlugin.Dependences { get { return asseblyInfos; } }
void IPlugin.Initialize()
{
var info = new List<TermInfo>();
try {
foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) {
if (!(type.IsClass && typeof(IFunction).IsAssignableFrom(type)))
continue;
var arguments = type.GetField("Arguments", BindingFlags.GetField | BindingFlags.Static | BindingFlags.Public);
if (arguments == null)
continue;
var args = arguments.GetValue(null) as int[];
foreach (var arg in args) {
functions.Add((IFunction)System.Activator.CreateInstance(type, new object[] {arg}));
}
}
foreach (var func in functions) {
var item = func.GetTermInfo(GlobalParams.CurLang3Letter);
info.Add(item);
LogInfo("[INFO ]", "{0}({1}) - {2}", item.Text, item.ChildCount, item.Description);
}
}
catch (System.Exception ex) {
LogInfo("[ERROR]", "{0}", ex.Message);
}
termInfos = info.ToArray();
LogInfo("[INFO ]", "Successfully. {0} functions loaded.", termInfos.Length);
}
bool SMath.Math.IPluginLowLevelEvaluation.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
{
if (root.Type != TermType.Function)
return false;
foreach (var func in functions) {
if (!func.Info.Equals(root))
continue;
try {
return func.ExpressionEvaluation(root, args,ref context, ref result);
}
catch (System.Exception ex) {
LogInfo("[ERROR]", "{0}({1}) {2}", root.Text, root.ChildCount, ex.Message);
throw;
}
}
return false;
}
}
}