Added SMath wrapper code

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2015-02-18 22:20:27 -05:00
parent 4f63c8834f
commit 8f56fb7a0e
21 changed files with 2169 additions and 2 deletions

View File

@@ -29,8 +29,9 @@ project(${project_name})
# Project version
set (COOLPROP_VERSION_MAJOR 5)
set (COOLPROP_VERSION_MINOR 0)
set (COOLPROP_VERSION_PATCH 8dev)
set (COOLPROP_VERSION ${COOLPROP_VERSION_MAJOR}.${COOLPROP_VERSION_MINOR}.${COOLPROP_VERSION_PATCH})
set (COOLPROP_VERSION_PATCH 8)
set (COOLPROP_VERSION_REVISION dev)
set (COOLPROP_VERSION ${COOLPROP_VERSION_MAJOR}.${COOLPROP_VERSION_MINOR}.${COOLPROP_VERSION_PATCH}${COOLPROP_VERSION_REVISION})
#######################################
# BUILD OPTIONS #
@@ -903,6 +904,17 @@ if (COOLPROP_MATHEMATICA_MODULE)
install (FILES "${CMAKE_SOURCE_DIR}/wrappers/Mathematica/example.nb" DESTINATION Mathematica)
endif()
if (COOLPROP_SMATH_MODULE)
set(COOLPROP_VERSION ${COOLPROP_VERSION_MAJOR}.${COOLPROP_VERSION_MINOR}.${COOLPROP_VERSION_PATCH}.0)
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/wrappers/SMath/coolprop_wrapper/Properties/AssemblyInfo.cs.template"
"${CMAKE_SOURCE_DIR}/wrappers/SMath/coolprop_wrapper/Properties/AssemblyInfo.cs")
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/wrappers/SMath/config.ini.template"
"${CMAKE_SOURCE_DIR}/wrappers/SMath/config.ini")
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/wrappers/SMath/coolprop_wrapper/install.bat.template"
"${CMAKE_SOURCE_DIR}/wrappers/SMath/coolprop_wrapper/install.bat")
endif()
if (COOLPROP_MY_MAIN)
list(APPEND APP_SOURCES "${COOLPROP_MY_MAIN}")
add_executable (Main ${APP_SOURCES})

View File

@@ -0,0 +1 @@
${COOLPROP_VERSION}

View File

@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coolprop_wrapper", "coolprop_wrapper\coolprop_wrapper.csproj", "{0D7973E8-7B3F-425C-A15D-2D087679C598}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0D7973E8-7B3F-425C-A15D-2D087679C598}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D7973E8-7B3F-425C-A15D-2D087679C598}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D7973E8-7B3F-425C-A15D-2D087679C598}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D7973E8-7B3F-425C-A15D-2D087679C598}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,138 @@
using System.Runtime.InteropServices;
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.dll", 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.dll", 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 EvaluationException(Errors.PluginCannotBeEnabled);
}
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

@@ -0,0 +1,106 @@
using System.Runtime.InteropServices;
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.dll", 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.dll", 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 EvaluationException(Errors.PluginCannotBeEnabled);
}
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)
throw new EvaluationException(Errors.ArgumentDoesNotMatchToExpectedKind);
result = coolpropPlugin.MakeStringResult(phase.ToString());
return true;
}
}
}

View File

@@ -0,0 +1,102 @@
using System.Runtime.InteropServices;
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.dll", 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.dll", 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 EvaluationException(Errors.PluginCannotBeEnabled);
}
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

@@ -0,0 +1,75 @@
using System.Runtime.InteropServices;
using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_Props1 : IFunction
{
// double Props1SI(const char *FluidName, const char* Output);
[DllImport(
"CoolProp.x86.dll", EntryPoint = "Props1SI",
CharSet = CharSet.Ansi)]
internal static extern double CoolPropDLLfunc_x86(
string FluidName,
string Output);
[DllImport(
"CoolProp.x64.dll", 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 EvaluationException(Errors.PluginCannotBeEnabled);
}
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);
result = coolpropPlugin.MakeDoubleResult(Result, Unit.Find(Output));
return true;
}
}
}

View File

@@ -0,0 +1,84 @@
using System.Runtime.InteropServices;
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.dll", 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.dll", 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 EvaluationException(Errors.PluginCannotBeEnabled);
}
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)
throw new EvaluationException(Errors.ArgumentDoesNotMatchToExpectedKind);
result = coolpropPlugin.MakeStringResult(output.ToString());
return true;
}
}
}

View File

@@ -0,0 +1,78 @@
using System.Runtime.InteropServices;
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.dll", 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.dll", EntryPoint = "get_global_param_string",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x64(
string param,
System.Text.StringBuilder Output,
int n);
internal static long CoolPropDLLfunc(
string param,
System.Text.StringBuilder Output,
int n)
{
switch (System.IntPtr.Size)
{
case 4:
return CoolPropDLLfunc_x86(param, Output, n);
case 8:
return CoolPropDLLfunc_x64(param, Output, n);
}
throw new EvaluationException(Errors.PluginCannotBeEnabled);
}
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);
var output = new System.Text.StringBuilder(10000);
var Result = CoolPropDLLfunc(param, output, output.Capacity);
coolpropPlugin.LogInfo("[INFO ]", "param = {0} output = {1} Result = {2}", param, output.ToString(), Result);
if (Result != 1)
throw new EvaluationException(Errors.ArgumentDoesNotMatchToExpectedKind);
result = coolpropPlugin.MakeStringResult(output.ToString());
return true;
}
}
}

View File

@@ -0,0 +1,70 @@
using System.Runtime.InteropServices;
using SMath.Manager;
namespace coolprop_wrapper.Functions
{
class CoolProp_get_param_index : IFunction
{
// long get_param_index(const char *param);
[DllImport(
"CoolProp.x86.dll", EntryPoint = "get_param_index",
CharSet = CharSet.Ansi)]
internal static extern long CoolPropDLLfunc_x86(
string param);
[DllImport(
"CoolProp.x64.dll", 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 EvaluationException(Errors.PluginCannotBeEnabled);
}
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

@@ -0,0 +1,83 @@
using System.Runtime.InteropServices;
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.dll", 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.dll", 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 EvaluationException(Errors.PluginCannotBeEnabled);
}
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)
throw new EvaluationException(Errors.ArgumentDoesNotMatchToExpectedKind);
result = coolpropPlugin.MakeStringResult(output.ToString());
return true;
}
}
}

View File

@@ -0,0 +1,95 @@
using System.Runtime.InteropServices;
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.dll", 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.dll", 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 EvaluationException(Errors.PluginCannotBeEnabled);
}
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

@@ -0,0 +1,95 @@
using System.Runtime.InteropServices;
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.dll", 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.dll", 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 EvaluationException(Errors.PluginCannotBeEnabled);
}
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

@@ -0,0 +1,75 @@
using System.Runtime.InteropServices;
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.dll", EntryPoint = "set_reference_stateS",
CharSet = CharSet.Ansi)]
internal static extern int CoolPropDLLfunc_x86(
string Ref,
string reference_state);
[DllImport(
"CoolProp.x64.dll", 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 EvaluationException(Errors.PluginCannotBeEnabled);
}
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

@@ -0,0 +1,15 @@
namespace coolprop_wrapper
{
interface IFunction
{
SMath.Manager.Term Info { get; }
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);
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("coolprop_wrapper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("coolprop_wrapper")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2be8d14b-ba62-4002-a959-9e5dad905310")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("${COOLPROP_VERSION}")]
[assembly: AssemblyFileVersion("${COOLPROP_VERSION}")]

View File

@@ -0,0 +1,205 @@
using SMath.Math.Symbolic;
namespace coolprop_wrapper
{
class Unit
{
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
"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
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 SMath.Math.Symbolic.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]
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 [J/kg dry air]
"Hha"); // [J/kg humid air]
AddUnits(ref dic, J_kg_K,
"Entropy", "S", // Mixture entropy [J/kg dry air/K] (Sda ???)
"C", "cp", // Mixture specific heat [J/kg dry air/K]
"Cha", "cp_ha"); // [J/kg humid air/K]
AddUnits(ref dic, Pa,
"P"); // Pressure [Pa]
AddUnits(ref dic, m3_kg,
"V", "Vda", // Mixture volume [m3/kg dry air]
"Vha"); // [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 SMath.Math.Symbolic.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

@@ -0,0 +1,142 @@
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 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)
{
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;
}
}
}

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0D7973E8-7B3F-425C-A15D-2D087679C598}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>coolprop_wrapper</RootNamespace>
<AssemblyName>coolprop_wrapper</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="SMath.Controls">
<HintPath>c:\Program Files (x86)\SMath Studio\SMath.Controls.dll</HintPath>
</Reference>
<Reference Include="SMath.Manager">
<HintPath>c:\Program Files (x86)\SMath Studio\SMath.Manager.dll</HintPath>
</Reference>
<Reference Include="SMath.Math.Numeric">
<HintPath>c:\Program Files (x86)\SMath Studio\SMath.Math.Numeric.dll</HintPath>
</Reference>
<Reference Include="SMath.Math.Symbolic">
<HintPath>c:\Program Files (x86)\SMath Studio\SMath.Math.Symbolic.dll</HintPath>
</Reference>
<Reference Include="SMath.UI">
<HintPath>c:\Program Files (x86)\SMath Studio\SMath.UI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="*.cs" />
<Compile Include="Functions\*.cs" />
<Compile Include="Properties\*.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,652 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?application progid="SMath Studio Desktop" version="0.97.5346.24640"?>
<regions>
<settings>
<identity>
<id>4a35301a-4a4d-4f4c-8963-6e6d56d24ef4</id>
<revision>52</revision>
</identity>
<calculation>
<precision>4</precision>
<exponentialThreshold>5</exponentialThreshold>
<fractions>decimal</fractions>
</calculation>
<pageModel active="true" printAreas="true" simpleEqualsOnly="false" printBackgroundImages="true">
<paper id="1" orientation="Portrait" width="850" height="1100" />
<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>
<dependences>
<assembly name="SMath Studio Desktop" version="0.97.5346.24640" guid="a37cba83-b69c-4c71-9992-55ff666763bd" />
<assembly name="coolprop_wrapper" version="1.0.5526.20489" guid="2be8d14b-ba62-4002-a959-9e5dad905310" />
<assembly name="Math Region" version="0.97.5346.24640" guid="02f1ab51-215b-466e-a74d-5d8b1cf85e8d" />
<assembly name="Special Functions" version="1.11.5346.31403" guid="2814e667-4e12-48b1-8d51-194e480eabc5" />
<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>
</settings>
<region id="0" left="0" top="0" width="445" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<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>
</result>
</math>
</region>
<region id="1" left="0" top="27" width="456" height="28" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand" style="string">version</e>
<e type="function" preserve="true" args="1">CoolProp_get_global_param_string</e>
<e type="function" preserve="true" args="1">strlen</e>
</input>
<result action="numeric">
<e type="operand">5</e>
</result>
</math>
</region>
<region id="2" left="0" top="72" width="428" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">RESET</e>
<e type="function" preserve="true" args="2">CoolProp_set_reference_stateS</e>
</input>
<result action="numeric">
<e type="operand">1</e>
</result>
</math>
</region>
<region id="3" left="0" top="126" width="488" height="28" color="#000000" bgColor="#ff8080" fontSize="10">
<math>
<input>
<e type="operand" style="string">P</e>
<e type="operand">1</e>
<e type="operand" style="unit">atm</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">5</e>
<e type="operator" args="1">-</e>
<e type="bracket">(</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="5">CoolProp_Phase</e>
</input>
<result action="numeric">
<e type="operand" style="string">liquid</e>
</result>
</math>
</region>
<region id="4" left="495" top="126" width="143" height="24" color="#ff0000" bgColor="#ffffff" fontSize="10">
<text lang="eng">
<p>Liquid? At -5°C?</p>
</text>
</region>
<region id="5" left="0" top="171" width="377" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">Tcrit</e>
<e type="function" preserve="true" args="2">CoolProp_Props1</e>
</input>
<result action="numeric">
<e type="operand">647.096</e>
<e type="operand" style="unit">K</e>
<e type="operator" args="2">*</e>
</result>
</math>
</region>
<region id="6" left="0" top="198" width="373" height="26" color="#000000" bgColor="#80ff80" fontSize="10">
<math>
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">Tcrit</e>
<e type="function" preserve="true" args="2">CoolProp_Props1</e>
</input>
<contract>
<e type="operand" style="unit">°C</e>
</contract>
<result action="numeric">
<e type="operand">373.946</e>
</result>
</math>
</region>
<region id="7" left="0" top="243" width="411" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<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" 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>
<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>
<contract>
<e type="operand" style="unit">kPa</e>
</contract>
<result action="numeric">
<e type="operand">22064</e>
</result>
</math>
</region>
<region id="9" left="0" top="333" width="603" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">373.15</e>
<e type="operand" style="string">water</e>
<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" 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>
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
<e type="operand">101.325</e>
<e type="operand" style="unit">kPa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">373.15</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</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">2675.5828</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">
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
<e type="operand">1</e>
<e type="operand" style="unit">atm</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">x</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
<e type="operand">10</e>
<e type="operand">3</e>
<e type="operator" args="1">-</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
</input>
</plot>
</region>
<region id="12" left="648" top="486" width="565" height="43" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand" style="string">Q</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">H</e>
<e type="operand">2000</e>
<e type="operand" style="unit">kJ</e>
<e type="operand" style="unit">kg</e>
<e type="operator" args="2">/</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
</input>
<result action="numeric">
<e type="operand">0.7366</e>
</result>
</math>
</region>
<region id="13" left="648" top="531" width="519" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand" style="string">Phase</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">0</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
</input>
<result action="numeric">
<e type="operand">0</e>
</result>
</math>
</region>
<region id="14" left="648" top="558" width="544" height="28" color="#000000" bgColor="#ffffff" fontSize="10">
<math error="43">
<input>
<e type="operand" style="string">Phase</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">10</e>
<e type="operator" args="1">-</e>
<e type="bracket">(</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
</input>
<result action="numeric">
<e type="operand">#</e>
</result>
</math>
</region>
<region id="15" left="648" top="585" width="536" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand" style="string">Phase</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">100</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">water</e>
<e type="function" preserve="true" args="6">CoolProp_Props</e>
</input>
<result action="numeric">
<e type="operand">5</e>
</result>
</math>
</region>
<region id="16" left="0" top="684" width="655" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">W</e>
<e type="operand" style="string">T</e>
<e type="operand">10</e>
<e type="operator" args="1">-</e>
<e type="bracket">(</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">R</e>
<e type="operand">1</e>
<e type="function" preserve="true" args="7">CoolProp_HAProps</e>
<e type="operand">1</e>
<e type="operator" args="2">*</e>
</input>
<contract>
<e type="operand" style="unit">g</e>
<e type="operand" style="unit">kg</e>
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">1.606200912602</e>
</result>
</math>
</region>
<region id="17" left="0" top="729" width="630" height="41" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">W</e>
<e type="operand" style="string">T</e>
<e type="operand">10</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">R</e>
<e type="operand">1</e>
<e type="function" preserve="true" args="7">CoolProp_HAProps</e>
<e type="operand">1</e>
<e type="operator" args="2">*</e>
</input>
<contract>
<e type="operand" style="unit">g</e>
<e type="operand" style="unit">kg</e>
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">7.66274517334</e>
</result>
</math>
</region>
<region id="18" left="0" top="774" width="642" height="43" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">W</e>
<e type="operand" style="string">T</e>
<e type="operand">10</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">R</e>
<e type="operand">1</e>
<e type="operand">2</e>
<e type="operator" args="2">/</e>
<e type="function" preserve="true" args="7">CoolProp_HAProps</e>
<e type="operand">2</e>
<e type="operator" args="2">*</e>
</input>
<contract>
<e type="operand" style="unit">g</e>
<e type="operand" style="unit">kg</e>
<e type="operator" args="2">/</e>
</contract>
<result action="numeric">
<e type="operand">7.615829321156</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">
<input>
<e type="operand" style="string">W</e>
<e type="operand" style="string">T</e>
<e type="operand">x</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">R</e>
<e type="operand">1</e>
<e type="function" preserve="true" args="7">CoolProp_HAProps</e>
<e type="operand">10</e>
<e type="operand">3</e>
<e type="operator" args="2">^</e>
<e type="operator" args="2">*</e>
</input>
</plot>
</region>
<region id="20" left="0" top="1107" width="411" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">NBP</e>
<e type="function" preserve="true" args="2">CoolProp_set_reference_stateS</e>
</input>
<result action="numeric">
<e type="operand">1</e>
</result>
</math>
</region>
<region id="21" left="0" top="1134" width="686" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">373.15</e>
<e type="operand" style="string">water</e>
<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" 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>
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">DEF</e>
<e type="function" preserve="true" args="2">CoolProp_set_reference_stateS</e>
</input>
<result action="numeric">
<e type="operand">1</e>
</result>
</math>
</region>
<region id="23" left="0" top="1197" width="686" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">373.15</e>
<e type="operand" style="string">water</e>
<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" 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>
<input>
<e type="operand" style="string">water</e>
<e type="operand" style="string">RESET</e>
<e type="function" preserve="true" args="2">CoolProp_set_reference_stateS</e>
</input>
<result action="numeric">
<e type="operand">1</e>
</result>
</math>
</region>
<region id="25" left="0" top="1260" width="686" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">373.15</e>
<e type="operand" style="string">water</e>
<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" 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>
<input>
<e type="operand" style="string">water</e>
<e type="operand">10</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<e type="operand">33</e>
<e type="operand" style="unit">mol</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>
<e type="operator" args="2">*</e>
<e type="operand">0</e>
<e type="operand">0</e>
<e type="function" preserve="true" args="5">CoolProp_set_reference_stateD</e>
</input>
<result action="numeric">
<e type="operand">1</e>
</result>
</math>
</region>
<region id="27" left="0" top="1350" width="686" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math decimalPlaces="15">
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">P</e>
<e type="operand">101325</e>
<e type="operand" style="unit">Pa</e>
<e type="operator" args="2">*</e>
<e type="operand" style="string">T</e>
<e type="operand">373.15</e>
<e type="operand" style="string">water</e>
<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" 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>
<input>
<e type="operand" style="string">n-Propane</e>
<e type="operand" style="string">aliases</e>
<e type="function" preserve="true" args="2">CoolProp_get_fluid_param_string</e>
</input>
<result action="numeric">
<e type="operand" style="string">Propane, propane, R290, C3H8, PROPANE, N-PROPANE</e>
</result>
</math>
</region>
<region id="29" left="0" top="1440" width="8423" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<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>
</result>
</math>
</region>
<region id="30" left="0" top="1467" width="288" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<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>
</result>
</math>
</region>
<region id="31" left="0" top="1494" width="535" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<e type="operand" style="string">H</e>
<e type="operand" style="string">units</e>
<e type="function" preserve="true" args="2">CoolProp_get_parameter_information_string</e>
</input>
<result action="numeric">
<e type="operand" style="string">J/kg</e>
</result>
</math>
</region>
<region id="32" left="0" top="1521" width="621" height="34" color="#000000" bgColor="#ffffff" fontSize="10">
<math>
<input>
<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">100</e>
<e type="operand" style="unit">°C</e>
<e type="operator" args="2">*</e>
<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" 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>
<input>
<e type="operand" style="string">n-Propane</e>
<e type="operand" style="string">GWP100</e>
<e type="function" preserve="true" args="2">CoolProp_Props1</e>
</input>
<result action="numeric">
<e type="operand">3</e>
</result>
</math>
</region>
</regions>

View File

@@ -0,0 +1,17 @@
set VERSION=${COOLPROP_VERSION}
REM Remove temporary directory if needed
rmdir %VERSION% /s /q
REM Add directory if needed
mkdir %VERSION%
xcopy bin\Release %VERSION%\
xcopy %VERSION% %AppData%\SMath\extensions\plugins\2be8d14b-ba62-4002-a959-9e5dad905310\%VERSION%\ /S
xcopy ..\config.ini %AppData%\SMath\extensions\plugins\2be8d14b-ba62-4002-a959-9e5dad905310\config.ini
REM Remove temporary directory if needed
rmdir %VERSION% /s /q