From 47486f81e090f39458a0d2a02216114e437147b1 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 00:09:00 +0200 Subject: [PATCH 01/18] Fixed creation of src folder for GCC builds Signed-off-by: Ian Bell --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e523b0d1..08a9933b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,6 +163,9 @@ if (COOLPROP_OCTAVE_MODULE) INCLUDE(${SWIG_USE_FILE}) FIND_PACKAGE(Octave REQUIRED) + # Make a src directory to deal with file permissions problem with MinGW makefile + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src) + # Find the required libraries find_library(OCTAVE_LIB octave PATHS ${OCTAVE_LINK_DIRS}) find_library(OCTINTERP_LIB octinterp PATHS ${OCTAVE_LINK_DIRS}) From 845427a268770b23bfd19ecabb8b1860ef49160c Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 00:44:43 +0200 Subject: [PATCH 02/18] C# "works" on windows - "works" meaning that it compiles, but some parts don't yet work properly. Example runs, but many failures Signed-off-by: Ian Bell --- CMakeLists.txt | 25 ++++- dev/cmake/Modules/FindCsharp.cmake | 72 +++++++++++++++ .../Modules/FindDotNetFrameworkSdk.cmake | 92 +++++++++++++++++++ 3 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 dev/cmake/Modules/FindCsharp.cmake create mode 100644 dev/cmake/Modules/FindDotNetFrameworkSdk.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index dc1ed0be..55e9c274 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,6 +169,7 @@ if (COOLPROP_OCTAVE_MODULE) # Find the required libraries find_library(OCTAVE_LIB octave PATHS ${OCTAVE_LINK_DIRS}) find_library(OCTINTERP_LIB octinterp PATHS ${OCTAVE_LINK_DIRS}) + find_library(CRUFT_LIB cruft PATHS ${OCTAVE_LINK_DIRS}) # Set the include folders SET(OCTAVE_WRAP_INCLUDE_DIRS ${INCLUDE_DIR}) @@ -181,13 +182,33 @@ if (COOLPROP_OCTAVE_MODULE) SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES CPLUSPLUS ON) SWIG_ADD_MODULE(CoolProp octave ${I_FILE} ${APP_SOURCES}) - SWIG_LINK_LIBRARIES(CoolProp ${OCTAVE_LIB} ${OCTINTERP_LIB}) + SWIG_LINK_LIBRARIES(CoolProp ${OCTAVE_LIB} ${OCTINTERP_LIB} ${CRUFT_LIB}) - add_dependencies (CoolProp generate_headers) set_target_properties(CoolProp PROPERTIES SUFFIX ".oct" PREFIX "") endif() +if (COOLPROP_CSHARP_MODULE) + + # Must have SWIG and Octave + FIND_PACKAGE(SWIG REQUIRED) + INCLUDE(${SWIG_USE_FILE}) + FIND_PACKAGE(Csharp REQUIRED) + + # Make a src directory to deal with file permissions problem with MinGW makefile + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src) + + set(I_FILE "${CMAKE_SOURCE_DIR}/src/CoolProp.i") + + SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES CPLUSPLUS ON) + SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES SWIG_FLAGS "-dllimport \"CoolProp\"") + + SWIG_ADD_MODULE(CoolProp csharp ${I_FILE} ${APP_SOURCES}) + + set_target_properties(CoolProp PROPERTIES PREFIX "") + +endif() + # NOT WORKING! if (COOLPROP_MATHEMATICA_MODULE) diff --git a/dev/cmake/Modules/FindCsharp.cmake b/dev/cmake/Modules/FindCsharp.cmake new file mode 100644 index 00000000..ba15f684 --- /dev/null +++ b/dev/cmake/Modules/FindCsharp.cmake @@ -0,0 +1,72 @@ +# +# A CMake Module for finding and using C# (.NET and Mono). +# +# The following variables are set: +# CSHARP_FOUND - set to ON if C# is found +# CSHARP_USE_FILE - the path to the C# use file +# CSHARP_TYPE - the type of the C# compiler (eg. ".NET" or "Mono") +# CSHARP_VERSION - the version of the C# compiler (eg. "v4.0" or "2.10.2") +# CSHARP_COMPILER - the path to the C# compiler executable (eg. "C:/Windows/Microsoft.NET/Framework/v4.0.30319/csc.exe" or "/usr/bin/gmcs") +# CSHARP_INTERPRETER - the path to interpreter needed to run CSharp executables +# CSHARP_PLATFORM - the C# target platform +# CSHARP_SDK - the SDK commandline switch (empty for .NET, for Mono eg. "/sdk:2" or "/sdk:4") +# +# This file is based on the work of GDCM: +# http://gdcm.svn.sf.net/viewvc/gdcm/trunk/CMake/FindCSharp.cmake +# Copyright (c) 2006-2010 Mathieu Malaterre +# + +# TODO: ADD ABILITY TO SELECT WHICH C# COMPILER eg. .NET or Mono (if both exist). For the moment, .NET is selected above Mono. + +# Make sure find package macros are included +include( FindPackageHandleStandardArgs ) + +unset( CSHARP_COMPILER CACHE ) +unset( CSHARP_INTERPRETER CACHE ) +unset( CSHARP_TYPE CACHE ) +unset( CSHARP_VERSION CACHE ) +unset( CSHARP_FOUND CACHE ) + +# By default use anycpu platform, allow the user to override +set( CSHARP_PLATFORM "anycpu" CACHE STRING "C# target platform: x86, x64, anycpu, or itanium" ) +if( NOT ${CSHARP_PLATFORM} MATCHES "x86|x64|anycpu|itanium" ) + message( FATAL_ERROR "The C# target platform '${CSHARP_PLATFORM}' is not valid. Please enter one of the following: x86, x64, anycpu, or itanium" ) +endif( ) + +if( WIN32 ) + find_package( DotNetFrameworkSdk ) + if( NOT CSHARP_DOTNET_FOUND ) + find_package( Mono ) + endif( ) +else( UNIX ) + find_package( Mono ) +endif( ) + +if( CSHARP_DOTNET_FOUND ) + set( CSHARP_TYPE ".NET" CACHE STRING "Using the .NET compiler" ) + set( CSHARP_VERSION ${CSHARP_DOTNET_VERSION} CACHE STRING "C# .NET compiler version" FORCE ) + set( CSHARP_COMPILER ${CSHARP_DOTNET_COMPILER_${CSHARP_DOTNET_VERSION}} CACHE STRING "Full path to .NET compiler" FORCE ) + set( CSHARP_INTERPRETER "" CACHE INTERNAL "Interpretor not required for .NET" FORCE ) +elseif( CSHARP_MONO_FOUND ) + set( CSHARP_TYPE "Mono" CACHE STRING "Using the Mono compiler" ) + set( CSHARP_VERSION ${CSHARP_MONO_VERSION} CACHE STRING "C# Mono compiler version" FORCE ) + set( CSHARP_COMPILER ${CSHARP_MONO_COMPILER_${CSHARP_MONO_VERSION}} CACHE STRING "Full path to Mono compiler" FORCE ) + set( CSHARP_INTERPRETER ${CSHARP_MONO_INTERPRETER_${CSHARP_MONO_VERSION}} CACHE STRING "Full path to Mono interpretor" FORCE ) + set( CSHARP_SDK "/sdk:2" CACHE STRING "C# Mono SDK commandline switch (e.g. /sdk:2, /sdk:4, /sdk:5)" ) +endif( ) + +# Handle WIN32 specific issues +if ( WIN32 ) + if ( CSHARP_COMPILER MATCHES "bat" ) + set( CSHARP_COMPILER "call ${CSHARP_COMPILER}" ) + endif ( ) +endif( ) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(CSharp DEFAULT_MSG CSHARP_TYPE CSHARP_VERSION CSHARP_COMPILER) + +mark_as_advanced( CSHARP_TYPE CSHARP_VERSION CSHARP_COMPILER CSHARP_INTERPRETER CSHARP_PLATFORM CSHARP_SDK ) + +# Set the USE_FILE path +# http://public.kitware.com/Bug/view.php?id=7757 +get_filename_component( current_list_path ${CMAKE_CURRENT_LIST_FILE} PATH ) +set( CSHARP_USE_FILE ${current_list_path}/UseCSharp.cmake ) diff --git a/dev/cmake/Modules/FindDotNetFrameworkSdk.cmake b/dev/cmake/Modules/FindDotNetFrameworkSdk.cmake new file mode 100644 index 00000000..3d84a536 --- /dev/null +++ b/dev/cmake/Modules/FindDotNetFrameworkSdk.cmake @@ -0,0 +1,92 @@ +# +# A CMake Module for finding C# .NET. +# +# The following variables are set: +# CSHARP_DOTNET_FOUND +# CSHARP_DOTNET_COMPILER_${version} eg. "CSHARP_DOTNET_COMPILER_v4.0.30319" +# CSHARP_DOTNET_VERSION eg. "v4.0.30319" +# CSHARP_DOTNET_VERSIONS eg. "v2.0.50727, v3.5, v4.0.30319" +# DotNetFrameworkSdk_USE_FILE +# +# Additional references can be found here: +# .NET SDK 1.1: http://www.microsoft.com/downloads/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d&displaylang=en +# .NET SDK 2.0: http://www.microsoft.com/downloads/details.aspx?FamilyID=fe6f2099-b7b4-4f47-a244-c96d69c35dec&displaylang=en +# .NET SDK 3.5: http://www.microsoft.com/downloads/details.aspx?familyid=333325fd-ae52-4e35-b531-508d977d32a6&displaylang=en +# C# Compiler options: http://msdn.microsoft.com/en-us/library/2fdbz5xd(v=VS.71).aspx +# +# This file is based on the work of GDCM: +# http://gdcm.svn.sf.net/viewvc/gdcm/trunk/CMake/FindDotNETFrameworkSDK.cmake +# Copyright (c) 2006-2010 Mathieu Malaterre +# + +set( csharp_dotnet_valid 1 ) +if( DEFINED CSHARP_DOTNET_FOUND ) + # The .NET compiler has already been found + # It may have been reset by the user, verify it is correct + if( NOT DEFINED CSHARP_DOTNET_COMPILER_${CSHARP_DOTNET_VERSION} ) + set( csharp_dotnet_version_user ${CSHARP_DOTNET_VERSION} ) + set( csharp_dotnet_valid 0 ) + set( CSHARP_DOTNET_FOUND 0 ) + set( CSHARP_DOTNET_VERSION "CSHARP_DOTNET_VERSION-NOTVALID" CACHE STRING "C# .NET compiler version, choices: ${CSHARP_DOTNET_VERSIONS}" FORCE ) + message( FATAL_ERROR "The C# .NET version '${csharp_dotnet_version_user}' is not valid. Please enter one of the following: ${CSHARP_DOTNET_VERSIONS}" ) + endif( ) +endif( ) + +unset( CSHARP_DOTNET_VERSIONS CACHE ) # Clear versions + +# Get the framework directory based on platform +if( ${CSHARP_PLATFORM} MATCHES "x64|itanium" ) + set( csharp_dotnet_framework_dir "$ENV{windir}/Microsoft.NET/Framework64" ) +else( ) + set( csharp_dotnet_framework_dir "$ENV{windir}/Microsoft.NET/Framework" ) +endif( ) + +# Search for .NET versions +string( REPLACE "\\" "/" csharp_dotnet_framework_dir ${csharp_dotnet_framework_dir} ) +file( GLOB_RECURSE csharp_dotnet_executables "${csharp_dotnet_framework_dir}/csc.exe" ) +list( SORT csharp_dotnet_executables ) +list( REVERSE csharp_dotnet_executables ) +foreach ( csharp_dotnet_executable ${csharp_dotnet_executables} ) + if( csharp_dotnet_valid ) + # Extract version number (eg. v4.0.30319) + # TODO: Consider using REGEX + string( REPLACE "${csharp_dotnet_framework_dir}/" "" csharp_dotnet_version_temp ${csharp_dotnet_executable} ) + string( REPLACE "/csc.exe" "" csharp_dotnet_version_temp ${csharp_dotnet_version_temp} ) + + # Add variable holding executable + set( CSHARP_DOTNET_COMPILER_${csharp_dotnet_version_temp} ${csharp_dotnet_executable} CACHE STRING "C# .NET compiler ${csharp_dotnet_version}" FORCE ) + mark_as_advanced( CSHARP_DOTNET_COMPILER_${csharp_dotnet_version_temp} ) + endif( ) + + # Create a list of supported compiler versions + if( NOT DEFINED CSHARP_DOTNET_VERSIONS ) + set( CSHARP_DOTNET_VERSIONS "${csharp_dotnet_version_temp}" CACHE STRING "Available C# .NET compiler versions" FORCE ) + else( ) + set( CSHARP_DOTNET_VERSIONS "${CSHARP_DOTNET_VERSIONS}, ${csharp_dotnet_version_temp}" CACHE STRING "Available C# .NET compiler versions" FORCE ) + endif( ) + mark_as_advanced( CSHARP_DOTNET_VERSIONS ) + + # We found at least one .NET compiler version + set( CSHARP_DOTNET_FOUND 1 CACHE INTERNAL "Boolean indicating if C# .NET was found" ) +endforeach( csharp_dotnet_executable ) + +if( CSHARP_DOTNET_FOUND ) + # Report the found versions + message( STATUS "Found the following C# .NET versions: ${CSHARP_DOTNET_VERSIONS}" ) + + # Set the compiler version + # Do not force, so that the user can manually select their own version if they wish + if ( DEFINED CSHARP_DOTNET_COMPILER_v2.0.50727 ) + # If available, select .NET v2.0.50727 (this is the minimal version as it supports generics, and allows use of VS2008) + set( CSHARP_DOTNET_VERSION "v2.0.50727" CACHE STRING "C# .NET compiler version" ) + else( ) + # Select the highest version (first in reverse sorted list) + list( GET CSHARP_DOTNET_VERSIONS 0 csharp_dotnet_version_temp ) + set( CSHARP_DOTNET_VERSION ${csharp_dotnet_version_temp} CACHE STRING "C# .NET compiler version" ) + endif( ) + mark_as_advanced( CSHARP_DOTNET_VERSION ) +endif( ) + +# Set USE_FILE +get_filename_component( current_list_path ${CMAKE_CURRENT_LIST_FILE} PATH ) +set( DotNetFrameworkSdk_USE_FILE ${current_list_path}/UseDotNetFrameworkSdk.cmake ) From e3282c8059c1ac872102d9a22c6e30c0981e0ce7 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 01:16:42 +0200 Subject: [PATCH 03/18] C# works on linux --- CMakeLists.txt | 12 ++- dev/cmake/Modules/FindMono.cmake | 162 +++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+), 4 deletions(-) create mode 100644 dev/cmake/Modules/FindMono.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 55e9c274..a85969fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,13 +199,17 @@ if (COOLPROP_CSHARP_MODULE) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src) set(I_FILE "${CMAKE_SOURCE_DIR}/src/CoolProp.i") - + + # Set properties before adding module SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES CPLUSPLUS ON) - SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES SWIG_FLAGS "-dllimport \"CoolProp\"") - + if (WIN32) + SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES SWIG_FLAGS "-dllimport CoolProp") + endif() SWIG_ADD_MODULE(CoolProp csharp ${I_FILE} ${APP_SOURCES}) - set_target_properties(CoolProp PROPERTIES PREFIX "") + if (WIN32) + set_target_properties(CoolProp PROPERTIES PREFIX "") + endif() endif() diff --git a/dev/cmake/Modules/FindMono.cmake b/dev/cmake/Modules/FindMono.cmake new file mode 100644 index 00000000..ed2d1f46 --- /dev/null +++ b/dev/cmake/Modules/FindMono.cmake @@ -0,0 +1,162 @@ +# +# A CMake Module for finding Mono. +# +# The following variables are set: +# CSHARP_MONO_FOUND +# CSHARP_MONO_COMPILER_${version} eg. "CSHARP_MONO_COMPILER_2.10.2" +# CSHARP_MONO_INTERPRETOR_${version} eg. "CSHARP_MONO_INTERPRETOR_2.10.2" +# CSHARP_MONO_VERSION eg. "2.10.2" +# CSHARP_MONO_VERSIONS eg. "2.10.2, 2.6.7" +# +# Additional references can be found here: +# http://www.mono-project.com/Main_Page +# http://www.mono-project.com/CSharp_Compiler +# http://mono-project.com/FAQ:_Technical (How can I tell where the Mono runtime is installed) +# +# This file is based on the work of GDCM: +# http://gdcm.svn.sf.net/viewvc/gdcm/trunk/CMake/FindMono.cmake +# Copyright (c) 2006-2010 Mathieu Malaterre +# + +set( csharp_mono_valid 1 ) +if( DEFINED CSHARP_MONO_FOUND ) + # The Mono compiler has already been found + # It may have been reset by the user, verify it is correct + if( NOT DEFINED CSHARP_MONO_COMPILER_${CSHARP_MONO_VERSION} ) + set( csharp_mono_version_user ${CSHARP_MONO_VERSION} ) + set( csharp_mono_valid 0 ) + set( CSHARP_MONO_FOUND 0 ) + set( CSHARP_MONO_VERSION "CSHARP_MONO_VERSION-NOTVALID" CACHE STRING "C# Mono compiler version, choices: ${CSHARP_MONO_VERSIONS}" FORCE ) + message( FATAL_ERROR "The C# Mono version '${csharp_mono_version_user}' is not valid. Please enter one of the following: ${CSHARP_MONO_VERSIONS}" ) + endif( NOT DEFINED CSHARP_MONO_COMPILER_${CSHARP_MONO_VERSION} ) +endif( DEFINED CSHARP_MONO_FOUND ) + +unset( CSHARP_MONO_VERSIONS CACHE ) # Clear versions +if( WIN32 ) + # Search for Mono on Win32 systems + # See http://mono-project.com/OldReleases and http://www.go-mono.com/mono-downloads/download.html + set( csharp_mono_bin_dirs ) + set( csharp_mono_search_hints + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.11.2;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10.9;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10.8;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10.7;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10.6;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10.5;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10.4;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10.3;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10.2;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10.1;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.10;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.8;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.6.7;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.6.4;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.6.3;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.6.1;SdkInstallRoot]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\2.6;SdkInstallRoot]/bin" + ) + foreach( csharp_mono_search_hint ${csharp_mono_search_hints} ) + get_filename_component( csharp_mono_bin_dir "${csharp_mono_search_hint}" ABSOLUTE ) + if ( EXISTS "${csharp_mono_bin_dir}" ) + set( csharp_mono_bin_dirs ${csharp_mono_bin_dirs} ${csharp_mono_bin_dir} ) + endif ( EXISTS "${csharp_mono_bin_dir}" ) + endforeach( csharp_mono_search_hint ) + # TODO: Use HKLM_LOCAL_MACHINE\Software\Novell\Mono\DefaultCLR to specify default version + # get_filename_component( test "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono;DefaultCLR]" NAME ) + + foreach ( csharp_mono_bin_dir ${csharp_mono_bin_dirs} ) + string( REPLACE "\\" "/" csharp_mono_bin_dir ${csharp_mono_bin_dir} ) + if (EXISTS "${csharp_mono_bin_dir}/dmcs.bat") + set( csharp_mono_executable "${csharp_mono_bin_dir}/dmcs.bat") + elseif (EXISTS "${csharp_mono_bin_dir}/gmcs.bat") + set( csharp_mono_executable "${csharp_mono_bin_dir}/gmcs.bat") + elseif (EXISTS "${csharp_mono_bin_dir}/mcs.bat") + set( csharp_mono_executable "${csharp_mono_bin_dir}/mcs.bat") + endif (EXISTS "${csharp_mono_bin_dir}/dmcs.bat") + + if( csharp_mono_valid ) + # Extract version number (eg. 2.10.2) + string(REGEX MATCH "([0-9]*)([.])([0-9]*)([.]*)([0-9]*)" csharp_mono_version_temp ${csharp_mono_bin_dir}) + set( CSHARP_MONO_VERSION ${csharp_mono_version_temp} CACHE STRING "C# Mono compiler version" ) + mark_as_advanced( CSHARP_MONO_VERSION ) + + # Add variable holding executable + set( CSHARP_MONO_COMPILER_${csharp_mono_version_temp} ${csharp_mono_executable} CACHE STRING "C# Mono compiler ${csharp_mono_version_temp}" FORCE ) + mark_as_advanced( CSHARP_MONO_COMPILER_${csharp_mono_version_temp} ) + + # Set interpreter + if (EXISTS "${csharp_mono_bin_dir}/mono.exe") + set( CSHARP_MONO_INTERPRETER_${csharp_mono_version_temp} "${csharp_mono_bin_dir}/mono.exe" CACHE STRING "C# Mono interpreter ${csharp_mono_version_temp}" FORCE ) + mark_as_advanced( CSHARP_MONO_INTERPRETER_${csharp_mono_version_temp} ) + endif (EXISTS "${csharp_mono_bin_dir}/mono.exe") + endif( csharp_mono_valid ) + + # Create a list of supported compiler versions + if( NOT DEFINED CSHARP_MONO_VERSIONS ) + set( CSHARP_MONO_VERSIONS "${csharp_mono_version_temp}" CACHE STRING "Available C# Mono compiler versions" FORCE ) + else( NOT DEFINED CSHARP_MONO_VERSIONS ) + set( CSHARP_MONO_VERSIONS "${CSHARP_MONO_VERSIONS}, ${csharp_mono_version_temp}" CACHE STRING "Available C# Mono versions" FORCE ) + endif( NOT DEFINED CSHARP_MONO_VERSIONS ) + mark_as_advanced( CSHARP_MONO_VERSIONS ) + + # We found at least one Mono compiler version + set( CSHARP_MONO_FOUND 1 CACHE INTERNAL "Boolean indicating if C# Mono was found" ) + endforeach( csharp_mono_bin_dir ) + +else( UNIX ) + # Search for Mono on non-Win32 systems + set( chsarp_mono_names "mcs" "mcs.exe" "dmcs" "dmcs.exe" "smcs" "smcs.exe" "gmcs" "gmcs.exe" ) + set( + csharp_mono_paths + "/usr/bin/" + "/usr/local/bin/" + "/usr/lib/mono/2.0" + "/opt/novell/mono/bin" + ) + find_program( + csharp_mono_compiler # variable is added to the cache, we removed it below + NAMES ${chsarp_mono_names} + PATHS ${csharp_mono_paths} + ) + + if( EXISTS ${csharp_mono_compiler} ) + # Determine version + find_program( + csharp_mono_interpreter # variable is added to the cache, we removed it below + NAMES mono + PATHS ${csharp_mono_paths} + ) + if ( EXISTS ${csharp_mono_interpreter} ) + execute_process( + COMMAND ${csharp_mono_interpreter} -V + OUTPUT_VARIABLE csharp_mono_version_string + ) + string( REGEX MATCH "([0-9]*)([.])([0-9]*)([.]*)([0-9]*)" csharp_mono_version_temp ${csharp_mono_version_string} ) + set( CSHARP_MONO_INTERPRETER_${CSHARP_MONO_VERSION} ${csharp_mono_interpreter} CACHE STRING "C# Mono interpreter ${csharp_mono_version_temp}" FORCE ) + mark_as_advanced( CSHARP_MONO_INTERPRETER_${CSHARP_MONO_VERSION} ) + endif ( EXISTS ${csharp_mono_interpreter} ) + unset( csharp_mono_interpreter CACHE ) + + # We found Mono compiler + set( CSHARP_MONO_VERSION ${csharp_mono_version_temp} CACHE STRING "C# Mono compiler version" ) + mark_as_advanced( CSHARP_MONO_VERSION ) + set( CSHARP_MONO_COMPILER_${CSHARP_MONO_VERSION} ${csharp_mono_compiler} CACHE STRING "C# Mono compiler ${CSHARP_MONO_VERSION}" FORCE ) + mark_as_advanced( CSHARP_MONO_COMPILER_${CSHARP_MONO_VERSION} ) + set( CSHARP_MONO_VERSIONS ${CSHARP_MONO_VERSION} CACHE STRING "Available C# Mono compiler versions" FORCE ) + mark_as_advanced( CSHARP_MONO_VERSIONS ) + set( CSHARP_MONO_FOUND 1 CACHE INTERNAL "Boolean indicating if C# Mono was found" ) + endif( EXISTS ${csharp_mono_compiler} ) + + # Remove temp variable from cache + unset( csharp_mono_compiler CACHE ) + +endif( WIN32 ) + +if( CSHARP_MONO_FOUND ) + # Report the found versions + message( STATUS "Found the following C# Mono versions: ${CSHARP_MONO_VERSIONS}" ) +endif( CSHARP_MONO_FOUND ) + +# Set USE_FILE +get_filename_component( current_list_path ${CMAKE_CURRENT_LIST_FILE} PATH ) +set( Mono_USE_FILE ${current_list_path}/UseMono.cmake ) From 4f1f53881f42f8dacf017a4f36dee6c415f1a634 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 11:31:43 +0200 Subject: [PATCH 04/18] Preliminary CMake for Java Signed-off-by: Ian Bell --- CMakeLists.txt | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55e9c274..e2594199 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,7 +190,7 @@ endif() if (COOLPROP_CSHARP_MODULE) - # Must have SWIG and Octave + # Must have SWIG and C# FIND_PACKAGE(SWIG REQUIRED) INCLUDE(${SWIG_USE_FILE}) FIND_PACKAGE(Csharp REQUIRED) @@ -209,6 +209,27 @@ if (COOLPROP_CSHARP_MODULE) endif() +if (COOLPROP_JAVA_MODULE) + + # Must have SWIG and Java + FIND_PACKAGE(SWIG REQUIRED) + INCLUDE(${SWIG_USE_FILE}) + FIND_PACKAGE(Java REQUIRED) + + # Make a src directory to deal with file permissions problem with MinGW makefile + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src) + + set(I_FILE "${CMAKE_SOURCE_DIR}/src/CoolProp.i") + + SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES CPLUSPLUS ON) + #SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES SWIG_FLAGS "-dllimport \"CoolProp\"") + + SWIG_ADD_MODULE(CoolProp java ${I_FILE} ${APP_SOURCES}) + + set_target_properties(CoolProp PROPERTIES PREFIX "") + +endif() + # NOT WORKING! if (COOLPROP_MATHEMATICA_MODULE) From 066dcfc413e9d877da3d0fc27c776e9cdac4501f Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 12:13:29 +0200 Subject: [PATCH 05/18] Java now works on windows Signed-off-by: Ian Bell --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e37fe03c..5703cea6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,15 +218,20 @@ if (COOLPROP_JAVA_MODULE) # Must have SWIG and Java FIND_PACKAGE(SWIG REQUIRED) INCLUDE(${SWIG_USE_FILE}) - FIND_PACKAGE(Java REQUIRED) - + find_package(Java REQUIRED) + find_package(JNI) + # Make a src directory to deal with file permissions problem with MinGW makefile file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src) + + message(STATUS "JAVA_INCLUDE_PATH = ${JAVA_INCLUDE_PATH}") + + include_directories(${JAVA_INCLUDE_PATH}) + include_directories(${JAVA_INCLUDE_PATH}/win32) set(I_FILE "${CMAKE_SOURCE_DIR}/src/CoolProp.i") SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES CPLUSPLUS ON) - #SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES SWIG_FLAGS "-dllimport \"CoolProp\"") SWIG_ADD_MODULE(CoolProp java ${I_FILE} ${APP_SOURCES}) From 9f857164fd99efc4c0f047917be734c2c9b2772c Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 12:34:37 +0200 Subject: [PATCH 06/18] Java works on linux --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5703cea6..b9ec5cd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,7 +235,13 @@ if (COOLPROP_JAVA_MODULE) SWIG_ADD_MODULE(CoolProp java ${I_FILE} ${APP_SOURCES}) - set_target_properties(CoolProp PROPERTIES PREFIX "") + if (WIN32) + set_target_properties(CoolProp PROPERTIES PREFIX "") + endif() + + if (!MSVC) + set_target_properties(COOLPROP_EES PROPERTIES COMPILE_FLAGS "-m64" LINK_FLAGS "-m64") + endif() endif() From e34cd9bd9f1578c7939b1ebbc03af88101aa89b6 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 14:42:22 +0200 Subject: [PATCH 07/18] Added surface tension for fluids covered in Mulero, JPCRD, 2014 (http://scitation.aip.org/content/aip/journal/jpcrd/43/2/10.1063/1.4878755) Signed-off-by: Ian Bell --- CoolPropBibTeXLibrary.bib | 15 +++- dev/fluids/CycloPropane.json | 11 +++ dev/fluids/Cyclopentane.json | 11 +++ dev/fluids/D4.json | 11 +++ dev/fluids/D5.json | 11 +++ dev/fluids/D6.json | 11 +++ dev/fluids/DimethylCarbonate.json | 11 +++ dev/fluids/EthylBenzene.json | 11 +++ dev/fluids/MD2M.json | 11 +++ dev/fluids/MD3M.json | 11 +++ dev/fluids/MD4M.json | 11 +++ dev/fluids/MDM.json | 11 +++ dev/fluids/MM.json | 11 +++ dev/fluids/MethylLinoleate.json | 11 +++ dev/fluids/MethylOleate.json | 11 +++ dev/fluids/MethylPalmitate.json | 13 ++++ dev/fluids/MethylStearate.json | 13 ++++ dev/fluids/Neopentane.json | 11 +++ dev/fluids/R1234ze(E).json | 13 ++++ dev/fluids/R143a.json | 6 +- dev/fluids/cis-2-Butene.json | 11 +++ dev/fluids/m-Xylene.json | 11 +++ dev/fluids/n-Undecane.json | 11 +++ dev/fluids/o-Xylene.json | 11 +++ dev/fluids/p-Xylene.json | 11 +++ dev/fluids/trans-2-Butene.json | 13 ++++ dev/package_json.py | 113 ++++++++++++++++++++++++++++-- 27 files changed, 398 insertions(+), 8 deletions(-) diff --git a/CoolPropBibTeXLibrary.bib b/CoolPropBibTeXLibrary.bib index 3651f6c9..5154c1ab 100644 --- a/CoolPropBibTeXLibrary.bib +++ b/CoolPropBibTeXLibrary.bib @@ -871,6 +871,19 @@ timestamp = {2013.09.21} } +@ARTICLE{Mulero-JPCRD-2014, + author = {A. Mulero and I. Cachadi{\~n}a}, + title = {{Recommended Correlations for the Surface Tension of Several Fluids + Included in the REFPROP Program}}, + journal = {J. Phys. Chem. Ref. Data}, + year = {2014}, + volume = {43}, + pages = {023104-1:8}, + doi = {10.1063/1.4878755}, + owner = {Belli}, + timestamp = {2014.06.10} +} + @ARTICLE{Mulero-JPCRD-2012, author = {A. Mulero and I. Cachadi{\~n}a and M. I. Parra}, title = {{Recommended Correlations for the Surface Tension of Common Fluids}}, @@ -1178,7 +1191,7 @@ @ARTICLE{SantamariaPerez-PRB-2010, author = {David Santamar{\'i}a-P{\'e}rez and Goutam Dev Mukherjee and Beate - Schwager and Reinhard Boehler}, + Schwager and Reinhard Boehler}, title = {High-pressure melting curve of helium and neon: Deviations from corresponding states theory}, journal = {Physical Review B}, diff --git a/dev/fluids/CycloPropane.json b/dev/fluids/CycloPropane.json index 22b38411..09692f9d 100644 --- a/dev/fluids/CycloPropane.json +++ b/dev/fluids/CycloPropane.json @@ -108,6 +108,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 398.3, + "a": [ + 0.06812 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.314 + ] } }, "CAS": "75-19-4", diff --git a/dev/fluids/Cyclopentane.json b/dev/fluids/Cyclopentane.json index 27d785f8..9d3e436f 100644 --- a/dev/fluids/Cyclopentane.json +++ b/dev/fluids/Cyclopentane.json @@ -108,6 +108,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 511.72, + "a": [ + 0.07348 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.388 + ] } }, "CAS": "287-92-3", diff --git a/dev/fluids/D4.json b/dev/fluids/D4.json index 2be20f0a..1e2dacd0 100644 --- a/dev/fluids/D4.json +++ b/dev/fluids/D4.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 586.5, + "a": [ + 0.04246 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.207 + ] } }, "CAS": "556-67-2", diff --git a/dev/fluids/D5.json b/dev/fluids/D5.json index 84d51322..629aab4b 100644 --- a/dev/fluids/D5.json +++ b/dev/fluids/D5.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 619.15, + "a": [ + 0.04408 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.357 + ] } }, "CAS": "541-02-6", diff --git a/dev/fluids/D6.json b/dev/fluids/D6.json index f05af3a5..326e7c5d 100644 --- a/dev/fluids/D6.json +++ b/dev/fluids/D6.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 645.78, + "a": [ + 0.05105 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.594 + ] } }, "CAS": "540-97-6", diff --git a/dev/fluids/DimethylCarbonate.json b/dev/fluids/DimethylCarbonate.json index 0812be52..548b4263 100644 --- a/dev/fluids/DimethylCarbonate.json +++ b/dev/fluids/DimethylCarbonate.json @@ -108,6 +108,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 557.0, + "a": [ + 0.0825 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.39 + ] } }, "CAS": "616-38-6", diff --git a/dev/fluids/EthylBenzene.json b/dev/fluids/EthylBenzene.json index 74f5b442..a61a28c8 100644 --- a/dev/fluids/EthylBenzene.json +++ b/dev/fluids/EthylBenzene.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 617.12, + "a": [ + 0.0638 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.22 + ] } }, "CAS": "100-41-4", diff --git a/dev/fluids/MD2M.json b/dev/fluids/MD2M.json index 001996cb..661e63f3 100644 --- a/dev/fluids/MD2M.json +++ b/dev/fluids/MD2M.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 599.4, + "a": [ + 0.0456 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.41 + ] } }, "CAS": "141-62-8", diff --git a/dev/fluids/MD3M.json b/dev/fluids/MD3M.json index a2717049..2b64e4f2 100644 --- a/dev/fluids/MD3M.json +++ b/dev/fluids/MD3M.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 628.36, + "a": [ + 0.03972 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.254 + ] } }, "CAS": "141-63-9", diff --git a/dev/fluids/MD4M.json b/dev/fluids/MD4M.json index 6a0e2517..a42c39b0 100644 --- a/dev/fluids/MD4M.json +++ b/dev/fluids/MD4M.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 653.2, + "a": [ + 0.040798 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.3323 + ] } }, "CAS": "107-52-8", diff --git a/dev/fluids/MDM.json b/dev/fluids/MDM.json index c1735569..fa945373 100644 --- a/dev/fluids/MDM.json +++ b/dev/fluids/MDM.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 564.09, + "a": [ + 0.04992 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.465 + ] } }, "CAS": "107-51-7", diff --git a/dev/fluids/MM.json b/dev/fluids/MM.json index 4bd9d1a4..4c87d88c 100644 --- a/dev/fluids/MM.json +++ b/dev/fluids/MM.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 518.75, + "a": [ + 0.04576 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.272 + ] } }, "CAS": "107-46-0", diff --git a/dev/fluids/MethylLinoleate.json b/dev/fluids/MethylLinoleate.json index f8212076..4d927db2 100644 --- a/dev/fluids/MethylLinoleate.json +++ b/dev/fluids/MethylLinoleate.json @@ -106,6 +106,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 799.0, + "a": [ + 0.072487 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.9014 + ] } }, "CAS": "112-63-0", diff --git a/dev/fluids/MethylOleate.json b/dev/fluids/MethylOleate.json index 6e3c7e62..2bd5fe74 100644 --- a/dev/fluids/MethylOleate.json +++ b/dev/fluids/MethylOleate.json @@ -106,6 +106,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 782.0, + "a": [ + 0.0565 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.31 + ] } }, "CAS": "112-62-9", diff --git a/dev/fluids/MethylPalmitate.json b/dev/fluids/MethylPalmitate.json index 237099a4..9e502369 100644 --- a/dev/fluids/MethylPalmitate.json +++ b/dev/fluids/MethylPalmitate.json @@ -106,6 +106,19 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 755.0, + "a": [ + 0.025025, + 0.044435 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 3.039, + 1.1653 + ] } }, "CAS": "112-39-0", diff --git a/dev/fluids/MethylStearate.json b/dev/fluids/MethylStearate.json index 0ad1c170..b2b916b8 100644 --- a/dev/fluids/MethylStearate.json +++ b/dev/fluids/MethylStearate.json @@ -106,6 +106,19 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 775.0, + "a": [ + 0.02313, + 0.04567 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 3.242, + 1.163 + ] } }, "CAS": "112-61-8", diff --git a/dev/fluids/Neopentane.json b/dev/fluids/Neopentane.json index 23e4de25..85139b49 100644 --- a/dev/fluids/Neopentane.json +++ b/dev/fluids/Neopentane.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 433.74, + "a": [ + 0.04465 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.21 + ] } }, "CAS": "463-82-1", diff --git a/dev/fluids/R1234ze(E).json b/dev/fluids/R1234ze(E).json index f946015c..8f4aed7f 100644 --- a/dev/fluids/R1234ze(E).json +++ b/dev/fluids/R1234ze(E).json @@ -108,6 +108,19 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 382.51, + "a": [ + 0.06158, + 0.8247 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.281, + 6.505 + ] } }, "CAS": "29118-24-9", diff --git a/dev/fluids/R143a.json b/dev/fluids/R143a.json index c0e52c8f..c8b0174d 100644 --- a/dev/fluids/R143a.json +++ b/dev/fluids/R143a.json @@ -108,14 +108,14 @@ "using_tau_r": true }, "surface_tension": { - "BibTeX": "Mulero-JPCRD-2012", + "BibTeX": "Mulero-JPCRD-2014", "Tc": 345.857, "a": [ - 0.05416 + 0.0537 ], "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", "n": [ - 1.255 + 1.25 ] } }, diff --git a/dev/fluids/cis-2-Butene.json b/dev/fluids/cis-2-Butene.json index a0316ee6..45b08599 100644 --- a/dev/fluids/cis-2-Butene.json +++ b/dev/fluids/cis-2-Butene.json @@ -107,6 +107,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 435.75, + "a": [ + 0.05903 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.246 + ] } }, "CAS": "590-18-1", diff --git a/dev/fluids/m-Xylene.json b/dev/fluids/m-Xylene.json index 5eb34036..0c84b6e5 100644 --- a/dev/fluids/m-Xylene.json +++ b/dev/fluids/m-Xylene.json @@ -108,6 +108,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 616.89, + "a": [ + 0.06445 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.256 + ] } }, "CAS": "108-38-3", diff --git a/dev/fluids/n-Undecane.json b/dev/fluids/n-Undecane.json index 9f395533..2bbbf681 100644 --- a/dev/fluids/n-Undecane.json +++ b/dev/fluids/n-Undecane.json @@ -109,6 +109,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 638.8, + "a": [ + 0.0556 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.32 + ] } }, "CAS": "1120-21-4", diff --git a/dev/fluids/o-Xylene.json b/dev/fluids/o-Xylene.json index e1c21a9d..e28ff120 100644 --- a/dev/fluids/o-Xylene.json +++ b/dev/fluids/o-Xylene.json @@ -108,6 +108,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 630.259, + "a": [ + 0.06477 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.227 + ] } }, "CAS": "95-47-6", diff --git a/dev/fluids/p-Xylene.json b/dev/fluids/p-Xylene.json index 4aefbd68..cf7b7448 100644 --- a/dev/fluids/p-Xylene.json +++ b/dev/fluids/p-Xylene.json @@ -108,6 +108,17 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 616.168, + "a": [ + 0.0619 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 1.21 + ] } }, "CAS": "106-42-3", diff --git a/dev/fluids/trans-2-Butene.json b/dev/fluids/trans-2-Butene.json index 78136ecf..e6baf53f 100644 --- a/dev/fluids/trans-2-Butene.json +++ b/dev/fluids/trans-2-Butene.json @@ -107,6 +107,19 @@ ], "type": "rhoV", "using_tau_r": true + }, + "surface_tension": { + "BibTeX": "Mulero-JPCRD-2014", + "Tc": 428.61, + "a": [ + 0.0001859, + 0.05539 + ], + "description": "sigma = sum(a_i*(1-T/Tc)^n_i)", + "n": [ + 0.07485, + 1.224 + ] } }, "CAS": "624-64-6", diff --git a/dev/package_json.py b/dev/package_json.py index b4c3e8a5..222c17fe 100644 --- a/dev/package_json.py +++ b/dev/package_json.py @@ -5,7 +5,7 @@ json_options = {'indent' : 2, 'sort_keys' : True} # Data from Mulero, JPCRD, 2012 # CAS codes added from CoolProp 4.2, and wikipedia where necessary -Mulero_data = """67-64-1 Acetone 0.0633 1.160 +Mulero2012_data = """67-64-1 Acetone 0.0633 1.160 7664-41-7 Ammonia 0.1028 1.211 -0.09453 5.585 7440-37-1 Argon 0.037 1.25 71-43-2 Benzene 0.07298 1.232 -0.0007802 0.8635 -0.0001756 0.3065 @@ -87,7 +87,7 @@ Mulero_data = """67-64-1 Acetone 0.0633 1.160 7732-18-5 Water -0.1306 2.471 0.2151 1.233 7440-63-3 Xenon -0.11538 1.0512 0.16598 1.098""" -def inject_surface_tension(root_dir): +def inject_surface_tension_2012(root_dir): print("*** Injecting surface tension curves from Mulero") Tc_dict = {'Argon':150.687, 'Benzene':562.02, @@ -174,7 +174,7 @@ def inject_surface_tension(root_dir): } import glob, json, os - for row in Mulero_data.split('\n'): + for row in Mulero2012_data.split('\n'): row = row.split(' ') cas = row.pop(0) name = row.pop(0) @@ -207,6 +207,109 @@ def inject_surface_tension(root_dir): fp = open(fname, 'w') fp.write(json.dumps(j, **json_options)) fp.close() + + +Mulero2014_data = """cis-2-butene 435.75 0.05903 1.246 +Cyclopentane 511.72 0.07348 1.388 +Cyclopropane 398.3 0.06812 1.314 +Decamethylcyclopentasiloxane 619.15 0.04408 1.357 +Decamethyltetrasiloxane 599.4 0.0456 1.41 +Diethyl ether 466.7 1.2348 1.4846 1.1808 1.5021 +Dimethyl carbonate (Dimethyl ester carbonic acid) 557 0.0825 1.39 +Dodecamethylcyclohexasiloxane 645.78 0.05105 1.594 +Dodecamethylpentasiloxane 628.36 0.03972 1.254 +Ethylbenzene 617.12 0.0638 1.22 +Ethylene oxide 468.92 0.07542 1.151 +Hexamethyldisiloxane 518.75 0.04576 1.272 +Hydrogen chloride 21 0.05994 1.0953 +Isooctane (2,2,4- trimethylpentane) 543.87 0.04794 1.209 +Methyl linoleate (Methyl (Z,Z)- 9,12-octadecadienoate) 799 0.072487 1.9014 +Methyl oleate (Methyl cis-9-octadecenoate) 782 0.0565 1.31 +Methyl palmitate (Methyl hexadecanoate) 755 0.025025 3.039 0.044435 1.1653 +Methyl stearate (Methyl octadecanoate) 775 0.02313 3.242 0.04567 1.163 +Methylcyclohexane 572.2 0.0606 1.3 +m-xylene (1,3-dimethylbenzene) 616.89 0.06445 1.256 +Neopentane (2,2- dimethylpropane) 433.74 0.04465 1.21 +Nitrogen trifluoride 234 0.063203 1.2565 +Octamethylcyclotetrasiloxane 586.5 0.04246 1.207 +Octamethyltrisiloxane 564.09 0.04992 1.465 +o-xylene (1,2-dimethylbenzene) 630.259 0.06477 1.227 +Propylcyclohexane 630.8 0.055 1.17 +p-xylene 616.168 0.0619 1.21 +R1216 (Hexafluoropropene) 358.9 0.053876 1.0944 0.038318 2.3239 +R1234ze(E) (trans-1,3,3,3-tetrafluoropropene) 382.51 0.06158 1.281 0.8247 6.505 +R143a (1,1,1-Trifluoroethane) 345.857 0.0537 1.25 +R40 (Methyl chloride) 416.3 0.071315 1.2177 +RE245cb2 (Methyl-pentafluoroethyl ether) 406.813 0.04534 1.237 +RE245fa2 (2,2,2-trifluoroethyl-difluoromethyl ether) 444.88 0.0699 1.222 +RE347mcc (HFE-7000 or Methyl-heptafluoropropyl ether) 437.7 0.05031 1.232 +Tetradecamethylhexasiloxane 653.2 0.040798 1.3323 +trans-2-butene 428.61 0.0001859 0.07485 0.05539 1.224 +Undecane 638.8 0.0556 1.32""" + +def inject_surface_tension_2014(root_dir): + rename = {'Undecane': 'n-Undecane', + 'm-xylene (1,3-dimethylbenzene)': 'm-Xylene', + 'o-xylene (1,2-dimethylbenzene)': 'o-Xylene', + 'R1234ze(E) (trans-1,3,3,3-tetrafluoropropene)':'R1234ze(E)', + 'R143a (1,1,1-Trifluoroethane)':'R143a', + 'Methyl linoleate (Methyl (Z,Z)- 9,12-octadecadienoate)':'MethylLinoleate', + 'Methyl oleate (Methyl cis-9-octadecenoate)':'MethylOleate', + 'Methyl palmitate (Methyl hexadecanoate)':'MethylPalmitate', + 'Methyl stearate (Methyl octadecanoate)':'MethylStearate', + 'Dimethyl carbonate (Dimethyl ester carbonic acid)':'DimethylCarbonate', + 'Hexamethyldisiloxane': 'MM', + 'Tetradecamethylhexasiloxane':'MD4M', + 'Dodecamethylpentasiloxane':'MD3M', + 'Octamethyltrisiloxane':'MDM', + 'Decamethyltetrasiloxane':'MD2M', + 'Octamethylcyclotetrasiloxane':'D4', + 'Dodecamethylcyclohexasiloxane':'D6', + 'Decamethylcyclopentasiloxane':'D5', + 'Diethyl ether':'DiethylEther', + 'Neopentane (2,2- dimethylpropane)':'Neopentane' + } + import glob, json, os + for line in Mulero2014_data.split('\n'): + + row = line.split(' ') + #print(row) + values = [] + j = 0 + for i in range(len(row)): + try: + values.append(float(row[i])) + except: + j = i + + name = ' '.join(row[0:j+1]) + + Tc = values.pop(0) + a = values[0:len(row):2] + n = values[1:len(row):2] + + # The dictionary of values for the surface tension + j_st = dict(Tc = Tc, + a = a, + n = n, + BibTeX = 'Mulero-JPCRD-2014', + description = 'sigma = sum(a_i*(1-T/Tc)^n_i)' + ) + + if name in rename: + name = rename[name] + fname = os.path.join(root_dir,'dev','fluids',name+'.json') + if not os.path.exists(fname): + print(fname + ' does not exist') + continue + + j = json.load(open(fname,'r')) + + j['ANCILLARIES']['surface_tension'] = j_st + + fp = open(fname, 'w') + fp.write(json.dumps(j, **json_options)) + fp.close() def inject_environmental_data(root_dir): print('*** Injecting environmental data from DTU') @@ -242,8 +345,9 @@ def inject_ancillaries(root_dir): fp.write(json.dumps(fluid, **json_options)) def inject(root_dir): + inject_surface_tension_2014(root_dir) inject_ancillaries(root_dir) - inject_surface_tension(root_dir) + inject_surface_tension_2012(root_dir) inject_environmental_data(root_dir) def combine_json(root_dir): @@ -291,4 +395,5 @@ def combine_json(root_dir): fp.close() if __name__=='__main__': + inject_surface_tension_2014(root_dir = '..') combine_json(root_dir = '..') \ No newline at end of file From b4791ed33a417f302796f457306638ab06f9a622 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 15:21:24 +0200 Subject: [PATCH 08/18] Implemented the viscosity correlation for n-Heptane of Assael, JPCRD, 2014 (http://scitation.aip.org/content/aip/journal/jpcrd/43/2/10.1063/1.4875930) and testing data Signed-off-by: Ian Bell --- dev/fluids/n-Heptane.json | 51 +++++++++++++++++++ include/CoolPropFluid.h | 1 + src/Backends/Helmholtz/Fluids/FluidLibrary.h | 3 ++ .../Helmholtz/HelmholtzEOSMixtureBackend.cpp | 2 + src/Backends/Helmholtz/TransportRoutines.cpp | 11 ++++ src/Backends/Helmholtz/TransportRoutines.h | 31 +++++------ src/Tests/CoolProp-Tests.cpp | 16 ++++-- 7 files changed, 96 insertions(+), 19 deletions(-) diff --git a/dev/fluids/n-Heptane.json b/dev/fluids/n-Heptane.json index b5b06ed2..20469d9c 100644 --- a/dev/fluids/n-Heptane.json +++ b/dev/fluids/n-Heptane.json @@ -394,6 +394,57 @@ ], "type": "polynomial" } + }, + "viscosity": { + "BibTeX": "Assael-JPCRD-2014-Heptane", + "dilute": { + "C": 2.1357e-08, + "a": [ + 0.33974, + -0.49396, + 0.08050 + ], + "molar_mass": 0.100202, + "molar_mass_units": "kg/mol", + "t": [ + 0, + 1, + 3 + ], + "type": "collision_integral" + }, + "epsilon_over_k": 426.118, + "epsilon_over_k_units": "K", + "higher_order": { + "hardcoded": "n-Heptane" + }, + "initial_density": { + "b": [ + -19.572881, + 219.73999, + -1015.3226, + 2471.01251, + -3375.1717, + 2491.6597, + -787.26086, + 14.085455, + -0.34664158 + ], + "t": [ + 0, + -0.25, + -0.5, + -0.75, + -1.0, + -1.25, + -1.5, + -2.5, + -5.5 + ], + "type": "Rainwater-Friend" + }, + "sigma_eta": 0.61362e-9, + "sigma_eta_units": "m" } } } \ No newline at end of file diff --git a/include/CoolPropFluid.h b/include/CoolPropFluid.h index 469b14c4..c4088f70 100644 --- a/include/CoolPropFluid.h +++ b/include/CoolPropFluid.h @@ -188,6 +188,7 @@ struct ViscosityHigherOrderVariables enum ViscosityDiluteEnum {VISCOSITY_HIGHER_ORDER_BATSCHINKI_HILDEBRAND, VISCOSITY_HIGHER_ORDER_HYDROGEN, VISCOSITY_HIGHER_ORDER_HEXANE, + VISCOSITY_HIGHER_ORDER_HEPTANE, VISCOSITY_HIGHER_ORDER_ETHANE, VISCOSITY_HIGHER_ORDER_FRICTION_THEORY, VISCOSITY_HIGHER_ORDER_NOT_SET diff --git a/src/Backends/Helmholtz/Fluids/FluidLibrary.h b/src/Backends/Helmholtz/Fluids/FluidLibrary.h index f21ade87..8727eaf7 100644 --- a/src/Backends/Helmholtz/Fluids/FluidLibrary.h +++ b/src/Backends/Helmholtz/Fluids/FluidLibrary.h @@ -427,6 +427,9 @@ protected: else if (!target.compare("n-Hexane")){ fluid.transport.viscosity_higher_order.type = CoolProp::ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_HEXANE; return; } + else if (!target.compare("n-Heptane")){ + fluid.transport.viscosity_higher_order.type = CoolProp::ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_HEPTANE; return; + } else if (!target.compare("Ethane")){ fluid.transport.viscosity_higher_order.type = CoolProp::ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_ETHANE; return; } diff --git a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp index 625164d1..3341d60e 100644 --- a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp +++ b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp @@ -189,6 +189,8 @@ long double HelmholtzEOSMixtureBackend::calc_viscosity_background(long double et delta_eta_h = TransportRoutines::viscosity_hydrogen_higher_order_hardcoded(*this); break; case ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_HEXANE: delta_eta_h = TransportRoutines::viscosity_hexane_higher_order_hardcoded(*this); break; + case ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_HEPTANE: + delta_eta_h = TransportRoutines::viscosity_heptane_higher_order_hardcoded(*this); break; case ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_ETHANE: delta_eta_h = TransportRoutines::viscosity_ethane_higher_order_hardcoded(*this); break; default: diff --git a/src/Backends/Helmholtz/TransportRoutines.cpp b/src/Backends/Helmholtz/TransportRoutines.cpp index 828772e3..296a3c10 100644 --- a/src/Backends/Helmholtz/TransportRoutines.cpp +++ b/src/Backends/Helmholtz/TransportRoutines.cpp @@ -280,6 +280,7 @@ long double TransportRoutines::viscosity_hydrogen_higher_order_hardcoded(Helmhol long double TransportRoutines::viscosity_hexane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS) { + long double Tr = HEOS.T()/507.82, rhor = HEOS.keyed_output(CoolProp::iDmass)/233.182; // Output is in Pa-s @@ -287,6 +288,16 @@ long double TransportRoutines::viscosity_hexane_higher_order_hardcoded(Helmholtz return pow(rhor,static_cast(2.0/3.0))*sqrt(Tr)*(c[0]/Tr+c[1]/(c[2]+Tr+c[3]*rhor*rhor)+c[4]*(1+rhor)/(c[5]+c[6]*Tr+c[7]*rhor+rhor*rhor+c[8]*rhor*Tr)); } +long double TransportRoutines::viscosity_heptane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS) +{ + /// From Assael, JPCRD, 2014 + long double Tr = HEOS.T()/540.13, rhor = HEOS.rhomass()/232; + + // Output is in Pa-s + double c[] = {0, 22.15000/1e6, -15.00870/1e6, 3.71791/1e6, 77.72818/1e6, 9.73449, 9.51900, -6.34076, -2.51909}; + return pow(rhor,2.0L/3.0L)*sqrt(Tr)*(c[1]*rhor+c[2]*pow(rhor,2)+c[3]*pow(rhor,3)+c[4]*rhor/(c[5]+c[6]*Tr+c[7]*rhor+rhor*rhor+c[8]*rhor*Tr)); +} + long double TransportRoutines::viscosity_higher_order_friction_theory(HelmholtzEOSMixtureBackend &HEOS) { if (HEOS.is_pure_or_pseudopure) diff --git a/src/Backends/Helmholtz/TransportRoutines.h b/src/Backends/Helmholtz/TransportRoutines.h index 29afef5b..cd74e24c 100644 --- a/src/Backends/Helmholtz/TransportRoutines.h +++ b/src/Backends/Helmholtz/TransportRoutines.h @@ -20,7 +20,7 @@ public: with \f$T^* = \frac{T}{\varepsilon/k}\f$ and \f$\sigma\f$ in nm, M is in kg/kmol. Yields viscosity in Pa-s. */ static long double viscosity_dilute_kinetic_theory(HelmholtzEOSMixtureBackend &HEOS); - + /** \brief The dilute gas viscosity term that is based on collision integral or effective cross section @@ -34,7 +34,7 @@ public: */ static long double viscosity_dilute_collision_integral(HelmholtzEOSMixtureBackend &HEOS); - /** + /** \brief A dilute gas viscosity term formed of summation of power terms \f[ @@ -46,7 +46,7 @@ public: static long double viscosity_dilute_collision_integral_powers_of_T(HelmholtzEOSMixtureBackend &HEOS); - /** + /** \brief The initial density dependence term \f$B_{\eta}\f$ from Rainwater-Friend theory The total contribution from this term is given by @@ -68,17 +68,17 @@ public: */ static long double viscosity_initial_density_dependence_Rainwater_Friend(HelmholtzEOSMixtureBackend &HEOS); - /** + /** \brief The modified Batschinski-Hildebrand contribution to the viscosity \f[ \Delta\eta = \displaystyle\sum_{i}a_{i}\delta^{d1_i}\tau^{t1_j}+\left(\displaystyle\sum_{i}f_i\delta^{d2_i}\tau^{t2_i}\right)\left(\frac{1}{\delta_0(\tau)-\delta}-\frac{1}{\delta_0(\tau)}\right) \f] - where \f$\tau = T_c/T\f$ and \f$\delta = \rho/\rho_c\f$ + where \f$\tau = T_c/T\f$ and \f$\delta = \rho/\rho_c\f$ \f[ \delta_0(\tau) = \displaystyle\frac{\displaystyle\sum_{i}g_i\tau^{h_i}}{\displaystyle\sum_{i}p_i\tau^{q_i}} \f] - The more general form of \f$\delta_0(\tau)\f$ is selected in order to be able to handle all the forms in the literature + The more general form of \f$\delta_0(\tau)\f$ is selected in order to be able to handle all the forms in the literature */ static long double viscosity_higher_order_modified_Batschinski_Hildebrand(HelmholtzEOSMixtureBackend &HEOS); @@ -91,6 +91,7 @@ public: static long double viscosity_ethane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS); static long double viscosity_hydrogen_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS); static long double viscosity_hexane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS); + static long double viscosity_heptane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS); static long double viscosity_higher_order_friction_theory(HelmholtzEOSMixtureBackend &HEOS); /** @@ -110,7 +111,7 @@ public: \Delta\lambda(\rho,T) = \displaystyle\sum_iA_i\tau^{t,i}\delta^{d_i} \f] - As used by Assael, Perkins, Huber, etc., the residual term is given by + As used by Assael, Perkins, Huber, etc., the residual term is given by \f[ \Delta\lambda(\rho,T) = \displaystyle\sum_i(B_{1,i}+B_{2,i}(T/T_c))(\rho/\rho_c)^i \f] @@ -135,9 +136,9 @@ public: \f[ \zeta = \zeta_0\left(\frac{p_c\rho}{\Gamma\rho_c^2}\right)^{\nu/\gamma}\left[\left.\frac{\partial \rho(T,\rho)}{\partial p} \right|_{T}- \frac{T_R}{T}\left.\frac{\partial \rho(T_R,\rho)}{\partial p} \right|_{T} \right]^{\nu/\gamma}, \f] - where \f$\lambda^{(c)}\f$ is in W\f$\cdot\f$m\f$^{-1}\f$\f$\cdot\f$K\f$^{-1}\f$, \f$\zeta\f$ is in m, - \f$c_p\f$ and \f$c_v\f$ are in J\f$\cdot\f$kg\f$^{-1}\cdot\f$K\f$^{-1}\f$, \f$p\f$ and \f$p_c\f$ are in Pa, - \f$\rho\f$ and \f$\rho_c\f$ are in mol\f$\cdot\f$m\f$^{-3}\f$, \f$\eta\f$ is the viscosity in Pa\f$\cdot\f$s, + where \f$\lambda^{(c)}\f$ is in W\f$\cdot\f$m\f$^{-1}\f$\f$\cdot\f$K\f$^{-1}\f$, \f$\zeta\f$ is in m, + \f$c_p\f$ and \f$c_v\f$ are in J\f$\cdot\f$kg\f$^{-1}\cdot\f$K\f$^{-1}\f$, \f$p\f$ and \f$p_c\f$ are in Pa, + \f$\rho\f$ and \f$\rho_c\f$ are in mol\f$\cdot\f$m\f$^{-3}\f$, \f$\eta\f$ is the viscosity in Pa\f$\cdot\f$s, and the remaining parameters are defined in the following tables. It should be noted that some authors use slightly different values for the "universal" constants @@ -145,9 +146,9 @@ public: Coefficients for use in the simplified Olchowy-Sengers critical term Parameter | Variable | Value --------- | -------- | ------ - Boltzmann constant | \f$k\f$ | \f$1.3806488\times 10^{-23}\f$ J\f$\cdot\f$K\f$^{-1}\f$ - Universal amplitude | \f$R_D\f$ | 1.03 - Critical exponent | \f$\nu\f$ | 0.63 + Boltzmann constant | \f$k\f$ | \f$1.3806488\times 10^{-23}\f$ J\f$\cdot\f$K\f$^{-1}\f$ + Universal amplitude | \f$R_D\f$ | 1.03 + Critical exponent | \f$\nu\f$ | 0.63 Critical exponent | \f$\gamma\f$ | 1.239 Reference temperature | \f$T_R\f$ | 1.5\f$T_c\f$ @@ -182,7 +183,7 @@ public: Bell, I. H.; Wronski, J.; Quoilin, S. & Lemort, V. (2014), Pure and Pseudo-pure Fluid Thermophysical Property Evaluation and the Open-Source Thermophysical Property Library CoolProp, Industrial & Engineering Chemistry Research, 53, (6), 2498-2508 - which is originally based on the methods presented in + which is originally based on the methods presented in Huber, M. L., Laesecke, A. and Perkins, R. A., (2003), Model for the Viscosity and Thermal Conductivity of Refrigerants, Including a New Correlation for the Viscosity of R134a, Industrial & Engineering Chemistry Research, v. 42, pp. 3163-3178 @@ -200,4 +201,4 @@ public: }; /* class TransportRoutines */ }; /* namespace CoolProp */ -#endif \ No newline at end of file +#endif diff --git a/src/Tests/CoolProp-Tests.cpp b/src/Tests/CoolProp-Tests.cpp index c2a0687d..8dabb84f 100644 --- a/src/Tests/CoolProp-Tests.cpp +++ b/src/Tests/CoolProp-Tests.cpp @@ -108,6 +108,14 @@ vel("Hexane", "T", 250, "Dmass", 700, "V", 528.2e-6, 1e-3), vel("Hexane", "T", 400, "Dmass", 600, "V", 177.62e-6, 1e-3), vel("Hexane", "T", 550, "Dmass", 500, "V", 95.002e-6, 1e-3), +// From Assael, JPCRD, 2014 +vel("Heptane", "T", 250, "Dmass", 1e-14, "V", 4.9717e-6, 1e-3), +vel("Heptane", "T", 400, "Dmass", 1e-14, "V", 7.8361e-6, 1e-3), +vel("Heptane", "T", 550, "Dmass", 1e-14, "V", 10.7394e-6, 1e-3), +vel("Heptane", "T", 250, "Dmass", 720, "V", 725.69e-6, 1e-3), +vel("Heptane", "T", 400, "Dmass", 600, "V", 175.94e-6, 1e-3), +vel("Heptane", "T", 550, "Dmass", 500, "V", 95.105e-6, 1e-3), + // From Fenghour, JPCRD, 1998 vel("CO2", "T", 220, "Dmass", 2.440, "V", 11.06e-6, 1e-3), vel("CO2", "T", 300, "Dmass", 1.773, "V", 15.02e-6, 1e-3), @@ -263,10 +271,10 @@ vel("Hexane", "T", 400, "Dmass", 650, "L", 129.28e-3, 2e-4), vel("Hexane", "T", 510, "Dmass", 2, "L", 36.772e-3, 1e-4), // From Assael, JPCRD, 2013 -//vel("Heptane", "T", 250, "Dmass", 720, "L", 137.09e-3, 1e-4), -//vel("Heptane", "T", 400, "Dmass", 2, "L", 21.794e-3, 1e-4), -//vel("Heptane", "T", 400, "Dmass", 650, "L", 120.75e-3, 1e-4), -//vel("Heptane", "T", 535, "Dmass", 100, "L", 51.655e-3, 1e-4), +vel("Heptane", "T", 250, "Dmass", 720, "L", 137.09e-3, 1e-4), +vel("Heptane", "T", 400, "Dmass", 2, "L", 21.794e-3, 1e-4), +vel("Heptane", "T", 400, "Dmass", 650, "L", 120.75e-3, 1e-4), +vel("Heptane", "T", 535, "Dmass", 100, "L", 51.655e-3, 1e-4), // From Assael, JPCRD, 2013 vel("Ethanol", "T", 300, "Dmass", 850, "L", 209.68e-3, 1e-4), From 68d943c92a8665f7ba86f85e62c0a879628f8d29 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 15:24:00 +0200 Subject: [PATCH 09/18] Updated reference for Heptane Signed-off-by: Ian Bell --- CoolPropBibTeXLibrary.bib | 13 +++++++++++++ dev/fluids/n-Heptane.json | 2 +- src/Backends/Helmholtz/TransportRoutines.cpp | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CoolPropBibTeXLibrary.bib b/CoolPropBibTeXLibrary.bib index 5154c1ab..5f9ba1c1 100644 --- a/CoolPropBibTeXLibrary.bib +++ b/CoolPropBibTeXLibrary.bib @@ -858,6 +858,19 @@ timestamp = {2013.04.09} } +@ARTICLE{Michailidou-JPCRD-2014-Heptane, + author = {E. K. Michailidou and M. J. Assael and M. L. Huber and I. M. Abdulagatov + and R. A. Perkins}, + title = {Reference Correlation of the Viscosity of n-Heptane from the Triple + Point to 600 K and up to 248 MPa}, + journal = {J. Phys. Chem. Ref. Data}, + year = {2014}, + volume = {43}, + pages = {023103}, + owner = {Belli}, + timestamp = {2014.06.10} +} + @ARTICLE{Michailidou-JPCRD-2013, author = {E. K. Michailidou and M. J. Assael and M. L. Huber and R. A. Perkins}, title = {{Reference Correlation of the Viscosity of n-Hexane from the Triple diff --git a/dev/fluids/n-Heptane.json b/dev/fluids/n-Heptane.json index 20469d9c..348b7627 100644 --- a/dev/fluids/n-Heptane.json +++ b/dev/fluids/n-Heptane.json @@ -396,7 +396,7 @@ } }, "viscosity": { - "BibTeX": "Assael-JPCRD-2014-Heptane", + "BibTeX": "Michailidou-JPCRD-2014-Heptane", "dilute": { "C": 2.1357e-08, "a": [ diff --git a/src/Backends/Helmholtz/TransportRoutines.cpp b/src/Backends/Helmholtz/TransportRoutines.cpp index 296a3c10..b7c91f06 100644 --- a/src/Backends/Helmholtz/TransportRoutines.cpp +++ b/src/Backends/Helmholtz/TransportRoutines.cpp @@ -290,7 +290,7 @@ long double TransportRoutines::viscosity_hexane_higher_order_hardcoded(Helmholtz long double TransportRoutines::viscosity_heptane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS) { - /// From Assael, JPCRD, 2014 + /// From Michailidou-JPCRD-2014-Heptane long double Tr = HEOS.T()/540.13, rhor = HEOS.rhomass()/232; // Output is in Pa-s From ce5e41412e6e388953ad6a12abf380ab14ea6232 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 15:24:40 +0200 Subject: [PATCH 10/18] hashes.json file gets saved in the right place Signed-off-by: Ian Bell --- dev/generate_headers.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/dev/generate_headers.py b/dev/generate_headers.py index 1632a85e..312d720e 100644 --- a/dev/generate_headers.py +++ b/dev/generate_headers.py @@ -14,8 +14,10 @@ import hashlib def get_hash(data): return hashlib.sha224(data).hexdigest() +repo_root_path = os.path.normpath(os.path.join(os.path.abspath(__file__),'..','..')) + # Load up the hashes of the data that will be written to each file -if os.path.exists('hashes.json'): +if os.path.exists(os.path.join(repo_root_path,'dev','hashes.json')): hashes = json.load(open('hashes.json','r')) else: hashes = dict() @@ -99,22 +101,19 @@ def gitrev_to_file(root_dir): pass if __name__=='__main__': - path = os.path.abspath(__file__) - path = os.path.dirname(path) - path = os.path.dirname(path) import shutil - shutil.copy2(os.path.join(path, 'externals','Catch','single_include','catch.hpp'),os.path.join(path,'include','catch.hpp')) + shutil.copy2(os.path.join(repo_root_path, 'externals','Catch','single_include','catch.hpp'),os.path.join(repo_root_path,'include','catch.hpp')) - version_to_file(root_dir = path) - gitrev_to_file(root_dir = path) + version_to_file(root_dir = repo_root_path) + gitrev_to_file(root_dir = repo_root_path) import JSON_to_CPP - JSON_to_CPP.TO_CPP(root_dir = path, hashes = hashes) + JSON_to_CPP.TO_CPP(root_dir = repo_root_path, hashes = hashes) # Write the hashes to a hashes JSON file if hashes: - fp = open('hashes.json','w') + fp = open(os.path.join(repo_root_path,'dev','hashes.json'),'w') fp.write(json.dumps(hashes)) fp.close() From 6ce2b4426f4e8bdace40cc0a5e1ef850eef9e0ce Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 15:50:30 +0200 Subject: [PATCH 11/18] Small modifications to the conductivity of Heptane Signed-off-by: Ian Bell --- dev/fluids/n-Heptane.json | 3 ++- src/Tests/CoolProp-Tests.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/fluids/n-Heptane.json b/dev/fluids/n-Heptane.json index 348b7627..9766bbc0 100644 --- a/dev/fluids/n-Heptane.json +++ b/dev/fluids/n-Heptane.json @@ -315,7 +315,8 @@ "conductivity": { "BibTeX": "Assael-JPCRD-2013-Heptane", "critical": { - "GAMMA": 0.0586, + "R0": 1.02, + "GAMMA": 0.0586, "qD": 1250000000.0, "type": "simplified_Olchowy_Sengers", "zeta0": 2.45e-10 diff --git a/src/Tests/CoolProp-Tests.cpp b/src/Tests/CoolProp-Tests.cpp index 8dabb84f..f8d3c929 100644 --- a/src/Tests/CoolProp-Tests.cpp +++ b/src/Tests/CoolProp-Tests.cpp @@ -274,7 +274,7 @@ vel("Hexane", "T", 510, "Dmass", 2, "L", 36.772e-3, 1e-4), vel("Heptane", "T", 250, "Dmass", 720, "L", 137.09e-3, 1e-4), vel("Heptane", "T", 400, "Dmass", 2, "L", 21.794e-3, 1e-4), vel("Heptane", "T", 400, "Dmass", 650, "L", 120.75e-3, 1e-4), -vel("Heptane", "T", 535, "Dmass", 100, "L", 51.655e-3, 1e-4), +vel("Heptane", "T", 535, "Dmass", 100, "L", 51.655e-3, 3e-3), // Relaxed tolerance because was conductivity was fit using older viscosity correlation // From Assael, JPCRD, 2013 vel("Ethanol", "T", 300, "Dmass", 850, "L", 209.68e-3, 1e-4), From 85ce0bb19978404967884974f05664c15391344e Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 15:55:11 +0200 Subject: [PATCH 12/18] typo Signed-off-by: Ian Bell --- src/Tests/CoolProp-Tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tests/CoolProp-Tests.cpp b/src/Tests/CoolProp-Tests.cpp index f8d3c929..5dd1f199 100644 --- a/src/Tests/CoolProp-Tests.cpp +++ b/src/Tests/CoolProp-Tests.cpp @@ -274,7 +274,7 @@ vel("Hexane", "T", 510, "Dmass", 2, "L", 36.772e-3, 1e-4), vel("Heptane", "T", 250, "Dmass", 720, "L", 137.09e-3, 1e-4), vel("Heptane", "T", 400, "Dmass", 2, "L", 21.794e-3, 1e-4), vel("Heptane", "T", 400, "Dmass", 650, "L", 120.75e-3, 1e-4), -vel("Heptane", "T", 535, "Dmass", 100, "L", 51.655e-3, 3e-3), // Relaxed tolerance because was conductivity was fit using older viscosity correlation +vel("Heptane", "T", 535, "Dmass", 100, "L", 51.655e-3, 3e-3), // Relaxed tolerance because conductivity was fit using older viscosity correlation // From Assael, JPCRD, 2013 vel("Ethanol", "T", 300, "Dmass", 850, "L", 209.68e-3, 1e-4), From 226dc8ed09ddf57c3717c19ca1bc32e525375046 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Jun 2014 15:56:21 +0200 Subject: [PATCH 13/18] Added mass-based methods to python wrapper Signed-off-by: Ian Bell --- wrappers/Python/CoolProp5/AbstractState.pxd | 6 ++++ wrappers/Python/CoolProp5/AbstractState.pyx | 35 ++++++++++++++------- wrappers/Python/CoolProp5/CoolProp.pyx | 4 +-- wrappers/Python/setup2.py | 4 +-- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/wrappers/Python/CoolProp5/AbstractState.pxd b/wrappers/Python/CoolProp5/AbstractState.pxd index f132b0c2..3898d8a0 100644 --- a/wrappers/Python/CoolProp5/AbstractState.pxd +++ b/wrappers/Python/CoolProp5/AbstractState.pxd @@ -19,6 +19,12 @@ cdef class AbstractState: cpdef double smolar(self) cpdef double cpmolar(self) cpdef double cvmolar(self) + cpdef double rhomass(self) + cpdef double hmass(self) + cpdef double smass(self) + cpdef double cpmass(self) + cpdef double cvmass(self) cpdef double speed_sound(self) + cpdef double keyed_output(self, long) \ No newline at end of file diff --git a/wrappers/Python/CoolProp5/AbstractState.pyx b/wrappers/Python/CoolProp5/AbstractState.pyx index adc3f3f6..18f01809 100644 --- a/wrappers/Python/CoolProp5/AbstractState.pyx +++ b/wrappers/Python/CoolProp5/AbstractState.pyx @@ -13,7 +13,7 @@ cdef class AbstractState: del self.thisptr cpdef update(self, long ipair, double Value1, double Value2): - """ Update :cpapi:`AbstractState::update` """ + """ Update function - mirrors c++ function :cpapi:`AbstractState::update` """ self.thisptr.update(ipair, Value1, Value2) ## ---------------------------------------- @@ -25,30 +25,43 @@ cdef class AbstractState: return self.thisptr.keyed_output(iOutput) cpdef double T(self) except *: + """ Get the temperature in K - wrapper of c++ function :cpapi:`AbstractState::T` """ return self.thisptr.T() cpdef double p(self) except *: + """ Get the pressure in Pa - wrapper of c++ function :cpapi:`AbstractState::p` """ return self.thisptr.p() cpdef double rhomolar(self) except *: + """ Get the density in mol/m^3 - wrapper of c++ function :cpapi:`AbstractState::rhomolar` """ return self.thisptr.rhomolar() -# cpdef double rhomass(self) except *: -# return self.thisptr.rhomass() + cpdef double rhomass(self) except *: + """ Get the density in kg/m^3 - wrapper of c++ function :cpapi:`AbstractState::rhomass` """ + return self.thisptr.rhomass() cpdef double hmolar(self) except *: + """ Get the enthalpy in J/mol - wrapper of c++ function :cpapi:`AbstractState::hmolar` """ return self.thisptr.hmolar() cpdef double smolar(self) except *: + """ Get the entropy in J/mol/K - wrapper of c++ function :cpapi:`AbstractState::smolar` """ return self.thisptr.smolar() cpdef double cpmolar(self) except *: + """ Get the constant pressure specific heat in J/mol/K - wrapper of c++ function :cpapi:`AbstractState::cpmolar` """ return self.thisptr.cpmolar() cpdef double cvmolar(self) except *: + """ Get the constant volume specific heat in J/mol/K - wrapper of c++ function :cpapi:`AbstractState::cvmolar` """ return self.thisptr.cvmolar() -# cpdef double hmass(self) except *: -# return self.thisptr.hmass() -# cpdef double smass(self) except *: -# return self.thisptr.smass() -# cpdef double cpmass(self) except *: -# return self.thisptr.cpmass() -# cpdef double cvmass(self) except *: -# return self.thisptr.cvmass() + cpdef double hmass(self) except *: + """ Get the enthalpy in J/kg - wrapper of c++ function :cpapi:`AbstractState::hmass` """ + return self.thisptr.hmass() + cpdef double smass(self) except *: + """ Get the entropy in J/kg/K - wrapper of c++ function :cpapi:`AbstractState::smass` """ + return self.thisptr.smass() + cpdef double cpmass(self) except *: + """ Get the constant pressure specific heat in J/kg/K - wrapper of c++ function :cpapi:`AbstractState::cpmass` """ + return self.thisptr.cpmass() + cpdef double cvmass(self) except *: + """ Get the constant volume specific heat in J/kg/K - wrapper of c++ function :cpapi:`AbstractState::cvmass` """ + return self.thisptr.cvmass() cpdef double speed_sound(self) except *: + """ Get the speed of sound in m/s - wrapper of c++ function :cpapi:`AbstractState::speed_sound` """ return self.thisptr.speed_sound() \ No newline at end of file diff --git a/wrappers/Python/CoolProp5/CoolProp.pyx b/wrappers/Python/CoolProp5/CoolProp.pyx index be03e060..21a2a966 100644 --- a/wrappers/Python/CoolProp5/CoolProp.pyx +++ b/wrappers/Python/CoolProp5/CoolProp.pyx @@ -276,8 +276,8 @@ cdef dict paras = {iDmass : 'D', iCpmass : 'C', # iC0 : 'C0', iCvmass : 'O', - iV : 'V', - iL : 'L', + iviscosity : 'V', + iconductivity : 'L', iSmass : 'S', iUmass : 'U', # iDpdT : 'dpdT' diff --git a/wrappers/Python/setup2.py b/wrappers/Python/setup2.py index 5780bc70..d48e1e49 100644 --- a/wrappers/Python/setup2.py +++ b/wrappers/Python/setup2.py @@ -126,7 +126,7 @@ if __name__=='__main__': url='http://coolprop.sourceforge.net', description = """Open-source thermodynamic and transport properties database""", packages = ['CoolProp5','CoolProp5.Plots','CoolProp5.tests','CoolProp5.GUI'], - ext_modules = [CoolProp_module, constants_module], + ext_modules = [CoolProp_module, AbstractState_module, constants_module], package_dir = {'CoolProp5':'CoolProp5',}, #package_data = {'CoolProp5':['State.pxd','CoolProp.pxd','constants_header.pxd','include/*.h','include/rapidjson/*.h','include/rapidjson/internal/*.h','CoolPropBibTeXLibrary.bib']}, cmdclass={'build_ext': build_ext}, @@ -144,7 +144,7 @@ if __name__=='__main__': sys.path.pop(0) import CoolProp5.CoolProp as CP5 - print(CP5.PropsSI('P','T',300,'D',1e-10,'Water')) + print(CP5.PropsSI('L','T',300,'D',1e-10,'Water')) # #Clean up the include folder # shutil.rmtree(os.path.join('CoolProp','include'), ignore_errors = True) From c241c516c66a24bdd8535538fe6ea6bc2e49fb08 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 11 Jun 2014 01:10:08 +0200 Subject: [PATCH 14/18] Added dependency on generate_headers to most of the wrappers --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9ec5cd3..f81433d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,7 @@ if (COOLPROP_EES_MODULE) if (!MSVC) set_target_properties(COOLPROP_EES PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") endif() + add_dependencies (${app_name} generate_headers) endif() if (COOLPROP_OCTAVE_MODULE) @@ -185,7 +186,7 @@ if (COOLPROP_OCTAVE_MODULE) SWIG_LINK_LIBRARIES(CoolProp ${OCTAVE_LIB} ${OCTINTERP_LIB} ${CRUFT_LIB}) set_target_properties(CoolProp PROPERTIES SUFFIX ".oct" PREFIX "") - + add_dependencies (${app_name} generate_headers) endif() if (COOLPROP_CSHARP_MODULE) @@ -210,7 +211,7 @@ if (COOLPROP_CSHARP_MODULE) if (WIN32) set_target_properties(CoolProp PROPERTIES PREFIX "") endif() - + add_dependencies (${app_name} generate_headers) endif() if (COOLPROP_JAVA_MODULE) @@ -242,7 +243,7 @@ if (COOLPROP_JAVA_MODULE) if (!MSVC) set_target_properties(COOLPROP_EES PROPERTIES COMPILE_FLAGS "-m64" LINK_FLAGS "-m64") endif() - + add_dependencies (${app_name} generate_headers) endif() # NOT WORKING! From 501274215a51bd33b45eca1ba617c142100f85ca Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 11 Jun 2014 01:11:39 +0200 Subject: [PATCH 15/18] properly load and save the hashes in file --- dev/generate_headers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/generate_headers.py b/dev/generate_headers.py index 312d720e..14205f8f 100644 --- a/dev/generate_headers.py +++ b/dev/generate_headers.py @@ -17,8 +17,9 @@ def get_hash(data): repo_root_path = os.path.normpath(os.path.join(os.path.abspath(__file__),'..','..')) # Load up the hashes of the data that will be written to each file -if os.path.exists(os.path.join(repo_root_path,'dev','hashes.json')): - hashes = json.load(open('hashes.json','r')) +hashes_fname = os.path.join(repo_root_path,'dev','hashes.json') +if os.path.exists(hashes_fname): + hashes = json.load(open(hashes_fname,'r')) else: hashes = dict() @@ -113,7 +114,7 @@ if __name__=='__main__': # Write the hashes to a hashes JSON file if hashes: - fp = open(os.path.join(repo_root_path,'dev','hashes.json'),'w') + fp = open(hashes_fname,'w') fp.write(json.dumps(hashes)) fp.close() From 747a1b3e2e87497b0612462299f03a84eb1375e6 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 11 Jun 2014 01:12:37 +0200 Subject: [PATCH 16/18] updated shared_ptr header for OSX; Now Java and C# compile on OSX --- include/crossplatform_shared_ptr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/crossplatform_shared_ptr.h b/include/crossplatform_shared_ptr.h index 70799f9f..b3511ec6 100644 --- a/include/crossplatform_shared_ptr.h +++ b/include/crossplatform_shared_ptr.h @@ -12,8 +12,8 @@ using std::shared_ptr; #include using namespace std::tr1; #elif defined(__ISAPPLE__) -#include -using namespace std::tr1; +#include +using std::shared_ptr; #elif defined(__ISWINDOWS__) && defined(__MINGW32__) #include using namespace std::tr1; From 3127ace162e5244b4efd13b6c60dc22c2042dc51 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 11 Jun 2014 12:16:48 +0200 Subject: [PATCH 17/18] MATLAB works on windows - 32-bit and 64-bit Signed-off-by: Ian Bell --- CMakeLists.txt | 41 ++++++++++++ dev/cmake/Modules/FindMatlab.cmake | 59 +++++++++++++++++ wrappers/MATLAB/{HAProps.c => HAProps.cpp} | 21 +++--- wrappers/MATLAB/Matlabdef.def | 1 + wrappers/MATLAB/{PropsSI.c => PropsSI.cpp} | 74 ++++++++-------------- 5 files changed, 138 insertions(+), 58 deletions(-) create mode 100644 dev/cmake/Modules/FindMatlab.cmake rename wrappers/MATLAB/{HAProps.c => HAProps.cpp} (67%) create mode 100644 wrappers/MATLAB/Matlabdef.def rename wrappers/MATLAB/{PropsSI.c => PropsSI.cpp} (62%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f81433d9..73158620 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,6 +246,47 @@ if (COOLPROP_JAVA_MODULE) add_dependencies (${app_name} generate_headers) endif() +if (COOLPROP_MATLAB_MODULE) + + add_definitions(/DMATLAB_MEX_FILE) #define matlab macros + add_definitions(/DMX_COMPAT_32) + + find_package(Matlab REQUIRED) + + IF(MATLAB_FOUND) + message(STATUS "MATLAB Found, MATLAB MEX will be compiled.") + ELSE(MATLAB_FOUND) + MESSAGE("MATLAB not found...nothing will be built.") + ENDIF(MATLAB_FOUND) + + # set up matlab libraries + INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR}) + add_library(PropsSI SHARED ${APP_SOURCES} ${CMAKE_SOURCE_DIR}/wrappers/MATLAB/Matlabdef.def ${CMAKE_SOURCE_DIR}/wrappers/MATLAB/PropsSI.cpp) + add_library(HAPropsSI SHARED ${APP_SOURCES} ${CMAKE_SOURCE_DIR}/wrappers/MATLAB/Matlabdef.def ${CMAKE_SOURCE_DIR}/wrappers/MATLAB/HAProps.cpp) + target_link_libraries(PropsSI ${MATLAB_LIBRARIES}) + target_link_libraries(HAPropsSI ${MATLAB_LIBRARIES}) + + if(WIN32) # 32-bit or 64-bit mex + if (CMAKE_CL_64) + SET_TARGET_PROPERTIES(PropsSI PROPERTIES PREFIX "" SUFFIX .mexw64) + SET_TARGET_PROPERTIES(HAPropsSI PROPERTIES PREFIX "" SUFFIX .mexw64) + else() + SET_TARGET_PROPERTIES(PropsSI PROPERTIES SUFFIX .mexw32) + SET_TARGET_PROPERTIES(HAPropsSI PROPERTIES SUFFIX .mexw32) + endif() + else() + if (CMAKE_SIZEOF_VOID_P MATCHES "8") + SET_TARGET_PROPERTIES(PropsSI PROPERTIES PREFIX "" SUFFIX .mexa64 PREFIX "") + SET_TARGET_PROPERTIES(HAPropsSI PROPERTIES PREFIX "" SUFFIX .mexa64 PREFIX "") + else() + SET_TARGET_PROPERTIES(PropsSI PROPERTIES PREFIX "" SUFFIX .mexglx PREFIX "") + SET_TARGET_PROPERTIES(HAPropsSI PROPERTIES PREFIX "" SUFFIX .mexglx PREFIX "") + endif() + endif() + add_dependencies (PropsSI generate_headers) + add_dependencies (HAPropsSI generate_headers) +endif() + # NOT WORKING! if (COOLPROP_MATHEMATICA_MODULE) diff --git a/dev/cmake/Modules/FindMatlab.cmake b/dev/cmake/Modules/FindMatlab.cmake new file mode 100644 index 00000000..71a4f405 --- /dev/null +++ b/dev/cmake/Modules/FindMatlab.cmake @@ -0,0 +1,59 @@ +# - this module looks for Matlab +# Defines: +# MATLAB_INCLUDE_DIR: include path for mex.h +# MATLAB_LIBRARIES: required libraries: libmex, libmx +# MATLAB_MEX_LIBRARY: path to libmex +# MATLAB_MX_LIBRARY: path to libmx + +SET(MATLAB_FOUND 0) +IF( "$ENV{MATLAB_ROOT}" STREQUAL "" ) + MESSAGE(STATUS "MATLAB_ROOT environment variable not set." ) + MESSAGE(STATUS "In Linux this can be done in your user .bashrc file by appending the corresponding line, e.g:" ) + MESSAGE(STATUS "export MATLAB_ROOT=/usr/local/MATLAB/R2012b" ) + MESSAGE(STATUS "In Windows this can be done by adding system variable, e.g:" ) + MESSAGE(STATUS "MATLAB_ROOT=D:\\Program Files\\MATLAB\\R2011a" ) +ELSE() + + FIND_PATH(MATLAB_INCLUDE_DIR mex.h + $ENV{MATLAB_ROOT}/extern/include) + + INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR}) + + FIND_LIBRARY( MATLAB_MEX_LIBRARY + NAMES libmex mex + PATHS $ENV{MATLAB_ROOT}/bin $ENV{MATLAB_ROOT}/extern/lib + PATH_SUFFIXES glnxa64 glnx86 win64/microsoft win32/microsoft) + + FIND_LIBRARY( MATLAB_MX_LIBRARY + NAMES libmx mx + PATHS $ENV{MATLAB_ROOT}/bin $ENV{MATLAB_ROOT}/extern/lib + PATH_SUFFIXES glnxa64 glnx86 win64/microsoft win32/microsoft) + + + +ENDIF() + +# This is common to UNIX and Win32: +SET(MATLAB_LIBRARIES + ${MATLAB_MEX_LIBRARY} + ${MATLAB_MX_LIBRARY} +) +MESSAGE (STATUS "MATLAB_ROOT: $ENV{MATLAB_ROOT}") +MESSAGE (STATUS "MATLAB_INCLUDE_DIR: ${MATLAB_INCLUDE_DIR}") +MESSAGE (STATUS "MATLAB_LIBRARIES: ${MATLAB_LIBRARIES}") +MESSAGE (STATUS "MATLAB_MEX_LIBRARY: ${MATLAB_MEX_LIBRARY}") +MESSAGE (STATUS "MATLAB_MX_LIBRARY: ${MATLAB_MX_LIBRARY}") + +IF(MATLAB_INCLUDE_DIR AND MATLAB_LIBRARIES) + SET(MATLAB_FOUND 1) + MESSAGE(STATUS "Matlab libraries will be used") +ENDIF() + +MARK_AS_ADVANCED( + MATLAB_LIBRARIES + MATLAB_MEX_LIBRARY + MATLAB_MX_LIBRARY + MATLAB_INCLUDE_DIR + MATLAB_FOUND + MATLAB_ROOT +) diff --git a/wrappers/MATLAB/HAProps.c b/wrappers/MATLAB/HAProps.cpp similarity index 67% rename from wrappers/MATLAB/HAProps.c rename to wrappers/MATLAB/HAProps.cpp index 8f55a04d..1847afa4 100644 --- a/wrappers/MATLAB/HAProps.c +++ b/wrappers/MATLAB/HAProps.cpp @@ -1,10 +1,11 @@ +#include "HumidAirProp.h" +#include "CoolPropTools.h" #include "mex.h" /*--This one is required*/ +#include +#include +#include "float.h" -/* Prototype for the Props function to be called. Can't use the CoolProp.h header because there are a lot of - c++ parts in the header that cannot be easily hidden when compiling */ -double HAProps(char *Output, char* Name1, double Prop1, char* Name2, double Prop2, char* Name3, double Prop3); - -void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) +extern "C" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int npol,Nel; int m,n,u,v,k,Output_len,Name1_len,Name2_len,Name3_len; @@ -21,27 +22,27 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) /* Get the output (it is a string) (+1 for the NULL terminator)*/ Output_len=(mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1; - Output = mxCalloc(Output_len, sizeof(char)); + Output = (char*)mxCalloc(Output_len, sizeof(char)); status = mxGetString(prhs[0], Output, Output_len); /* Get the output (it is a string) (+1 for the NULL terminator)*/ Name1_len=(mxGetM(prhs[1]) * mxGetN(prhs[1])) + 1; - Name1 = mxCalloc(Name1_len, sizeof(char)); + Name1 = (char*)mxCalloc(Name1_len, sizeof(char)); mxGetString(prhs[1], Name1, Name1_len); Name2_len=(mxGetM(prhs[3]) * mxGetN(prhs[3])) + 1; - Name2 = mxCalloc(Name2_len, sizeof(char)); + Name2 = (char*)mxCalloc(Name2_len, sizeof(char)); mxGetString(prhs[3], Name2, Name2_len); Name3_len=(mxGetM(prhs[5]) * mxGetN(prhs[5])) + 1; - Name3 = mxCalloc(Name3_len, sizeof(char)); + Name3 = (char*)mxCalloc(Name3_len, sizeof(char)); mxGetString(prhs[5], Name3, Name3_len); Prop1 = mxGetScalar(prhs[2]); Prop2 = mxGetScalar(prhs[4]); Prop3 = mxGetScalar(prhs[6]); - x = HAProps(Output,Name1,Prop1,Name2,Prop2,Name3,Prop3); + x = HumidAir::HAPropsSI(Output,Name1,Prop1,Name2,Prop2,Name3,Prop3); *mxGetPr(plhs[0])=x; } else diff --git a/wrappers/MATLAB/Matlabdef.def b/wrappers/MATLAB/Matlabdef.def new file mode 100644 index 00000000..c54c4e0a --- /dev/null +++ b/wrappers/MATLAB/Matlabdef.def @@ -0,0 +1 @@ +EXPORTS mexFunction \ No newline at end of file diff --git a/wrappers/MATLAB/PropsSI.c b/wrappers/MATLAB/PropsSI.cpp similarity index 62% rename from wrappers/MATLAB/PropsSI.c rename to wrappers/MATLAB/PropsSI.cpp index 13886df2..f55eb8a7 100644 --- a/wrappers/MATLAB/PropsSI.c +++ b/wrappers/MATLAB/PropsSI.cpp @@ -1,23 +1,11 @@ +#include "CoolProp.h" +#include "CoolPropTools.h" #include "mex.h" /*--This one is required*/ - -/* Prototype for the Props function to be called. Can't use the CoolProp.h header because there are a lot of - c++ parts in the header that cannot be easily hidden when compiling */ -double PropsSI(char *Output, char *Name1, double Prop1, char *Name2, double Prop2, char * Ref); -double Props1(char *Output, char * Ref); -long get_global_param_string(char*, char*); -long get_fluid_param_string(char *fluid, char *param, char * Output); -long get_standard_unit_system(void); -void set_standard_unit_system(long); -#include "GlobalConstants.h" +#include +#include #include "float.h" -bool ValidNumber(double x) -{ - // Idea from http://www.johndcook.com/IEEE_exceptions_in_cpp.html - return (x <= DBL_MAX && x >= -DBL_MAX); -}; - -void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) +extern "C" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int npol,Nel; int m,n,u,v,k,Output_len,Name1_len,Name2_len,Ref_len,Param_len; @@ -31,29 +19,19 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* Get the refrigerant (it is a string) (+1 for the NULL terminator)*/ Ref_len=(mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1; - Ref = mxCalloc(Ref_len, sizeof(char)); + Ref = (char*)mxCalloc(Ref_len, sizeof(char)); status = mxGetString(prhs[0], Ref, Ref_len); /* Get the output (it is a string) (+1 for the NULL terminator)*/ Output_len=(mxGetM(prhs[1]) * mxGetN(prhs[1])) + 1; - Output = mxCalloc(Output_len, sizeof(char)); + Output = (char*)mxCalloc(Output_len, sizeof(char)); status = mxGetString(prhs[1], Output, Output_len); /* Try to shortcut to get the strings for the fluid */ if (!strcmp(Output,"aliases") || !strcmp(Output,"CAS") || !strcmp(Output,"CAS_number") || !strcmp(Output,"ASHRAE34") || !strcmp(Output,"REFPROPName") || !strcmp(Output,"REFPROP_name") || !strcmp(Output,"TTSE_mode")) { - get_fluid_param_string(Ref,Output,fluidslist); - plhs[0] = mxCreateString(fluidslist); - return; - } - else if (!strcmp(Output,"enable_TTSE")) - { - enable_TTSE_LUT(Ref); - return; - } - else if (!strcmp(Output,"disable_TTSE")) - { - disable_TTSE_LUT(Ref); + std::string fluidslist = CoolProp::get_fluid_param_string(Ref,Output); + plhs[0] = mxCreateString(fluidslist.c_str()); return; } @@ -61,9 +39,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) /* Create matrix for the return argument. */ plhs[0] = mxCreateDoubleMatrix(1,1, mxREAL); - + /* Get the value*/ - val = Props1(Ref,Output); + val = CoolProp::PropsSI(Ref,"T",0,"P",0,Output); /* If it is a good value, return it*/ if (ValidNumber(val)) { @@ -72,8 +50,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) /* Otherwise there was an error, return the CoolProp error*/ else { - get_global_param_string("errstring",errstr); - sprintf(errstr2,"CoolProp Error: %s",errstr); + std::string errstr = CoolProp::get_global_param_string("errstring"); + sprintf(errstr2,"CoolProp Error: %s",errstr.c_str()); mexErrMsgTxt(errstr2); } } @@ -84,26 +62,26 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) /* Get the refrigerant (it is a string) (+1 for the NULL terminator)*/ Ref_len=(mxGetM(prhs[5]) * mxGetN(prhs[5])) + 1; - Ref = mxCalloc(Ref_len, sizeof(char)); + Ref = (char*)mxCalloc(Ref_len, sizeof(char)); mxGetString(prhs[5], Ref, Ref_len); /* Get the output (it is a string) (+1 for the NULL terminator)*/ Output_len=(mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1; - Output = mxCalloc(Output_len, sizeof(char)); + Output = (char*)mxCalloc(Output_len, sizeof(char)); mxGetString(prhs[0], Output, Output_len); Name1_len=(mxGetM(prhs[1]) * mxGetN(prhs[1])) + 1; - Name1 = mxCalloc(Name1_len, sizeof(char)); + Name1 = (char*)mxCalloc(Name1_len, sizeof(char)); mxGetString(prhs[1], Name1, Name1_len); Name2_len=(mxGetM(prhs[3]) * mxGetN(prhs[3])) + 1; - Name2 = mxCalloc(Name2_len, sizeof(char)); + Name2 = (char*)mxCalloc(Name2_len, sizeof(char)); mxGetString(prhs[3], Name2, Name2_len); Prop1 = mxGetScalar(prhs[2]); Prop2 = mxGetScalar(prhs[4]); - val = PropsSI(Output,Name1,Prop1,Name2,Prop2,Ref); + val = CoolProp::PropsSI(Output,Name1,Prop1,Name2,Prop2,Ref); /* If it is a good value, return it */ if (ValidNumber(val)) @@ -113,32 +91,32 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) /* Otherwise there was an error, return the CoolProp error*/ else { - get_global_param_string("errstring",errstr); - sprintf(errstr2,"CoolProp Error: %s",errstr); + std::string errstr = CoolProp::get_global_param_string("errstring"); + sprintf(errstr2,"CoolProp Error: %s",errstr.c_str()); mexErrMsgTxt(errstr2); } } else if (nrhs == 1 && mxIsChar (prhs[0])) { Ref_len=(mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1; - Ref = mxCalloc(Ref_len, sizeof(char)); + Ref = (char*)mxCalloc(Ref_len, sizeof(char)); status = mxGetString(prhs[0], Ref, Ref_len); - + std::string s; if (!strcmp(Ref,"FluidsList")){ - get_global_param_string("FluidsList",fluidslist); + s = CoolProp::get_global_param_string("FluidsList"); } else if (!strcmp(Ref,"version")){ - get_global_param_string("version",fluidslist); + s = CoolProp::get_global_param_string("version"); } else if (!strcmp(Ref,"gitrevision")){ - get_global_param_string("gitrevision", fluidslist); + s = CoolProp::get_global_param_string("gitrevision"); } else { sprintf(errstr2,"single input is invalid: %s",Ref); mexErrMsgTxt(errstr2); } - plhs[0] = mxCreateString(fluidslist); + plhs[0] = mxCreateString(s.c_str()); return; } else From ca7fc30a58049c0515d050e61954792d3a5b6560 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 11 Jun 2014 15:38:49 +0200 Subject: [PATCH 18/18] Added saturation spline to the AbstractState and REFPROP interfaces Signed-off-by: Ian Bell --- include/AbstractState.h | 25 +++++++++++-------- src/AbstractState.cpp | 4 +++ .../REFPROP/REFPROPMixtureBackend.cpp | 19 +++++++++----- src/Backends/REFPROP/REFPROPMixtureBackend.h | 16 ++++++------ src/Backends/REFPROP/REFPROP_lib.h | 7 ++++++ 5 files changed, 47 insertions(+), 24 deletions(-) diff --git a/include/AbstractState.h b/include/AbstractState.h index c9f7df45..9fa7baa0 100644 --- a/include/AbstractState.h +++ b/include/AbstractState.h @@ -71,19 +71,19 @@ protected: //~ return true; //~ } - + /// Two important points SimpleState _critical, _reducing; /// Molar mass [mol/kg] CachedElement _molar_mass; - + /// Universal gas constant [J/mol/K] CachedElement _gas_constant; /// Bulk values double _rhomolar, _T, _p, _Q, _R; - + CachedElement _tau, _delta; /// Transport properties @@ -161,7 +161,7 @@ protected: virtual long double calc_d2alphar_dDelta_dTau(void){throw NotImplementedError("calc_d2alphar_dDelta_dTau is not implemented for this backend");}; /// Using this backend, calculate the residual Helmholtz energy term \f$\alpha^r_{\tau\tau}\f$ (dimensionless) virtual long double calc_d2alphar_dTau2(void){throw NotImplementedError("calc_d2alphar_dTau2 is not implemented for this backend");}; - + // Derivatives of ideal-gas helmholtz energy /// Using this backend, calculate the ideal-gas Helmholtz energy term \f$\alpha^0\f$ (dimensionless) virtual long double calc_alpha0(void){throw NotImplementedError("calc_alpha0 is not implemented for this backend");}; @@ -197,7 +197,7 @@ protected: virtual long double calc_health_hazard(void){throw NotImplementedError("calc_health_hazard is not implemented for this backend");}; /// Using this backend, calculate the physical hazard virtual long double calc_physical_hazard(void){throw NotImplementedError("calc_physical_hazard is not implemented for this backend");}; - + /// Calculate the first partial derivative for the desired derivative virtual long double calc_first_partial_deriv(int Of, int Wrt, int Constant){throw NotImplementedError("calc_first_partial_deriv is not implemented for this backend");}; @@ -217,7 +217,7 @@ protected: /// Using this backend, get the name of the fluid virtual std::string calc_name(void){throw NotImplementedError("calc_name is not implemented for this backend");}; - + /// Using this backend, get the triple point temperature in K virtual long double calc_Ttriple(void){throw NotImplementedError("calc_Ttriple is not implemented for this backend");}; @@ -228,6 +228,8 @@ protected: /// Using this backend, get the critical point molar density in mol/m^3 virtual long double calc_rhomolar_critical(void){throw NotImplementedError("calc_rhomolar_critical is not implemented for this backend");}; + /// Using this backend, construct the phase envelope, the variable type describes the type of phase envelope to be built. + virtual void calc_phase_envelope(const std::string &type){throw NotImplementedError("calc_phase_envelope is not implemented for this backend");}; public: virtual long double calc_melt_p_T(long double T){throw NotImplementedError("calc_melt_p_T is not implemented for this backend");}; @@ -236,13 +238,13 @@ public: AbstractState(){}; virtual ~AbstractState(){}; - + /// A factory function to return a pointer to a new-allocated instance of one of the backends. /** Very Important!! : Use a smart pointer to manage the pointer returned. In older versions of C++, you can use std::tr1::smart_ptr. In C++2011 you can use std::shared_ptr Several backends are possible: - + 1. "?" : The backend is unknown, we will parse the fluid string to determine the backend to be used. Probably will use HEOS backend (see below) 2. "HEOS" : The Helmholtz Equation of State backend for use with pure and pseudo-pure fluids, and mixtures, all of which are based on multi-parameter Helmholtz Energy equations of state. The fluid part of the string should then either be 1. A pure or pseudo-pure fluid name (eg. "PROPANE" or "R410A"), yielding a HelmholtzEOSBackend instance. @@ -251,14 +253,14 @@ public: 3. "REFPROP" : The REFPROP backend will be used. The fluid part of the string should then either be 1. A pure or pseudo-pure fluid name (eg. "PROPANE" or "R410A"), yielding a REFPROPBackend instance. 2. A string that encodes the components of the mixture with a "&" between them (e.g. "R32&R125"), yielding a REFPROPMixtureBackend instance. - + 4. "TTSE&XXXX": The TTSE backend will be used, and the tables will be generated using the XXXX backend where XXXX is one of the base backends("HEOS", "REFPROP", etc. ) 5. "BICUBIC&XXXX": The Bicubic backend will be used, and the tables will be generated using the XXXX backend where XXXX is one of the base backends("HEOS", "REFPROP", etc. ) 6. "INCOMP": The incompressible backend will be used 7. "BRINE": The brine backend will be used */ static AbstractState * factory(const std::string &backend, const std::string &fluid_string); - + // The derived classes must implement this function to define whether they use mole fractions (true) or mass fractions (false) virtual bool using_mole_fractions(void) = 0; @@ -268,7 +270,7 @@ public: /// Clear all the cached values bool clear(); - + void set_mole_fractions(const std::vector &mole_fractions){set_mole_fractions(std::vector(mole_fractions.begin(), mole_fractions.end()));}; void set_mass_fractions(const std::vector &mass_fractions){set_mass_fractions(std::vector(mass_fractions.begin(), mass_fractions.end()));}; @@ -360,6 +362,7 @@ public: /// Return the isobaric expansion coefficient \f$ \beta = \frac{1}{v}\left.\frac{\partial v}{\partial T}\right|_p = -\frac{1}{\rho}\left.\frac{\partial \rho}{\partial T}\right|_p\f$ in 1/K double isobaric_expansion_coefficient(void); double fugacity_coefficient(int i); + void build_phase_envelope(const std::string &type); //double fundamental_derivative_of_gas_dynamics(void); // ---------------------------------------- diff --git a/src/AbstractState.cpp b/src/AbstractState.cpp index d00d64d2..7299f86f 100644 --- a/src/AbstractState.cpp +++ b/src/AbstractState.cpp @@ -302,6 +302,10 @@ double AbstractState::fugacity_coefficient(int i){ // TODO: Cache the fug. coeff for each component return calc_fugacity_coefficient(i); } +void AbstractState::build_phase_envelope(const std::string &type) +{ + calc_phase_envelope(type); +} double AbstractState::isothermal_compressibility(void){ return 1.0/_rhomolar*first_partial_deriv(iDmolar, iP, iT); } diff --git a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp index d5671183..d77fd2e4 100644 --- a/src/Backends/REFPROP/REFPROPMixtureBackend.cpp +++ b/src/Backends/REFPROP/REFPROPMixtureBackend.cpp @@ -181,6 +181,7 @@ static char default_reference_state[] = "DEF"; SATPdll_POINTER SATPdll; SATSdll_POINTER SATSdll; SATTdll_POINTER SATTdll; + SATSPLNdll_POINTER SATSPLNdll; SETAGAdll_POINTER SETAGAdll; SETKTVdll_POINTER SETKTVdll; SETMIXdll_POINTER SETMIXdll; @@ -307,6 +308,7 @@ double setFunctionPointers() SATPdll = (SATPdll_POINTER) getFunctionPointer((char *)SATPdll_NAME); SATSdll = (SATSdll_POINTER) getFunctionPointer((char *)SATSdll_NAME); SATTdll = (SATTdll_POINTER) getFunctionPointer((char *)SATTdll_NAME); + SATSPLNdll = (SATSPLNdll_POINTER) getFunctionPointer((char *)SATSPLNdll_NAME); SETAGAdll = (SETAGAdll_POINTER) getFunctionPointer((char *)SETAGAdll_NAME); SETKTVdll = (SETKTVdll_POINTER) getFunctionPointer((char *)SETKTVdll_NAME); SETMIXdll = (SETMIXdll_POINTER) getFunctionPointer((char *)SETMIXdll_NAME); @@ -550,7 +552,8 @@ void REFPROPMixtureBackend::set_REFPROP_fluids(const std::vector &f } else if (ierr > 0) // Error { - if (k==0) continue; + if (k==0 && N > 1) + continue; // Allow us to use PPF if a pure fluid else throw ValueError(format("%s",herr)); } @@ -603,11 +606,6 @@ long double REFPROPMixtureBackend::calc_melt_p_T(long double T) long ierr; char herr[255]; - if (T > calc_melt_Tmax()) - { - throw ValueError(format("Melting temperature [%g] is out of range",T)); - } - MELTTdll(&_T, &(mole_fractions[0]), &p_kPa, &ierr,herr,errormessagelength); // Error message @@ -672,6 +670,15 @@ long double REFPROPMixtureBackend::calc_fugacity_coefficient(int i) return static_cast(fug_cof[i]); } +void REFPROPMixtureBackend::calc_phase_envelope(const std::string &type) +{ + long ierr; + char herr[255]; + SATSPLNdll(&(mole_fractions[0]), // Inputs + &ierr, herr, errormessagelength); // Error message + if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } +} + void REFPROPMixtureBackend::update(long input_pair, double value1, double value2) { double rho_mol_L=_HUGE, rhoLmol_L=_HUGE, rhoVmol_L=_HUGE, diff --git a/src/Backends/REFPROP/REFPROPMixtureBackend.h b/src/Backends/REFPROP/REFPROPMixtureBackend.h index d38af71a..f82113fd 100644 --- a/src/Backends/REFPROP/REFPROPMixtureBackend.h +++ b/src/Backends/REFPROP/REFPROPMixtureBackend.h @@ -24,7 +24,7 @@ protected: std::vector mole_fractions_liq, mole_fractions_vap; public: REFPROPMixtureBackend(){}; - + /// The instantiator /// @param fluid_names The vector of strings of the fluid components, without file ending REFPROPMixtureBackend(const std::vector& fluid_names); @@ -34,10 +34,10 @@ public: bool using_mole_fractions(){return true;} /// Updating function for REFPROP - /** + /** In this function we take a pair of thermodynamic states, those defined in the input_pairs enumeration and update all the internal variables that we can. REFPROP calculates - a lot of other state variables each time you use a flash routine so we cache all the + a lot of other state variables each time you use a flash routine so we cache all the outputs that we can, which saves on computational time. @param input_pair Integer key from CoolProp::input_pairs to the two inputs that will be passed to the function @@ -59,17 +59,19 @@ public: void set_REFPROP_fluids(const std::vector &fluid_names); /// Set the mole fractions - /** + /** @param mole_fractions The vector of mole fractions of the components */ void set_mole_fractions(const std::vector &mole_fractions); - + /// Set the mass fractions - /** + /** @param mass_fractions The vector of mass fractions of the components */ void set_mass_fractions(const std::vector &mass_fractions); + void calc_phase_envelope(const std::string &type); + /// Check if the mole fractions have been set, etc. void check_status(); @@ -81,7 +83,7 @@ public: long double calc_surface_tension(void); long double calc_fugacity_coefficient(int i); - + long double calc_melt_p_T(long double T); long double calc_melt_T_p(long double p); long double calc_melt_rho_T(long double T); diff --git a/src/Backends/REFPROP/REFPROP_lib.h b/src/Backends/REFPROP/REFPROP_lib.h index 6741433c..372f896a 100644 --- a/src/Backends/REFPROP/REFPROP_lib.h +++ b/src/Backends/REFPROP/REFPROP_lib.h @@ -95,6 +95,7 @@ # define SATPdll SATPdll # define SATSdll SATSdll # define SATTdll SATTdll +# define SATSPLNdll SATSPLNdll # define SETAGAdll SETAGAdll # define SETKTVdll SETKTVdll # define SETMIXdll SETMIXdll @@ -210,6 +211,7 @@ # define SATPdll satpdll_ # define SATSdll satsdll_ # define SATTdll sattdll_ +# define SATSPLNdll satsplndll_ # define SETAGAdll setagadll_ # define SETKTVdll setktvdll_ # define SETMIXdll setmixdll_ @@ -316,6 +318,7 @@ # define SATPdll satpdll_ # define SATSdll satsdll_ # define SATTdll sattdll_ +# define SATSPLNdll satsplndll_ # define SETAGAdll setagadll_ # define SETKTVdll setktvdll_ # define SETMIXdll setmixdll_ @@ -420,6 +423,7 @@ # define SATPdll satpdll # define SATSdll satsdll # define SATTdll sattdll +# define SATSPLNdll satsplndll # define SETAGAdll setagadll # define SETKTVdll setktvdll # define SETMIXdll setmixdll @@ -536,6 +540,7 @@ #define SATPdll_NAME FUNCTION_NAME(SATPdll) #define SATSdll_NAME FUNCTION_NAME(SATSdll) #define SATTdll_NAME FUNCTION_NAME(SATTdll) +#define SATSPLNdll_NAME FUNCTION_NAME(SATSPLNdll) #define SETAGAdll_NAME FUNCTION_NAME(SETAGAdll) #define SETKTVdll_NAME FUNCTION_NAME(SETKTVdll) #define SETMIXdll_NAME FUNCTION_NAME(SETMIXdll) @@ -649,6 +654,7 @@ extern "C" { typedef void (CALLCONV SATPdll_TYPE)(double *,double *,long *,double *,double *,double *,double *,double *,long *,char*,long ); typedef void (CALLCONV SATSdll_TYPE)(double *,double *,long *,long *,long *,double *,double *,double *,long *,double *,double *,double *,long *,double *,double *,double *,long *,char*,long ); typedef void (CALLCONV SATTdll_TYPE)(double *,double *,long *,double *,double *,double *,double *,double *,long *,char*,long ); + typedef void (CALLCONV SATSPLNdll_TYPE)(double *,long *,char*,long ); typedef void (CALLCONV SETAGAdll_TYPE)(long *,char*,long ); typedef void (CALLCONV SETKTVdll_TYPE)(long *,long *,char*,double *,char*,long *,char*,long ,long ,long ); typedef void (CALLCONV SETMIXdll_TYPE)(char*,char*,char*,long *,char*,double *,long *,char*,long ,long ,long ,long ,long ); @@ -857,6 +863,7 @@ extern "C" { typedef SATPdll_TYPE * SATPdll_POINTER; typedef SATSdll_TYPE * SATSdll_POINTER; typedef SATTdll_TYPE * SATTdll_POINTER; + typedef SATSPLNdll_TYPE * SATSPLNdll_POINTER; typedef SETAGAdll_TYPE * SETAGAdll_POINTER; typedef SETKTVdll_TYPE * SETKTVdll_POINTER; typedef SETMIXdll_TYPE * SETMIXdll_POINTER;