diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000..6e934445
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,244 @@
+name: Continuous Integration
+
+#on:
+# push:
+# tags:
+# - 'v*'
+
+on: [push]
+
+jobs:
+ finish-ci:
+ runs-on: ubuntu-latest
+ needs: [build-macos, build-linux, build-windows, build-msys-openmodelica, build-msys, build-docs]
+ steps:
+ - uses: actions/download-artifact@v2
+ - name: Display structure of downloaded files
+ run: ls -R
+ # - name: Zip binaries
+ # uses: papeloto/action-zip@v1
+ # with:
+ # files: binaries/
+ # recursive: true
+ # dest: latest.zip
+ # - name: Upload zipped binaries
+ # uses: actions/upload-artifact@v1
+ # with:
+ # name: latest
+ # path: latest.zip
+ # - name: Deploy zipped binaries
+ # uses: peaceiris/actions-gh-pages@v3
+ # with:
+ # github_token: ${{ secrets.GITHUB_TOKEN }}
+ # publish_dir: Documentation/html
+ # #destination_dir: latest
+
+ build-macos:
+ runs-on: macOS-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Create Build Environment
+ run: |
+ cmake --version
+ cmake -E make_directory ${{runner.workspace}}/build
+ - name: Configure with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: |
+ cmake ${GITHUB_WORKSPACE}/Projects -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=0 -DCOOLPROP=1 || true
+ cmake ${GITHUB_WORKSPACE}/Projects -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=0 -DCOOLPROP=1
+ - name: Build with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: cmake --build . --target ExternalMediaLib
+ - name: Install with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: cmake --build . --target install
+ - name: upload macos artifacts
+ uses: actions/upload-artifact@v1
+ with:
+ name: binaries
+ path: Modelica
+
+
+ build-linux:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Create Build Environment
+ run: |
+ cmake --version
+ cmake -E make_directory ${{runner.workspace}}/build
+ - name: Configure with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: |
+ cmake ${GITHUB_WORKSPACE}/Projects -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=0 -DCOOLPROP=1 || true
+ cmake ${GITHUB_WORKSPACE}/Projects -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=0 -DCOOLPROP=1
+ - name: Build with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: cmake --build . --target ExternalMediaLib
+ - name: Install with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: cmake --build . --target install
+ - name: upload linux artifacts
+ uses: actions/upload-artifact@v1
+ with:
+ name: binaries
+ path: Modelica
+
+
+ build-windows:
+ runs-on: ${{ matrix.platform }}
+ strategy:
+ matrix:
+ include:
+ - platform: windows-2019
+ generator: Visual Studio 16 2019
+ arch: Win32
+ toolset: v142
+ - platform: windows-2019
+ generator: Visual Studio 16 2019
+ arch: x64
+ toolset: v142
+ - platform: windows-2016
+ generator: Visual Studio 15 2017
+ arch: Win32
+ toolset: v141
+ - platform: windows-2016
+ generator: Visual Studio 15 2017
+ arch: x64
+ toolset: v141
+ - platform: windows-2016
+ generator: Visual Studio 15 2017
+ arch: Win32
+ toolset: v140
+ - platform: windows-2016
+ generator: Visual Studio 15 2017
+ arch: x64
+ toolset: v140
+ #cmake -G "Visual Studio 14" -T v120 -T v141,version=14.11
+ steps:
+ - uses: actions/checkout@v2
+ - name: Create Build Environment
+ run: |
+ cmake --version
+ cmake -E make_directory ${{runner.workspace}}/build
+ - name: Configure with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: |
+ cmake ${{ runner.workspace }}/ExternalMedia/Projects -A ${{ matrix.arch }} -G "${{ matrix.generator }}" -T "${{ matrix.toolset }}" -DFLUIDPROP=1 -DCOOLPROP=1
+ cmake ${{ runner.workspace }}/ExternalMedia/Projects -A ${{ matrix.arch }} -G "${{ matrix.generator }}" -T "${{ matrix.toolset }}" -DFLUIDPROP=1 -DCOOLPROP=1
+ - name: Build with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: cmake --build . --target ExternalMediaLib --config Release
+ - name: Install with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: cmake --build . --target install --config Release
+ - name: upload windows artifacts
+ uses: actions/upload-artifact@v1
+ with:
+ name: binaries
+ path: Modelica
+
+
+ build-msys-openmodelica:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Create Build Environment
+ run: |
+ cmake --version
+ svn checkout -q https://openmodelica.org/svn/OpenModelicaExternal/trunk/tools/windows/OMDev C:/OMDev
+ - name: Configure with CMake for 32bit
+ working-directory: ${{runner.workspace}}
+ run: |
+ $env:Path = "${env:ProgramFiles}\CMake\bin;C:\OMDev\tools\msys\usr\bin;C:\OMDev\tools\msys\mingw32\bin;$env:Path"
+ cmake -B build32 -S ${{ runner.workspace }}/ExternalMedia/Projects -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=1 -DCOOLPROP=1
+ cmake -B build32 -S ${{ runner.workspace }}/ExternalMedia/Projects -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=1 -DCOOLPROP=1
+ - name: Build with CMake for 32bit
+ working-directory: ${{runner.workspace}}
+ run: |
+ $env:Path = "${env:ProgramFiles}\CMake\bin;C:\OMDev\tools\msys\usr\bin;C:\OMDev\tools\msys\mingw32\bin;$env:Path"
+ cmake --build build32 --target ExternalMediaLib
+ cmake --build build32 --target install
+ - name: Configure with CMake for 64bit
+ working-directory: ${{runner.workspace}}
+ run: |
+ $env:Path = "${env:ProgramFiles}\CMake\bin;C:\OMDev\tools\msys\usr\bin;C:\OMDev\tools\msys\mingw64\bin;$env:Path"
+ cmake -B build64 -S ${{ runner.workspace }}/ExternalMedia/Projects -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=1 -DCOOLPROP=1
+ cmake -B build64 -S ${{ runner.workspace }}/ExternalMedia/Projects -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=1 -DCOOLPROP=1
+ - name: Build with CMake for 64bit
+ working-directory: ${{runner.workspace}}
+ run: |
+ $env:Path = "${env:ProgramFiles}\CMake\bin;C:\OMDev\tools\msys\usr\bin;C:\OMDev\tools\msys\mingw64\bin;$env:Path"
+ cmake --build build64 --target ExternalMediaLib
+ cmake --build build64 --target install
+ - name: upload msys-openmodelica artifacts
+ uses: actions/upload-artifact@v1
+ with:
+ name: binaries
+ path: Modelica
+
+#set Path=%ProgramFiles%\CMake\bin;C:\OMDev\tools\msys\usr\bin;C:\OMDev\tools\msys\mingw64\bin;%Path%
+#cmake -B build64 -S Projects -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=1 -DCOOLPROP=1
+#cmake -B build64 -S Projects -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=1 -DCOOLPROP=1
+#cmake --build build64 --target ExternalMediaLib
+#cmake --build build64 --target install
+
+ build-msys:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Create Build Environment
+ run: |
+ cmake --version
+ cmake -E make_directory ${{runner.workspace}}/build
+ - name: Configure with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: |
+ cmake ${{ runner.workspace }}/ExternalMedia/Projects -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=1 -DCOOLPROP=1
+ cmake ${{ runner.workspace }}/ExternalMedia/Projects -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLUIDPROP=1 -DCOOLPROP=1
+ - name: Build with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: cmake --build . --target ExternalMediaLib
+ - name: Install with CMake
+ working-directory: ${{runner.workspace}}/build
+ run: cmake --build . --target install
+ #- name: upload msys artifacts
+ # uses: actions/upload-artifact@v1
+ # with:
+ # name: binaries
+ # path: Modelica
+
+ build-docs:
+ runs-on: ubuntu-latest
+ steps:
+
+ - uses: actions/checkout@v2
+
+ - name: Build Doxygen sources
+ uses: mattnotmitt/doxygen-action@v1
+ with:
+ working-directory: 'Projects/'
+ doxyfile-path: './Doxyfile'
+ enable-latex: true
+
+ - name: Upload documentation artifacts
+ uses: actions/upload-artifact@v1
+ with:
+ name: docs
+ path: Projects/Documentation
+
+ - name: Copy PDF to Modelica tree
+ run: cp 'Projects/Documentation/latex/refman.pdf' 'Modelica/ExternalMedia 3.3.0/Resources/manual.pdf'
+
+ - name: Upload Modelica sources with PDF
+ uses: actions/upload-artifact@v1
+ with:
+ name: binaries
+ path: Modelica
+
+ - name: Deploy generated HTML
+ uses: peaceiris/actions-gh-pages@v3
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ publish_dir: Projects/Documentation/html
+ #destination_dir: latest
diff --git a/.gitignore b/.gitignore
index ad2d65ea..fcadc1f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,21 +1,26 @@
-*.mat
-
-*~
-
-buildlog.txt
-
-dsfinal.txt
-
-dsin.txt
-
-dslog.txt
-
-dsmodelext1.c
-
-dsmodel.c
-
-dymosim.exe
-
-dymosim.exp
-
-dymosim.lib
+*.mat
+
+*~
+
+buildlog.txt
+
+dsfinal.txt
+
+dsin.txt
+
+dslog.txt
+
+dsmodelext1.c
+
+dsmodel.c
+
+dymosim.exe
+
+dymosim.exp
+
+dymosim.lib
+/.svn/
+/externals/
+/build/
+/build32/
+/build64/
diff --git a/Installation.txt b/Installation.txt
deleted file mode 100644
index adef4bc1..00000000
--- a/Installation.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-# INSTALLATION INSTRUCTIONS FOR THE ExternalMedia LIBRARY
-
-The provided version of ExternalMedia is compatible with Modelica
-Standard Library 3.2.1.
-
-You can also use it with Modelica Standard Library 3.2, provided you
-change the uses annotation in the package.mo file of the Modelica package
-root directory to uses(Modelica(version = "3.2")).
-
-Previous versions of the Modelica Standard Library are no longer supported.
-
-For installation, check out the content of the Modelica directory
-library from the Modelica SVN or GitHub repositories, then follow
-the tool- and OS- specific instructions below.
-
-If you want to experiment with the code and recompile the static libraries,
-check the Projects/CompilationHowTo.txt file.
-
-The library works with FluidProp version 3.0 and later. It might work with
-previous versions of that software, but compatibility is no longer guaranteed.
-
-
-## Dymola under Windows
-
-- Go to the Modelica/ExternalMedia 3.2.1/Resources/Library/win32 directory
-- Copy the ExternalMediaLib.Dymola-VS20XX.lib file to a new file named
- ExternalMediaLib.lib in the same directory, according to the version
- of VisualStudio you use with your Dymola installation
-
-You can now load the library, by opening the Modelica/ExternalMedia 3.2.1/package.mo
-file
-
-## OpenModelica under Windows
-
-- Go to the Modelica/ExternalMedia 3.2.1/Resources/Library/win32 directory
-- Copy the libExternalMediaLib.OMC-gcc.a file to a new file named
- libExternalMediaLib.a in the same directory
-
-You can now load the library, by opening the Modelica/ExternalMedia 3.2.1/package.mo
-file
-
-
-## For Linux users
-
-You have to compile your own library file to use ExternalMedia on Linux.
-It has been tested with Dymola, but should also work with OpenModelica
-since they use the same compiler under Linux.
-
-Please note that you have to add the dl library to the compilation if you
-would like to use NIST REFPROP through the CoolProp interface. For Dymola,
-you can add "-ldl" to the compilation options in the dsbuild.sh file in
-/opt/dymola/insert.
-
-Please follow the developer instructions in `Projects/CompilationHowTo.txt`
-to create your own version of ExternalMedia.
-
-Note: Replace 'CPPC=g++' with 'CPPC=g++ -m32' in the 'makefile-linux' file,
- if the Dymola Linux compiler is 32bit.
-
-
-## For developers and other platforms
-
-If you are interested in using ExternalMedia with other Modelica
-tools and/or other operating systems and/or other external codes
-for fluid property computation, please contact the main
-developer francesco.casella@polimi.it
-
diff --git a/Modelica/ExternalMedia 3.2.1/Resources/Include/externalmedialib.h b/Modelica/ExternalMedia 3.2.1/Resources/Include/externalmedialib.h
deleted file mode 100644
index 8690e47f..00000000
--- a/Modelica/ExternalMedia 3.2.1/Resources/Include/externalmedialib.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/*!
- \file externalmedialib.h
- \brief Header file to be included in the Modelica tool, with external function interfaces
-
- C/C++ layer for external medium models extending from
- PartialExternalTwoPhaseMedium.
-
- Francesco Casella, Christoph Richter, Roberto Bonifetto
- 2006-2012
- Copyright Politecnico di Milano, TU Braunschweig, Politecnico di Torino
-
- Minor additions in 2014 to make ExternalMedia compatible
- with GCC on Linux operating systems
- Jorrit Wronski (Technical University of Denmark)
-*/
-
-#ifndef EXTERNALMEDIALIB_H_
-#define EXTERNALMEDIALIB_H_
-
-// Constants for input choices (see ExternalMedia.Common.InputChoices)
-#define CHOICE_dT 1
-#define CHOICE_hs 2
-#define CHOICE_ph 3
-#define CHOICE_ps 4
-#define CHOICE_pT 5
-
-/*! Detect the platform in order to avoid the DLL commands from
- * making g++ choke. Code taken from CoolProp...
- */
-#if defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__)
-# define __ISWINDOWS__
-#elif __APPLE__
-# define __ISAPPLE__
-#elif __linux
-# define __ISLINUX__
-#endif
-
-/*!
-Portable definitions of the EXPORT macro
- */
-#ifndef EXPORT
-# if defined(__ISLINUX__)
-# define EXPORT
-# elif defined(__ISAPPLE__)
-# define EXPORT
-# else
-# define EXPORT __declspec(dllexport)
-# endif
-#endif
-
-// Define struct
-//! ExternalThermodynamicState property struct
-/*!
- The ExternalThermodynamicState propery struct defines all the properties that
- are computed by external Modelica medium models extending from
- PartialExternalTwoPhaseMedium.
-*/
-
-typedef struct {
-
- //! Temperature
- double T;
- //! Velocity of sound
- double a;
- //! Isobaric expansion coefficient
- double beta;
- //! Specific heat capacity cp
- double cp;
- //! Specific heat capacity cv
- double cv;
- //! Density
- double d;
- //! Derivative of density wrt enthalpy at constant pressure
- double ddhp;
- //! Derivative of density wrt pressure at constant enthalpy
- double ddph;
- //! Dynamic viscosity
- double eta;
- //! Specific enthalpy
- double h;
- //! Compressibility
- double kappa;
- //! Thermal conductivity
- double lambda;
- //! Pressure
- double p;
- //! Phase flag: 2 for two-phase, 1 for one-phase
- int phase;
- //! Specific entropy
- double s;
-
-} ExternalThermodynamicState;
-
-//! ExternalSaturationProperties property struct
-/*!
- The ExternalSaturationProperties propery struct defines all the saturation properties
- for the dew and the bubble line that are computed by external Modelica medium models
- extending from PartialExternalTwoPhaseMedium.
-*/
-
-typedef struct {
- //! Saturation temperature
- double Tsat;
- //! Derivative of Ts wrt pressure
- double dTp;
- //! Derivative of dls wrt pressure
- double ddldp;
- //! Derivative of dvs wrt pressure
- double ddvdp;
- //! Derivative of hls wrt pressure
- double dhldp;
- //! Derivative of hvs wrt pressure
- double dhvdp;
- //! Density at bubble line (for pressure ps)
- double dl;
- //! Density at dew line (for pressure ps)
- double dv;
- //! Specific enthalpy at bubble line (for pressure ps)
- double hl;
- //! Specific enthalpy at dew line (for pressure ps)
- double hv;
- //! Saturation pressure
- double psat;
- //! Surface tension
- double sigma;
- //! Specific entropy at bubble line (for pressure ps)
- double sl;
- //! Specific entropy at dew line (for pressure ps)
- double sv;
-
-} ExternalSaturationProperties;
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
- EXPORT double TwoPhaseMedium_getMolarMass_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_getCriticalTemperature_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_getCriticalPressure_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_getCriticalMolarVolume_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT void TwoPhaseMedium_setState_ph_C_impl(double p, double h, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setState_pT_C_impl(double p, double T, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setState_dT_C_impl(double d, double T, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setState_ps_C_impl(double p, double s, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setState_hs_C_impl(double h, double s, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT double TwoPhaseMedium_partialDeriv_state_C_impl(const char *of, const char *wrt, const char *cst, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT double TwoPhaseMedium_prandtlNumber_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_temperature_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_velocityOfSound_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_isobaricExpansionCoefficient_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_specificHeatCapacityCp_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_specificHeatCapacityCv_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_density_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_density_derh_p_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_density_derp_h_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dynamicViscosity_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_specificEnthalpy_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_isothermalCompressibility_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_thermalConductivity_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_pressure_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_specificEntropy_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_density_ph_der_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_isentropicEnthalpy_C_impl(double p_downstream, ExternalThermodynamicState *refState, const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT void TwoPhaseMedium_setSat_p_C_impl(double p, ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setSat_T_C_impl(double T, ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setBubbleState_C_impl(ExternalSaturationProperties *sat, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setDewState_C_impl(ExternalSaturationProperties *sat, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT double TwoPhaseMedium_saturationTemperature_C_impl(double p, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_saturationTemperature_derp_C_impl(double p, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_saturationTemperature_derp_sat_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT double TwoPhaseMedium_dBubbleDensity_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dDewDensity_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dBubbleEnthalpy_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dDewEnthalpy_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_bubbleDensity_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dewDensity_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_bubbleEnthalpy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dewEnthalpy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_saturationPressure_C_impl(double T, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_surfaceTension_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_bubbleEntropy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dewEntropy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#endif /*EXTERNALMEDIALIB_H_*/
diff --git a/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/ExternalMediaLib.Dymola-VS2008.lib b/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/ExternalMediaLib.Dymola-VS2008.lib
deleted file mode 100644
index db81a664..00000000
Binary files a/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/ExternalMediaLib.Dymola-VS2008.lib and /dev/null differ
diff --git a/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/ExternalMediaLib.Dymola-VS2010.lib b/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/ExternalMediaLib.Dymola-VS2010.lib
deleted file mode 100644
index a23f60d0..00000000
Binary files a/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/ExternalMediaLib.Dymola-VS2010.lib and /dev/null differ
diff --git a/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/ExternalMediaLib.Dymola-VS2012.lib b/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/ExternalMediaLib.Dymola-VS2012.lib
deleted file mode 100644
index 88de09f3..00000000
Binary files a/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/ExternalMediaLib.Dymola-VS2012.lib and /dev/null differ
diff --git a/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/libExternalMediaLib.OMC-gcc.a b/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/libExternalMediaLib.OMC-gcc.a
deleted file mode 100644
index 2dfe1d4f..00000000
Binary files a/Modelica/ExternalMedia 3.2.1/Resources/Library/win32/libExternalMediaLib.OMC-gcc.a and /dev/null differ
diff --git a/Modelica/ExternalMedia 3.2.1/Resources/manual.pdf b/Modelica/ExternalMedia 3.2.1/Resources/manual.pdf
deleted file mode 100644
index d1fbc5df..00000000
Binary files a/Modelica/ExternalMedia 3.2.1/Resources/manual.pdf and /dev/null differ
diff --git a/Modelica/ExternalMedia 3.2.1/Common/CheckCoolPropOptions.mo b/Modelica/ExternalMedia 3.3.0/Common/CheckCoolPropOptions.mo
similarity index 100%
rename from Modelica/ExternalMedia 3.2.1/Common/CheckCoolPropOptions.mo
rename to Modelica/ExternalMedia 3.3.0/Common/CheckCoolPropOptions.mo
diff --git a/Modelica/ExternalMedia 3.2.1/Common/InputChoice.mo b/Modelica/ExternalMedia 3.3.0/Common/InputChoice.mo
similarity index 96%
rename from Modelica/ExternalMedia 3.2.1/Common/InputChoice.mo
rename to Modelica/ExternalMedia 3.3.0/Common/InputChoice.mo
index 73ff961d..2c012ac6 100644
--- a/Modelica/ExternalMedia 3.2.1/Common/InputChoice.mo
+++ b/Modelica/ExternalMedia 3.3.0/Common/InputChoice.mo
@@ -1,7 +1,7 @@
-within ExternalMedia.Common;
-type InputChoice = enumeration(
- dT "(d,T) as inputs",
- hs "(h,s) as inputs",
- ph "(p,h) as inputs",
- ps "(p,s) as inputs",
- pT "(p,T) as inputs");
+within ExternalMedia.Common;
+type InputChoice = enumeration(
+ dT "(d,T) as inputs",
+ hs "(h,s) as inputs",
+ ph "(p,h) as inputs",
+ ps "(p,s) as inputs",
+ pT "(p,T) as inputs");
diff --git a/Modelica/ExternalMedia 3.2.1/Common/InputChoiceIncompressible.mo b/Modelica/ExternalMedia 3.3.0/Common/InputChoiceIncompressible.mo
similarity index 100%
rename from Modelica/ExternalMedia 3.2.1/Common/InputChoiceIncompressible.mo
rename to Modelica/ExternalMedia 3.3.0/Common/InputChoiceIncompressible.mo
diff --git a/Modelica/ExternalMedia 3.2.1/Common/InputChoiceMixture.mo b/Modelica/ExternalMedia 3.3.0/Common/InputChoiceMixture.mo
similarity index 100%
rename from Modelica/ExternalMedia 3.2.1/Common/InputChoiceMixture.mo
rename to Modelica/ExternalMedia 3.3.0/Common/InputChoiceMixture.mo
diff --git a/Modelica/ExternalMedia 3.2.1/Common/XtoName.mo b/Modelica/ExternalMedia 3.3.0/Common/XtoName.mo
similarity index 93%
rename from Modelica/ExternalMedia 3.2.1/Common/XtoName.mo
rename to Modelica/ExternalMedia 3.3.0/Common/XtoName.mo
index 2f117ed8..efb79353 100644
--- a/Modelica/ExternalMedia 3.2.1/Common/XtoName.mo
+++ b/Modelica/ExternalMedia 3.3.0/Common/XtoName.mo
@@ -1,39 +1,39 @@
-within ExternalMedia.Common;
-function XtoName "A function to convert concentration to substance name"
- extends Modelica.Icons.Function;
- input String substanceName = "";
- input Real[:] composition = {0.0};
- input String delimiter = "|";
- input Boolean debug = false;
- output String result;
-protected
- Integer nextIndex;
- Integer inLength;
- String name;
- String rest;
-algorithm
- if noEvent(size(composition,1) <= 0) then
- assert(not debug, "You are passing an empty composition vector, returning name only: "+substanceName, level= AssertionLevel.warning);
- result :=substanceName;
- else
- assert(noEvent(size(composition,1)==1), "Your mixture has more than two components, ignoring all but the first element.", level= AssertionLevel.warning);
- inLength := Modelica.Utilities.Strings.length(substanceName);
- nextIndex := Modelica.Utilities.Strings.find(substanceName, delimiter);
- if noEvent(nextIndex<2) then
- // Assuming there are no special options
- name := substanceName;
- rest := "";
- else
- name := Modelica.Utilities.Strings.substring(substanceName, 1, nextIndex-1);
- rest := Modelica.Utilities.Strings.substring(substanceName, nextIndex, inLength);
- end if;
- if noEvent(noEvent(composition[1]<=0) or noEvent(composition[1]>=1)) then
- result := substanceName;
- else
- result := name + "-" + String(composition[1]) + rest;
- end if;
- end if;
- if noEvent(debug) then
- Modelica.Utilities.Streams.print(result+" --- "+substanceName);
- end if;
-end XtoName;
+within ExternalMedia.Common;
+function XtoName "A function to convert concentration to substance name"
+ extends Modelica.Icons.Function;
+ input String substanceName = "";
+ input Real[:] composition = {0.0};
+ input String delimiter = "|";
+ input Boolean debug = false;
+ output String result;
+protected
+ Integer nextIndex;
+ Integer inLength;
+ String name;
+ String rest;
+algorithm
+ if noEvent(size(composition,1) <= 0) then
+ assert(not debug, "You are passing an empty composition vector, returning name only: "+substanceName, level= AssertionLevel.warning);
+ result :=substanceName;
+ else
+ assert(noEvent(size(composition,1)==1), "Your mixture has more than two components, ignoring all but the first element.", level= AssertionLevel.warning);
+ inLength := Modelica.Utilities.Strings.length(substanceName);
+ nextIndex := Modelica.Utilities.Strings.find(substanceName, delimiter);
+ if noEvent(nextIndex<2) then
+ // Assuming there are no special options
+ name := substanceName;
+ rest := "";
+ else
+ name := Modelica.Utilities.Strings.substring(substanceName, 1, nextIndex-1);
+ rest := Modelica.Utilities.Strings.substring(substanceName, nextIndex, inLength);
+ end if;
+ if noEvent(noEvent(composition[1]<=0) or noEvent(composition[1]>=1)) then
+ result := substanceName;
+ else
+ result := name + "[" + String(composition[1]) + "]" + rest;
+ end if;
+ end if;
+ if noEvent(debug) then
+ Modelica.Utilities.Streams.print(result+" --- "+substanceName);
+ end if;
+end XtoName;
diff --git a/Modelica/ExternalMedia 3.2.1/Common/package.mo b/Modelica/ExternalMedia 3.3.0/Common/package.mo
similarity index 96%
rename from Modelica/ExternalMedia 3.2.1/Common/package.mo
rename to Modelica/ExternalMedia 3.3.0/Common/package.mo
index 9160c429..cf50c872 100644
--- a/Modelica/ExternalMedia 3.2.1/Common/package.mo
+++ b/Modelica/ExternalMedia 3.3.0/Common/package.mo
@@ -1,4 +1,4 @@
-within ExternalMedia;
-package Common "Package with common definitions"
- extends Modelica.Icons.Package;
-end Common;
+within ExternalMedia;
+package Common "Package with common definitions"
+ extends Modelica.Icons.Package;
+end Common;
diff --git a/Modelica/ExternalMedia 3.2.1/Common/package.order b/Modelica/ExternalMedia 3.3.0/Common/package.order
similarity index 94%
rename from Modelica/ExternalMedia 3.2.1/Common/package.order
rename to Modelica/ExternalMedia 3.3.0/Common/package.order
index d08c65f8..c07bcdaf 100644
--- a/Modelica/ExternalMedia 3.2.1/Common/package.order
+++ b/Modelica/ExternalMedia 3.3.0/Common/package.order
@@ -1,5 +1,5 @@
-InputChoice
-InputChoiceMixture
-InputChoiceIncompressible
-XtoName
-CheckCoolPropOptions
+InputChoice
+InputChoiceMixture
+InputChoiceIncompressible
+XtoName
+CheckCoolPropOptions
diff --git a/Modelica/ExternalMedia 3.2.1/Examples.mo b/Modelica/ExternalMedia 3.3.0/Examples.mo
similarity index 86%
rename from Modelica/ExternalMedia 3.2.1/Examples.mo
rename to Modelica/ExternalMedia 3.3.0/Examples.mo
index 1797879b..c78a955f 100644
--- a/Modelica/ExternalMedia 3.2.1/Examples.mo
+++ b/Modelica/ExternalMedia 3.3.0/Examples.mo
@@ -1,76 +1,85 @@
-within ExternalMedia;
-package Examples "Examples of external medium models"
- extends Modelica.Icons.Package;
- package WaterIF95 "RefProp water model"
- extends ExternalMedia.Media.FluidPropMedium(
- mediumName = "Water",
- libraryName = "FluidProp.RefProp",
- substanceNames = {"H2O"},
- ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph);
- end WaterIF95;
-
- package WaterTPSI "TPSI Water model"
- extends ExternalMedia.Media.FluidPropMedium(
- mediumName = "Water",
- libraryName = "FluidProp.TPSI",
- substanceNames = {"H2O"},
- ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph);
- end WaterTPSI;
-
- package WaterIF97 "IF97 Water model"
- extends ExternalMedia.Media.FluidPropMedium(
- mediumName = "Water",
- libraryName = "FluidProp.IF97",
- substanceNames = {"H2O"},
- ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph);
- end WaterIF97;
-
- package CO2StanMix "StanMix model of CO2"
- extends ExternalMedia.Media.FluidPropMedium(
- mediumName = "Carbon Dioxide",
- libraryName = "FluidProp.StanMix",
- substanceNames = {"CO2"},
- ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph);
- end CO2StanMix;
-
- package CO2RefProp "RefProp model of CO2"
- extends ExternalMedia.Media.FluidPropMedium(
- mediumName = "Carbon Dioxide",
- libraryName = "FluidProp.RefProp",
- substanceNames = {"CO2"},
- ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
- SpecificEnthalpy(start = 2e5));
- end CO2RefProp;
-
- package CO2CoolProp "CoolProp model of CO2"
- extends ExternalMedia.Media.CoolPropMedium(
- mediumName = "CarbonDioxide",
- substanceNames = {"CO2"},
- ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
- SpecificEnthalpy(start=2e5));
- end CO2CoolProp;
-
- package WaterCoolProp "CoolProp model of water"
- extends ExternalMedia.Media.CoolPropMedium(
- mediumName = "Water",
- substanceNames = {"water"},
- ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
- AbsolutePressure(start=10e5),
- SpecificEnthalpy(start=2e5));
- end WaterCoolProp;
-
- package DowQCoolProp "DowthermQ properties from CoolProp"
- extends ExternalMedia.Media.IncompressibleCoolPropMedium(
- mediumName="DowQ",
- substanceNames={"DowQ|calc_transport=1"},
- ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.pT);
- end DowQCoolProp;
-
- package LiBrAQCoolProp "Lithium bromide solution properties from CoolProp"
- extends ExternalMedia.Media.IncompressibleCoolPropMedium(
- mediumName="LiBr",
- substanceNames={"LiBr|calc_transport=1","dummyToMakeBasePropertiesWork"},
- ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.pTX);
- end LiBrAQCoolProp;
-
-end Examples;
+within ExternalMedia;
+package Examples "Examples of external medium models"
+ extends Modelica.Icons.Package;
+ package WaterIF95 "RefProp water model"
+ extends ExternalMedia.Media.FluidPropMedium(
+ mediumName = "Water",
+ libraryName = "FluidProp.RefProp",
+ substanceNames = {"H2O"},
+ ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph);
+ end WaterIF95;
+
+ package WaterTPSI "TPSI Water model"
+ extends ExternalMedia.Media.FluidPropMedium(
+ mediumName = "Water",
+ libraryName = "FluidProp.TPSI",
+ substanceNames = {"H2O"},
+ ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph);
+ end WaterTPSI;
+
+ package WaterIF97 "IF97 Water model"
+ extends ExternalMedia.Media.FluidPropMedium(
+ mediumName = "Water",
+ libraryName = "FluidProp.IF97",
+ substanceNames = {"H2O"},
+ ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph);
+ end WaterIF97;
+
+ package CO2StanMix "StanMix model of CO2"
+ extends ExternalMedia.Media.FluidPropMedium(
+ mediumName = "Carbon Dioxide",
+ libraryName = "FluidProp.StanMix",
+ substanceNames = {"CO2"},
+ ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph);
+ end CO2StanMix;
+
+ package CO2RefProp "RefProp model of CO2"
+ extends ExternalMedia.Media.FluidPropMedium(
+ mediumName = "Carbon Dioxide",
+ libraryName = "FluidProp.RefProp",
+ substanceNames = {"CO2"},
+ ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
+ SpecificEnthalpy(start = 2e5));
+ end CO2RefProp;
+
+ package CO2CoolProp "CoolProp model of CO2"
+ extends ExternalMedia.Media.CoolPropMedium(
+ mediumName = "CarbonDioxide",
+ substanceNames = {"CO2"},
+ ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
+ SpecificEnthalpy(start=2e5));
+ end CO2CoolProp;
+
+ package WaterCoolProp "CoolProp model of water"
+ extends ExternalMedia.Media.CoolPropMedium(
+ mediumName = "Water",
+ substanceNames = {"water"},
+ ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
+ AbsolutePressure(start=10e5),
+ SpecificEnthalpy(start=2e5));
+ end WaterCoolProp;
+
+ package WaterCoolPropTabular "CoolProp model of water using tabulated data"
+ extends ExternalMedia.Media.CoolPropMedium(
+ mediumName = "Water",
+ substanceNames = {"water|enable_BICUBIC=1"},
+ ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
+ AbsolutePressure(start=10e5),
+ SpecificEnthalpy(start=2e5));
+ end WaterCoolPropTabular;
+
+ package DowQCoolProp "DowthermQ properties from CoolProp"
+ extends ExternalMedia.Media.IncompressibleCoolPropMedium(
+ mediumName="DowQ",
+ substanceNames={"DowQ|calc_transport=1"},
+ ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.pT);
+ end DowQCoolProp;
+
+ package LiBrAQCoolProp "Lithium bromide solution properties from CoolProp"
+ extends ExternalMedia.Media.IncompressibleCoolPropMedium(
+ mediumName="LiBr",
+ substanceNames={"LiBr|calc_transport=1","dummyToMakeBasePropertiesWork"},
+ ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.pTX);
+ end LiBrAQCoolProp;
+
+end Examples;
diff --git a/Modelica/ExternalMedia 3.2.1/Media/BaseClasses/ExternalTwoPhaseMedium.mo b/Modelica/ExternalMedia 3.3.0/Media/BaseClasses/ExternalTwoPhaseMedium.mo
similarity index 100%
rename from Modelica/ExternalMedia 3.2.1/Media/BaseClasses/ExternalTwoPhaseMedium.mo
rename to Modelica/ExternalMedia 3.3.0/Media/BaseClasses/ExternalTwoPhaseMedium.mo
diff --git a/Modelica/ExternalMedia 3.2.1/Media/BaseClasses/package.mo b/Modelica/ExternalMedia 3.3.0/Media/BaseClasses/package.mo
similarity index 100%
rename from Modelica/ExternalMedia 3.2.1/Media/BaseClasses/package.mo
rename to Modelica/ExternalMedia 3.3.0/Media/BaseClasses/package.mo
diff --git a/Modelica/ExternalMedia 3.2.1/Media/BaseClasses/package.order b/Modelica/ExternalMedia 3.3.0/Media/BaseClasses/package.order
similarity index 100%
rename from Modelica/ExternalMedia 3.2.1/Media/BaseClasses/package.order
rename to Modelica/ExternalMedia 3.3.0/Media/BaseClasses/package.order
diff --git a/Modelica/ExternalMedia 3.2.1/Media/CoolPropMedium.mo b/Modelica/ExternalMedia 3.3.0/Media/CoolPropMedium.mo
similarity index 100%
rename from Modelica/ExternalMedia 3.2.1/Media/CoolPropMedium.mo
rename to Modelica/ExternalMedia 3.3.0/Media/CoolPropMedium.mo
diff --git a/Modelica/ExternalMedia 3.2.1/Media/FluidPropMedium.mo b/Modelica/ExternalMedia 3.3.0/Media/FluidPropMedium.mo
similarity index 98%
rename from Modelica/ExternalMedia 3.2.1/Media/FluidPropMedium.mo
rename to Modelica/ExternalMedia 3.3.0/Media/FluidPropMedium.mo
index 7b93edf6..51951f1b 100644
--- a/Modelica/ExternalMedia 3.2.1/Media/FluidPropMedium.mo
+++ b/Modelica/ExternalMedia 3.3.0/Media/FluidPropMedium.mo
@@ -1,49 +1,49 @@
-within ExternalMedia.Media;
-package FluidPropMedium "Medium package accessing the FluidProp solver"
- extends BaseClasses.ExternalTwoPhaseMedium;
- redeclare replaceable function setBubbleState
- "Set the thermodynamic state on the bubble line"
- extends Modelica.Icons.Function;
- input SaturationProperties sat "saturation point";
- input FixedPhase phase = 0 "phase flag";
- output ThermodynamicState state "complete thermodynamic state info";
- // Standard definition
- external "C" TwoPhaseMedium_setBubbleState_C_impl(sat, phase, state, mediumName, libraryName, substanceName)
- annotation(Include="#include \"externalmedialib.h\"", Library="ExternalMediaLib", IncludeDirectory="modelica://ExternalMedia/Resources/Include", LibraryDirectory="modelica://ExternalMedia/Resources/Library");
- annotation(Inline = true);
- end setBubbleState;
-
- redeclare replaceable function setDewState
- "Set the thermodynamic state on the dew line"
- extends Modelica.Icons.Function;
- input SaturationProperties sat "saturation point";
- input FixedPhase phase = 0 "phase flag";
- output ThermodynamicState state "complete thermodynamic state info";
- // Standard definition
- external "C" TwoPhaseMedium_setDewState_C_impl(sat, phase, state, mediumName, libraryName, substanceName)
- annotation(Include="#include \"externalmedialib.h\"", Library="ExternalMediaLib", IncludeDirectory="modelica://ExternalMedia/Resources/Include", LibraryDirectory="modelica://ExternalMedia/Resources/Library");
- annotation(Inline = true);
- end setDewState;
-
- redeclare function bubbleEntropy "Return bubble point specific entropy"
- input SaturationProperties sat "saturation property record";
- output SI.SpecificEntropy sl "boiling curve specific entropy";
- algorithm
- sl := specificEntropy(setBubbleState(sat));
- end bubbleEntropy;
-
- redeclare function dewEntropy "Return dew point specific entropy"
- input SaturationProperties sat "saturation property record";
- output SI.SpecificEntropy sv "dew curve specific entropy";
- algorithm
- sv := specificEntropy(setDewState(sat));
- end dewEntropy;
-
- redeclare function surfaceTension
- extends Modelica.Icons.Function;
- input SaturationProperties sat "saturation property record";
- output SurfaceTension sigma "Surface tension sigma in the two phase region";
- algorithm
- assert(false, "The FluidProp solver does not provide surface tension");
- end surfaceTension;
-end FluidPropMedium;
+within ExternalMedia.Media;
+package FluidPropMedium "Medium package accessing the FluidProp solver"
+ extends BaseClasses.ExternalTwoPhaseMedium;
+ redeclare replaceable function setBubbleState
+ "Set the thermodynamic state on the bubble line"
+ extends Modelica.Icons.Function;
+ input SaturationProperties sat "saturation point";
+ input FixedPhase phase = 0 "phase flag";
+ output ThermodynamicState state "complete thermodynamic state info";
+ // Standard definition
+ external "C" TwoPhaseMedium_setBubbleState_C_impl(sat, phase, state, mediumName, libraryName, substanceName)
+ annotation(Include="#include \"externalmedialib.h\"", Library="ExternalMediaLib", IncludeDirectory="modelica://ExternalMedia/Resources/Include", LibraryDirectory="modelica://ExternalMedia/Resources/Library");
+ annotation(Inline = true);
+ end setBubbleState;
+
+ redeclare replaceable function setDewState
+ "Set the thermodynamic state on the dew line"
+ extends Modelica.Icons.Function;
+ input SaturationProperties sat "saturation point";
+ input FixedPhase phase = 0 "phase flag";
+ output ThermodynamicState state "complete thermodynamic state info";
+ // Standard definition
+ external "C" TwoPhaseMedium_setDewState_C_impl(sat, phase, state, mediumName, libraryName, substanceName)
+ annotation(Include="#include \"externalmedialib.h\"", Library="ExternalMediaLib", IncludeDirectory="modelica://ExternalMedia/Resources/Include", LibraryDirectory="modelica://ExternalMedia/Resources/Library");
+ annotation(Inline = true);
+ end setDewState;
+
+ redeclare function bubbleEntropy "Return bubble point specific entropy"
+ input SaturationProperties sat "saturation property record";
+ output SI.SpecificEntropy sl "boiling curve specific entropy";
+ algorithm
+ sl := specificEntropy(setBubbleState(sat));
+ end bubbleEntropy;
+
+ redeclare function dewEntropy "Return dew point specific entropy"
+ input SaturationProperties sat "saturation property record";
+ output SI.SpecificEntropy sv "dew curve specific entropy";
+ algorithm
+ sv := specificEntropy(setDewState(sat));
+ end dewEntropy;
+
+ redeclare function surfaceTension
+ extends Modelica.Icons.Function;
+ input SaturationProperties sat "saturation property record";
+ output SurfaceTension sigma "Surface tension sigma in the two phase region";
+ algorithm
+ assert(false, "The FluidProp solver does not provide surface tension");
+ end surfaceTension;
+end FluidPropMedium;
diff --git a/Modelica/ExternalMedia 3.2.1/Media/IncompressibleCoolPropMedium.mo b/Modelica/ExternalMedia 3.3.0/Media/IncompressibleCoolPropMedium.mo
similarity index 99%
rename from Modelica/ExternalMedia 3.2.1/Media/IncompressibleCoolPropMedium.mo
rename to Modelica/ExternalMedia 3.3.0/Media/IncompressibleCoolPropMedium.mo
index c90dce4f..d650770d 100644
--- a/Modelica/ExternalMedia 3.2.1/Media/IncompressibleCoolPropMedium.mo
+++ b/Modelica/ExternalMedia 3.3.0/Media/IncompressibleCoolPropMedium.mo
@@ -6,7 +6,7 @@ partial package IncompressibleCoolPropMedium
singleState = true,
reducedX = true);
import ExternalMedia.Common.InputChoiceIncompressible;
- constant String libraryName = "CoolProp"
+ constant String libraryName = "CoolProp|INCOMP"
"Name of the external fluid property computation library";
constant String substanceName = ExternalMedia.Common.CheckCoolPropOptions(substanceNames[1],debug=false)
"Only one substance can be specified, predefined mixture in CoolProp";
diff --git a/Modelica/ExternalMedia 3.2.1/Media/TestMedium.mo b/Modelica/ExternalMedia 3.3.0/Media/TestMedium.mo
similarity index 97%
rename from Modelica/ExternalMedia 3.2.1/Media/TestMedium.mo
rename to Modelica/ExternalMedia 3.3.0/Media/TestMedium.mo
index 6e32b5c9..bb0a9358 100644
--- a/Modelica/ExternalMedia 3.2.1/Media/TestMedium.mo
+++ b/Modelica/ExternalMedia 3.3.0/Media/TestMedium.mo
@@ -1,7 +1,7 @@
-within ExternalMedia.Media;
-package TestMedium "Simple water medium model for debugging and testing"
- extends BaseClasses.ExternalTwoPhaseMedium(
- mediumName = "TestMedium",
- libraryName = "TestMedium",
- ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.pT);
-end TestMedium;
+within ExternalMedia.Media;
+package TestMedium "Simple water medium model for debugging and testing"
+ extends BaseClasses.ExternalTwoPhaseMedium(
+ mediumName = "TestMedium",
+ libraryName = "TestMedium",
+ ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.pT);
+end TestMedium;
diff --git a/Modelica/ExternalMedia 3.2.1/Media/package.mo b/Modelica/ExternalMedia 3.3.0/Media/package.mo
similarity index 97%
rename from Modelica/ExternalMedia 3.2.1/Media/package.mo
rename to Modelica/ExternalMedia 3.3.0/Media/package.mo
index 3d6e35c8..b0e8f15c 100644
--- a/Modelica/ExternalMedia 3.2.1/Media/package.mo
+++ b/Modelica/ExternalMedia 3.3.0/Media/package.mo
@@ -1,4 +1,4 @@
-within ExternalMedia;
-package Media "Medium packages compatible with Modelica.Media"
- extends Modelica.Icons.Package;
-end Media;
+within ExternalMedia;
+package Media "Medium packages compatible with Modelica.Media"
+ extends Modelica.Icons.Package;
+end Media;
diff --git a/Modelica/ExternalMedia 3.2.1/Media/package.order b/Modelica/ExternalMedia 3.3.0/Media/package.order
similarity index 94%
rename from Modelica/ExternalMedia 3.2.1/Media/package.order
rename to Modelica/ExternalMedia 3.3.0/Media/package.order
index 442273e7..db97a764 100644
--- a/Modelica/ExternalMedia 3.2.1/Media/package.order
+++ b/Modelica/ExternalMedia 3.3.0/Media/package.order
@@ -1,5 +1,5 @@
-FluidPropMedium
-CoolPropMedium
-IncompressibleCoolPropMedium
-TestMedium
-BaseClasses
+FluidPropMedium
+CoolPropMedium
+IncompressibleCoolPropMedium
+TestMedium
+BaseClasses
diff --git a/Modelica/ExternalMedia 3.3.0/Resources/Include/.gitignore b/Modelica/ExternalMedia 3.3.0/Resources/Include/.gitignore
new file mode 100644
index 00000000..172f4779
--- /dev/null
+++ b/Modelica/ExternalMedia 3.3.0/Resources/Include/.gitignore
@@ -0,0 +1 @@
+/externalmedialib.h
diff --git a/Modelica/ExternalMedia 3.3.0/Resources/Library/.gitignore b/Modelica/ExternalMedia 3.3.0/Resources/Library/.gitignore
new file mode 100644
index 00000000..e294dc79
--- /dev/null
+++ b/Modelica/ExternalMedia 3.3.0/Resources/Library/.gitignore
@@ -0,0 +1,5 @@
+**.lib
+**.a
+**.dll
+**.so
+**.dylib
diff --git a/Modelica/ExternalMedia 3.2.1/Test.mo b/Modelica/ExternalMedia 3.3.0/Test.mo
similarity index 95%
rename from Modelica/ExternalMedia 3.2.1/Test.mo
rename to Modelica/ExternalMedia 3.3.0/Test.mo
index 2db623e7..cc4e9250 100644
--- a/Modelica/ExternalMedia 3.2.1/Test.mo
+++ b/Modelica/ExternalMedia 3.3.0/Test.mo
@@ -1,1780 +1,1795 @@
-within ExternalMedia;
-package Test "Test models for the different solvers"
- extends Modelica.Icons.ExamplesPackage;
- package TestMedium "Test cases for TestMedium"
- extends Modelica.Icons.ExamplesPackage;
- model TestConstants "Test case using TestMedium with package constants"
- extends Modelica.Icons.Example;
- replaceable package Medium = Media.TestMedium;
- Medium.Temperature Tc=Medium.fluidConstants[1].criticalTemperature;
- end TestConstants;
-
- model TestState "Test case using TestMedium with a single state record"
- extends Modelica.Icons.Example;
- replaceable package Medium = Media.TestMedium;
- Medium.ThermodynamicState state;
- equation
- state = Medium.setState_ph(1e5, 1e5 + 1e5*time);
- end TestState;
-
- model TestSat
- "Test case using TestMedium with a single saturation properties record"
- extends Modelica.Icons.Example;
- replaceable package Medium = Media.TestMedium;
- Medium.SaturationProperties sat;
- equation
- sat = Medium.setSat_p(1e5 + 1e5*time);
- end TestSat;
-
- model TestStatesSat "Test case using TestMedium with state + sat records"
- extends Modelica.Icons.Example;
- replaceable package Medium = Media.TestMedium;
- Medium.BaseProperties baseProperties1;
- Medium.BaseProperties baseProperties2;
- Medium.ThermodynamicState state1;
- Medium.ThermodynamicState state2;
- Medium.SaturationProperties sat1;
- Medium.SaturationProperties sat2;
- Medium.Temperature Ts;
- Medium.AbsolutePressure ps;
- GenericModels.CompleteThermodynamicState completeState1(redeclare package
- Medium = Medium, state=state1);
- GenericModels.CompleteThermodynamicState completeState2(redeclare package
- Medium = Medium, state=state2);
- GenericModels.CompleteSaturationProperties completeSat1(redeclare package
- Medium = Medium, sat=sat1);
- GenericModels.CompleteSaturationProperties completeSat2(redeclare package
- Medium = Medium, sat=sat2);
- GenericModels.CompleteBubbleDewStates completeBubbleDewStates1(redeclare
- package Medium = Medium, sat=sat1);
- GenericModels.CompleteBubbleDewStates completeBubbleDewStates2(redeclare
- package Medium = Medium, sat=sat1);
- equation
- baseProperties1.p = 1e5 + 1e5*time;
- baseProperties1.h = 1e5;
- baseProperties2.p = 1e5;
- baseProperties2.h = 1e5 + 2e5*time;
- state1 = Medium.setState_ph(1e5 + 1e5*time, 1e5);
- state2 = Medium.setState_pT(1e5, 300 + 50*time);
- sat1 = Medium.setSat_p(1e5 + 1e5*time);
- sat2 = Medium.setSat_T(300 + 50*time);
- Ts = Medium.saturationTemperature(1e5 + 1e5*time);
- ps = Medium.saturationPressure(300 + 50*time);
- end TestStatesSat;
-
- model TestBasePropertiesExplicit
- "Test case using TestMedium and BaseProperties with explicit equations"
- extends Modelica.Icons.Example;
- replaceable package Medium = Media.TestMedium;
- ExternalMedia.Test.TestMedium.GenericModels.CompleteBaseProperties
- medium1(redeclare package Medium = Medium)
- "Constant pressure, varying enthalpy";
- ExternalMedia.Test.TestMedium.GenericModels.CompleteBaseProperties
- medium2(redeclare package Medium = Medium)
- "Varying pressure, constant enthalpy";
- equation
- medium1.baseProperties.p = 1e5 + 1e5*time;
- medium1.baseProperties.h = 1e5;
- medium2.baseProperties.p = 1e5;
- medium2.baseProperties.h = 1e5 + 2e5*time;
- end TestBasePropertiesExplicit;
-
- model TestBasePropertiesImplicit
- "Test case using TestMedium and BaseProperties with implicit equations"
- replaceable package Medium = Media.TestMedium;
- extends Modelica.Icons.Example;
- ExternalMedia.Test.TestMedium.GenericModels.CompleteBaseProperties
- medium1(redeclare package Medium = Medium, baseProperties(h(start=1e5)))
- "Constant pressure, varying enthalpy";
- ExternalMedia.Test.TestMedium.GenericModels.CompleteBaseProperties
- medium2(redeclare package Medium = Medium, baseProperties(h(start=1e5)))
- "Varying pressure, constant enthalpy";
- equation
- medium1.baseProperties.p = 1e5*time;
- medium1.baseProperties.T = 300 + 25*time;
- medium2.baseProperties.p = 1e5 + 1e5*time;
- medium2.baseProperties.T = 300;
- end TestBasePropertiesImplicit;
-
- model TestBasePropertiesDynamic
- "Test case using TestMedium and dynamic equations"
- extends Modelica.Icons.Example;
- replaceable package Medium = Media.TestMedium;
- parameter SI.Volume V=1 "Storage Volume";
- parameter Real p_atm=101325 "Atmospheric pressure";
- parameter SI.Temperature Tstart=300;
- parameter Real Kv0=1.00801e-2 "Valve flow coefficient";
- Medium.BaseProperties medium(preferredMediumStates=true);
- SI.Mass M;
- SI.Energy U;
- SI.MassFlowRate win(start=100);
- SI.MassFlowRate wout;
- SI.SpecificEnthalpy hin;
- SI.SpecificEnthalpy hout;
- SI.Power Q;
- Real Kv;
- equation
- // Mass & energy balance equation
- M = medium.d*V;
- U = medium.u*M;
- der(M) = win - wout;
- der(U) = win*hin - wout*hout + Q;
- // Inlet pump equations
- medium.p - p_atm = 2e5 - (1e5/100^2)*win^2;
- hin = 1e5;
- // Outlet valve equation
- wout = Kv*sqrt(medium.d*(medium.p - p_atm));
- hout = medium.h;
- // Input variables
- Kv = if time < 50 then Kv0 else Kv0*1.1;
- Q = if time < 1 then 0 else 1e7;
- initial equation
- // Initial conditions
- // Fixed initial states
- // medium.p = 2e5;
- // medium.h = 1e5;
- // Steady state equations
- der(medium.p) = 0;
- der(medium.h) = 0;
- annotation (experiment(StopTime=80, Tolerance=1e-007),
- experimentSetupOutput(equdistant=false));
- end TestBasePropertiesDynamic;
-
- package GenericModels
- "Contains generic models to use for thorough medium model testing"
- extends Modelica.Icons.BasesPackage;
- model CompleteFluidConstants
- "Compute all available medium fluid constants"
- replaceable package Medium =
- Modelica.Media.Interfaces.PartialTwoPhaseMedium;
- // Fluid constants
- Medium.Temperature Tc=Medium.fluidConstants[1].criticalTemperature;
- Medium.AbsolutePressure pc=Medium.fluidConstants[1].criticalPressure;
- Medium.MolarVolume vc=Medium.fluidConstants[1].criticalMolarVolume;
- Medium.MolarMass MM=Medium.fluidConstants[1].molarMass;
- end CompleteFluidConstants;
-
- model CompleteThermodynamicState
- "Compute all available two-phase medium properties from a ThermodynamicState model"
- replaceable package Medium =
- Modelica.Media.Interfaces.PartialTwoPhaseMedium;
- // ThermodynamicState record
- input Medium.ThermodynamicState state;
- // Medium properties
- Medium.AbsolutePressure p=Medium.pressure(state);
- Medium.SpecificEnthalpy h=Medium.specificEnthalpy(state);
- Medium.Temperature T=Medium.temperature(state);
- Medium.Density d=Medium.density(state);
- Medium.SpecificEntropy s=Medium.specificEntropy(state);
- Medium.SpecificHeatCapacity cp=Medium.specificHeatCapacityCp(state);
- Medium.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(state);
- Medium.IsobaricExpansionCoefficient beta=
- Medium.isobaricExpansionCoefficient(state);
- SI.IsothermalCompressibility kappa=Medium.isothermalCompressibility(
- state);
- Medium.DerDensityByPressure d_d_dp_h=Medium.density_derp_h(state);
- Medium.DerDensityByEnthalpy d_d_dh_p=Medium.density_derh_p(state);
- Medium.MolarMass MM=Medium.molarMass(state);
- end CompleteThermodynamicState;
-
- model CompleteSaturationProperties
- "Compute all available saturation properties from a SaturationProperties record"
- replaceable package Medium =
- Modelica.Media.Interfaces.PartialTwoPhaseMedium;
- // SaturationProperties record
- input Medium.SaturationProperties sat;
- // Saturation properties
- Medium.Temperature Ts=Medium.saturationTemperature_sat(sat);
- Medium.Density dl=Medium.bubbleDensity(sat);
- Medium.Density dv=Medium.dewDensity(sat);
- Medium.SpecificEnthalpy hl=Medium.bubbleEnthalpy(sat);
- Medium.SpecificEnthalpy hv=Medium.dewEnthalpy(sat);
- Real d_Ts_dp=Medium.saturationTemperature_derp_sat(sat);
- Real d_dl_dp=Medium.dBubbleDensity_dPressure(sat);
- Real d_dv_dp=Medium.dDewDensity_dPressure(sat);
- Real d_hl_dp=Medium.dBubbleEnthalpy_dPressure(sat);
- Real d_hv_dp=Medium.dDewEnthalpy_dPressure(sat);
- end CompleteSaturationProperties;
-
- model CompleteBubbleDewStates
- "Compute all available properties for dewpoint and bubble point states corresponding to a sat record"
- replaceable package Medium =
- Modelica.Media.Interfaces.PartialTwoPhaseMedium;
- // SaturationProperties record
- input Medium.SaturationProperties sat;
- CompleteThermodynamicState dewStateOnePhase(state=Medium.setDewState(
- sat, 1), redeclare package Medium = Medium);
- CompleteThermodynamicState dewStateTwoPhase(state=Medium.setDewState(
- sat, 2), redeclare package Medium = Medium);
- CompleteThermodynamicState bubbleStateOnePhase(state=
- Medium.setBubbleState(sat, 1), redeclare package Medium = Medium);
- CompleteThermodynamicState bubbleStateTwoPhase(state=
- Medium.setBubbleState(sat, 2), redeclare package Medium = Medium);
- end CompleteBubbleDewStates;
-
- model CompleteBaseProperties
- "Compute all available two-phase medium properties from a BaseProperties model"
- replaceable package Medium =
- Modelica.Media.Interfaces.PartialTwoPhaseMedium;
- // BaseProperties object
- Medium.BaseProperties baseProperties;
- // All the complete properties
- CompleteThermodynamicState completeState(redeclare package Medium =
- Medium, state=baseProperties.state);
- CompleteSaturationProperties completeSat(redeclare package Medium =
- Medium, sat=baseProperties.sat);
- CompleteFluidConstants completeConstants(redeclare package Medium =
- Medium);
- CompleteBubbleDewStates completeBubbleDewStates(redeclare package
- Medium = Medium, sat=baseProperties.sat);
- end CompleteBaseProperties;
- end GenericModels;
-
- model TestRunner "A model to collect generaic test cases"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- ExternalMedia.Test.GenericModels.CompleteFluidConstants
- completeFluidConstants(redeclare package Medium =
- ExternalMedia.Media.TestMedium)
- annotation (Placement(transformation(extent={{-60,60},{-40,80}})));
- equation
-
- end TestRunner;
- end TestMedium;
-
- package FluidProp "Test cases for FluidPropMedium"
- extends Modelica.Icons.ExamplesPackage;
-
- package WaterIF95 "Test suite for the FluidProp-Refprop IF95 medium model"
- extends Modelica.Icons.ExamplesPackage;
- model TestStates "Test case with state records"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStates(
- redeclare package Medium =
- ExternalMedia.Examples.WaterIF95);
- equation
- p1 = 1e5;
- h1 = 1e5 + 2e5*time;
- p2 = 1e5;
- T2 = 300 + 50*time;
- end TestStates;
-
- model TestStatesSat "Test case with state + sat records"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStatesSat(
- redeclare package Medium =
- ExternalMedia.Examples.WaterIF95);
- equation
- p1 = 1e5;
- h1 = 1e5 + 2e5*time;
- p2 = 1e5;
- T2 = 300 + 50*time;
- end TestStatesSat;
-
- model TestBasePropertiesExplicit
- "Test case using BaseProperties and explicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
- redeclare package
- Medium = ExternalMedia.Examples.WaterIF95);
- equation
- p1 = 1e5 + 1e5*time;
- h1 = 1e5;
- p2 = 1e5;
- h2 = 1e5 + 2e5*time;
- end TestBasePropertiesExplicit;
-
- model TestBasePropertiesImplicit
- "Test case using BaseProperties and implicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit(
- redeclare package
- Medium = ExternalMedia.Examples.WaterIF95, hstart=1e5);
- equation
- p1 = 1e5 + 1e5*time;
- T1 = 300 + 25*time;
- p2 = 1e5 + 1e5*time;
- T2 = 300;
- end TestBasePropertiesImplicit;
-
- model TestBasePropertiesDynamic
- "Test case using BaseProperties and dynamic equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic(
- redeclare package Medium = ExternalMedia.Examples.WaterIF95,
- Tstart=300,
- Kv0=1.00801e-2);
- equation
- // Inlet pump equations
- medium.p - p_atm = 2e5 - (1e5/100^2)*win^2;
- hin = 1e5;
- // Input variables
- Kv = if time < 50 then Kv0 else Kv0*1.1;
- Q = if time < 1 then 0 else 1e7;
- annotation (experiment(StopTime=80, Tolerance=1e-007),
- experimentSetupOutput(equdistant=false));
- end TestBasePropertiesDynamic;
-
- model CompareModelicaFluidProp_liquid
- "Comparison between Modelica IF97 and FluidProp IF95 models - liquid"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
- redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
- redeclare package FluidPropMedium = ExternalMedia.Examples.WaterIF95,
- pmin=1e5,
- pmax=1e5,
- hmin=1e5,
- hmax=4e5);
- end CompareModelicaFluidProp_liquid;
-
- model CompareModelicaFluidProp_twophase
- "Comparison between Modelica IF97 and FluidProp IF95 models - liquid"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
- redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
- redeclare package FluidPropMedium = ExternalMedia.Examples.WaterIF95,
- pmin=60e5,
- pmax=60e5,
- hmin=1000e3,
- hmax=2000e3);
- end CompareModelicaFluidProp_twophase;
-
- model CompareModelicaFluidProp_vapour
- "Comparison between Modelica IF97 and FluidProp IF95 models - liquid"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
- redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
- redeclare package FluidPropMedium = ExternalMedia.Examples.WaterIF95,
- pmin=60e5,
- pmax=60e5,
- hmin=2800e3,
- hmax=3200e3);
- end CompareModelicaFluidProp_vapour;
- end WaterIF95;
-
- package WaterIF97 "Test suite for the FluidProp IF97 medium model"
- extends Modelica.Icons.ExamplesPackage;
- model TestStates "Test case with state records"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStates(
- redeclare package Medium =
- ExternalMedia.Examples.WaterIF97);
- equation
- p1 = 1e5;
- h1 = 1e5 + 2e5*time;
- p2 = 1e5;
- T2 = 300 + 50*time;
- end TestStates;
-
- model TestStatesSat "Test case with state + sat records"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStatesSat(
- redeclare package Medium =
- ExternalMedia.Examples.WaterIF97);
- equation
- p1 = 1e5;
- h1 = 1e5 + 2e5*time;
- p2 = 1e5;
- T2 = 300 + 50*time;
- end TestStatesSat;
-
- model TestBasePropertiesExplicit
- "Test case using BaseProperties and explicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
- redeclare package
- Medium = ExternalMedia.Examples.WaterIF97);
- equation
- p1 = 1e5 + 1e5*time;
- h1 = 1e5;
- p2 = 1e5;
- h2 = 1e5 + 2e5*time;
- end TestBasePropertiesExplicit;
-
- model TestBasePropertiesImplicit
- "Test case using BaseProperties and implicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit(
- redeclare package
- Medium = ExternalMedia.Examples.WaterIF97, hstart=1e5);
- equation
- p1 = 1e5 + 1e5*time;
- T1 = 300 + 25*time;
- p2 = 1e5 + 1e5*time;
- T2 = 300;
- end TestBasePropertiesImplicit;
-
- model TestBasePropertiesDynamic
- "Test case using BaseProperties and dynamic equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic(
- redeclare package Medium = ExternalMedia.Examples.WaterIF97,
- Tstart=300,
- Kv0=1.00801e-2);
- equation
- // Inlet pump equations
- medium.p - p_atm = 2e5 - (1e5/100^2)*win^2;
- hin = 1e5;
- // Input variables
- Kv = if time < 50 then Kv0 else Kv0*1.1;
- Q = if time < 1 then 0 else 1e7;
- annotation (experiment(StopTime=80, Tolerance=1e-007),
- experimentSetupOutput(equdistant=false));
- end TestBasePropertiesDynamic;
-
- model CompareModelicaFluidProp_liquid
- "Comparison between Modelica IF97 and FluidProp IF97 models - liquid"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
- redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
- redeclare package FluidPropMedium = ExternalMedia.Examples.WaterIF97,
- pmin=1e5,
- pmax=1e5,
- hmin=1e5,
- hmax=4e5);
- end CompareModelicaFluidProp_liquid;
-
- model CompareModelicaFluidProp_twophase
- "Comparison between Modelica IF97 and FluidProp IF97 models - liquid"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
- redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
- redeclare package FluidPropMedium = ExternalMedia.Examples.WaterIF97,
- pmin=60e5,
- pmax=60e5,
- hmin=1000e3,
- hmax=2000e3);
- end CompareModelicaFluidProp_twophase;
-
- model CompareModelicaFluidProp_vapour
- "Comparison between Modelica IF97 and FluidProp IF97 models - liquid"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
- redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
- redeclare package FluidPropMedium = ExternalMedia.Examples.WaterIF97,
- pmin=60e5,
- pmax=60e5,
- hmin=2800e3,
- hmax=3200e3);
- end CompareModelicaFluidProp_vapour;
- end WaterIF97;
-
- package WaterTPSI "Test suite for the FluidProp TPSI water medium model"
- extends Modelica.Icons.ExamplesPackage;
- model TestStates "Test case with state records"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStates(
- redeclare package Medium =
- ExternalMedia.Examples.WaterTPSI);
- equation
- p1 = 1e5;
- h1 = 1e5 + 2e5*time;
- p2 = 1e5;
- T2 = 300 + 50*time;
- end TestStates;
-
- model TestStatesSat "Test case with state + sat records"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStatesSat(
- redeclare package Medium =
- ExternalMedia.Examples.WaterTPSI);
- equation
- p1 = 1e5;
- h1 = 1e5 + 2e5*time;
- p2 = 1e5;
- T2 = 300 + 50*time;
- end TestStatesSat;
-
- model TestBasePropertiesExplicit
- "Test case using BaseProperties and explicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
- redeclare package
- Medium = ExternalMedia.Examples.WaterTPSI);
- equation
- p1 = 1e5 + 1e5*time;
- h1 = 1e5;
- p2 = 1e5;
- h2 = 1e5 + 2e5*time;
- end TestBasePropertiesExplicit;
-
- model TestBasePropertiesImplicit
- "Test case using BaseProperties and implicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit(
- redeclare package
- Medium = ExternalMedia.Examples.WaterTPSI, hstart=1e5);
- equation
- p1 = 1e5 + 1e5*time;
- T1 = 300 + 25*time;
- p2 = 1e5 + 1e5*time;
- T2 = 300;
- end TestBasePropertiesImplicit;
-
- model TestBasePropertiesDynamic
- "Test case using BaseProperties and dynamic equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic(
- redeclare package Medium = ExternalMedia.Examples.WaterTPSI,
- Tstart=300,
- Kv0=1.00801e-2);
- equation
- // Inlet pump equations
- medium.p - p_atm = 2e5 - (1e5/100^2)*win^2;
- hin = 1e5;
- // Input variables
- Kv = if time < 50 then Kv0 else Kv0*1.1;
- Q = if time < 1 then 0 else 1e7;
- annotation (experiment(StopTime=80, Tolerance=1e-007),
- experimentSetupOutput(equdistant=false));
- end TestBasePropertiesDynamic;
-
- model CompareModelicaFluidProp_liquid
- "Comparison between Modelica IF97 and FluidProp TPSI models - liquid"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
- redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
- redeclare package FluidPropMedium = ExternalMedia.Examples.WaterTPSI,
- pmin=1e5,
- pmax=1e5,
- hmin=1e5,
- hmax=4e5);
- end CompareModelicaFluidProp_liquid;
-
- model CompareModelicaFluidProp_twophase
- "Comparison between Modelica IF97 and FluidProp TPSI models - liquid"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
- redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
- redeclare package FluidPropMedium = ExternalMedia.Examples.WaterTPSI,
- pmin=60e5,
- pmax=60e5,
- hmin=1000e3,
- hmax=2000e3);
- end CompareModelicaFluidProp_twophase;
-
- model CompareModelicaFluidProp_vapour
- "Comparison between Modelica IF97 and FluidProp TPSI models - liquid"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
- redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
- redeclare package FluidPropMedium = ExternalMedia.Examples.WaterTPSI,
- pmin=60e5,
- pmax=60e5,
- hmin=2800e3,
- hmax=3200e3);
- end CompareModelicaFluidProp_vapour;
- end WaterTPSI;
-
- package CO2StanMix "Test suite for the StanMix CO2 medium model"
- extends Modelica.Icons.ExamplesPackage;
- model TestStatesSupercritical
- "Test case with state records, supercritical conditions"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStates(
- redeclare package Medium =
- ExternalMedia.Examples.CO2StanMix);
- equation
- p1 = 8e6;
- h1 = -4.2e5 + 6e5*time;
- p2 = 8e6;
- T2 = 280 + 50*time;
- end TestStatesSupercritical;
-
- model TestStatesTranscritical
- "Test case with state records, transcritical conditions"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStates(
- redeclare package Medium =
- ExternalMedia.Examples.CO2StanMix);
- equation
- p1 = 1e6 + time*10e6;
- h1 = -4.2e5 + 0*time;
- p2 = 1e6 + time*10e6;
- T2 = 330;
- end TestStatesTranscritical;
-
- model TestStatesSatSubcritical
- "Test case with state + sat records, subcritical conditions"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStatesSat(
- redeclare package Medium =
- ExternalMedia.Examples.CO2StanMix);
- equation
- p1 = 1e6;
- h1 = -4.2e5 + 6e5*time;
- p2 = 1e6;
- T2 = 250 + 50*time;
- end TestStatesSatSubcritical;
-
- model TestBasePropertiesExplicit
- "Test case using BaseProperties and explicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
- redeclare package
- Medium = ExternalMedia.Examples.CO2StanMix);
- equation
- p1 = 8e6;
- h1 = -4.2e5 + 6e5*time;
- p2 = 1e6;
- h2 = -4.2e5 + 6e5*time;
- end TestBasePropertiesExplicit;
-
- model TestBasePropertiesImplicit
- "Test case using BaseProperties and implicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit(
- redeclare package
- Medium = ExternalMedia.Examples.CO2StanMix, hstart=0);
- equation
- p1 = 8e6;
- T1 = 280 + 20*time;
- p2 = 1e6;
- T2 = 280 + 20*time;
- end TestBasePropertiesImplicit;
-
- model TestBasePropertiesDynamic
- "Test case using BaseProperties and dynamic equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic(
- redeclare package Medium = ExternalMedia.Examples.CO2StanMix,
- Tstart=300,
- hstart=0,
- pstart=1e6,
- Kv0=1.00801e-4,
- V=0.1);
- equation
- // Inlet equations
- win = 1;
- hin = 0;
- // Input variables
- Kv = if time < 50 then Kv0 else Kv0*1.1;
- Q = if time < 1 then 0 else 1e4;
- annotation (experiment(StopTime=80, Tolerance=1e-007),
- experimentSetupOutput(equdistant=false));
- end TestBasePropertiesDynamic;
-
- model TestBasePropertiesTranscritical
- "Test case using BaseProperties and explicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
- redeclare package
- Medium = ExternalMedia.Examples.CO2StanMix);
- equation
- p1 = 1e6 + time*10e6;
- h1 = -4.2e5 + 0*time;
- p2 = 1e6 + time*10e6;
- h2 = 2.0e5;
- end TestBasePropertiesTranscritical;
- end CO2StanMix;
-
- package CO2RefProp "Test suite for the REFPROP CO2 medium model"
- extends Modelica.Icons.ExamplesPackage;
- model TestStatesSupercritical
- "Test case with state records, supercritical conditions"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStates(
- redeclare package Medium =
- ExternalMedia.Examples.CO2RefProp);
- equation
- p1 = 8e6;
- h1 = 1.0e5 + 6e5*time;
- p2 = 8e6;
- T2 = 280 + 50*time;
- end TestStatesSupercritical;
-
- model TestStatesTranscritical
- "Test case with state records, transcritical conditions"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStates(
- redeclare package Medium =
- ExternalMedia.Examples.CO2RefProp);
- equation
- p1 = 1e6 + time*10e6;
- h1 = 1.0e5;
- p2 = 1e6 + time*10e6;
- T2 = 330;
- end TestStatesTranscritical;
-
- model TestStatesSatSubcritical
- "Test case state + sat records, subcritical conditions"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestStatesSat(
- redeclare package Medium =
- ExternalMedia.Examples.CO2RefProp);
- equation
- p1 = 1e6;
- h1 = 1.0e5 + 6e5*time;
- p2 = 1e6;
- T2 = 250 + 50*time;
- end TestStatesSatSubcritical;
-
- model TestBasePropertiesExplicit
- "Test case using BaseProperties and explicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
- redeclare package
- Medium = ExternalMedia.Examples.CO2RefProp);
- equation
- p1 = 8e6;
- h1 = 1.0e5 + 6e5*time;
- p2 = 1e6;
- h2 = 1.0e5 + 6e5*time;
- end TestBasePropertiesExplicit;
-
- model TestBasePropertiesImplicit
- "Test case using BaseProperties and implicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit(
- redeclare package
- Medium = ExternalMedia.Examples.CO2RefProp, hstart=1e5);
- equation
- p1 = 8e6;
- T1 = 280 + 50*time;
- p2 = 1e6;
- T2 = 280 + 50*time;
- end TestBasePropertiesImplicit;
-
- model TestBasePropertiesDynamic
- "Test case using BaseProperties and dynamic equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic(
- redeclare package Medium = ExternalMedia.Examples.CO2RefProp,
- Tstart=300,
- hstart=4e5,
- pstart=1e6,
- Kv0=1.00801e-4,
- V=0.1);
- equation
- // Inlet equations
- win = 1;
- hin = 5e5;
- // Input variables
- Kv = if time < 50 then Kv0 else Kv0*1.1;
- Q = if time < 1 then 0 else 1e4;
- annotation (experiment(StopTime=80, Tolerance=1e-007),
- experimentSetupOutput(equdistant=false));
- end TestBasePropertiesDynamic;
-
- model TestBasePropertiesTranscritical
- "Test case using BaseProperties and explicit equations"
- import ExternalMedia;
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
- redeclare package
- Medium = ExternalMedia.Examples.CO2RefProp);
- equation
- p1 = 1e6 + time*10e6;
- h1 = 1.0e5;
- p2 = 1e6 + time*10e6;
- h2 = 7.0e5;
- end TestBasePropertiesTranscritical;
- end CO2RefProp;
- end FluidProp;
-
- package CoolProp "Test cases for CoolProp"
- extends Modelica.Icons.ExamplesPackage;
- package CO2 "Test suite for the CoolProp CO2 medium model"
- extends Modelica.Icons.ExamplesPackage;
- model TestStatesSupercritical
- "Test case with state records, supercritical conditions"
- extends Modelica.Icons.Example;
- extends GenericModels.TestStates( redeclare package Medium =
- ExternalMedia.Examples.CO2CoolProp);
- equation
- p1 = 8e6;
- h1 = 1.0e5 + 6e5*time;
- p2 = 8e6;
- T2 = 280 + 50*time;
- end TestStatesSupercritical;
-
- model TestStatesTranscritical
- "Test case with state records, transcritical conditions"
- extends Modelica.Icons.Example;
- extends GenericModels.TestStates( redeclare package Medium =
- ExternalMedia.Examples.CO2CoolProp);
- equation
- p1 = 1e6 + time*10e6;
- h1 = 1.0e5;
- p2 = 1e6 + time*10e6;
- T2 = 330;
- end TestStatesTranscritical;
-
- model TestStatesSatSubcritical
- "Test case state + sat records, subcritical conditions"
- extends Modelica.Icons.Example;
- extends GenericModels.TestStatesSat( redeclare package Medium
- = ExternalMedia.Examples.CO2CoolProp);
- equation
- p1 = 1e6;
- h1 = 1.0e5 + 6e5*time;
- p2 = 1e6;
- T2 = 250 + 50*time;
- end TestStatesSatSubcritical;
-
- model TestBasePropertiesExplicit
- "Test case using BaseProperties and explicit equations"
- extends Modelica.Icons.Example;
- extends GenericModels.TestBasePropertiesExplicit( redeclare
- package Medium = ExternalMedia.Examples.CO2CoolProp);
- equation
- p1 = 8e6;
- h1 = 1.0e5 + 6e5*time;
- p2 = 1e6;
- h2 = 1.0e5 + 6e5*time;
- end TestBasePropertiesExplicit;
-
- model TestBasePropertiesImplicit
- "Test case using BaseProperties and implicit equations"
- extends Modelica.Icons.Example;
- extends GenericModels.TestBasePropertiesImplicit( redeclare
- package Medium = ExternalMedia.Examples.CO2CoolProp, hstart=1e5);
- equation
- p1 = 8e6;
- T1 = 280 + 50*time;
- p2 = 1e6;
- T2 = 280 + 50*time;
- end TestBasePropertiesImplicit;
-
- model TestBasePropertiesDynamic
- "Test case using BaseProperties and dynamic equations"
- extends Modelica.Icons.Example;
- extends GenericModels.TestBasePropertiesDynamic(
- redeclare package Medium = ExternalMedia.Examples.CO2CoolProp,
- Tstart=300,
- hstart=4e5,
- pstart=1e6,
- Kv0=1.00801e-4,
- V=0.1);
- equation
- // Inlet equations
- win = 1;
- hin = 5e5;
- // Input variables
- Kv = if time < 50 then Kv0 else Kv0*1.1;
- Q = if time < 1 then 0 else 1e4;
- annotation (experiment(StopTime=80, Tolerance=1e-007),
- experimentSetupOutput(equdistant=false));
- end TestBasePropertiesDynamic;
-
- model TestBasePropertiesTranscritical
- "Test case using BaseProperties and explicit equations"
- extends Modelica.Icons.Example;
- extends GenericModels.TestBasePropertiesExplicit( redeclare
- package Medium = ExternalMedia.Examples.CO2CoolProp);
- equation
- p1 = 1e6 + time*10e6;
- h1 = 1.0e5;
- p2 = 1e6 + time*10e6;
- h2 = 7.0e5;
- end TestBasePropertiesTranscritical;
-
- end CO2;
-
- model Pentane_hs
- package wf
- extends ExternalMedia.Media.CoolPropMedium(
- mediumName = "Pentane",
- substanceNames = {"n-Pentane"},
- inputChoice=ExternalMedia.Common.InputChoice.hs);
- end wf;
- wf.BaseProperties fluid "Properties of the two-phase fluid";
- Modelica.SIunits.SpecificEnthalpy h;
- Modelica.SIunits.Pressure p;
- Modelica.SIunits.SpecificEntropy s;
- Modelica.SIunits.DerDensityByEnthalpy drdh
- "Derivative of average density by enthalpy";
- Modelica.SIunits.DerDensityByPressure drdp
- "Derivative of average density by pressure";
- equation
- //p = 1E5;
- h = 0 + time*1E6;
- s = 1500; //600 + time*2000;
- fluid.p = p;
- fluid.s = s;
- fluid.h = h;
- drdp = wf.density_derp_h(fluid.state);
- drdh = wf.density_derh_p(fluid.state);
- end Pentane_hs;
-
- model Pentane_hs_state
- package wf
- extends ExternalMedia.Media.CoolPropMedium(
- mediumName = "Pentane",
- substanceNames = {"n-Pentane"},
- inputChoice=ExternalMedia.Common.InputChoice.hs);
- end wf;
- wf.ThermodynamicState fluid "Properties of the two-phase fluid";
- Modelica.SIunits.SpecificEnthalpy h;
- Modelica.SIunits.Pressure p;
- Modelica.SIunits.SpecificEntropy s;
- Modelica.SIunits.DerDensityByEnthalpy drdh
- "Derivative of average density by enthalpy";
- Modelica.SIunits.DerDensityByPressure drdp
- "Derivative of average density by pressure";
- equation
- //p = 1E5;
- h = 0 + time*1E6;
- s = 600 + time*2000;
- fluid = wf.setState_hs(h,s);
- fluid.p = p;
- drdp = wf.density_derp_h(fluid);
- drdh = wf.density_derh_p(fluid);
- end Pentane_hs_state;
-
- model MSL_Models
- import ExternalMedia;
- extends Modelica.Icons.Example;
-
- ExternalMedia.Test.MSL_Models.BranchingDynamicPipes branchingDynamicPipes(
- redeclare package NewMedium = ExternalMedia.Examples.WaterCoolProp)
- annotation (Placement(transformation(extent={{-50,20},{-30,40}})));
- end MSL_Models;
-
- model CheckOptions
- extends Modelica.Icons.Example;
- String test;
- algorithm
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_TTSE");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_TTSE=0");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_TTSE=1");
- //
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_BICUBIC");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_BICUBIC=0");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_BICUBIC=1");
- //
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_EXTTP");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_EXTTP=0");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_EXTTP=1");
- //
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|twophase_derivsmoothing_xend");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|twophase_derivsmoothing_xend=0.0");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|twophase_derivsmoothing_xend=0.1");
- //
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|rho_smoothing_xend");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|rho_smoothing_xend=0.0");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|rho_smoothing_xend=0.1");
- //
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|debug");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|debug=0");
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|debug=100");
- //
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_TTSE=1|debug=0|enable_EXTTP",debug=true);
- test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_TTSE=1|debug=0|enableEXTTP=1");
- end CheckOptions;
-
- package Incompressible
- extends Modelica.Icons.ExamplesPackage;
- model incompressibleCoolPropMedium
- extends Modelica.Icons.Example;
-
- package DowQ_CP "DowthermQ properties from CoolProp"
- extends ExternalMedia.Media.IncompressibleCoolPropMedium(
- mediumName="DowQ",
- substanceNames={"DowQ|calc_transport=1|debug=1000"},
- ThermoStates=Modelica.Media.Interfaces.PartialMedium.Choices.IndependentVariables.pT);
- end DowQ_CP;
-
- //replaceable package Fluid = ExternalMedia.Examples.WaterCoolProp (
- // ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.pTX) constrainedby
- // Modelica.Media.Interfaces.PartialMedium "Medium model";
-
- replaceable package Fluid = DowQ_CP constrainedby
- Modelica.Media.Interfaces.PartialMedium "Medium model";
- Fluid.ThermodynamicState state;
- Fluid.Temperature T;
- Fluid.AbsolutePressure p;
- Fluid.BaseProperties props;
-
- equation
- p = 10E5;
- T = 273.15 + 15.0 + time * 50.0;
- state = Fluid.setState_pT(p,T);
- // And now we do some testing with the BaseProperties
- props.T = T;
- props.p = p;
- end incompressibleCoolPropMedium;
-
- model incompressibleCoolPropMixture
- extends Modelica.Icons.Example;
-
- package LiBr_CP "Lithium bromide solution properties from CoolProp"
- extends ExternalMedia.Media.IncompressibleCoolPropMedium(
- mediumName="LiBr",
- substanceNames={"LiBr|calc_transport=1|debug=1000","dummyToMakeBasePropertiesWork"},
- ThermoStates=Modelica.Media.Interfaces.PartialMedium.Choices.IndependentVariables.pTX);
- end LiBr_CP;
-
- replaceable package Fluid = LiBr_CP constrainedby
- Modelica.Media.Interfaces.PartialMedium "Medium model";
- Fluid.ThermodynamicState state_var;
- Fluid.ThermodynamicState state_con;
- Fluid.Temperature T;
- Fluid.AbsolutePressure p;
- Fluid.MassFraction[1] X_var;
- Fluid.MassFraction[1] X_con;
- Fluid.BaseProperties varProps;
-
- equation
- p = 10E5;
- T = 273.15 + 15.0 + time * 50.0;
- X_var[1] = 0.00 + 0.1 + time * 0.5;
- X_con[1] = 0.00 + 0.1;
- state_var = Fluid.setState_pTX(p,T,X_var);
- state_con = Fluid.setState_pTX(p,T,X_con);
- // And now we do some testing with the BaseProperties
- varProps.T = T;
- varProps.p = p;
- varProps.Xi = X_var;
- end incompressibleCoolPropMixture;
- end Incompressible;
-
- model RhoSmoothing
- extends Modelica.Icons.Example;
- package fluid_std
- extends ExternalMedia.Media.CoolPropMedium(
- mediumName = "Pentane",
- substanceNames = {"n-Pentane|rho_smoothing_xend=0.0"},
- inputChoice=ExternalMedia.Common.InputChoice.ph);
- end fluid_std;
-
- package fluid_spl
- extends ExternalMedia.Media.CoolPropMedium(
- mediumName = "Pentane",
- substanceNames = {"n-Pentane|rho_smoothing_xend=0.2"},
- inputChoice=ExternalMedia.Common.InputChoice.ph);
- end fluid_spl;
-
- fluid_std.ThermodynamicState state_std "Properties of the two-phase fluid";
- fluid_spl.ThermodynamicState state_spl "Properties of the two-phase fluid";
-
- Modelica.SIunits.AbsolutePressure p;
- Modelica.SIunits.SpecificEnthalpy h;
-
- fluid_std.SaturationProperties sat_std;
-
- Modelica.SIunits.SpecificEnthalpy h_start;
- Modelica.SIunits.SpecificEnthalpy h_end;
- Modelica.SIunits.SpecificEnthalpy h_delta;
-
- Modelica.SIunits.Time t = 1;
-
- equation
- p = 10E5;
- sat_std = fluid_std.setSat_p(p);
- h_start = fluid_std.bubbleEnthalpy(sat_std);
- h_end = fluid_std.dewEnthalpy(sat_std);
- h_delta = 3e3;
- h = (h_start - h_delta) + (h_end-h_start+2*h_delta)*time/t;
- state_std = fluid_std.setState_ph(p,h);
- state_spl = fluid_spl.setState_ph(p,h);
- end RhoSmoothing;
- end CoolProp;
-
- package WrongMedium "Test cases with wrong medium models"
- extends Modelica.Icons.ExamplesPackage;
- model TestWrongMedium
- "Test the error reporting messages for unsupported external media"
- extends Modelica.Icons.Example;
- package Medium = Media.BaseClasses.ExternalTwoPhaseMedium;
- Medium.BaseProperties medium;
- equation
- medium.p = 1e5;
- medium.h = 1e5;
- end TestWrongMedium;
- end WrongMedium;
-
- package TestOMC "Test cases for OpenModelica implementation"
- extends Modelica.Icons.ExamplesPackage;
- package TestHelium
- "Test for NIST Helium model using ExternalMedia and FluidProp"
- extends Modelica.Icons.ExamplesPackage;
- package Helium "Helium model from NIST RefProp database"
- extends ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium(
- mediumName="Helium",
- libraryName="FluidProp.RefProp",
- substanceNames={"He"},
- ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
- AbsolutePressure(
- min=500,
- max=44e5,
- nominal=1e5,
- start=1e5),
- Density(
- min=0.1,
- max=200,
- nominal=100,
- start=100),
- SpecificEnthalpy(
- min=-6000,
- max=1.7e6,
- nominal=1000,
- start=0),
- SpecificEntropy(
- min=-4000,
- max=30e3,
- nominal=1000,
- start=0),
- Temperature(
- min=2.17,
- max=310,
- nominal=10,
- start=5,
- displayUnit="K"));
- end Helium;
-
- model TestSupercriticalHelium
- extends Modelica.Icons.Example;
- package Medium = Helium;
- Medium.ThermodynamicState state;
- Medium.Temperature T;
- Medium.Temperature Tcrit=Medium.fluidConstants[1].criticalTemperature;
- Medium.AbsolutePressure p;
- Modelica.SIunits.Density d;
- Medium.AbsolutePressure pcrit=Medium.fluidConstants[1].criticalPressure;
- equation
- T = 300 - 297.5*time;
- p = 4e5 + 0*time;
- state = Medium.setState_pT(p, T);
- d = Medium.density(state);
- end TestSupercriticalHelium;
-
- model TestSaturatedHelium
- extends Modelica.Icons.Example;
- package Medium = Helium;
- Medium.SaturationProperties sat;
- Medium.Temperature T;
- Medium.AbsolutePressure p;
- Modelica.SIunits.Density dl;
- Modelica.SIunits.Density dv;
- equation
- p = 1e5 + 1.27e5*time;
- sat = Medium.setSat_p(p);
- dv = Medium.dewDensity(sat);
- dl = Medium.bubbleDensity(sat);
- T = Medium.saturationTemperature_sat(sat);
- end TestSaturatedHelium;
-
- model TypicalHeliumProperties
- extends Modelica.Icons.Example;
- package Medium = Helium;
- Medium.ThermodynamicState state;
- Medium.Temperature T;
- Medium.Temperature Tcrit=Medium.fluidConstants[1].criticalTemperature;
- Medium.AbsolutePressure p;
- Modelica.SIunits.Density d;
- Medium.AbsolutePressure pcrit=Medium.fluidConstants[1].criticalPressure;
- Modelica.SIunits.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(
- state);
- equation
- T = 5;
- p = 5e5;
- state = Medium.setState_pT(p, T);
- d = Medium.density(state);
- end TypicalHeliumProperties;
- end TestHelium;
-
- package TestHeliumHardCodedProperties
- "Test for NIST Helium model using ExternalMedia and FluidProp, hard-coded fluid properties package constants"
- extends Modelica.Icons.ExamplesPackage;
- package Helium "Helium model from NIST RefProp database"
- extends ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium(
- mediumName="Helium",
- libraryName="FluidProp.RefProp",
- substanceNames={"He"},
- externalFluidConstants=FluidConstants(
- iupacName="unknown",
- casRegistryNumber="unknown",
- chemicalFormula="unknown",
- structureFormula="unknown",
- molarMass=4.0026e-3,
- criticalTemperature=5.1953,
- criticalPressure=2.2746e5,
- criticalMolarVolume=1/69.641*4.0026e-3,
- acentricFactor=0,
- triplePointTemperature=280.0,
- triplePointPressure=500.0,
- meltingPoint=280,
- normalBoilingPoint=380.0,
- dipoleMoment=2.0),
- ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
- AbsolutePressure(
- min=500,
- max=44e5,
- nominal=1e5,
- start=1e5),
- Density(
- min=0.1,
- max=200,
- nominal=100,
- start=100),
- SpecificEnthalpy(
- min=-6000,
- max=1.7e6,
- nominal=1000,
- start=0),
- SpecificEntropy(
- min=-4000,
- max=30e3,
- nominal=1000,
- start=0),
- Temperature(
- min=2.17,
- max=310,
- nominal=10,
- start=5,
- displayUnit="K"));
- end Helium;
-
- model TestSupercriticalHelium
- extends Modelica.Icons.Example;
- package Medium = Helium;
- Medium.ThermodynamicState state;
- Medium.Temperature T;
- Medium.Temperature Tcrit=Medium.fluidConstants[1].criticalTemperature;
- Medium.AbsolutePressure p;
- Modelica.SIunits.Density d;
- Medium.AbsolutePressure pcrit=Medium.fluidConstants[1].criticalPressure;
- equation
- T = 300 - 297.5*time;
- p = 4e5 + 0*time;
- state = Medium.setState_pT(p, T);
- d = Medium.density(state);
- end TestSupercriticalHelium;
-
- model TestSaturatedHelium
- extends Modelica.Icons.Example;
- package Medium = Helium;
- Medium.SaturationProperties sat;
- Medium.Temperature T;
- Medium.AbsolutePressure p;
- Modelica.SIunits.Density dl;
- Modelica.SIunits.Density dv;
- equation
- p = 1e5 + 1.27e5*time;
- sat = Medium.setSat_p(p);
- dv = Medium.dewDensity(sat);
- dl = Medium.bubbleDensity(sat);
- T = Medium.saturationTemperature_sat(sat);
- end TestSaturatedHelium;
-
- model TypicalHeliumProperties
- extends Modelica.Icons.Example;
- package Medium = Helium;
- Medium.ThermodynamicState state;
- Medium.Temperature T;
- Medium.Temperature Tcrit=Medium.fluidConstants[1].criticalTemperature;
- Medium.AbsolutePressure p;
- Modelica.SIunits.Density d;
- Medium.AbsolutePressure pcrit=Medium.fluidConstants[1].criticalPressure;
- Modelica.SIunits.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(
- state);
- equation
- T = 5;
- p = 5e5;
- state = Medium.setState_pT(p, T);
- d = Medium.density(state);
- end TypicalHeliumProperties;
- end TestHeliumHardCodedProperties;
- end TestOMC;
-
- package GenericModels "Generic models for FluidProp media tests"
- extends Modelica.Icons.BasesPackage;
- package DummyTwoPhaseMedium "A dummy to allow for pedantic checking"
- extends Modelica.Media.Water.WaterIF97_ph;
- end DummyTwoPhaseMedium;
-
- model CompleteFluidConstants "Compute all available medium fluid constants"
- replaceable package Medium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
- // Fluid constants
- Medium.Temperature Tc=Medium.fluidConstants[1].criticalTemperature;
- Medium.AbsolutePressure pc=Medium.fluidConstants[1].criticalPressure;
- Medium.MolarVolume vc=Medium.fluidConstants[1].criticalMolarVolume;
- Medium.MolarMass MM=Medium.fluidConstants[1].molarMass;
- end CompleteFluidConstants;
-
- model CompleteThermodynamicState
- "Compute all available two-phase medium properties from a ThermodynamicState model"
- replaceable package Medium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
- // ThermodynamicState record
- input Medium.ThermodynamicState state;
- // Medium properties
- Medium.AbsolutePressure p=Medium.pressure(state);
- Medium.SpecificEnthalpy h=Medium.specificEnthalpy(state);
- Medium.Temperature T=Medium.temperature(state);
- Medium.Density d=Medium.density(state);
- Medium.SpecificEntropy s=Medium.specificEntropy(state);
- Medium.SpecificHeatCapacity cp=Medium.specificHeatCapacityCp(state);
- Medium.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(state);
- Medium.IsobaricExpansionCoefficient beta=Medium.isobaricExpansionCoefficient(state);
- SI.IsothermalCompressibility kappa=Medium.isothermalCompressibility(state);
- Medium.DerDensityByPressure d_d_dp_h=Medium.density_derp_h(state);
- Medium.DerDensityByEnthalpy d_d_dh_p=Medium.density_derh_p(state);
- Medium.MolarMass MM=Medium.molarMass(state);
- end CompleteThermodynamicState;
-
- model CompleteSaturationProperties
- "Compute all available saturation properties from a SaturationProperties record"
- replaceable package Medium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
- // SaturationProperties record
- input Medium.SaturationProperties sat;
- // Saturation properties
- Medium.Temperature Ts=Medium.saturationTemperature_sat(sat);
- Medium.Density dl=Medium.bubbleDensity(sat);
- Medium.Density dv=Medium.dewDensity(sat);
- Medium.SpecificEnthalpy hl=Medium.bubbleEnthalpy(sat);
- Medium.SpecificEnthalpy hv=Medium.dewEnthalpy(sat);
- Real d_Ts_dp=Medium.saturationTemperature_derp_sat(sat);
- Real d_dl_dp=Medium.dBubbleDensity_dPressure(sat);
- Real d_dv_dp=Medium.dDewDensity_dPressure(sat);
- Real d_hl_dp=Medium.dBubbleEnthalpy_dPressure(sat);
- Real d_hv_dp=Medium.dDewEnthalpy_dPressure(sat);
- end CompleteSaturationProperties;
-
- model CompleteBubbleDewStates
- "Compute all available properties for dewpoint and bubble point states corresponding to a sat record"
- replaceable package Medium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
- // SaturationProperties record
- input Medium.SaturationProperties sat;
- // and the rest based on sat
- CompleteThermodynamicState dewStateOnePhase(state=Medium.setDewState(sat, 1),
- redeclare package Medium = Medium);
- CompleteThermodynamicState dewStateTwoPhase(state=Medium.setDewState(sat, 2),
- redeclare package Medium = Medium);
- CompleteThermodynamicState bubbleStateOnePhase(state=Medium.setBubbleState(
- sat, 1), redeclare package Medium = Medium);
- CompleteThermodynamicState bubbleStateTwoPhase(state=Medium.setBubbleState(
- sat, 2), redeclare package Medium = Medium);
- end CompleteBubbleDewStates;
-
- model CompleteBaseProperties
- "Compute all available two-phase medium properties from a BaseProperties model"
- replaceable package Medium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
- // BaseProperties object
- Medium.BaseProperties baseProperties;
- // All the complete properties
- CompleteThermodynamicState completeState(redeclare package Medium = Medium,
- state=baseProperties.state);
- CompleteSaturationProperties completeSat(redeclare package Medium = Medium,
- sat=baseProperties.sat);
- CompleteFluidConstants completeConstants(redeclare package Medium = Medium);
- end CompleteBaseProperties;
-
- partial model TestStates "Test case with state"
- replaceable package Medium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
- Medium.AbsolutePressure p1;
- Medium.SpecificEnthalpy h1;
- Medium.AbsolutePressure p2;
- Medium.Temperature T2;
- Medium.ThermodynamicState state1;
- Medium.ThermodynamicState state2;
- CompleteThermodynamicState completeState1(redeclare package Medium = Medium,
- state=state1);
- CompleteThermodynamicState completeState2(redeclare package Medium = Medium,
- state=state2);
- equation
- state1 = Medium.setState_ph(p1, h1);
- state2 = Medium.setState_pT(p2, T2);
- end TestStates;
-
- partial model TestStatesSat "Test case with state + sat records"
- replaceable package Medium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
- Medium.AbsolutePressure p1;
- Medium.SpecificEnthalpy h1;
- Medium.AbsolutePressure p2;
- Medium.Temperature T2;
- Medium.ThermodynamicState state1;
- Medium.ThermodynamicState state2;
- Medium.SaturationProperties sat1;
- Medium.SaturationProperties sat2;
- Medium.Temperature Ts;
- Medium.AbsolutePressure ps;
- CompleteThermodynamicState completeState1(redeclare package Medium = Medium,
- state=state1);
- CompleteThermodynamicState completeState2(redeclare package Medium = Medium,
- state=state2);
- CompleteSaturationProperties completeSat1(redeclare package Medium = Medium,
- sat=sat1);
- CompleteSaturationProperties completeSat2(redeclare package Medium = Medium,
- sat=sat2);
- CompleteBubbleDewStates completeBubbleDewStates1(redeclare package Medium
- = Medium, sat=sat1);
- CompleteBubbleDewStates completeBubbleDewStates2(redeclare package Medium
- = Medium, sat=sat2);
- equation
- state1 = Medium.setState_ph(p1, h1);
- state2 = Medium.setState_pT(p2, T2);
- sat1 = Medium.setSat_p(p1);
- sat2 = Medium.setSat_T(T2);
- Ts = Medium.saturationTemperature(p1);
- ps = Medium.saturationPressure(T2);
- end TestStatesSat;
-
- partial model TestBasePropertiesExplicit
- "Test case using BaseProperties and explicit equations"
- replaceable package Medium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
- CompleteBaseProperties medium1(redeclare package Medium = Medium)
- "Constant pressure, varying enthalpy";
- CompleteBaseProperties medium2(redeclare package Medium = Medium)
- "Varying pressure, constant enthalpy";
- Medium.AbsolutePressure p1;
- Medium.AbsolutePressure p2;
- Medium.SpecificEnthalpy h1;
- Medium.SpecificEnthalpy h2;
- equation
- medium1.baseProperties.p = p1;
- medium1.baseProperties.h = h1;
- medium2.baseProperties.p = p2;
- medium2.baseProperties.h = h2;
- end TestBasePropertiesExplicit;
-
- partial model TestBasePropertiesImplicit
- "Test case using BaseProperties and implicit equations"
- replaceable package Medium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
- parameter Medium.SpecificEnthalpy hstart
- "Start value for specific enthalpy";
- CompleteBaseProperties medium1(redeclare package Medium = Medium,
- baseProperties(h(start=hstart)))
- "Constant pressure, varying enthalpy";
- CompleteBaseProperties medium2(redeclare package Medium = Medium,
- baseProperties(h(start=hstart)))
- "Varying pressure, constant enthalpy";
- Medium.AbsolutePressure p1;
- Medium.AbsolutePressure p2;
- Medium.Temperature T1;
- Medium.Temperature T2;
- equation
- medium1.baseProperties.p = p1;
- medium1.baseProperties.T = T1;
- medium2.baseProperties.p = p2;
- medium2.baseProperties.T = T2;
- end TestBasePropertiesImplicit;
-
- partial model TestBasePropertiesDynamic
- "Test case using BaseProperties and dynamic equations"
- replaceable package Medium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
- parameter SI.Volume V=1 "Storage Volume";
- parameter Real p_atm=101325 "Atmospheric pressure";
- parameter SI.Temperature Tstart=300;
- parameter SI.SpecificEnthalpy hstart=1e5;
- parameter SI.Pressure pstart=p_atm;
- parameter Real Kv0 "Valve flow coefficient";
- Medium.BaseProperties medium(
- preferredMediumStates=true,
- h(start=hstart),
- p(start=pstart));
- SI.Mass M;
- SI.Energy U;
- SI.MassFlowRate win(start=100);
- SI.MassFlowRate wout;
- SI.SpecificEnthalpy hin;
- SI.SpecificEnthalpy hout;
- SI.Power Q;
- Real Kv;
- equation
- // Mass & energy balance equation
- M = medium.d*V;
- U = medium.u*M;
- der(M) = win - wout;
- der(U) = win*hin - wout*hout + Q;
- // Outlet valve equation
- wout = Kv*sqrt(medium.d*(medium.p - p_atm));
- hout = medium.h;
- initial equation
- // Steady state equations
- der(medium.p) = 0;
- der(medium.h) = 0;
- annotation (experiment(StopTime=80, Tolerance=1e-007));
- end TestBasePropertiesDynamic;
-
- partial model CompareModelicaTestMedium
- "Comparison between Modelica and TestMedium models"
- replaceable package ModelicaMedium =
- Modelica.Media.Water.WaterIF97_ph
- constrainedby Modelica.Media.Interfaces.PartialMedium
- annotation(choicesAllMatching=true);
- replaceable package TestMedium =
- ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
- constrainedby Modelica.Media.Interfaces.PartialMedium
- annotation(choicesAllMatching=true);
- CompleteBaseProperties modelicaMedium(redeclare package Medium =
- ModelicaMedium) "Modelica medium model";
- CompleteBaseProperties testMedium(redeclare package Medium = TestMedium)
- "TestMedium medium model";
- parameter Modelica.SIunits.Pressure pmin;
- parameter Modelica.SIunits.Pressure pmax;
- parameter Modelica.SIunits.SpecificEnthalpy hmin;
- parameter Modelica.SIunits.SpecificEnthalpy hmax;
- equation
- modelicaMedium.baseProperties.p = pmin + (pmax - pmin)*time;
- modelicaMedium.baseProperties.h = hmin + (hmax - hmin)*time;
- testMedium.baseProperties.p = pmin + (pmax - pmin)*time;
- testMedium.baseProperties.h = hmin + (hmax - hmin)*time;
- end CompareModelicaTestMedium;
-
- partial model TestRunner
- "A collection of models to test the states and base properties"
- extends Modelica.Icons.Example;
-
- replaceable package Medium = Modelica.Media.Water.StandardWater
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
-
- Medium.AbsolutePressure p_in;
- Medium.SpecificEnthalpy h_in;
- Medium.Temperature T_in;
- Medium.SaturationProperties sat_in;
- parameter Medium.SpecificEnthalpy hstart = 2e5
- "Start value for specific enthalpy";
-
- model TestStates_Impl
- extends ExternalMedia.Test.GenericModels.TestStates;
- input Medium.AbsolutePressure _p1;
- input Medium.SpecificEnthalpy _h1;
- input Medium.AbsolutePressure _p2;
- input Medium.Temperature _T2;
- equation
- p1 = _p1;
- h1 = _h1;
- p2 = _p2;
- T2 = _T2;
- end TestStates_Impl;
-
- TestStates_Impl testStates(
- redeclare package Medium = Medium,
- _p1=p_in,
- _h1=h_in,
- _p2=p_in*1.15,
- _T2=T_in) annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
-
- model TestStatesSat_Impl
- extends ExternalMedia.Test.GenericModels.TestStatesSat;
- input Medium.AbsolutePressure _p1;
- input Medium.SpecificEnthalpy _h1;
- input Medium.AbsolutePressure _p2;
- input Medium.Temperature _T2;
- equation
- p1 = _p1;
- h1 = _h1;
- p2 = _p2;
- T2 = _T2;
- end TestStatesSat_Impl;
-
- TestStatesSat_Impl testStatesSat(
- redeclare package Medium = Medium,
- _p1=p_in,
- _h1=h_in,
- _p2=p_in*1.15,
- _T2=T_in) annotation (Placement(transformation(extent={{-40,60},{-20,80}})));
-
- model TestBasePropertiesExplicit_Impl
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit;
- input Medium.AbsolutePressure _p1;
- input Medium.SpecificEnthalpy _h1;
- input Medium.AbsolutePressure _p2;
- input Medium.SpecificEnthalpy _h2;
- equation
- p1 = _p1;
- h1 = _h1;
- p2 = _p2;
- h2 = _h2;
- end TestBasePropertiesExplicit_Impl;
-
- TestBasePropertiesExplicit_Impl testBasePropertiesExplicit(
- redeclare package Medium = Medium,
- _p1=p_in,
- _h1=h_in,
- _p2=p_in*1.15,
- _h2=h_in) annotation (Placement(transformation(extent={{-40,20},{-20,40}})));
-
- model TestBasePropertiesImplicit_Impl
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit;
- input Medium.AbsolutePressure _p1;
- input Medium.Temperature _T1;
- input Medium.AbsolutePressure _p2;
- input Medium.Temperature _T2;
- equation
- p1 = _p1;
- T1 = _T1;
- p2 = _p2;
- T2 = _T2;
- end TestBasePropertiesImplicit_Impl;
-
- TestBasePropertiesImplicit_Impl testBasePropertiesImplicit(
- redeclare package Medium = Medium,
- _p1=p_in,
- _T1=T_in,
- _p2=p_in*1.15,
- _T2=T_in,
- hstart=hstart)
- annotation (Placement(transformation(extent={{-80,20},{-60,40}})));
-
- model TestBasePropertiesDynamic_Impl
- extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic;
- input Medium.SpecificEnthalpy _h1;
- equation
- // Inlet equations
- win = 1;
- hin = _h1;
- // Input variables
- Kv = if time < 50 then Kv0 else Kv0*1.1;
- Q = if time < 1 then 0 else 1e4;
- end TestBasePropertiesDynamic_Impl;
-
- TestBasePropertiesDynamic_Impl testBasePropertiesDynamic(Tstart=300,
- hstart=4e5,
- pstart=1e6,
- Kv0=1.00801e-4,
- V=0.1,
- redeclare package Medium = Medium,_h1=h_in)
- annotation (Placement(transformation(extent={{0,20},{20,40}})));
- annotation (experiment(StopTime=80, Tolerance=1e-007));
- end TestRunner;
-
- model TestRunnerTwoPhase
- "A collection of models to test the saturation states"
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestRunner( redeclare
- package Medium =
- TwoPhaseMedium);
-
- replaceable package TwoPhaseMedium = Modelica.Media.Water.StandardWater
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
-
- parameter Medium.AbsolutePressure p_start = 1e5;
- algorithm
- assert(Medium.fluidConstants[1].criticalPressure>p_start, "You have to start below the critical pressure.");
- equation
- p_in = p_start+0.5*(Medium.fluidConstants[1].criticalPressure-p_start)*time;
- sat_in = Medium.setSat_p(p=p_in);
- h_in = Medium.bubbleEnthalpy(sat_in);
- T_in = Medium.saturationTemperature_sat(sat_in);
- end TestRunnerTwoPhase;
-
- model TestRunnerTranscritical
- "A collection of models to test the transcritical states"
- extends Modelica.Icons.Example;
- extends ExternalMedia.Test.GenericModels.TestRunner( redeclare
- package Medium =
- TwoPhaseMedium);
-
- replaceable package TwoPhaseMedium = Modelica.Media.Water.StandardWater
- constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
- annotation(choicesAllMatching=true);
-
- parameter Medium.AbsolutePressure p_start = 1e5;
- algorithm
- assert(Medium.fluidConstants[1].criticalPressure>p_start, "You have to start below the critical pressure.");
- equation
- p_in = p_start+1.5*(Medium.fluidConstants[1].criticalPressure-p_start)*time;
- sat_in = Medium.setSat_p(p=p_in);
- h_in = Medium.bubbleEnthalpy(sat_in);
- T_in = Medium.saturationTemperature_sat(sat_in);
- end TestRunnerTranscritical;
- end GenericModels;
-
- package MSL_Models
- "Test cases taken from the Modelica Standard Library, medium redefinition needed."
- extends Modelica.Icons.BasesPackage;
-
- model BranchingDynamicPipes "From Fluid library, needs medium definition"
- extends Modelica.Fluid.Examples.BranchingDynamicPipes(
- redeclare package Medium=NewMedium);
-
- replaceable package NewMedium=Modelica.Media.Water.StandardWater constrainedby
- Modelica.Media.Interfaces.PartialMedium
- annotation(choicesAllMatching=true);
-
- //replaceable package NewMedium=ExternalMedia.Examples.WaterCoolProp;
- //replaceable package NewMedium=Modelica.Media.Water.StandardWater;
- //replaceable package NewMedium=ExternalMedia.Examples.WaterIF97;
- end BranchingDynamicPipes;
-
- model IncompressibleFluidNetwork
- "From Fluid library, needs medium definition"
- extends Modelica.Fluid.Examples.IncompressibleFluidNetwork(
- redeclare package Medium=NewMedium);
- replaceable package NewMedium=Modelica.Media.Water.StandardWater constrainedby
- Modelica.Media.Interfaces.PartialMedium
- annotation(choicesAllMatching=true);
- end IncompressibleFluidNetwork;
- end MSL_Models;
-
- model WaterComparison "Compares different implementations of water"
- extends Modelica.Icons.Example;
-
- GenericModels.TestRunnerTwoPhase testRunnerTwoPhaseWater1(
- hstart=4e5,
- redeclare package TwoPhaseMedium = ExternalMedia.Examples.WaterCoolProp,
- p_start=100000)
- annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
- end WaterComparison;
-end Test;
+within ExternalMedia;
+package Test "Test models for the different solvers"
+ extends Modelica.Icons.ExamplesPackage;
+ package TestMedium "Test cases for TestMedium"
+ extends Modelica.Icons.ExamplesPackage;
+ model TestConstants "Test case using TestMedium with package constants"
+ extends Modelica.Icons.Example;
+ replaceable package Medium = Media.TestMedium;
+ Medium.Temperature Tc=Medium.fluidConstants[1].criticalTemperature;
+ end TestConstants;
+
+ model TestState "Test case using TestMedium with a single state record"
+ extends Modelica.Icons.Example;
+ replaceable package Medium = Media.TestMedium;
+ Medium.ThermodynamicState state;
+ equation
+ state = Medium.setState_ph(1e5, 1e5 + 1e5*time);
+ end TestState;
+
+ model TestSat
+ "Test case using TestMedium with a single saturation properties record"
+ extends Modelica.Icons.Example;
+ replaceable package Medium = Media.TestMedium;
+ Medium.SaturationProperties sat;
+ equation
+ sat = Medium.setSat_p(1e5 + 1e5*time);
+ end TestSat;
+
+ model TestStatesSat "Test case using TestMedium with state + sat records"
+ extends Modelica.Icons.Example;
+ replaceable package Medium = Media.TestMedium;
+ Medium.BaseProperties baseProperties1;
+ Medium.BaseProperties baseProperties2;
+ Medium.ThermodynamicState state1;
+ Medium.ThermodynamicState state2;
+ Medium.SaturationProperties sat1;
+ Medium.SaturationProperties sat2;
+ Medium.Temperature Ts;
+ Medium.AbsolutePressure ps;
+ GenericModels.CompleteThermodynamicState completeState1(redeclare package
+ Medium = Medium, state=state1);
+ GenericModels.CompleteThermodynamicState completeState2(redeclare package
+ Medium = Medium, state=state2);
+ GenericModels.CompleteSaturationProperties completeSat1(redeclare package
+ Medium = Medium, sat=sat1);
+ GenericModels.CompleteSaturationProperties completeSat2(redeclare package
+ Medium = Medium, sat=sat2);
+ GenericModels.CompleteBubbleDewStates completeBubbleDewStates1(redeclare
+ package Medium = Medium, sat=sat1);
+ GenericModels.CompleteBubbleDewStates completeBubbleDewStates2(redeclare
+ package Medium = Medium, sat=sat1);
+ equation
+ baseProperties1.p = 1e5 + 1e5*time;
+ baseProperties1.h = 1e5;
+ baseProperties2.p = 1e5;
+ baseProperties2.h = 1e5 + 2e5*time;
+ state1 = Medium.setState_ph(1e5 + 1e5*time, 1e5);
+ state2 = Medium.setState_pT(1e5, 300 + 50*time);
+ sat1 = Medium.setSat_p(1e5 + 1e5*time);
+ sat2 = Medium.setSat_T(300 + 50*time);
+ Ts = Medium.saturationTemperature(1e5 + 1e5*time);
+ ps = Medium.saturationPressure(300 + 50*time);
+ end TestStatesSat;
+
+ model TestBasePropertiesExplicit
+ "Test case using TestMedium and BaseProperties with explicit equations"
+ extends Modelica.Icons.Example;
+ replaceable package Medium = Media.TestMedium;
+ ExternalMedia.Test.TestMedium.GenericModels.CompleteBaseProperties
+ medium1(redeclare package Medium = Medium)
+ "Constant pressure, varying enthalpy";
+ ExternalMedia.Test.TestMedium.GenericModels.CompleteBaseProperties
+ medium2(redeclare package Medium = Medium)
+ "Varying pressure, constant enthalpy";
+ equation
+ medium1.baseProperties.p = 1e5 + 1e5*time;
+ medium1.baseProperties.h = 1e5;
+ medium2.baseProperties.p = 1e5;
+ medium2.baseProperties.h = 1e5 + 2e5*time;
+ end TestBasePropertiesExplicit;
+
+ model TestBasePropertiesImplicit
+ "Test case using TestMedium and BaseProperties with implicit equations"
+ replaceable package Medium = Media.TestMedium;
+ extends Modelica.Icons.Example;
+ ExternalMedia.Test.TestMedium.GenericModels.CompleteBaseProperties
+ medium1(redeclare package Medium = Medium, baseProperties(h(start=1e5)))
+ "Constant pressure, varying enthalpy";
+ ExternalMedia.Test.TestMedium.GenericModels.CompleteBaseProperties
+ medium2(redeclare package Medium = Medium, baseProperties(h(start=1e5)))
+ "Varying pressure, constant enthalpy";
+ equation
+ medium1.baseProperties.p = 1e5*time;
+ medium1.baseProperties.T = 300 + 25*time;
+ medium2.baseProperties.p = 1e5 + 1e5*time;
+ medium2.baseProperties.T = 300;
+ end TestBasePropertiesImplicit;
+
+ model TestBasePropertiesDynamic
+ "Test case using TestMedium and dynamic equations"
+ extends Modelica.Icons.Example;
+ replaceable package Medium = Media.TestMedium;
+ parameter SI.Volume V=1 "Storage Volume";
+ parameter Real p_atm=101325 "Atmospheric pressure";
+ parameter SI.Temperature Tstart=300;
+ parameter Real Kv0=1.00801e-2 "Valve flow coefficient";
+ Medium.BaseProperties medium(preferredMediumStates=true);
+ SI.Mass M;
+ SI.Energy U;
+ SI.MassFlowRate win(start=100);
+ SI.MassFlowRate wout;
+ SI.SpecificEnthalpy hin;
+ SI.SpecificEnthalpy hout;
+ SI.Power Q;
+ Real Kv;
+ equation
+ // Mass & energy balance equation
+ M = medium.d*V;
+ U = medium.u*M;
+ der(M) = win - wout;
+ der(U) = win*hin - wout*hout + Q;
+ // Inlet pump equations
+ medium.p - p_atm = 2e5 - (1e5/100^2)*win^2;
+ hin = 1e5;
+ // Outlet valve equation
+ wout = Kv*sqrt(medium.d*(medium.p - p_atm));
+ hout = medium.h;
+ // Input variables
+ Kv = if time < 50 then Kv0 else Kv0*1.1;
+ Q = if time < 1 then 0 else 1e7;
+ initial equation
+ // Initial conditions
+ // Fixed initial states
+ // medium.p = 2e5;
+ // medium.h = 1e5;
+ // Steady state equations
+ der(medium.p) = 0;
+ der(medium.h) = 0;
+ annotation (experiment(StopTime=80, Tolerance=1e-007),
+ experimentSetupOutput(equdistant=false));
+ end TestBasePropertiesDynamic;
+
+ package GenericModels
+ "Contains generic models to use for thorough medium model testing"
+ extends Modelica.Icons.BasesPackage;
+ model CompleteFluidConstants
+ "Compute all available medium fluid constants"
+ replaceable package Medium =
+ Modelica.Media.Interfaces.PartialTwoPhaseMedium;
+ // Fluid constants
+ Medium.Temperature Tc=Medium.fluidConstants[1].criticalTemperature;
+ Medium.AbsolutePressure pc=Medium.fluidConstants[1].criticalPressure;
+ Medium.MolarVolume vc=Medium.fluidConstants[1].criticalMolarVolume;
+ Medium.MolarMass MM=Medium.fluidConstants[1].molarMass;
+ end CompleteFluidConstants;
+
+ model CompleteThermodynamicState
+ "Compute all available two-phase medium properties from a ThermodynamicState model"
+ replaceable package Medium =
+ Modelica.Media.Interfaces.PartialTwoPhaseMedium;
+ // ThermodynamicState record
+ input Medium.ThermodynamicState state;
+ // Medium properties
+ Medium.AbsolutePressure p=Medium.pressure(state);
+ Medium.SpecificEnthalpy h=Medium.specificEnthalpy(state);
+ Medium.Temperature T=Medium.temperature(state);
+ Medium.Density d=Medium.density(state);
+ Medium.SpecificEntropy s=Medium.specificEntropy(state);
+ Medium.SpecificHeatCapacity cp=Medium.specificHeatCapacityCp(state);
+ Medium.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(state);
+ Medium.IsobaricExpansionCoefficient beta=
+ Medium.isobaricExpansionCoefficient(state);
+ SI.IsothermalCompressibility kappa=Medium.isothermalCompressibility(
+ state);
+ Medium.DerDensityByPressure d_d_dp_h=Medium.density_derp_h(state);
+ Medium.DerDensityByEnthalpy d_d_dh_p=Medium.density_derh_p(state);
+ Medium.MolarMass MM=Medium.molarMass(state);
+ end CompleteThermodynamicState;
+
+ model CompleteSaturationProperties
+ "Compute all available saturation properties from a SaturationProperties record"
+ replaceable package Medium =
+ Modelica.Media.Interfaces.PartialTwoPhaseMedium;
+ // SaturationProperties record
+ input Medium.SaturationProperties sat;
+ // Saturation properties
+ Medium.Temperature Ts=Medium.saturationTemperature_sat(sat);
+ Medium.Density dl=Medium.bubbleDensity(sat);
+ Medium.Density dv=Medium.dewDensity(sat);
+ Medium.SpecificEnthalpy hl=Medium.bubbleEnthalpy(sat);
+ Medium.SpecificEnthalpy hv=Medium.dewEnthalpy(sat);
+ Real d_Ts_dp=Medium.saturationTemperature_derp_sat(sat);
+ Real d_dl_dp=Medium.dBubbleDensity_dPressure(sat);
+ Real d_dv_dp=Medium.dDewDensity_dPressure(sat);
+ Real d_hl_dp=Medium.dBubbleEnthalpy_dPressure(sat);
+ Real d_hv_dp=Medium.dDewEnthalpy_dPressure(sat);
+ end CompleteSaturationProperties;
+
+ model CompleteBubbleDewStates
+ "Compute all available properties for dewpoint and bubble point states corresponding to a sat record"
+ replaceable package Medium =
+ Modelica.Media.Interfaces.PartialTwoPhaseMedium;
+ // SaturationProperties record
+ input Medium.SaturationProperties sat;
+ CompleteThermodynamicState dewStateOnePhase(state=Medium.setDewState(
+ sat, 1), redeclare package Medium = Medium);
+ CompleteThermodynamicState dewStateTwoPhase(state=Medium.setDewState(
+ sat, 2), redeclare package Medium = Medium);
+ CompleteThermodynamicState bubbleStateOnePhase(state=
+ Medium.setBubbleState(sat, 1), redeclare package Medium = Medium);
+ CompleteThermodynamicState bubbleStateTwoPhase(state=
+ Medium.setBubbleState(sat, 2), redeclare package Medium = Medium);
+ end CompleteBubbleDewStates;
+
+ model CompleteBaseProperties
+ "Compute all available two-phase medium properties from a BaseProperties model"
+ replaceable package Medium =
+ Modelica.Media.Interfaces.PartialTwoPhaseMedium;
+ // BaseProperties object
+ Medium.BaseProperties baseProperties;
+ // All the complete properties
+ CompleteThermodynamicState completeState(redeclare package Medium =
+ Medium, state=baseProperties.state);
+ CompleteSaturationProperties completeSat(redeclare package Medium =
+ Medium, sat=baseProperties.sat);
+ CompleteFluidConstants completeConstants(redeclare package Medium =
+ Medium);
+ CompleteBubbleDewStates completeBubbleDewStates(redeclare package
+ Medium = Medium, sat=baseProperties.sat);
+ end CompleteBaseProperties;
+ end GenericModels;
+
+ model TestRunner "A model to collect generaic test cases"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ ExternalMedia.Test.GenericModels.CompleteFluidConstants
+ completeFluidConstants(redeclare package Medium =
+ ExternalMedia.Media.TestMedium)
+ annotation (Placement(transformation(extent={{-60,60},{-40,80}})));
+ equation
+
+ end TestRunner;
+ end TestMedium;
+
+ package FluidProp "Test cases for FluidPropMedium"
+ extends Modelica.Icons.ExamplesPackage;
+
+ package WaterIF95 "Test suite for the FluidProp-Refprop IF95 medium model"
+ extends Modelica.Icons.ExamplesPackage;
+ model TestStates "Test case with state records"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStates(
+ redeclare package Medium =
+ ExternalMedia.Examples.WaterIF95);
+ equation
+ p1 = 1e5;
+ h1 = 1e5 + 2e5*time;
+ p2 = 1e5;
+ T2 = 300 + 50*time;
+ end TestStates;
+
+ model TestStatesSat "Test case with state + sat records"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStatesSat(
+ redeclare package Medium =
+ ExternalMedia.Examples.WaterIF95);
+ equation
+ p1 = 1e5;
+ h1 = 1e5 + 2e5*time;
+ p2 = 1e5;
+ T2 = 300 + 50*time;
+ end TestStatesSat;
+
+ model TestBasePropertiesExplicit
+ "Test case using BaseProperties and explicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.WaterIF95);
+ equation
+ p1 = 1e5 + 1e5*time;
+ h1 = 1e5;
+ p2 = 1e5;
+ h2 = 1e5 + 2e5*time;
+ end TestBasePropertiesExplicit;
+
+ model TestBasePropertiesImplicit
+ "Test case using BaseProperties and implicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.WaterIF95, hstart=1e5);
+ equation
+ p1 = 1e5 + 1e5*time;
+ T1 = 300 + 25*time;
+ p2 = 1e5 + 1e5*time;
+ T2 = 300;
+ end TestBasePropertiesImplicit;
+
+ model TestBasePropertiesDynamic
+ "Test case using BaseProperties and dynamic equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic(
+ redeclare package Medium = ExternalMedia.Examples.WaterIF95,
+ Tstart=300,
+ Kv0=1.00801e-2);
+ equation
+ // Inlet pump equations
+ medium.p - p_atm = 2e5 - (1e5/100^2)*win^2;
+ hin = 1e5;
+ // Input variables
+ Kv = if time < 50 then Kv0 else Kv0*1.1;
+ Q = if time < 1 then 0 else 1e7;
+ annotation (experiment(StopTime=80, Tolerance=1e-007),
+ experimentSetupOutput(equdistant=false));
+ end TestBasePropertiesDynamic;
+
+ model CompareModelicaFluidProp_liquid
+ "Comparison between Modelica IF97 and FluidProp IF95 models - liquid"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
+ redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
+ redeclare package TestMedium = ExternalMedia.Examples.WaterIF95,
+ pmin=1e5,
+ pmax=1e5,
+ hmin=1e5,
+ hmax=4e5);
+ end CompareModelicaFluidProp_liquid;
+
+ model CompareModelicaFluidProp_twophase
+ "Comparison between Modelica IF97 and FluidProp IF95 models - liquid"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
+ redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
+ redeclare package TestMedium = ExternalMedia.Examples.WaterIF95,
+ pmin=60e5,
+ pmax=60e5,
+ hmin=1000e3,
+ hmax=2000e3);
+ end CompareModelicaFluidProp_twophase;
+
+ model CompareModelicaFluidProp_vapour
+ "Comparison between Modelica IF97 and FluidProp IF95 models - liquid"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
+ redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
+ redeclare package TestMedium = ExternalMedia.Examples.WaterIF95,
+ pmin=60e5,
+ pmax=60e5,
+ hmin=2800e3,
+ hmax=3200e3);
+ end CompareModelicaFluidProp_vapour;
+ end WaterIF95;
+
+ package WaterIF97 "Test suite for the FluidProp IF97 medium model"
+ extends Modelica.Icons.ExamplesPackage;
+ model TestStates "Test case with state records"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStates(
+ redeclare package Medium =
+ ExternalMedia.Examples.WaterIF97);
+ equation
+ p1 = 1e5;
+ h1 = 1e5 + 2e5*time;
+ p2 = 1e5;
+ T2 = 300 + 50*time;
+ end TestStates;
+
+ model TestStatesSat "Test case with state + sat records"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStatesSat(
+ redeclare package Medium =
+ ExternalMedia.Examples.WaterIF97);
+ equation
+ p1 = 1e5;
+ h1 = 1e5 + 2e5*time;
+ p2 = 1e5;
+ T2 = 300 + 50*time;
+ end TestStatesSat;
+
+ model TestBasePropertiesExplicit
+ "Test case using BaseProperties and explicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.WaterIF97);
+ equation
+ p1 = 1e5 + 1e5*time;
+ h1 = 1e5;
+ p2 = 1e5;
+ h2 = 1e5 + 2e5*time;
+ end TestBasePropertiesExplicit;
+
+ model TestBasePropertiesImplicit
+ "Test case using BaseProperties and implicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.WaterIF97, hstart=1e5);
+ equation
+ p1 = 1e5 + 1e5*time;
+ T1 = 300 + 25*time;
+ p2 = 1e5 + 1e5*time;
+ T2 = 300;
+ end TestBasePropertiesImplicit;
+
+ model TestBasePropertiesDynamic
+ "Test case using BaseProperties and dynamic equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic(
+ redeclare package Medium = ExternalMedia.Examples.WaterIF97,
+ Tstart=300,
+ Kv0=1.00801e-2);
+ equation
+ // Inlet pump equations
+ medium.p - p_atm = 2e5 - (1e5/100^2)*win^2;
+ hin = 1e5;
+ // Input variables
+ Kv = if time < 50 then Kv0 else Kv0*1.1;
+ Q = if time < 1 then 0 else 1e7;
+ annotation (experiment(StopTime=80, Tolerance=1e-007),
+ experimentSetupOutput(equdistant=false));
+ end TestBasePropertiesDynamic;
+
+ model CompareModelicaFluidProp_liquid
+ "Comparison between Modelica IF97 and FluidProp IF97 models - liquid"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
+ redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
+ redeclare package TestMedium = ExternalMedia.Examples.WaterIF97,
+ pmin=1e5,
+ pmax=1e5,
+ hmin=1e5,
+ hmax=4e5);
+ end CompareModelicaFluidProp_liquid;
+
+ model CompareModelicaFluidProp_twophase
+ "Comparison between Modelica IF97 and FluidProp IF97 models - liquid"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
+ redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
+ redeclare package TestMedium = ExternalMedia.Examples.WaterIF97,
+ pmin=60e5,
+ pmax=60e5,
+ hmin=1000e3,
+ hmax=2000e3);
+ end CompareModelicaFluidProp_twophase;
+
+ model CompareModelicaFluidProp_vapour
+ "Comparison between Modelica IF97 and FluidProp IF97 models - liquid"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
+ redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
+ redeclare package TestMedium = ExternalMedia.Examples.WaterIF97,
+ pmin=60e5,
+ pmax=60e5,
+ hmin=2800e3,
+ hmax=3200e3);
+ end CompareModelicaFluidProp_vapour;
+ end WaterIF97;
+
+ package WaterTPSI "Test suite for the FluidProp TPSI water medium model"
+ extends Modelica.Icons.ExamplesPackage;
+ model TestStates "Test case with state records"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStates(
+ redeclare package Medium =
+ ExternalMedia.Examples.WaterTPSI);
+ equation
+ p1 = 1e5;
+ h1 = 1e5 + 2e5*time;
+ p2 = 1e5;
+ T2 = 300 + 50*time;
+ end TestStates;
+
+ model TestStatesSat "Test case with state + sat records"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStatesSat(
+ redeclare package Medium =
+ ExternalMedia.Examples.WaterTPSI);
+ equation
+ p1 = 1e5;
+ h1 = 1e5 + 2e5*time;
+ p2 = 1e5;
+ T2 = 300 + 50*time;
+ end TestStatesSat;
+
+ model TestBasePropertiesExplicit
+ "Test case using BaseProperties and explicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.WaterTPSI);
+ equation
+ p1 = 1e5 + 1e5*time;
+ h1 = 1e5;
+ p2 = 1e5;
+ h2 = 1e5 + 2e5*time;
+ end TestBasePropertiesExplicit;
+
+ model TestBasePropertiesImplicit
+ "Test case using BaseProperties and implicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.WaterTPSI, hstart=1e5);
+ equation
+ p1 = 1e5 + 1e5*time;
+ T1 = 300 + 25*time;
+ p2 = 1e5 + 1e5*time;
+ T2 = 300;
+ end TestBasePropertiesImplicit;
+
+ model TestBasePropertiesDynamic
+ "Test case using BaseProperties and dynamic equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic(
+ redeclare package Medium = ExternalMedia.Examples.WaterTPSI,
+ Tstart=300,
+ Kv0=1.00801e-2);
+ equation
+ // Inlet pump equations
+ medium.p - p_atm = 2e5 - (1e5/100^2)*win^2;
+ hin = 1e5;
+ // Input variables
+ Kv = if time < 50 then Kv0 else Kv0*1.1;
+ Q = if time < 1 then 0 else 1e7;
+ annotation (experiment(StopTime=80, Tolerance=1e-007),
+ experimentSetupOutput(equdistant=false));
+ end TestBasePropertiesDynamic;
+
+ model CompareModelicaFluidProp_liquid
+ "Comparison between Modelica IF97 and FluidProp TPSI models - liquid"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
+ redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
+ redeclare package TestMedium = ExternalMedia.Examples.WaterTPSI,
+ pmin=1e5,
+ pmax=1e5,
+ hmin=1e5,
+ hmax=4e5);
+ end CompareModelicaFluidProp_liquid;
+
+ model CompareModelicaFluidProp_twophase
+ "Comparison between Modelica IF97 and FluidProp TPSI models - liquid"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
+ redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
+ redeclare package TestMedium = ExternalMedia.Examples.WaterTPSI,
+ pmin=60e5,
+ pmax=60e5,
+ hmin=1000e3,
+ hmax=2000e3);
+ end CompareModelicaFluidProp_twophase;
+
+ model CompareModelicaFluidProp_vapour
+ "Comparison between Modelica IF97 and FluidProp TPSI models - liquid"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.CompareModelicaTestMedium(
+ redeclare package ModelicaMedium = Modelica.Media.Water.StandardWater,
+ redeclare package TestMedium = ExternalMedia.Examples.WaterTPSI,
+ pmin=60e5,
+ pmax=60e5,
+ hmin=2800e3,
+ hmax=3200e3);
+ end CompareModelicaFluidProp_vapour;
+ end WaterTPSI;
+
+ package CO2StanMix "Test suite for the StanMix CO2 medium model"
+ extends Modelica.Icons.ExamplesPackage;
+ model TestStatesSupercritical
+ "Test case with state records, supercritical conditions"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStates(
+ redeclare package Medium =
+ ExternalMedia.Examples.CO2StanMix);
+ equation
+ p1 = 8e6;
+ h1 = -4.2e5 + 6e5*time;
+ p2 = 8e6;
+ T2 = 280 + 50*time;
+ end TestStatesSupercritical;
+
+ model TestStatesTranscritical
+ "Test case with state records, transcritical conditions"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStates(
+ redeclare package Medium =
+ ExternalMedia.Examples.CO2StanMix);
+ equation
+ p1 = 1e6 + time*10e6;
+ h1 = -4.2e5 + 0*time;
+ p2 = 1e6 + time*10e6;
+ T2 = 330;
+ end TestStatesTranscritical;
+
+ model TestStatesSatSubcritical
+ "Test case with state + sat records, subcritical conditions"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStatesSat(
+ redeclare package Medium =
+ ExternalMedia.Examples.CO2StanMix);
+ equation
+ p1 = 1e6;
+ h1 = -4.2e5 + 6e5*time;
+ p2 = 1e6;
+ T2 = 250 + 50*time;
+ end TestStatesSatSubcritical;
+
+ model TestBasePropertiesExplicit
+ "Test case using BaseProperties and explicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.CO2StanMix);
+ equation
+ p1 = 8e6;
+ h1 = -4.2e5 + 6e5*time;
+ p2 = 1e6;
+ h2 = -4.2e5 + 6e5*time;
+ end TestBasePropertiesExplicit;
+
+ model TestBasePropertiesImplicit
+ "Test case using BaseProperties and implicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.CO2StanMix, hstart=0);
+ equation
+ p1 = 8e6;
+ T1 = 280 + 20*time;
+ p2 = 1e6;
+ T2 = 280 + 20*time;
+ end TestBasePropertiesImplicit;
+
+ model TestBasePropertiesDynamic
+ "Test case using BaseProperties and dynamic equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic(
+ redeclare package Medium = ExternalMedia.Examples.CO2StanMix,
+ Tstart=300,
+ hstart=0,
+ pstart=1e6,
+ Kv0=1.00801e-4,
+ V=0.1);
+ equation
+ // Inlet equations
+ win = 1;
+ hin = 0;
+ // Input variables
+ Kv = if time < 50 then Kv0 else Kv0*1.1;
+ Q = if time < 1 then 0 else 1e4;
+ annotation (experiment(StopTime=80, Tolerance=1e-007),
+ experimentSetupOutput(equdistant=false));
+ end TestBasePropertiesDynamic;
+
+ model TestBasePropertiesTranscritical
+ "Test case using BaseProperties and explicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.CO2StanMix);
+ equation
+ p1 = 1e6 + time*10e6;
+ h1 = -4.2e5 + 0*time;
+ p2 = 1e6 + time*10e6;
+ h2 = 2.0e5;
+ end TestBasePropertiesTranscritical;
+ end CO2StanMix;
+
+ package CO2RefProp "Test suite for the REFPROP CO2 medium model"
+ extends Modelica.Icons.ExamplesPackage;
+ model TestStatesSupercritical
+ "Test case with state records, supercritical conditions"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStates(
+ redeclare package Medium =
+ ExternalMedia.Examples.CO2RefProp);
+ equation
+ p1 = 8e6;
+ h1 = 1.0e5 + 6e5*time;
+ p2 = 8e6;
+ T2 = 280 + 50*time;
+ end TestStatesSupercritical;
+
+ model TestStatesTranscritical
+ "Test case with state records, transcritical conditions"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStates(
+ redeclare package Medium =
+ ExternalMedia.Examples.CO2RefProp);
+ equation
+ p1 = 1e6 + time*10e6;
+ h1 = 1.0e5;
+ p2 = 1e6 + time*10e6;
+ T2 = 330;
+ end TestStatesTranscritical;
+
+ model TestStatesSatSubcritical
+ "Test case state + sat records, subcritical conditions"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestStatesSat(
+ redeclare package Medium =
+ ExternalMedia.Examples.CO2RefProp);
+ equation
+ p1 = 1e6;
+ h1 = 1.0e5 + 6e5*time;
+ p2 = 1e6;
+ T2 = 250 + 50*time;
+ end TestStatesSatSubcritical;
+
+ model TestBasePropertiesExplicit
+ "Test case using BaseProperties and explicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.CO2RefProp);
+ equation
+ p1 = 8e6;
+ h1 = 1.0e5 + 6e5*time;
+ p2 = 1e6;
+ h2 = 1.0e5 + 6e5*time;
+ end TestBasePropertiesExplicit;
+
+ model TestBasePropertiesImplicit
+ "Test case using BaseProperties and implicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.CO2RefProp, hstart=1e5);
+ equation
+ p1 = 8e6;
+ T1 = 280 + 50*time;
+ p2 = 1e6;
+ T2 = 280 + 50*time;
+ end TestBasePropertiesImplicit;
+
+ model TestBasePropertiesDynamic
+ "Test case using BaseProperties and dynamic equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic(
+ redeclare package Medium = ExternalMedia.Examples.CO2RefProp,
+ Tstart=300,
+ hstart=4e5,
+ pstart=1e6,
+ Kv0=1.00801e-4,
+ V=0.1);
+ equation
+ // Inlet equations
+ win = 1;
+ hin = 5e5;
+ // Input variables
+ Kv = if time < 50 then Kv0 else Kv0*1.1;
+ Q = if time < 1 then 0 else 1e4;
+ annotation (experiment(StopTime=80, Tolerance=1e-007),
+ experimentSetupOutput(equdistant=false));
+ end TestBasePropertiesDynamic;
+
+ model TestBasePropertiesTranscritical
+ "Test case using BaseProperties and explicit equations"
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit(
+ redeclare package
+ Medium = ExternalMedia.Examples.CO2RefProp);
+ equation
+ p1 = 1e6 + time*10e6;
+ h1 = 1.0e5;
+ p2 = 1e6 + time*10e6;
+ h2 = 7.0e5;
+ end TestBasePropertiesTranscritical;
+ end CO2RefProp;
+ end FluidProp;
+
+ package CoolProp "Test cases for CoolProp"
+ extends Modelica.Icons.ExamplesPackage;
+ package CO2 "Test suite for the CoolProp CO2 medium model"
+ extends Modelica.Icons.ExamplesPackage;
+ model TestStatesSupercritical
+ "Test case with state records, supercritical conditions"
+ extends Modelica.Icons.Example;
+ extends GenericModels.TestStates( redeclare package Medium =
+ ExternalMedia.Examples.CO2CoolProp);
+ equation
+ p1 = 8e6;
+ h1 = 1.0e5 + 6e5*time;
+ p2 = 8e6;
+ T2 = 280 + 50*time;
+ end TestStatesSupercritical;
+
+ model TestStatesTranscritical
+ "Test case with state records, transcritical conditions"
+ extends Modelica.Icons.Example;
+ extends GenericModels.TestStates( redeclare package Medium =
+ ExternalMedia.Examples.CO2CoolProp);
+ equation
+ p1 = 1e6 + time*10e6;
+ h1 = 1.0e5;
+ p2 = 1e6 + time*10e6;
+ T2 = 330;
+ end TestStatesTranscritical;
+
+ model TestStatesSatSubcritical
+ "Test case state + sat records, subcritical conditions"
+ extends Modelica.Icons.Example;
+ extends GenericModels.TestStatesSat( redeclare package Medium =
+ ExternalMedia.Examples.CO2CoolProp);
+ equation
+ p1 = 1e6;
+ h1 = 1.0e5 + 6e5*time;
+ p2 = 1e6;
+ T2 = 250 + 50*time;
+ end TestStatesSatSubcritical;
+
+ model TestBasePropertiesExplicit
+ "Test case using BaseProperties and explicit equations"
+ extends Modelica.Icons.Example;
+ extends GenericModels.TestBasePropertiesExplicit( redeclare
+ package Medium = ExternalMedia.Examples.CO2CoolProp);
+ equation
+ p1 = 8e6;
+ h1 = 1.0e5 + 6e5*time;
+ p2 = 1e6;
+ h2 = 1.0e5 + 6e5*time;
+ end TestBasePropertiesExplicit;
+
+ model TestBasePropertiesImplicit
+ "Test case using BaseProperties and implicit equations"
+ extends Modelica.Icons.Example;
+ extends GenericModels.TestBasePropertiesImplicit( redeclare
+ package Medium = ExternalMedia.Examples.CO2CoolProp, hstart=1e5);
+ equation
+ p1 = 8e6;
+ T1 = 280 + 50*time;
+ p2 = 1e6;
+ T2 = 280 + 50*time;
+ end TestBasePropertiesImplicit;
+
+ model TestBasePropertiesDynamic
+ "Test case using BaseProperties and dynamic equations"
+ extends Modelica.Icons.Example;
+ extends GenericModels.TestBasePropertiesDynamic(
+ redeclare package Medium = ExternalMedia.Examples.CO2CoolProp,
+ Tstart=300,
+ hstart=4e5,
+ pstart=1e6,
+ Kv0=1.00801e-4,
+ V=0.1);
+ equation
+ // Inlet equations
+ win = 1;
+ hin = 5e5;
+ // Input variables
+ Kv = if time < 50 then Kv0 else Kv0*1.1;
+ Q = if time < 1 then 0 else 1e4;
+ annotation (experiment(StopTime=80, Tolerance=1e-007),
+ experimentSetupOutput(equdistant=false));
+ end TestBasePropertiesDynamic;
+
+ model TestBasePropertiesTranscritical
+ "Test case using BaseProperties and explicit equations"
+ extends Modelica.Icons.Example;
+ extends GenericModels.TestBasePropertiesExplicit( redeclare
+ package Medium = ExternalMedia.Examples.CO2CoolProp);
+ equation
+ p1 = 1e6 + time*10e6;
+ h1 = 1.0e5;
+ p2 = 1e6 + time*10e6;
+ h2 = 7.0e5;
+ end TestBasePropertiesTranscritical;
+
+ end CO2;
+
+ model Pentane_hs
+ package wf
+ extends ExternalMedia.Media.CoolPropMedium(
+ mediumName = "Pentane",
+ substanceNames = {"n-Pentane"},
+ inputChoice=ExternalMedia.Common.InputChoice.hs);
+ end wf;
+ wf.BaseProperties fluid "Properties of the two-phase fluid";
+ Modelica.SIunits.SpecificEnthalpy h;
+ Modelica.SIunits.Pressure p;
+ Modelica.SIunits.SpecificEntropy s;
+ Modelica.SIunits.DerDensityByEnthalpy drdh
+ "Derivative of average density by enthalpy";
+ Modelica.SIunits.DerDensityByPressure drdp
+ "Derivative of average density by pressure";
+ equation
+ //p = 1E5;
+ h = 0 + time*1E6;
+ s = 1500; //600 + time*2000;
+ fluid.p = p;
+ fluid.s = s;
+ fluid.h = h;
+ drdp = wf.density_derp_h(fluid.state);
+ drdh = wf.density_derh_p(fluid.state);
+ end Pentane_hs;
+
+ model Pentane_hs_state
+ package wf
+ extends ExternalMedia.Media.CoolPropMedium(
+ mediumName = "Pentane",
+ substanceNames = {"n-Pentane"},
+ inputChoice=ExternalMedia.Common.InputChoice.hs);
+ end wf;
+ wf.ThermodynamicState fluid "Properties of the two-phase fluid";
+ Modelica.SIunits.SpecificEnthalpy h;
+ Modelica.SIunits.Pressure p;
+ Modelica.SIunits.SpecificEntropy s;
+ Modelica.SIunits.DerDensityByEnthalpy drdh
+ "Derivative of average density by enthalpy";
+ Modelica.SIunits.DerDensityByPressure drdp
+ "Derivative of average density by pressure";
+ equation
+ //p = 1E5;
+ h = 0 + time*1E6;
+ s = 600 + time*2000;
+ fluid = wf.setState_hs(h,s);
+ fluid.p = p;
+ drdp = wf.density_derp_h(fluid);
+ drdh = wf.density_derh_p(fluid);
+ end Pentane_hs_state;
+
+ model MSL_Models
+ import ExternalMedia;
+ extends Modelica.Icons.Example;
+
+ ExternalMedia.Test.MSL_Models.BranchingDynamicPipes branchingDynamicPipes(
+ redeclare package NewMedium = ExternalMedia.Examples.WaterCoolProp)
+ annotation (Placement(transformation(extent={{-50,20},{-30,40}})));
+ end MSL_Models;
+
+ model CheckOptions
+ extends Modelica.Icons.Example;
+ String test;
+ algorithm
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_TTSE");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_TTSE=0");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_TTSE=1");
+ //
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_BICUBIC");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_BICUBIC=0");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_BICUBIC=1");
+ //
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_EXTTP");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_EXTTP=0");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_EXTTP=1");
+ //
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|twophase_derivsmoothing_xend");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|twophase_derivsmoothing_xend=0.0");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|twophase_derivsmoothing_xend=0.1");
+ //
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|rho_smoothing_xend");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|rho_smoothing_xend=0.0");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|rho_smoothing_xend=0.1");
+ //
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|debug");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|debug=0");
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|debug=100");
+ //
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_TTSE=1|debug=0|enable_EXTTP",debug=true);
+ test := ExternalMedia.Common.CheckCoolPropOptions("LiBr|enable_TTSE=1|debug=0|enableEXTTP=1");
+ end CheckOptions;
+
+ package Incompressible
+ extends Modelica.Icons.ExamplesPackage;
+ model incompressibleCoolPropMedium
+ extends Modelica.Icons.Example;
+
+ package DowQ_CP "DowthermQ properties from CoolProp"
+ extends ExternalMedia.Media.IncompressibleCoolPropMedium(
+ mediumName="DowQ",
+ substanceNames={"DowQ|calc_transport=1|debug=1000"},
+ ThermoStates=Modelica.Media.Interfaces.PartialMedium.Choices.IndependentVariables.pT);
+ end DowQ_CP;
+
+ //replaceable package Fluid = ExternalMedia.Examples.WaterCoolProp (
+ // ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.pTX) constrainedby
+ // Modelica.Media.Interfaces.PartialMedium "Medium model";
+
+ replaceable package Fluid = DowQ_CP constrainedby
+ Modelica.Media.Interfaces.PartialMedium "Medium model";
+ Fluid.ThermodynamicState state;
+ Fluid.Temperature T;
+ Fluid.AbsolutePressure p;
+ Fluid.BaseProperties props;
+
+ equation
+ p = 10E5;
+ T = 273.15 + 15.0 + time * 50.0;
+ state = Fluid.setState_pT(p,T);
+ // And now we do some testing with the BaseProperties
+ props.T = T;
+ props.p = p;
+ end incompressibleCoolPropMedium;
+
+ model incompressibleCoolPropMixture
+ extends Modelica.Icons.Example;
+
+ package LiBr_CP "Lithium bromide solution properties from CoolProp"
+ extends ExternalMedia.Media.IncompressibleCoolPropMedium(
+ mediumName="LiBr",
+ substanceNames={"LiBr|calc_transport=1|debug=1000","dummyToMakeBasePropertiesWork"},
+ ThermoStates=Modelica.Media.Interfaces.PartialMedium.Choices.IndependentVariables.pTX);
+ end LiBr_CP;
+
+ replaceable package Fluid = LiBr_CP constrainedby
+ Modelica.Media.Interfaces.PartialMedium "Medium model";
+ Fluid.ThermodynamicState state_var;
+ Fluid.ThermodynamicState state_con;
+ Fluid.Temperature T;
+ Fluid.AbsolutePressure p;
+ Fluid.MassFraction[1] X_var;
+ Fluid.MassFraction[1] X_con;
+ Fluid.BaseProperties varProps;
+
+ equation
+ p = 10E5;
+ T = 273.15 + 15.0 + time * 50.0;
+ X_var[1] = 0.00 + 0.1 + time * 0.5;
+ X_con[1] = 0.00 + 0.1;
+ state_var = Fluid.setState_pTX(p,T,X_var);
+ state_con = Fluid.setState_pTX(p,T,X_con);
+ // And now we do some testing with the BaseProperties
+ varProps.T = T;
+ varProps.p = p;
+ varProps.Xi = X_var;
+ end incompressibleCoolPropMixture;
+ end Incompressible;
+
+ model RhoSmoothing
+ extends Modelica.Icons.Example;
+ package fluid_std
+ extends ExternalMedia.Media.CoolPropMedium(
+ mediumName = "Water",
+ substanceNames = {"Water|rho_smoothing_xend=0.0|calc_transport=0"},
+ inputChoice=ExternalMedia.Common.InputChoice.ph);
+ end fluid_std;
+
+ package fluid_spl
+ extends ExternalMedia.Media.CoolPropMedium(
+ mediumName = "Water",
+ substanceNames = {"Water|rho_smoothing_xend=0.1|calc_transport=0"},
+ inputChoice=ExternalMedia.Common.InputChoice.ph);
+ end fluid_spl;
+
+ package fluid_tbl
+ extends ExternalMedia.Media.CoolPropMedium(
+ mediumName = "Water",
+ substanceNames = {"Water|rho_smoothing_xend=0.1|calc_transport=0|enable_TTSE=1"},
+ inputChoice=ExternalMedia.Common.InputChoice.ph);
+ end fluid_tbl;
+
+ fluid_std.ThermodynamicState state_std "Properties of the two-phase fluid";
+ fluid_spl.ThermodynamicState state_spl "Properties of the two-phase fluid";
+ fluid_tbl.ThermodynamicState state_tbl "Properties of the two-phase fluid";
+
+ Modelica.SIunits.AbsolutePressure p;
+ Modelica.SIunits.SpecificEnthalpy h;
+
+ fluid_std.SaturationProperties sat_std;
+
+ Modelica.SIunits.SpecificEnthalpy h_start;
+ Modelica.SIunits.SpecificEnthalpy h_end;
+ Modelica.SIunits.SpecificEnthalpy h_delta;
+
+ Modelica.SIunits.Time t = 1;
+
+ Real x_std, x_spl, x_tbl;
+
+ equation
+ p = 10E5;
+ sat_std = fluid_std.setSat_p(p);
+ h_start = fluid_std.bubbleEnthalpy(sat_std);
+ h_end = fluid_std.dewEnthalpy(sat_std);
+ h_delta = 3e3;
+ h = (h_start - h_delta) + (h_end-h_start+2*h_delta)*time/t;
+ state_std = fluid_std.setState_ph(p,h);
+ state_spl = fluid_spl.setState_ph(p,h);
+ state_tbl = fluid_tbl.setState_ph(p,h);
+ x_std = fluid_std.vapourQuality(state_std);
+ x_spl = fluid_spl.vapourQuality(state_spl);
+ x_tbl = fluid_spl.vapourQuality(state_tbl);
+ end RhoSmoothing;
+ end CoolProp;
+
+ package WrongMedium "Test cases with wrong medium models"
+ extends Modelica.Icons.ExamplesPackage;
+ model TestWrongMedium
+ "Test the error reporting messages for unsupported external media"
+ extends Modelica.Icons.Example;
+ package Medium = Media.BaseClasses.ExternalTwoPhaseMedium;
+ Medium.BaseProperties medium;
+ equation
+ medium.p = 1e5;
+ medium.h = 1e5;
+ end TestWrongMedium;
+ end WrongMedium;
+
+ package TestOMC "Test cases for OpenModelica implementation"
+ extends Modelica.Icons.ExamplesPackage;
+ package TestHelium
+ "Test for NIST Helium model using ExternalMedia and FluidProp"
+ extends Modelica.Icons.ExamplesPackage;
+ package Helium "Helium model from NIST RefProp database"
+ extends ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium(
+ mediumName="Helium",
+ libraryName="FluidProp.RefProp",
+ substanceNames={"He"},
+ ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
+ AbsolutePressure(
+ min=500,
+ max=44e5,
+ nominal=1e5,
+ start=1e5),
+ Density(
+ min=0.1,
+ max=200,
+ nominal=100,
+ start=100),
+ SpecificEnthalpy(
+ min=-6000,
+ max=1.7e6,
+ nominal=1000,
+ start=0),
+ SpecificEntropy(
+ min=-4000,
+ max=30e3,
+ nominal=1000,
+ start=0),
+ Temperature(
+ min=2.17,
+ max=310,
+ nominal=10,
+ start=5,
+ displayUnit="K"));
+ end Helium;
+
+ model TestSupercriticalHelium
+ extends Modelica.Icons.Example;
+ package Medium = Helium;
+ Medium.ThermodynamicState state;
+ Medium.Temperature T;
+ Medium.Temperature Tcrit=Medium.fluidConstants[1].criticalTemperature;
+ Medium.AbsolutePressure p;
+ Modelica.SIunits.Density d;
+ Medium.AbsolutePressure pcrit=Medium.fluidConstants[1].criticalPressure;
+ equation
+ T = 300 - 297.5*time;
+ p = 4e5 + 0*time;
+ state = Medium.setState_pT(p, T);
+ d = Medium.density(state);
+ end TestSupercriticalHelium;
+
+ model TestSaturatedHelium
+ extends Modelica.Icons.Example;
+ package Medium = Helium;
+ Medium.SaturationProperties sat;
+ Medium.Temperature T;
+ Medium.AbsolutePressure p;
+ Modelica.SIunits.Density dl;
+ Modelica.SIunits.Density dv;
+ equation
+ p = 1e5 + 1.27e5*time;
+ sat = Medium.setSat_p(p);
+ dv = Medium.dewDensity(sat);
+ dl = Medium.bubbleDensity(sat);
+ T = Medium.saturationTemperature_sat(sat);
+ end TestSaturatedHelium;
+
+ model TypicalHeliumProperties
+ extends Modelica.Icons.Example;
+ package Medium = Helium;
+ Medium.ThermodynamicState state;
+ Medium.Temperature T;
+ Medium.Temperature Tcrit=Medium.fluidConstants[1].criticalTemperature;
+ Medium.AbsolutePressure p;
+ Modelica.SIunits.Density d;
+ Medium.AbsolutePressure pcrit=Medium.fluidConstants[1].criticalPressure;
+ Modelica.SIunits.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(
+ state);
+ equation
+ T = 5;
+ p = 5e5;
+ state = Medium.setState_pT(p, T);
+ d = Medium.density(state);
+ end TypicalHeliumProperties;
+ end TestHelium;
+
+ package TestHeliumHardCodedProperties
+ "Test for NIST Helium model using ExternalMedia and FluidProp, hard-coded fluid properties package constants"
+ extends Modelica.Icons.ExamplesPackage;
+ package Helium "Helium model from NIST RefProp database"
+ extends ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium(
+ mediumName="Helium",
+ libraryName="FluidProp.RefProp",
+ substanceNames={"He"},
+ externalFluidConstants=FluidConstants(
+ iupacName="unknown",
+ casRegistryNumber="unknown",
+ chemicalFormula="unknown",
+ structureFormula="unknown",
+ molarMass=4.0026e-3,
+ criticalTemperature=5.1953,
+ criticalPressure=2.2746e5,
+ criticalMolarVolume=1/69.641*4.0026e-3,
+ acentricFactor=0,
+ triplePointTemperature=280.0,
+ triplePointPressure=500.0,
+ meltingPoint=280,
+ normalBoilingPoint=380.0,
+ dipoleMoment=2.0),
+ ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
+ AbsolutePressure(
+ min=500,
+ max=44e5,
+ nominal=1e5,
+ start=1e5),
+ Density(
+ min=0.1,
+ max=200,
+ nominal=100,
+ start=100),
+ SpecificEnthalpy(
+ min=-6000,
+ max=1.7e6,
+ nominal=1000,
+ start=0),
+ SpecificEntropy(
+ min=-4000,
+ max=30e3,
+ nominal=1000,
+ start=0),
+ Temperature(
+ min=2.17,
+ max=310,
+ nominal=10,
+ start=5,
+ displayUnit="K"));
+ end Helium;
+
+ model TestSupercriticalHelium
+ extends Modelica.Icons.Example;
+ package Medium = Helium;
+ Medium.ThermodynamicState state;
+ Medium.Temperature T;
+ Medium.Temperature Tcrit=Medium.fluidConstants[1].criticalTemperature;
+ Medium.AbsolutePressure p;
+ Modelica.SIunits.Density d;
+ Medium.AbsolutePressure pcrit=Medium.fluidConstants[1].criticalPressure;
+ equation
+ T = 300 - 297.5*time;
+ p = 4e5 + 0*time;
+ state = Medium.setState_pT(p, T);
+ d = Medium.density(state);
+ end TestSupercriticalHelium;
+
+ model TestSaturatedHelium
+ extends Modelica.Icons.Example;
+ package Medium = Helium;
+ Medium.SaturationProperties sat;
+ Medium.Temperature T;
+ Medium.AbsolutePressure p;
+ Modelica.SIunits.Density dl;
+ Modelica.SIunits.Density dv;
+ equation
+ p = 1e5 + 1.27e5*time;
+ sat = Medium.setSat_p(p);
+ dv = Medium.dewDensity(sat);
+ dl = Medium.bubbleDensity(sat);
+ T = Medium.saturationTemperature_sat(sat);
+ end TestSaturatedHelium;
+
+ model TypicalHeliumProperties
+ extends Modelica.Icons.Example;
+ package Medium = Helium;
+ Medium.ThermodynamicState state;
+ Medium.Temperature T;
+ Medium.Temperature Tcrit=Medium.fluidConstants[1].criticalTemperature;
+ Medium.AbsolutePressure p;
+ Modelica.SIunits.Density d;
+ Medium.AbsolutePressure pcrit=Medium.fluidConstants[1].criticalPressure;
+ Modelica.SIunits.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(
+ state);
+ equation
+ T = 5;
+ p = 5e5;
+ state = Medium.setState_pT(p, T);
+ d = Medium.density(state);
+ end TypicalHeliumProperties;
+ end TestHeliumHardCodedProperties;
+ end TestOMC;
+
+ package GenericModels "Generic models for FluidProp media tests"
+ extends Modelica.Icons.BasesPackage;
+ package DummyTwoPhaseMedium "A dummy to allow for pedantic checking"
+ extends Modelica.Media.Water.WaterIF97_ph;
+ end DummyTwoPhaseMedium;
+
+ model CompleteFluidConstants "Compute all available medium fluid constants"
+ replaceable package Medium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+ // Fluid constants
+ Medium.Temperature Tc=Medium.fluidConstants[1].criticalTemperature;
+ Medium.AbsolutePressure pc=Medium.fluidConstants[1].criticalPressure;
+ Medium.MolarVolume vc=Medium.fluidConstants[1].criticalMolarVolume;
+ Medium.MolarMass MM=Medium.fluidConstants[1].molarMass;
+ end CompleteFluidConstants;
+
+ model CompleteThermodynamicState
+ "Compute all available two-phase medium properties from a ThermodynamicState model"
+ replaceable package Medium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+ // ThermodynamicState record
+ input Medium.ThermodynamicState state;
+ // Medium properties
+ Medium.AbsolutePressure p=Medium.pressure(state);
+ Medium.SpecificEnthalpy h=Medium.specificEnthalpy(state);
+ Medium.Temperature T=Medium.temperature(state);
+ Medium.Density d=Medium.density(state);
+ Medium.SpecificEntropy s=Medium.specificEntropy(state);
+ Medium.SpecificHeatCapacity cp=Medium.specificHeatCapacityCp(state);
+ Medium.SpecificHeatCapacity cv=Medium.specificHeatCapacityCv(state);
+ Medium.IsobaricExpansionCoefficient beta=Medium.isobaricExpansionCoefficient(state);
+ SI.IsothermalCompressibility kappa=Medium.isothermalCompressibility(state);
+ Medium.DerDensityByPressure d_d_dp_h=Medium.density_derp_h(state);
+ Medium.DerDensityByEnthalpy d_d_dh_p=Medium.density_derh_p(state);
+ Medium.MolarMass MM=Medium.molarMass(state);
+ end CompleteThermodynamicState;
+
+ model CompleteSaturationProperties
+ "Compute all available saturation properties from a SaturationProperties record"
+ replaceable package Medium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+ // SaturationProperties record
+ input Medium.SaturationProperties sat;
+ // Saturation properties
+ Medium.Temperature Ts=Medium.saturationTemperature_sat(sat);
+ Medium.Density dl=Medium.bubbleDensity(sat);
+ Medium.Density dv=Medium.dewDensity(sat);
+ Medium.SpecificEnthalpy hl=Medium.bubbleEnthalpy(sat);
+ Medium.SpecificEnthalpy hv=Medium.dewEnthalpy(sat);
+ Real d_Ts_dp=Medium.saturationTemperature_derp_sat(sat);
+ Real d_dl_dp=Medium.dBubbleDensity_dPressure(sat);
+ Real d_dv_dp=Medium.dDewDensity_dPressure(sat);
+ Real d_hl_dp=Medium.dBubbleEnthalpy_dPressure(sat);
+ Real d_hv_dp=Medium.dDewEnthalpy_dPressure(sat);
+ end CompleteSaturationProperties;
+
+ model CompleteBubbleDewStates
+ "Compute all available properties for dewpoint and bubble point states corresponding to a sat record"
+ replaceable package Medium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+ // SaturationProperties record
+ input Medium.SaturationProperties sat;
+ // and the rest based on sat
+ CompleteThermodynamicState dewStateOnePhase(state=Medium.setDewState(sat, 1),
+ redeclare package Medium = Medium);
+ CompleteThermodynamicState dewStateTwoPhase(state=Medium.setDewState(sat, 2),
+ redeclare package Medium = Medium);
+ CompleteThermodynamicState bubbleStateOnePhase(state=Medium.setBubbleState(
+ sat, 1), redeclare package Medium = Medium);
+ CompleteThermodynamicState bubbleStateTwoPhase(state=Medium.setBubbleState(
+ sat, 2), redeclare package Medium = Medium);
+ end CompleteBubbleDewStates;
+
+ model CompleteBaseProperties
+ "Compute all available two-phase medium properties from a BaseProperties model"
+ replaceable package Medium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+ // BaseProperties object
+ Medium.BaseProperties baseProperties;
+ // All the complete properties
+ CompleteThermodynamicState completeState(redeclare package Medium = Medium,
+ state=baseProperties.state);
+ CompleteSaturationProperties completeSat(redeclare package Medium = Medium,
+ sat=baseProperties.sat);
+ CompleteFluidConstants completeConstants(redeclare package Medium = Medium);
+ end CompleteBaseProperties;
+
+ partial model TestStates "Test case with state"
+ replaceable package Medium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+ Medium.AbsolutePressure p1;
+ Medium.SpecificEnthalpy h1;
+ Medium.AbsolutePressure p2;
+ Medium.Temperature T2;
+ Medium.ThermodynamicState state1;
+ Medium.ThermodynamicState state2;
+ CompleteThermodynamicState completeState1(redeclare package Medium = Medium,
+ state=state1);
+ CompleteThermodynamicState completeState2(redeclare package Medium = Medium,
+ state=state2);
+ equation
+ state1 = Medium.setState_ph(p1, h1);
+ state2 = Medium.setState_pT(p2, T2);
+ end TestStates;
+
+ partial model TestStatesSat "Test case with state + sat records"
+ replaceable package Medium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+ Medium.AbsolutePressure p1;
+ Medium.SpecificEnthalpy h1;
+ Medium.AbsolutePressure p2;
+ Medium.Temperature T2;
+ Medium.ThermodynamicState state1;
+ Medium.ThermodynamicState state2;
+ Medium.SaturationProperties sat1;
+ Medium.SaturationProperties sat2;
+ Medium.Temperature Ts;
+ Medium.AbsolutePressure ps;
+ CompleteThermodynamicState completeState1(redeclare package Medium = Medium,
+ state=state1);
+ CompleteThermodynamicState completeState2(redeclare package Medium = Medium,
+ state=state2);
+ CompleteSaturationProperties completeSat1(redeclare package Medium = Medium,
+ sat=sat1);
+ CompleteSaturationProperties completeSat2(redeclare package Medium = Medium,
+ sat=sat2);
+ CompleteBubbleDewStates completeBubbleDewStates1(redeclare package Medium =
+ Medium, sat=sat1);
+ CompleteBubbleDewStates completeBubbleDewStates2(redeclare package Medium =
+ Medium, sat=sat2);
+ equation
+ state1 = Medium.setState_ph(p1, h1);
+ state2 = Medium.setState_pT(p2, T2);
+ sat1 = Medium.setSat_p(p1);
+ sat2 = Medium.setSat_T(T2);
+ Ts = Medium.saturationTemperature(p1);
+ ps = Medium.saturationPressure(T2);
+ end TestStatesSat;
+
+ partial model TestBasePropertiesExplicit
+ "Test case using BaseProperties and explicit equations"
+ replaceable package Medium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+ CompleteBaseProperties medium1(redeclare package Medium = Medium)
+ "Constant pressure, varying enthalpy";
+ CompleteBaseProperties medium2(redeclare package Medium = Medium)
+ "Varying pressure, constant enthalpy";
+ Medium.AbsolutePressure p1;
+ Medium.AbsolutePressure p2;
+ Medium.SpecificEnthalpy h1;
+ Medium.SpecificEnthalpy h2;
+ equation
+ medium1.baseProperties.p = p1;
+ medium1.baseProperties.h = h1;
+ medium2.baseProperties.p = p2;
+ medium2.baseProperties.h = h2;
+ end TestBasePropertiesExplicit;
+
+ partial model TestBasePropertiesImplicit
+ "Test case using BaseProperties and implicit equations"
+ replaceable package Medium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+ parameter Medium.SpecificEnthalpy hstart
+ "Start value for specific enthalpy";
+ CompleteBaseProperties medium1(redeclare package Medium = Medium,
+ baseProperties(h(start=hstart)))
+ "Constant pressure, varying enthalpy";
+ CompleteBaseProperties medium2(redeclare package Medium = Medium,
+ baseProperties(h(start=hstart)))
+ "Varying pressure, constant enthalpy";
+ Medium.AbsolutePressure p1;
+ Medium.AbsolutePressure p2;
+ Medium.Temperature T1;
+ Medium.Temperature T2;
+ equation
+ medium1.baseProperties.p = p1;
+ medium1.baseProperties.T = T1;
+ medium2.baseProperties.p = p2;
+ medium2.baseProperties.T = T2;
+ end TestBasePropertiesImplicit;
+
+ partial model TestBasePropertiesDynamic
+ "Test case using BaseProperties and dynamic equations"
+ replaceable package Medium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+ parameter SI.Volume V=1 "Storage Volume";
+ parameter Real p_atm=101325 "Atmospheric pressure";
+ parameter SI.Temperature Tstart=300;
+ parameter SI.SpecificEnthalpy hstart=1e5;
+ parameter SI.Pressure pstart=p_atm;
+ parameter Real Kv0 "Valve flow coefficient";
+ Medium.BaseProperties medium(
+ preferredMediumStates=true,
+ h(start=hstart),
+ p(start=pstart));
+ SI.Mass M;
+ SI.Energy U;
+ SI.MassFlowRate win(start=100);
+ SI.MassFlowRate wout;
+ SI.SpecificEnthalpy hin;
+ SI.SpecificEnthalpy hout;
+ SI.Power Q;
+ Real Kv;
+ equation
+ // Mass & energy balance equation
+ M = medium.d*V;
+ U = medium.u*M;
+ der(M) = win - wout;
+ der(U) = win*hin - wout*hout + Q;
+ // Outlet valve equation
+ wout = Kv*sqrt(medium.d*(medium.p - p_atm));
+ hout = medium.h;
+ initial equation
+ // Steady state equations
+ der(medium.p) = 0;
+ der(medium.h) = 0;
+ annotation (experiment(StopTime=80, Tolerance=1e-007));
+ end TestBasePropertiesDynamic;
+
+ partial model CompareModelicaTestMedium
+ "Comparison between Modelica and TestMedium models"
+ replaceable package ModelicaMedium =
+ Modelica.Media.Water.WaterIF97_ph
+ constrainedby Modelica.Media.Interfaces.PartialMedium
+ annotation(choicesAllMatching=true);
+ replaceable package TestMedium =
+ ExternalMedia.Test.GenericModels.DummyTwoPhaseMedium
+ constrainedby Modelica.Media.Interfaces.PartialMedium
+ annotation(choicesAllMatching=true);
+ CompleteBaseProperties modelicaMedium(redeclare package Medium =
+ ModelicaMedium) "Modelica medium model";
+ CompleteBaseProperties testMedium(redeclare package Medium = TestMedium)
+ "TestMedium medium model";
+ parameter Modelica.SIunits.Pressure pmin;
+ parameter Modelica.SIunits.Pressure pmax;
+ parameter Modelica.SIunits.SpecificEnthalpy hmin;
+ parameter Modelica.SIunits.SpecificEnthalpy hmax;
+ equation
+ modelicaMedium.baseProperties.p = pmin + (pmax - pmin)*time;
+ modelicaMedium.baseProperties.h = hmin + (hmax - hmin)*time;
+ testMedium.baseProperties.p = pmin + (pmax - pmin)*time;
+ testMedium.baseProperties.h = hmin + (hmax - hmin)*time;
+ end CompareModelicaTestMedium;
+
+ partial model TestRunner
+ "A collection of models to test the states and base properties"
+ extends Modelica.Icons.Example;
+
+ replaceable package Medium = Modelica.Media.Water.StandardWater
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+
+ Medium.AbsolutePressure p_in;
+ Medium.SpecificEnthalpy h_in;
+ Medium.Temperature T_in;
+ Medium.SaturationProperties sat_in;
+ parameter Medium.SpecificEnthalpy hstart = 2e5
+ "Start value for specific enthalpy";
+
+ model TestStates_Impl
+ extends ExternalMedia.Test.GenericModels.TestStates;
+ input Medium.AbsolutePressure _p1;
+ input Medium.SpecificEnthalpy _h1;
+ input Medium.AbsolutePressure _p2;
+ input Medium.Temperature _T2;
+ equation
+ p1 = _p1;
+ h1 = _h1;
+ p2 = _p2;
+ T2 = _T2;
+ end TestStates_Impl;
+
+ TestStates_Impl testStates(
+ redeclare package Medium = Medium,
+ _p1=p_in,
+ _h1=h_in,
+ _p2=p_in*1.15,
+ _T2=T_in) annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
+
+ model TestStatesSat_Impl
+ extends ExternalMedia.Test.GenericModels.TestStatesSat;
+ input Medium.AbsolutePressure _p1;
+ input Medium.SpecificEnthalpy _h1;
+ input Medium.AbsolutePressure _p2;
+ input Medium.Temperature _T2;
+ equation
+ p1 = _p1;
+ h1 = _h1;
+ p2 = _p2;
+ T2 = _T2;
+ end TestStatesSat_Impl;
+
+ TestStatesSat_Impl testStatesSat(
+ redeclare package Medium = Medium,
+ _p1=p_in,
+ _h1=h_in,
+ _p2=p_in*1.15,
+ _T2=T_in) annotation (Placement(transformation(extent={{-40,60},{-20,80}})));
+
+ model TestBasePropertiesExplicit_Impl
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesExplicit;
+ input Medium.AbsolutePressure _p1;
+ input Medium.SpecificEnthalpy _h1;
+ input Medium.AbsolutePressure _p2;
+ input Medium.SpecificEnthalpy _h2;
+ equation
+ p1 = _p1;
+ h1 = _h1;
+ p2 = _p2;
+ h2 = _h2;
+ end TestBasePropertiesExplicit_Impl;
+
+ TestBasePropertiesExplicit_Impl testBasePropertiesExplicit(
+ redeclare package Medium = Medium,
+ _p1=p_in,
+ _h1=h_in,
+ _p2=p_in*1.15,
+ _h2=h_in) annotation (Placement(transformation(extent={{-40,20},{-20,40}})));
+
+ model TestBasePropertiesImplicit_Impl
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesImplicit;
+ input Medium.AbsolutePressure _p1;
+ input Medium.Temperature _T1;
+ input Medium.AbsolutePressure _p2;
+ input Medium.Temperature _T2;
+ equation
+ p1 = _p1;
+ T1 = _T1;
+ p2 = _p2;
+ T2 = _T2;
+ end TestBasePropertiesImplicit_Impl;
+
+ TestBasePropertiesImplicit_Impl testBasePropertiesImplicit(
+ redeclare package Medium = Medium,
+ _p1=p_in,
+ _T1=T_in,
+ _p2=p_in*1.15,
+ _T2=T_in,
+ hstart=hstart)
+ annotation (Placement(transformation(extent={{-80,20},{-60,40}})));
+
+ model TestBasePropertiesDynamic_Impl
+ extends ExternalMedia.Test.GenericModels.TestBasePropertiesDynamic;
+ input Medium.SpecificEnthalpy _h1;
+ equation
+ // Inlet equations
+ win = 1;
+ hin = _h1;
+ // Input variables
+ Kv = if time < 50 then Kv0 else Kv0*1.1;
+ Q = if time < 1 then 0 else 1e4;
+ end TestBasePropertiesDynamic_Impl;
+
+ TestBasePropertiesDynamic_Impl testBasePropertiesDynamic(Tstart=300,
+ hstart=4e5,
+ pstart=1e6,
+ Kv0=1.00801e-4,
+ V=0.1,
+ redeclare package Medium = Medium,_h1=h_in)
+ annotation (Placement(transformation(extent={{0,20},{20,40}})));
+ annotation (experiment(StopTime=80, Tolerance=1e-007));
+ end TestRunner;
+
+ model TestRunnerTwoPhase
+ "A collection of models to test the saturation states"
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestRunner( redeclare
+ package Medium =
+ TwoPhaseMedium);
+
+ replaceable package TwoPhaseMedium = Modelica.Media.Water.StandardWater
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+
+ parameter Medium.AbsolutePressure p_start = 1e5;
+ algorithm
+ assert(Medium.fluidConstants[1].criticalPressure>p_start, "You have to start below the critical pressure.");
+ equation
+ p_in = p_start+0.5*(Medium.fluidConstants[1].criticalPressure-p_start)*time;
+ sat_in = Medium.setSat_p(p=p_in);
+ h_in = Medium.bubbleEnthalpy(sat_in);
+ T_in = Medium.saturationTemperature_sat(sat_in);
+ end TestRunnerTwoPhase;
+
+ model TestRunnerTranscritical
+ "A collection of models to test the transcritical states"
+ extends Modelica.Icons.Example;
+ extends ExternalMedia.Test.GenericModels.TestRunner( redeclare
+ package Medium =
+ TwoPhaseMedium);
+
+ replaceable package TwoPhaseMedium = Modelica.Media.Water.StandardWater
+ constrainedby Modelica.Media.Interfaces.PartialTwoPhaseMedium
+ annotation(choicesAllMatching=true);
+
+ parameter Medium.AbsolutePressure p_start = 1e5;
+ algorithm
+ assert(Medium.fluidConstants[1].criticalPressure>p_start, "You have to start below the critical pressure.");
+ equation
+ p_in = p_start+1.5*(Medium.fluidConstants[1].criticalPressure-p_start)*time;
+ sat_in = Medium.setSat_p(p=p_in);
+ h_in = Medium.bubbleEnthalpy(sat_in);
+ T_in = Medium.saturationTemperature_sat(sat_in);
+ end TestRunnerTranscritical;
+ end GenericModels;
+
+ package MSL_Models
+ "Test cases taken from the Modelica Standard Library, medium redefinition needed."
+ extends Modelica.Icons.BasesPackage;
+
+ model BranchingDynamicPipes "From Fluid library, needs medium definition"
+ extends Modelica.Fluid.Examples.BranchingDynamicPipes(
+ redeclare package Medium=NewMedium);
+
+ replaceable package NewMedium=Modelica.Media.Water.StandardWater constrainedby
+ Modelica.Media.Interfaces.PartialMedium
+ annotation(choicesAllMatching=true);
+
+ //replaceable package NewMedium=ExternalMedia.Examples.WaterCoolProp;
+ //replaceable package NewMedium=Modelica.Media.Water.StandardWater;
+ //replaceable package NewMedium=ExternalMedia.Examples.WaterIF97;
+ end BranchingDynamicPipes;
+
+ model IncompressibleFluidNetwork
+ "From Fluid library, needs medium definition"
+ extends Modelica.Fluid.Examples.IncompressibleFluidNetwork(
+ redeclare package Medium=NewMedium);
+ replaceable package NewMedium=Modelica.Media.Water.StandardWater constrainedby
+ Modelica.Media.Interfaces.PartialMedium
+ annotation(choicesAllMatching=true);
+ end IncompressibleFluidNetwork;
+ end MSL_Models;
+
+ model WaterComparison "Compares different implementations of water"
+ extends Modelica.Icons.Example;
+
+ GenericModels.TestRunnerTwoPhase testRunnerTwoPhaseWater1(
+ hstart=4e5,
+ redeclare package TwoPhaseMedium =
+ ExternalMedia.Examples.WaterCoolPropTabular,
+ p_start=100000)
+ annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
+ end WaterComparison;
+end Test;
diff --git a/Modelica/ExternalMedia 3.2.1/UserGuide.mo b/Modelica/ExternalMedia 3.3.0/UserGuide.mo
similarity index 100%
rename from Modelica/ExternalMedia 3.2.1/UserGuide.mo
rename to Modelica/ExternalMedia 3.3.0/UserGuide.mo
diff --git a/Modelica/ExternalMedia 3.2.1/package.mo b/Modelica/ExternalMedia 3.3.0/package.mo
similarity index 58%
rename from Modelica/ExternalMedia 3.2.1/package.mo
rename to Modelica/ExternalMedia 3.3.0/package.mo
index 555d88ef..721cdf68 100644
--- a/Modelica/ExternalMedia 3.2.1/package.mo
+++ b/Modelica/ExternalMedia 3.3.0/package.mo
@@ -1,21 +1,23 @@
-within ;
-package ExternalMedia
- extends Modelica.Icons.Package;
- import SI = Modelica.SIunits;
-
-
- annotation(uses(Modelica(version="3.2.1")),
- Documentation(info="
-
The ExternalMedia library provides a framework for interfacing external codes computing fluid properties to Modelica.Media-compatible component models. The library has been designed with two main goals: maximizing the efficiency of the code, while minimizing the amount of extra code required to interface existing external codes to the library.
-The library covers pure fluids models, possibly two-phase, compliant with the Modelica.Media.Interfaces.PartialTwoPhaseMedium interface.
-Two external softwares for fluid property computation are currently suppored by the ExternalMedia library:
-
-- FluidProp, formerly developed at TU Delft and currently devloped and maintained by Asimptote
-- CoolProp, developed at the University of Liege and at the Technical University of Denmark (DTU)
-
-The library has been tested with the Dymola and OpenModelica tools under the Windows operating system. If you are interested in the support of other tools, operating systems, and external fluid property computation codes, please contact the developers.
-Main contributors: Francesco Casella, Christoph Richter, Roberto Bonifetto, Ian Bell.
-The code is licensed under the Modelica License 2. For license conditions (including the disclaimer of warranty) visit https://www.modelica.org/licenses/ModelicaLicense2.
-Copyright © 2006-2014, Politecnico di Milano, TU Braunschweig, Politecnico di Torino, Université de Liege.
-"));
-end ExternalMedia;
+within ;
+package ExternalMedia
+ extends Modelica.Icons.Package;
+ import SI = Modelica.SIunits;
+
+
+ annotation(uses(Modelica(version="3.2.3")),
+ version="3.3.0",
+ Documentation(info="
+The ExternalMedia library provides a framework for interfacing external codes computing fluid properties to Modelica.Media-compatible component models. The library has been designed with two main goals: maximizing the efficiency of the code, while minimizing the amount of extra code required to interface existing external codes to the library.
+The library covers pure fluids models, possibly two-phase, compliant with the Modelica.Media.Interfaces.PartialTwoPhaseMedium interface.
+Two external softwares for fluid property computation are currently supported by the ExternalMedia library:
+
+- FluidProp, formerly developed at TU Delft and currently devloped and maintained by Asimptote
+- CoolProp, developed at the University of Liege and at the Technical University of Denmark (DTU)
+
+A detailed documentation of the software is available in the technical manual.
+The library has been tested with the Dymola and OpenModelica tools under the Windows and Linux operating system. If you are interested in the support of other tools, operating systems, and external fluid property computation codes, please contact the developers.
+Main contributors: Francesco Casella, Christoph Richter, Roberto Bonifetto, Ian Bell, Jorrit Wronski.
+The code is licensed under the BSD 3-clause license. For license conditions visit https://opensource.org/licenses/BSD-3-Clause.
+Copyright © 2006-2021, Francesco Casella, Christoph Richter, Roberto Bonifetto, Ian Bell, Jorrit Wronski.
+"));
+end ExternalMedia;
diff --git a/Modelica/ExternalMedia 3.2.1/package.order b/Modelica/ExternalMedia 3.3.0/package.order
similarity index 88%
rename from Modelica/ExternalMedia 3.2.1/package.order
rename to Modelica/ExternalMedia 3.3.0/package.order
index 8deac6ba..a31e2613 100644
--- a/Modelica/ExternalMedia 3.2.1/package.order
+++ b/Modelica/ExternalMedia 3.3.0/package.order
@@ -1,5 +1,5 @@
-UserGuide
-Common
-Media
-Examples
-Test
+UserGuide
+Common
+Media
+Examples
+Test
diff --git a/Projects/.gitignore b/Projects/.gitignore
new file mode 100644
index 00000000..c0037334
--- /dev/null
+++ b/Projects/.gitignore
@@ -0,0 +1 @@
+/build/
diff --git a/Projects/BuildLib-Dymola-VS2008.bat b/Projects/BuildLib-Dymola-VS2008.bat
deleted file mode 100644
index e6ff017f..00000000
--- a/Projects/BuildLib-Dymola-VS2008.bat
+++ /dev/null
@@ -1,13 +0,0 @@
-REM ******** set the variables ************
-REM call both to ensure that one works
-call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
-call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
-
-call BuildLib-VS
-
-echo "Copying files to External Media 3.2.1"
-copy ExternalMediaLib.lib "..\Modelica\ExternalMedia 3.2.1\Resources\Library\win32\ExternalMediaLib.Dymola-vs2008.lib"
-copy ExternalMediaLib.lib "..\Modelica\ExternalMedia 3.2.1\Resources\Library\win32\ExternalMediaLib.lib"
-del ExternalMediaLib.lib
-copy Sources\externalmedialib.h "..\Modelica\ExternalMedia 3.2.1\Resources\Include"
-echo "All done"
\ No newline at end of file
diff --git a/Projects/BuildLib-Dymola-VS2010.bat b/Projects/BuildLib-Dymola-VS2010.bat
deleted file mode 100644
index c1afa1c4..00000000
--- a/Projects/BuildLib-Dymola-VS2010.bat
+++ /dev/null
@@ -1,13 +0,0 @@
-REM ******** set the variables ************
-REM call both to ensure that one works
-call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
-call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
-
-call BuildLib-VS
-
-echo "Copying files to External Media 3.2.1"
-copy ExternalMediaLib.lib "..\Modelica\ExternalMedia 3.2.1\Resources\Library\win32\ExternalMediaLib.Dymola-vs2010.lib"
-copy ExternalMediaLib.lib "..\Modelica\ExternalMedia 3.2.1\Resources\Library\win32\ExternalMediaLib.lib"
-del ExternalMediaLib.lib
-copy Sources\externalmedialib.h "..\Modelica\ExternalMedia 3.2.1\Resources\Include"
-echo "All done"
\ No newline at end of file
diff --git a/Projects/BuildLib-Dymola-VS2012.bat b/Projects/BuildLib-Dymola-VS2012.bat
deleted file mode 100644
index 0103e193..00000000
--- a/Projects/BuildLib-Dymola-VS2012.bat
+++ /dev/null
@@ -1,13 +0,0 @@
-REM ******** set the variables ************
-REM call both to ensure that one works
-call "C:\Program Files\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"
-call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"
-
-call BuildLib-VS
-
-echo "Copying files to External Media 3.2.1"
-copy ExternalMediaLib.lib "..\Modelica\ExternalMedia 3.2.1\Resources\Library\win32\ExternalMediaLib.Dymola-vs2012.lib"
-copy ExternalMediaLib.lib "..\Modelica\ExternalMedia 3.2.1\Resources\Library\win32\ExternalMediaLib.lib"
-del ExternalMediaLib.lib
-copy Sources\externalmedialib.h "..\Modelica\ExternalMedia 3.2.1\Resources\Include"
-echo "All done"
\ No newline at end of file
diff --git a/Projects/BuildLib-OMC-gcc-linux.sh b/Projects/BuildLib-OMC-gcc-linux.sh
deleted file mode 100644
index 666a599d..00000000
--- a/Projects/BuildLib-OMC-gcc-linux.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-
-# -DCOOLPROP=1 enables the use of CoolProp, which defaults to being disabled.
-# Use -DCOOLPROP=0 to compile ExternalMedia wrapper without coolprop support
-# The C++ files for CoolProp will still be compiled
-
-GCC_OPTS="-O2 -loleaut32 -DCOOLPROP=1"
-CP=../externals/coolprop/trunk
-CPinc=${CP}/CoolProp
-INCLUDES="-I${CPinc}"
-
-# echo "Getting coolpropsolver.cpp from CoolProp"
-# cp ${CP}/wrappers/Modelica/src/coolpropsolver.cpp Sources
-# cp ${CP}/wrappers/Modelica/src/coolpropsolver.h Sources
-
-echo "Compiling sources"
-# ****** compile all the OpenModelica files ************
-gcc ${GCC_OPTS} -c ${INCLUDES} Sources/*.cpp
-# ********** CoolProp sources *********
-gcc ${GCC_OPTS} -c ${INCLUDES} ${CP}/CoolProp/*.cpp
-
-ar -r libExternalMediaLib.a *.o
-ranlib libExternalMediaLib.a
-
-echo "Copying files to External Media 3.2.1"
-cp libExternalMediaLib.a "../Modelica/ExternalMedia 3.2.1/Resources/Library/linux32/libExternalMediaLib.OMC-gcc.a"
-cp libExternalMediaLib.a "../Modelica/ExternalMedia 3.2.1/Resources/Library/linux32/libExternalMediaLib.a"
-rm libExternalMediaLib.a
-cp Sources/externalmedialib.h "../Modelica/ExternalMedia 3.2.1/Resources/Include"
-echo "All done"
\ No newline at end of file
diff --git a/Projects/BuildLib-OMC-gcc-windows.sh b/Projects/BuildLib-OMC-gcc-windows.sh
deleted file mode 100644
index 1fac1d0b..00000000
--- a/Projects/BuildLib-OMC-gcc-windows.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-# -DCOOLPROP=1 enables the use of CoolProp, which defaults to being disabled.
-# Use -DCOOLPROP=0 to compile ExternalMedia wrapper without coolprop support
-# The C++ files for CoolProp will still be compiled
-
-GCC_OPTS="-O2 -loleaut32 -DCOOLPROP=1"
-CP=../externals/coolprop/trunk
-CPinc=${CP}/CoolProp
-INCLUDES="-I${CPinc}"
-
-# echo "Getting coolpropsolver.cpp from CoolProp"
-# cp ${CP}/wrappers/Modelica/src/coolpropsolver.cpp Sources
-# cp ${CP}/wrappers/Modelica/src/coolpropsolver.h Sources
-
-echo "Compiling sources"
-# ****** compile all the OpenModelica files ************
-gcc ${GCC_OPTS} -c ${INCLUDES} Sources/*.cpp
-# ********** CoolProp sources *********
-gcc ${GCC_OPTS} -c ${INCLUDES} ${CP}/CoolProp/*.cpp
-
-ar -r libExternalMediaLib.a *.o
-ranlib libExternalMediaLib.a
-
-echo "Copying files to External Media 3.2.1"
-cp libExternalMediaLib.a "../Modelica/ExternalMedia 3.2.1/Resources/Library/win32/libExternalMediaLib.OMC-gcc.a"
-cp libExternalMediaLib.a "../Modelica/ExternalMedia 3.2.1/Resources/Library/win32/libExternalMediaLib.a"
-cp Sources/externalmedialib.h "../Modelica/ExternalMedia 3.2.1/Resources/Include"
-rm libExternalMediaLib.a
-rm *.o
-echo "All done"
\ No newline at end of file
diff --git a/Projects/BuildLib-VS.bat b/Projects/BuildLib-VS.bat
deleted file mode 100644
index e5ae31d5..00000000
--- a/Projects/BuildLib-VS.bat
+++ /dev/null
@@ -1,49 +0,0 @@
-echo off
-
-REM ****************** README *********************************
-REM BuildLib-VSXXXX.bat should be called to set the proper environmental variables
-REM Do not run this file directly!!!
-REM ****************** README *********************************
-REM ~ /Ox : full optimization
-REM ~ /c : compile
-REM ~ /MP3 :
-REM ~ /fp:fast :
-REM ~ /MD : Multi-threaded DLL runtime library
-REM ~ /Ehsc : Explicitly enable exception handling
-
-set C_OPTS=/Ox /c /MP3 /fp:fast /MD /EHsc
-set CP=..\externals\coolprop\trunk
-set CPinc=%CP%\CoolProp
-set INCLUDES=-I%CPinc%
-
-echo ' '
-echo "Detecting supported solvers"
-setlocal EnableDelayedExpansion
-set i=0
-for /f "delims=" %%a in ('FINDSTR FLUIDPROP Sources\include.h') do (
- set line[!i!]=%%a
- set /A i=i+1
- )
-for /f "tokens=3" %%a in ("%line[0]%") do set FLUIDP=%%a
-echo "FluidProp support set to: %FLUIDP%"
-
-set i=0
-for /f "delims=" %%a in ('FINDSTR COOLPROP Sources\include.h') do (
- set line[!i!]=%%a
- set /A i=i+1
- )
-for /f "tokens=3" %%a in ("%line[0]%") do set COOLP=%%a
-echo " CoolProp support set to: %COOLP%"
-
-
-REM echo "Compiling sources"
-REM ****** compile all the sources for OpenModelica ************
-cl %C_OPTS% /c %INCLUDES% Sources\*.cpp
-
-REM ********** CoolProp sources *********
-if "%COOLP%"=="1" cl %C_OPTS% /c %INCLUDES% %CP%\CoolProp\*.cpp
-
-lib *.obj /OUT:ExternalMediaLib.lib
-erase *.obj
-
-:End
\ No newline at end of file
diff --git a/Projects/CMakeLists.txt b/Projects/CMakeLists.txt
new file mode 100644
index 00000000..dac109e7
--- /dev/null
+++ b/Projects/CMakeLists.txt
@@ -0,0 +1,239 @@
+cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
+include(ExternalProject)
+
+CMAKE_POLICY(SET CMP0053 OLD)
+
+#######################################
+# PROJECT INFORMATION #
+#######################################
+
+# Project name
+project ("ExternalMedia")
+
+# Project version
+set (VERSION_MAJOR 3)
+set (VERSION_MINOR 3)
+set (VERSION_PATCH 0)
+set (APP_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
+message (STATUS "ExternalMedia library version: ${APP_VERSION}")
+set (LIBRARY_NAME "ExternalMediaLib")
+set (LIBRARY_HEADER "externalmedialib.h")
+
+
+#######################################
+# PROJECT-WIDE SETTINGS #
+#######################################
+if (MSVC)
+# # Force visual studio to statically link the c runtime to avoid dependency on MSVCRXXX.dll
+# set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
+# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
+# set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
+# set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
+ ADD_DEFINITIONS (-D_CRT_SECURE_NO_WARNINGS)
+endif()
+#ADD_DEFINITIONS (-DMODELICA_ERRORS=0 -DNOMINMAX)
+# Workaround for missing ModelicaMessage and ModelicaError objects
+set(INCLUDE_DIRS "")
+
+if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../externals")
+ file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../externals")
+endif()
+
+option(COOLPROP "Include the CoolProp library for fluid properties" ON)
+option(FLUIDPROP "Include the FluidProp library for fluid properties" OFF)
+
+#######################################
+# INCLUDE COOLPROP #
+#######################################
+
+if(COOLPROP)
+ # Get the CoolProp code
+ if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../externals/CoolProp.git")
+ file(DOWNLOAD https://sourceforge.net/projects/coolprop/files/CoolProp/5.1.1/source/CoolProp_sources.zip/download "${CMAKE_BINARY_DIR}/coolprop.zip")
+ #file(DOWNLOAD https://sourceforge.net/projects/coolprop/files/CoolProp/nightly/source/CoolProp_sources.zip/download "${CMAKE_BINARY_DIR}/coolprop.zip")
+ file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/coolprop-tmp")
+ # Use CMake to unzip
+ file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/coolprop-tmp")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar xjf "${CMAKE_BINARY_DIR}/coolprop.zip"
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/coolprop-tmp"
+ )
+ #file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/coolprop.zip)
+ #execute_process(COMMAND unzip ${CMAKE_BINARY_DIR}/coolprop.zip -d "${CMAKE_BINARY_DIR}/coolprop-tmp")
+ #execute_process(COMMAND sed -i '421s;^;\#;' "${CMAKE_BINARY_DIR}/coolprop-tmp/CoolProp.sources/CMakeLists.txt")
+ file(RENAME "${CMAKE_BINARY_DIR}/coolprop-tmp/CoolProp.sources" "${CMAKE_CURRENT_SOURCE_DIR}/../externals/CoolProp.git")
+ file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/coolprop-tmp")
+ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/CoolProp")
+ endif()
+ # Configure CMake switches for CoolProp
+ SET(COOLPROP_STATIC_LIBRARY OFF CACHE BOOL "Force the object library")
+ SET(COOLPROP_SHARED_LIBRARY OFF CACHE BOOL "Force the object library")
+ SET(COOLPROP_OBJECT_LIBRARY ON CACHE BOOL "Force the object library")
+ # Force bitness for MinGW
+ if(MINGW)
+ if(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ SET(FORCE_BITNESS_64 ON CACHE BOOL "force 64 bit")
+ else()
+ SET(FORCE_BITNESS_32 ON CACHE BOOL "force 32 bit")
+ endif()
+ endif()
+ # Enable this for shared libraries (either CoolProp itself or ExternalMedia)
+ SET(COOLPROP_FPIC ON CACHE BOOL "force -fPIC switch")
+ # Add the CoolProp sources
+ ADD_SUBDIRECTORY ("${CMAKE_CURRENT_SOURCE_DIR}/../externals/CoolProp.git" "${CMAKE_CURRENT_BINARY_DIR}/CoolProp")
+ list (APPEND INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../externals/CoolProp.git")
+ list (APPEND INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../externals/CoolProp.git/include")
+ list (APPEND INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../externals/CoolProp.git/externals/msgpack-c/include")
+ # Handle different CoolProp versions
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../externals/CoolProp.git/externals/cppformat")
+ list (APPEND INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../externals/CoolProp.git/externals/cppformat")
+ endif()
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../externals/CoolProp.git/externals/fmtlib")
+ list (APPEND INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../externals/CoolProp.git/externals/fmtlib")
+ endif()
+endif()
+
+## We use CMake to handle the dependency since the primary VCS for
+## ExternalMedia still is SVN.
+#ExternalProject_Add(
+# CoolProp
+#
+# GIT_REPOSITORY "https://github.com/CoolProp/CoolProp.git"
+# GIT_TAG "master"
+#
+# #UPDATE_COMMAND ""
+# #PATCH_COMMAND ""
+#
+# SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/externals/CoolProp.git"
+# CMAKE_ARGS -DCOOLPROP_OBJECT_LIBRARY=ON -DCOOLPROP_SHARED_LIBRARY=OFF -DCOOLPROP_STATIC_LIBRARY=OFF
+#
+# TEST_COMMAND ""
+#)
+#
+#set(CoolProp_INCLUDE_DIRS "")
+#list (APPEND CoolProp_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/externals/CoolProp.git/include")
+#list (APPEND CoolProp_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/externals/CoolProp.git/externals/msgpack-c/include")
+##set(CoolProp_OBJECTS "${CMAKE_SHARED_LIBRARY_PREFIX}humblelogging${CMAKE_SHARED_LIBRARY_SUFFIX}")
+#set(CoolProp_OBJECTS $)
+#foreach (_dir ${CoolProp_INCLUDE_DIRS})
+# list (APPEND INCLUDE_DIRS ${_dir})
+#endforeach()
+
+
+#######################################
+# TARGET DEFINITIONS #
+#######################################
+list (APPEND INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/Sources")
+include_directories (${INCLUDE_DIRS})
+file (GLOB_RECURSE LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/Sources/*.cpp")
+
+if(NOT FLUIDPROP)
+ list(REMOVE_ITEM LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/Sources/FluidProp_IF.cpp")
+ list(REMOVE_ITEM LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/Sources/FluidProp_COM.cpp")
+ list(REMOVE_ITEM LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/Sources/fluidpropsolver.cpp")
+endif()
+
+if(COOLPROP)
+ list(APPEND LIB_SOURCES $)
+else()
+ list(REMOVE_ITEM LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/Sources/coolpropsolver.cpp")
+endif()
+
+# Add the target for ExternalMedia
+add_library(${LIBRARY_NAME} STATIC ${LIB_SOURCES})
+set_property(TARGET ${LIBRARY_NAME} PROPERTY VERSION ${APP_VERSION})
+target_compile_definitions(${LIBRARY_NAME} PRIVATE EXTERNALMEDIA_FLUIDPROP=$,1,0>)
+target_compile_definitions(${LIBRARY_NAME} PRIVATE EXTERNALMEDIA_COOLPROP=$,1,0>)
+target_compile_definitions(${LIBRARY_NAME} PRIVATE EXTERNALMEDIA_MODELICA_ERRORS=1) # Use 0 for a shared library and 1 for a static library
+#target_compile_definitions(${LIBRARY_NAME} PRIVATE EXTERNALMEDIA_LIBRARY_EXPORTS) # Use this for a shared library
+if(COOLPROP)
+add_dependencies(${LIBRARY_NAME} CoolProp)
+endif()
+
+if(WIN32)
+ if(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ set(MODELICA_PLATFORM "win64")
+ else()
+ set(MODELICA_PLATFORM "win32")
+ endif()
+elseif(APPLE)
+ if(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ set(MODELICA_PLATFORM "linux64")
+ else()
+ set(MODELICA_PLATFORM "linux32")
+ endif()
+elseif(UNIX)
+ if(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ set(MODELICA_PLATFORM "linux64")
+ else()
+ set(MODELICA_PLATFORM "linux32")
+ endif()
+else()
+ message(FATAL_ERROR "Could not determine the MODELICA_PLATFORM, aborting.")
+endif()
+
+if(MSVC) #CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+ if (MSVC_TOOLSET_VERSION EQUAL 80 )
+ set(MODELICA_COMPILER vs2005)
+ elseif(MSVC_TOOLSET_VERSION EQUAL 90 )
+ set(MODELICA_COMPILER vs2008)
+ elseif(MSVC_TOOLSET_VERSION EQUAL 100)
+ set(MODELICA_COMPILER vs2010)
+ elseif(MSVC_TOOLSET_VERSION EQUAL 110)
+ set(MODELICA_COMPILER vs2012)
+ elseif(MSVC_TOOLSET_VERSION EQUAL 120)
+ set(MODELICA_COMPILER vs2013)
+ elseif(MSVC_TOOLSET_VERSION EQUAL 140)
+ set(MODELICA_COMPILER vs2015)
+ elseif(MSVC_TOOLSET_VERSION EQUAL 141)
+ set(MODELICA_COMPILER vs2017)
+ elseif(MSVC_TOOLSET_VERSION EQUAL 142)
+ set(MODELICA_COMPILER vs2019)
+ else()
+ message(WARNING "\"${MSVC_TOOLSET_VERSION}\" is not explicitly supported. Please check you build carefully.")
+ endif()
+elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ string(REPLACE "." ";" _VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
+ list(GET _VERSION_LIST 0 _VERSION_MAJOR)
+ list(GET _VERSION_LIST 1 _VERSION_MINOR)
+ set(MODELICA_COMPILER gcc${_VERSION_MAJOR}${_VERSION_MINOR})
+elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ string(REPLACE "." ";" _VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
+ list(GET _VERSION_LIST 0 _VERSION_MAJOR)
+ list(GET _VERSION_LIST 1 _VERSION_MINOR)
+ set(MODELICA_COMPILER clang${_VERSION_MAJOR}${_VERSION_MINOR})
+elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
+ string(REPLACE "." ";" _VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
+ list(GET _VERSION_LIST 0 _VERSION_MAJOR)
+ list(GET _VERSION_LIST 1 _VERSION_MINOR)
+ set(MODELICA_COMPILER appleclang${_VERSION_MAJOR}${_VERSION_MINOR})
+else()
+ message(WARNING "\"${CMAKE_CXX_COMPILER_ID}\" is not explicitly supported. Please check you build carefully.")
+endif()
+
+if(MINGW)
+ if(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ set(MODELICA_PLATFORM "mingw64")
+ else()
+ set(MODELICA_PLATFORM "mingw32")
+ endif()
+ set(MODELICA_COMPILER "")
+ message(WARNING "Discarded compiler information since OpenModelica expect the mingw32/64 platform.")
+endif()
+
+set(MODELICA_INSTALL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../Modelica/ExternalMedia ${APP_VERSION}/Resources")
+
+message(STATUS "Installation path: ${MODELICA_INSTALL_PATH}/Library/${MODELICA_PLATFORM}/${MODELICA_COMPILER}")
+
+INSTALL(TARGETS "${LIBRARY_NAME}" DESTINATION "${MODELICA_INSTALL_PATH}/Library/${MODELICA_PLATFORM}/${MODELICA_COMPILER}")
+INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/Sources/${LIBRARY_HEADER}" DESTINATION "${MODELICA_INSTALL_PATH}/Include")
+
+
+#######################################
+# TEST DEFINITIONS #
+#######################################
+# Customise this part to use your own CPP files
+if (COOLPROP)
+ add_executable (main EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/Tests/coolprop_comparisons.cpp ${LIB_SOURCES})
+ add_dependencies (main CoolProp)
+endif()
diff --git a/Projects/CompilationHowTo.txt b/Projects/CompilationHowTo.txt
deleted file mode 100644
index 9c4ca0e5..00000000
--- a/Projects/CompilationHowTo.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-# For developers and Linux users
-
-This directory contains the C/C++ source files in the Sources directory
-and script files to build the library using different Modelica tools,
-operating systems, and C/C++ compilers.
-
-
-## BUILDING THE LIBRARY FOR DYMOLA USING MICROSOFT VISUAL STUDIO ON WINDOWS
-
-Run the BuildLib-Dymola-VS20XX.bat script corresponding to the version
-of Visual Studio that Dymola uses to compile the simulation executable.
-This can be done from the Windows console (cmd.exe), or just by
-double-clicking on the .bat file from the file explorer.
-
-The scripts build the static library, copies it twice to the Resources/Library
-directory of the Modelica library, once with a version- and tool-specific name,
-for archival on the SVN server, and once with the appropriate name ExternalMediaLib.lib,
-which is loaded by the Modelica tool. Note that this latter file is not stored
-as such on the SVN repo, because there are different versions of it depending
-the compiler used. Finally, it copies the externalmedia.h header file into the
-Resources/Include directory. In this way, the library can be used right away
-by loading the main package.mo file immediately after running the compile script.
-
-For library maintenance, it is suggested that the Visual Studio binary libraries
-are updated on the SVN server when major changes or bugfixes are applied to the
-source code, so that other users can benefit without the need of recompiling them
-
-
-## BUIDING THE LIBRARY FOR OPENMODELICA USING GCC ON WINDOWS
-
-- Get the OMDEV environment from the SVN repository:
- https://openmodelica.org/svn/OpenModelicaExternal/trunk/tools/windows/OMDev
- user: anonymous
- pass: none
-- Install OMDEV in the C:\OMDev path
-- Start C:\OMDev\tools\msys\msys.bat (You should get a command window pop up
- that looks like the emulation of a unix prompt - because it is)
-- $ mount d:/Path_to_your_ExternalMediaLibrary_working_copy /ExternalMediaLibrary
-- $ cd /ExternalMediaLibrary/Projects
-- $ BuildLib-OMC-gcc-windows.sh
-
-This will build the static gcc library and copy it and the externalmedia.h
-header files in the Resource directories of the Modelica packages, so it can
-be used right away by just loading the Modelica package in OMC
-
-
-## For Dymola users on Linux systems
-
-This procedure has not been tested with OpenModelica. Please report any errors
-in order to help us to improve the Linux support of ExternalMedia.
-
-Please compile the source code using the `makefile-linux` from the console:
-- Go to the `Projects`directory: `cd Projects`
-- Compile the files: `make -f makefile-linux header library`
-- Install the files: `make -f makefile-linux install`
-
-You can now load the library, by opening the package.mo file
\ No newline at end of file
diff --git a/Projects/Doxyfile b/Projects/Doxyfile
new file mode 100644
index 00000000..56f77a55
--- /dev/null
+++ b/Projects/Doxyfile
@@ -0,0 +1,368 @@
+# Doxyfile 1.8.11
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+DOXYFILE_ENCODING = UTF-8
+PROJECT_NAME = ExternalMedia
+PROJECT_NUMBER = 3.3.0
+PROJECT_BRIEF = "A framework for Modelica.Media-compatible fluid properties"
+PROJECT_LOGO =
+OUTPUT_DIRECTORY = Documentation
+CREATE_SUBDIRS = NO
+ALLOW_UNICODE_NAMES = NO
+OUTPUT_LANGUAGE = English
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = YES
+STRIP_FROM_PATH =
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = NO
+JAVADOC_AUTOBRIEF = NO
+QT_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+INHERIT_DOCS = YES
+SEPARATE_MEMBER_PAGES = NO
+TAB_SIZE = 4
+ALIASES =
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+OPTIMIZE_FOR_FORTRAN = NO
+OPTIMIZE_OUTPUT_VHDL = NO
+EXTENSION_MAPPING =
+MARKDOWN_SUPPORT = YES
+AUTOLINK_SUPPORT = YES
+BUILTIN_STL_SUPPORT = NO
+CPP_CLI_SUPPORT = NO
+SIP_SUPPORT = NO
+IDL_PROPERTY_SUPPORT = YES
+DISTRIBUTE_GROUP_DOC = NO
+GROUP_NESTED_COMPOUNDS = NO
+SUBGROUPING = YES
+INLINE_GROUPED_CLASSES = NO
+INLINE_SIMPLE_STRUCTS = NO
+TYPEDEF_HIDES_STRUCT = NO
+LOOKUP_CACHE_SIZE = 0
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = NO
+EXTRACT_PACKAGE = NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES = YES
+EXTRACT_LOCAL_METHODS = NO
+EXTRACT_ANON_NSPACES = NO
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+HIDE_COMPOUND_REFERENCE= NO
+SHOW_INCLUDE_FILES = YES
+SHOW_GROUPED_MEMB_INC = NO
+FORCE_LOCAL_INCLUDES = NO
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+SORT_BRIEF_DOCS = NO
+SORT_MEMBERS_CTORS_1ST = NO
+SORT_GROUP_NAMES = NO
+SORT_BY_SCOPE_NAME = NO
+STRICT_PROTO_MATCHING = NO
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_FILES = YES
+SHOW_NAMESPACES = YES
+FILE_VERSION_FILTER =
+LAYOUT_FILE =
+CITE_BIB_FILES =
+#---------------------------------------------------------------------------
+# Configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_NO_PARAMDOC = NO
+WARN_AS_ERROR = NO
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# Configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = Sources/ ../
+INPUT_ENCODING = UTF-8
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.idl \
+ *.ddl \
+ *.odl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.cs \
+ *.d \
+ *.php \
+ *.php4 \
+ *.php5 \
+ *.phtml \
+ *.inc \
+ *.m \
+ *.markdown \
+ *.md \
+ *.mm \
+ *.dox \
+ *.py \
+ *.pyw \
+ *.f90 \
+ *.f \
+ *.for \
+ *.tcl \
+ *.vhd \
+ *.vhdl \
+ *.ucf \
+ *.qsf \
+ *.as \
+ *.js
+RECURSIVE = NO
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXCLUDE_SYMBOLS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS = *
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+FILTER_SOURCE_PATTERNS =
+USE_MDFILE_AS_MAINPAGE = README.md
+#---------------------------------------------------------------------------
+# Configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION = NO
+REFERENCES_LINK_SOURCE = YES
+SOURCE_TOOLTIPS = YES
+USE_HTAGS = NO
+VERBATIM_HEADERS = YES
+#CLANG_ASSISTED_PARSING = NO
+#CLANG_OPTIONS =
+#---------------------------------------------------------------------------
+# Configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = YES
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_EXTRA_STYLESHEET =
+HTML_EXTRA_FILES =
+HTML_COLORSTYLE_HUE = 220
+HTML_COLORSTYLE_SAT = 100
+HTML_COLORSTYLE_GAMMA = 80
+HTML_TIMESTAMP = NO
+HTML_DYNAMIC_SECTIONS = NO
+HTML_INDEX_NUM_ENTRIES = 100
+GENERATE_DOCSET = NO
+DOCSET_FEEDNAME = "Doxygen generated docs"
+DOCSET_BUNDLE_ID = org.doxygen.Project
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+DOCSET_PUBLISHER_NAME = Publisher
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+CHM_INDEX_ENCODING =
+BINARY_TOC = NO
+TOC_EXPAND = NO
+GENERATE_QHP = NO
+QCH_FILE =
+QHP_NAMESPACE = org.doxygen.Project
+QHP_VIRTUAL_FOLDER = doc
+QHP_CUST_FILTER_NAME =
+QHP_CUST_FILTER_ATTRS =
+QHP_SECT_FILTER_ATTRS =
+QHG_LOCATION =
+GENERATE_ECLIPSEHELP = NO
+ECLIPSE_DOC_ID = org.doxygen.Project
+DISABLE_INDEX = NO
+GENERATE_TREEVIEW = NO
+ENUM_VALUES_PER_LINE = 4
+TREEVIEW_WIDTH = 250
+EXT_LINKS_IN_WINDOW = NO
+FORMULA_FONTSIZE = 10
+FORMULA_TRANSPARENT = YES
+USE_MATHJAX = NO
+MATHJAX_FORMAT = HTML-CSS
+MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
+MATHJAX_EXTENSIONS =
+MATHJAX_CODEFILE =
+SEARCHENGINE = YES
+SERVER_BASED_SEARCH = NO
+EXTERNAL_SEARCH = NO
+SEARCHENGINE_URL =
+SEARCHDATA_FILE = searchdata.xml
+EXTERNAL_SEARCH_ID =
+EXTRA_SEARCH_MAPPINGS =
+#---------------------------------------------------------------------------
+# Configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = YES
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4
+EXTRA_PACKAGES =
+LATEX_HEADER =
+LATEX_FOOTER =
+LATEX_EXTRA_STYLESHEET =
+LATEX_EXTRA_FILES =
+PDF_HYPERLINKS = YES
+USE_PDFLATEX = YES
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+LATEX_SOURCE_CODE = NO
+LATEX_BIB_STYLE = plain
+LATEX_TIMESTAMP = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+RTF_SOURCE_CODE = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_SUBDIR =
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+XML_OUTPUT = xml
+XML_PROGRAMLISTING = YES
+#---------------------------------------------------------------------------
+# Configuration options related to the DOCBOOK output
+#---------------------------------------------------------------------------
+GENERATE_DOCBOOK = NO
+DOCBOOK_OUTPUT = docbook
+DOCBOOK_PROGRAMLISTING = NO
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration options related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+EXTERNAL_PAGES = YES
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+DIA_PATH =
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+DOT_NUM_THREADS = 0
+DOT_FONTNAME = Helvetica
+DOT_FONTSIZE = 10
+DOT_FONTPATH =
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+GROUP_GRAPHS = YES
+UML_LOOK = NO
+UML_LIMIT_NUM_FIELDS = 10
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = NO
+CALLER_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DIRECTORY_GRAPH = YES
+DOT_IMAGE_FORMAT = png
+INTERACTIVE_SVG = NO
+DOT_PATH =
+DOTFILE_DIRS =
+MSCFILE_DIRS =
+DIAFILE_DIRS =
+PLANTUML_JAR_PATH =
+PLANTUML_INCLUDE_PATH =
+DOT_GRAPH_MAX_NODES = 50
+MAX_DOT_GRAPH_DEPTH = 0
+DOT_TRANSPARENT = NO
+DOT_MULTI_TARGETS = NO
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
diff --git a/Projects/RunTests/runtests.3.2.mos b/Projects/RunTests/runtests.3.2.mos
deleted file mode 100644
index 4399fd48..00000000
--- a/Projects/RunTests/runtests.3.2.mos
+++ /dev/null
@@ -1,51 +0,0 @@
-openModel("../../Modelica/ExternalMedia 3.2/package.mo")
-cd("../../Projects/RunTests/Results")
-simulateModel("ExternalMedia.Test.TestMedium.TestStatesSat", method="dassl", resultFile="TestMedium-TestStatesSat");
-simulateModel("ExternalMedia.Test.TestMedium.TestBasePropertiesExplicit", method="dassl", resultFile="TestMedium-TestBasePropertiesExplicit");
-simulateModel("ExternalMedia.Test.TestMedium.TestBasePropertiesImplicit", method="dassl", resultFile="TestMedium-TestBasePropertiesImplicit");
-simulateModel("ExternalMedia.Test.TestMedium.TestBasePropertiesDynamic", method="dassl", resultFile="TestMedium-TestBasePropertiesDynamic");
-
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestStates", method="dassl", resultFile="FluidProp-IF95-TestStates");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestStatesSat", method="dassl", resultFile="FluidProp-IF95-TestStatesSat");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-IF95-TestBasePropertiesExplicit");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-IF95-TestBasePropertiesImplicit");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestBasePropertiesDynamic", method="dassl", resultFile="FluidProp-IF95-TestBasePropertiesDynamic");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.CompareModelicaFluidProp_liquid", method="dassl", resultFile="FluidProp-IF95-CompareModelicaFluidProp_liquid");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.CompareModelicaFluidProp_twophase", method="dassl", resultFile="FluidProp-IF95-CompareModelicaFluidProp_twophase");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.CompareModelicaFluidProp_vapour", method="dassl", resultFile="FluidProp-IF95-CompareModelicaFluidProp_vapour");
-
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestStates", method="dassl", resultFile="FluidProp-IF97-TestStates");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestStatesSat", method="dassl", resultFile="FluidProp-IF97-TestStatesSat");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-IF97-TestBasePropertiesExplicit");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-IF97-TestBasePropertiesImplicit");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestBasePropertiesDynamic", method="dassl", resultFile="FluidProp-IF97-TestBasePropertiesDynamic");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.CompareModelicaFluidProp_liquid", method="dassl", resultFile="FluidProp-IF97-CompareModelicaFluidProp_liquid");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.CompareModelicaFluidProp_twophase", method="dassl", resultFile="FluidProp-IF97-CompareModelicaFluidProp_twophase");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.CompareModelicaFluidProp_vapour", method="dassl", resultFile="FluidProp-IF97-CompareModelicaFluidProp_vapour");
-
-// TPSI has convergence problems for slightly subcooled liquid, so these tests fail
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestStates", method="dassl", resultFile="FluidProp-TPSI-TestStates");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestStatesSat", method="dassl", resultFile="FluidProp-TPSI-TestStatesSat");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-TPSI-TestBasePropertiesExplicit");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-TPSI-TestBasePropertiesImplicit");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestBasePropertiesDynamic", method="dassl", resultFile="FluidProp-TPSI-TestBasePropertiesDynamic");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.CompareModelicaFluidProp_liquid", method="dassl", resultFile="FluidProp-TPSI-CompareModelicaFluidProp_liquid");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.CompareModelicaFluidProp_twophase", method="dassl", resultFile="FluidProp-TPSI-CompareModelicaFluidProp_twophase");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.CompareModelicaFluidProp_vapour", method="dassl", resultFile="FluidProp-TPSI-CompareModelicaFluidProp_vapour");
-
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestStatesSupercritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestStatesSupercritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestStatesTranscritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestStatesTranscritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestStatesSatSubcritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestStatesSatSubcritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-CO2StanMix-TestBasePropertiesExplicit");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-CO2StanMix-TestBasePropertiesImplicit");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesDynamic", method="dassl", stopTime = 80, resultFile="FluidProp-CO2StanMix-TestBasePropertiesDynamic");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesTranscritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestBasePropertiesTranscritical");
-
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestStatesSupercritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestStatesSupercritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestStatesTranscritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestStatesTranscritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestStatesSatSubcritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestStatesSatSubcritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-CO2RefProp-TestBasePropertiesExplicit");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-CO2RefProp-TestBasePropertiesImplicit");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesDynamic", method="dassl", stopTime = 80, resultFile="FluidProp-CO2RefProp-TestBasePropertiesDynamic");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesTranscritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestBasePropertiesTranscritical");
-
diff --git a/Projects/RunTests/runtests.3.2.1.mos b/Projects/RunTests/runtests.mos
similarity index 98%
rename from Projects/RunTests/runtests.3.2.1.mos
rename to Projects/RunTests/runtests.mos
index ce3eb200..5e08fb1e 100644
--- a/Projects/RunTests/runtests.3.2.1.mos
+++ b/Projects/RunTests/runtests.mos
@@ -1,51 +1,51 @@
-openModel("../../Modelica/ExternalMedia 3.2.1/package.mo")
-cd("../../Projects/RunTests/Results")
-simulateModel("ExternalMedia.Test.TestMedium.TestStatesSat", method="dassl", resultFile="TestMedium-TestStatesSat");
-simulateModel("ExternalMedia.Test.TestMedium.TestBasePropertiesExplicit", method="dassl", resultFile="TestMedium-TestBasePropertiesExplicit");
-simulateModel("ExternalMedia.Test.TestMedium.TestBasePropertiesImplicit", method="dassl", resultFile="TestMedium-TestBasePropertiesImplicit");
-simulateModel("ExternalMedia.Test.TestMedium.TestBasePropertiesDynamic", method="dassl", resultFile="TestMedium-TestBasePropertiesDynamic");
-
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestStates", method="dassl", resultFile="FluidProp-IF95-TestStates");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestStatesSat", method="dassl", resultFile="FluidProp-IF95-TestStatesSat");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-IF95-TestBasePropertiesExplicit");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-IF95-TestBasePropertiesImplicit");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestBasePropertiesDynamic", method="dassl", resultFile="FluidProp-IF95-TestBasePropertiesDynamic");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.CompareModelicaFluidProp_liquid", method="dassl", resultFile="FluidProp-IF95-CompareModelicaFluidProp_liquid");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.CompareModelicaFluidProp_twophase", method="dassl", resultFile="FluidProp-IF95-CompareModelicaFluidProp_twophase");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.CompareModelicaFluidProp_vapour", method="dassl", resultFile="FluidProp-IF95-CompareModelicaFluidProp_vapour");
-
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestStates", method="dassl", resultFile="FluidProp-IF97-TestStates");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestStatesSat", method="dassl", resultFile="FluidProp-IF97-TestStatesSat");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-IF97-TestBasePropertiesExplicit");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-IF97-TestBasePropertiesImplicit");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestBasePropertiesDynamic", method="dassl", resultFile="FluidProp-IF97-TestBasePropertiesDynamic");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.CompareModelicaFluidProp_liquid", method="dassl", resultFile="FluidProp-IF97-CompareModelicaFluidProp_liquid");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.CompareModelicaFluidProp_twophase", method="dassl", resultFile="FluidProp-IF97-CompareModelicaFluidProp_twophase");
-simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.CompareModelicaFluidProp_vapour", method="dassl", resultFile="FluidProp-IF97-CompareModelicaFluidProp_vapour");
-
-// TPSI has convergence problems for slightly subcooled liquid, so these tests fail
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestStates", method="dassl", resultFile="FluidProp-TPSI-TestStates");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestStatesSat", method="dassl", resultFile="FluidProp-TPSI-TestStatesSat");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-TPSI-TestBasePropertiesExplicit");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-TPSI-TestBasePropertiesImplicit");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestBasePropertiesDynamic", method="dassl", resultFile="FluidProp-TPSI-TestBasePropertiesDynamic");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.CompareModelicaFluidProp_liquid", method="dassl", resultFile="FluidProp-TPSI-CompareModelicaFluidProp_liquid");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.CompareModelicaFluidProp_twophase", method="dassl", resultFile="FluidProp-TPSI-CompareModelicaFluidProp_twophase");
-//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.CompareModelicaFluidProp_vapour", method="dassl", resultFile="FluidProp-TPSI-CompareModelicaFluidProp_vapour");
-
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestStatesSupercritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestStatesSupercritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestStatesTranscritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestStatesTranscritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestStatesSatSubcritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestStatesSatSubcritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-CO2StanMix-TestBasePropertiesExplicit");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-CO2StanMix-TestBasePropertiesImplicit");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesDynamic", method="dassl", stopTime = 80, resultFile="FluidProp-CO2StanMix-TestBasePropertiesDynamic");
-simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesTranscritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestBasePropertiesTranscritical");
-
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestStatesSupercritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestStatesSupercritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestStatesTranscritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestStatesTranscritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestStatesSatSubcritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestStatesSatSubcritical");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-CO2RefProp-TestBasePropertiesExplicit");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-CO2RefProp-TestBasePropertiesImplicit");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesDynamic", method="dassl", stopTime = 80, resultFile="FluidProp-CO2RefProp-TestBasePropertiesDynamic");
-simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesTranscritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestBasePropertiesTranscritical");
-
+openModel("../../Modelica/ExternalMedia 3.3.0/package.mo")
+cd("../../Projects/RunTests/Results")
+simulateModel("ExternalMedia.Test.TestMedium.TestStatesSat", method="dassl", resultFile="TestMedium-TestStatesSat");
+simulateModel("ExternalMedia.Test.TestMedium.TestBasePropertiesExplicit", method="dassl", resultFile="TestMedium-TestBasePropertiesExplicit");
+simulateModel("ExternalMedia.Test.TestMedium.TestBasePropertiesImplicit", method="dassl", resultFile="TestMedium-TestBasePropertiesImplicit");
+simulateModel("ExternalMedia.Test.TestMedium.TestBasePropertiesDynamic", method="dassl", resultFile="TestMedium-TestBasePropertiesDynamic");
+
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestStates", method="dassl", resultFile="FluidProp-IF95-TestStates");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestStatesSat", method="dassl", resultFile="FluidProp-IF95-TestStatesSat");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-IF95-TestBasePropertiesExplicit");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-IF95-TestBasePropertiesImplicit");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.TestBasePropertiesDynamic", method="dassl", resultFile="FluidProp-IF95-TestBasePropertiesDynamic");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.CompareModelicaFluidProp_liquid", method="dassl", resultFile="FluidProp-IF95-CompareModelicaFluidProp_liquid");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.CompareModelicaFluidProp_twophase", method="dassl", resultFile="FluidProp-IF95-CompareModelicaFluidProp_twophase");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF95.CompareModelicaFluidProp_vapour", method="dassl", resultFile="FluidProp-IF95-CompareModelicaFluidProp_vapour");
+
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestStates", method="dassl", resultFile="FluidProp-IF97-TestStates");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestStatesSat", method="dassl", resultFile="FluidProp-IF97-TestStatesSat");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-IF97-TestBasePropertiesExplicit");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-IF97-TestBasePropertiesImplicit");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.TestBasePropertiesDynamic", method="dassl", resultFile="FluidProp-IF97-TestBasePropertiesDynamic");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.CompareModelicaFluidProp_liquid", method="dassl", resultFile="FluidProp-IF97-CompareModelicaFluidProp_liquid");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.CompareModelicaFluidProp_twophase", method="dassl", resultFile="FluidProp-IF97-CompareModelicaFluidProp_twophase");
+simulateModel("ExternalMedia.Test.FluidProp.WaterIF97.CompareModelicaFluidProp_vapour", method="dassl", resultFile="FluidProp-IF97-CompareModelicaFluidProp_vapour");
+
+// TPSI has convergence problems for slightly subcooled liquid, so these tests fail
+//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestStates", method="dassl", resultFile="FluidProp-TPSI-TestStates");
+//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestStatesSat", method="dassl", resultFile="FluidProp-TPSI-TestStatesSat");
+//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-TPSI-TestBasePropertiesExplicit");
+//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-TPSI-TestBasePropertiesImplicit");
+//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.TestBasePropertiesDynamic", method="dassl", resultFile="FluidProp-TPSI-TestBasePropertiesDynamic");
+//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.CompareModelicaFluidProp_liquid", method="dassl", resultFile="FluidProp-TPSI-CompareModelicaFluidProp_liquid");
+//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.CompareModelicaFluidProp_twophase", method="dassl", resultFile="FluidProp-TPSI-CompareModelicaFluidProp_twophase");
+//simulateModel("ExternalMedia.Test.FluidProp.WaterTPSI.CompareModelicaFluidProp_vapour", method="dassl", resultFile="FluidProp-TPSI-CompareModelicaFluidProp_vapour");
+
+simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestStatesSupercritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestStatesSupercritical");
+simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestStatesTranscritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestStatesTranscritical");
+simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestStatesSatSubcritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestStatesSatSubcritical");
+simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-CO2StanMix-TestBasePropertiesExplicit");
+simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-CO2StanMix-TestBasePropertiesImplicit");
+simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesDynamic", method="dassl", stopTime = 80, resultFile="FluidProp-CO2StanMix-TestBasePropertiesDynamic");
+simulateModel("ExternalMedia.Test.FluidProp.CO2StanMix.TestBasePropertiesTranscritical", method="dassl", resultFile="FluidProp-CO2StanMix-TestBasePropertiesTranscritical");
+
+simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestStatesSupercritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestStatesSupercritical");
+simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestStatesTranscritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestStatesTranscritical");
+simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestStatesSatSubcritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestStatesSatSubcritical");
+simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesExplicit", method="dassl", resultFile="FluidProp-CO2RefProp-TestBasePropertiesExplicit");
+simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesImplicit", method="dassl", resultFile="FluidProp-CO2RefProp-TestBasePropertiesImplicit");
+simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesDynamic", method="dassl", stopTime = 80, resultFile="FluidProp-CO2RefProp-TestBasePropertiesDynamic");
+simulateModel("ExternalMedia.Test.FluidProp.CO2RefProp.TestBasePropertiesTranscritical", method="dassl", resultFile="FluidProp-CO2RefProp-TestBasePropertiesTranscritical");
+
diff --git a/Projects/Sources/Doxyfile b/Projects/Sources/Doxyfile
deleted file mode 100644
index a41a6717..00000000
--- a/Projects/Sources/Doxyfile
+++ /dev/null
@@ -1,225 +0,0 @@
-# Doxyfile 1.5.1-p1
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME = ExternalMedia
-PROJECT_NUMBER = 1.0
-OUTPUT_DIRECTORY = ..\..\Documentation
-CREATE_SUBDIRS = NO
-OUTPUT_LANGUAGE = English
-USE_WINDOWS_ENCODING = YES
-BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = YES
-ABBREVIATE_BRIEF =
-ALWAYS_DETAILED_SEC = NO
-INLINE_INHERITED_MEMB = NO
-FULL_PATH_NAMES = YES
-STRIP_FROM_PATH =
-STRIP_FROM_INC_PATH =
-SHORT_NAMES = NO
-JAVADOC_AUTOBRIEF = NO
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP = NO
-INHERIT_DOCS = YES
-SEPARATE_MEMBER_PAGES = NO
-TAB_SIZE = 8
-ALIASES =
-OPTIMIZE_OUTPUT_FOR_C = NO
-OPTIMIZE_OUTPUT_JAVA = NO
-BUILTIN_STL_SUPPORT = NO
-DISTRIBUTE_GROUP_DOC = NO
-SUBGROUPING = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL = NO
-EXTRACT_PRIVATE = NO
-EXTRACT_STATIC = NO
-EXTRACT_LOCAL_CLASSES = YES
-EXTRACT_LOCAL_METHODS = NO
-HIDE_UNDOC_MEMBERS = YES
-HIDE_UNDOC_CLASSES = YES
-HIDE_FRIEND_COMPOUNDS = NO
-HIDE_IN_BODY_DOCS = NO
-INTERNAL_DOCS = NO
-CASE_SENSE_NAMES = NO
-HIDE_SCOPE_NAMES = NO
-SHOW_INCLUDE_FILES = YES
-INLINE_INFO = YES
-SORT_MEMBER_DOCS = YES
-SORT_BRIEF_DOCS = NO
-SORT_BY_SCOPE_NAME = NO
-GENERATE_TODOLIST = YES
-GENERATE_TESTLIST = YES
-GENERATE_BUGLIST = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS =
-MAX_INITIALIZER_LINES = 30
-SHOW_USED_FILES = YES
-SHOW_DIRECTORIES = NO
-FILE_VERSION_FILTER =
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET = NO
-WARNINGS = YES
-WARN_IF_UNDOCUMENTED = YES
-WARN_IF_DOC_ERROR = YES
-WARN_NO_PARAMDOC = NO
-WARN_FORMAT = "$file:$line: $text"
-WARN_LOGFILE =
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT =
-FILE_PATTERNS =
-RECURSIVE = NO
-EXCLUDE =
-EXCLUDE_SYMLINKS = NO
-EXCLUDE_PATTERNS =
-EXAMPLE_PATH =
-EXAMPLE_PATTERNS =
-EXAMPLE_RECURSIVE = NO
-IMAGE_PATH =
-INPUT_FILTER =
-FILTER_PATTERNS =
-FILTER_SOURCE_FILES = NO
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER = NO
-INLINE_SOURCES = NO
-STRIP_CODE_COMMENTS = YES
-REFERENCED_BY_RELATION = NO
-REFERENCES_RELATION = NO
-REFERENCES_LINK_SOURCE = YES
-USE_HTAGS = NO
-VERBATIM_HEADERS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX = NO
-COLS_IN_ALPHA_INDEX = 5
-IGNORE_PREFIX =
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML = YES
-HTML_OUTPUT = html
-HTML_FILE_EXTENSION = .html
-HTML_HEADER =
-HTML_FOOTER =
-HTML_STYLESHEET =
-HTML_ALIGN_MEMBERS = YES
-GENERATE_HTMLHELP = NO
-CHM_FILE =
-HHC_LOCATION =
-GENERATE_CHI = NO
-BINARY_TOC = NO
-TOC_EXPAND = NO
-DISABLE_INDEX = NO
-ENUM_VALUES_PER_LINE = 4
-GENERATE_TREEVIEW = NO
-TREEVIEW_WIDTH = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX = YES
-LATEX_OUTPUT = latex
-LATEX_CMD_NAME = latex
-MAKEINDEX_CMD_NAME = makeindex
-COMPACT_LATEX = NO
-PAPER_TYPE = a4wide
-EXTRA_PACKAGES =
-LATEX_HEADER =
-PDF_HYPERLINKS = NO
-USE_PDFLATEX = NO
-LATEX_BATCHMODE = NO
-LATEX_HIDE_INDICES = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF = NO
-RTF_OUTPUT = rtf
-COMPACT_RTF = NO
-RTF_HYPERLINKS = NO
-RTF_STYLESHEET_FILE =
-RTF_EXTENSIONS_FILE =
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN = NO
-MAN_OUTPUT = man
-MAN_EXTENSION = .3
-MAN_LINKS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML = NO
-XML_OUTPUT = xml
-XML_SCHEMA =
-XML_DTD =
-XML_PROGRAMLISTING = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD = NO
-PERLMOD_LATEX = NO
-PERLMOD_PRETTY = YES
-PERLMOD_MAKEVAR_PREFIX =
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING = YES
-MACRO_EXPANSION = NO
-EXPAND_ONLY_PREDEF = NO
-SEARCH_INCLUDES = YES
-INCLUDE_PATH =
-INCLUDE_FILE_PATTERNS =
-PREDEFINED =
-EXPAND_AS_DEFINED =
-SKIP_FUNCTION_MACROS = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-TAGFILES =
-GENERATE_TAGFILE =
-ALLEXTERNALS = NO
-EXTERNAL_GROUPS = YES
-PERL_PATH = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS = YES
-HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = NO
-CLASS_GRAPH = YES
-COLLABORATION_GRAPH = YES
-GROUP_GRAPHS = YES
-UML_LOOK = NO
-TEMPLATE_RELATIONS = NO
-INCLUDE_GRAPH = YES
-INCLUDED_BY_GRAPH = YES
-CALL_GRAPH = NO
-CALLER_GRAPH = NO
-GRAPHICAL_HIERARCHY = YES
-DIRECTORY_GRAPH = YES
-DOT_IMAGE_FORMAT = png
-DOT_PATH =
-DOTFILE_DIRS =
-MAX_DOT_GRAPH_WIDTH = 1024
-MAX_DOT_GRAPH_HEIGHT = 1024
-MAX_DOT_GRAPH_DEPTH = 0
-DOT_TRANSPARENT = NO
-DOT_MULTI_TARGETS = NO
-GENERATE_LEGEND = YES
-DOT_CLEANUP = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-SEARCHENGINE = NO
diff --git a/Projects/Sources/FluidProp_IF.cpp b/Projects/Sources/FluidProp_IF.cpp
index f700f91c..0509f9ad 100644
--- a/Projects/Sources/FluidProp_IF.cpp
+++ b/Projects/Sources/FluidProp_IF.cpp
@@ -1,1147 +1,1147 @@
-//============================================================================//
-// //
-// FluidProp C++ interface //
-// ----------------------- //
-// //
-// The class defined in this file, TFluidProp, is as a wrapper class for //
-// the IFluidProp_COM interface. TFluidProp hides COM specific details //
-// like safe arrays (SAFEARRAY) and binary strings (BSTR) in IFluidProp_COM. //
-// In the TFluidProp class only standard C++ data types are used. This is //
-// the recommended way working with the FluidProp COM server in C++. //
-// //
-// July, 2004, for FluidProp 1 //
-// January, 2006, for FluidProp 2 //
-// April, 2007, for FluidProp 2.3 //
-// November, 2012, for FluidProp 2.5 //
-// //
-//============================================================================//
-
-#include
-#include "include.h"
-#include "FluidProp_IF.h"
-
-#if defined(__MINGW32__)
-#include
-#endif
-
-// Conversion of a binary string BSTR to a string.
-static inline string ConvertBSTRToString(BSTR BString)
-{
- char* tmp_string = _com_util::ConvertBSTRToString(BString);
- string retval = tmp_string;
- delete[] tmp_string;
- return retval;
-}
-// Conversion of a string to a binary string BSTR.
-static inline BSTR ConvertStringToBSTR(string &String)
-{
- return _com_util::ConvertStringToBSTR(String.c_str());
-}
-
-
-// {F30D147D-1F7C-4092-B481-ADE326A2ECD5}
-static const GUID CLSID_FluidProp =
-{ 0xF30D147DL, 0x1F7C, 0x4092,
-{ 0xB4, 0x81, 0xAD, 0xE3, 0x26, 0xA2, 0xEC, 0xD5 } };
-
-// {2430EE09-2C1E-4A86-AB62-CB67AEF6E484}
-static const IID IID_IFluidProp =
-{ 0x2430EE09L, 0x2C1E, 0x4A86,
-{ 0xAB, 0x62, 0xCB, 0x67, 0xAE, 0xF6, 0xE4, 0x84 } };
-
-
-TFluidProp::TFluidProp() : FluidProp_COM(NULL)
-{
- // Init COM
- CoInitialize(0);
-
- // Retrieve class factory interface pointer to our FluidProp COM object
- HRESULT hr = CoGetClassObject(CLSID_FluidProp, CLSCTX_INPROC_SERVER, 0, IID_IClassFactory, (void**) &ClassFactory);
-
- // Have class factory make the object for us - then release factory
- if (SUCCEEDED(hr)) {
- HRESULT hr2 = ClassFactory->CreateInstance(0, IID_IFluidProp, (void**) &FluidProp_COM);
- ClassFactory->Release();
- ClassFactory = 0;
- if (FAILED(hr2)) {
- if (hr2 == CLASS_E_NOTLICENSED)
- std::cout << "FluidProp license not valid." << std::endl;
- std::cout << "Failed to create FluidProp COM object" << std::endl;
- }
- }
-}
-
-TFluidProp::~TFluidProp()
-{
- // Free FluidProp object
- if (FluidProp_COM)
- FluidProp_COM->Release();
-
- // Unitialize COM
- CoUninitialize();
-}
-
-bool TFluidProp::IsValid()
-{
- return !!FluidProp_COM;
-}
-
-void TFluidProp::CreateObject( string ModelName, string* ErrorMsg)
-{
- BSTR BSTR_Model = ConvertStringToBSTR(ModelName);
- BSTR BSTR_Error;
-
- FluidProp_COM->CreateObject(BSTR_Model, &BSTR_Error);
- SysFreeString(BSTR_Model);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-}
-
-void TFluidProp::ReleaseObjects()
-{
- FluidProp_COM->ReleaseObjects();
-}
-
-void TFluidProp::SetFluid( string ModelName, int nComp, string* Comp, double* Conc, string* ErrorMsg)
-{
- // Convert model name to binary string
- BSTR BSTR_Model = ConvertStringToBSTR(ModelName);
-
- // Convert character array Comp via binary strings (BSTR) into a SafeArray
- SAFEARRAY FAR* sa_Comp = SafeArrayCreateVector(VT_BSTR, 1, nComp);
- for (long i = 1; i <= (long)nComp; i++) {
- BSTR BSTR_Comp = ConvertStringToBSTR(Comp[i-1]);
- SafeArrayPutElement(sa_Comp, &i, BSTR_Comp);
- SysFreeString(BSTR_Comp);
- }
-
- // Convert the double array Conc into a SafeArray
- SAFEARRAY FAR* sa_Conc = SafeArrayCreateVector(VT_R8, 1, nComp);
- for (long i = 1; i <= (long)nComp; i++)
- SafeArrayPutElement(sa_Conc, &i, &Conc[i-1]);
-
- // Now load the fluid parameters for the model selected.
- BSTR BSTR_Error;
- FluidProp_COM->SetFluid( BSTR_Model, nComp, &sa_Comp, &sa_Conc, &BSTR_Error);
- SysFreeString(BSTR_Model);
- SafeArrayDestroy(sa_Comp);
- SafeArrayDestroy(sa_Conc);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-}
-
-void TFluidProp::GetFluid( string* ModelName, int* nComp, string* Comp, double* Conc, bool CompInfo)
-{
- // When CompInfo is true, the components and their concentrations in the mixture are returned
- // instead of the mixture name.
-
- long long_nComp = *nComp;
-
- // Convert character array Comp via binary strings (BSTR) into a SafeArray
- // This needs to be done because in the COM interface Comp is an inout argument,
- // because for out arguments an assumed array size is not allowed...
- SAFEARRAY FAR* sa_Comp = SafeArrayCreateVector(VT_BSTR, 1, long_nComp);
- for (long i = 1; i <= long_nComp; i++) {
- BSTR BSTR_Comp = ConvertStringToBSTR(Comp[i-1]);
- SafeArrayPutElement(sa_Comp, &i, BSTR_Comp);
- SysFreeString(BSTR_Comp);
- }
-
- // Convert the double array Conc into a SafeArray
- // This needs to be done because in the COM interface Conc is an inout argument,
- // because for out arguments an assumed array size is not allowed...
- SAFEARRAY FAR* sa_Conc = SafeArrayCreateVector(VT_R8, 1, long_nComp);
- for (long i = 1; i <= long_nComp; i++)
- SafeArrayPutElement(sa_Conc, &i, &Conc[i-1]);
-
- // Now retrieve the fluid parameters set wit SetFluid
- string blank = string(" ");
- BSTR BSTR_Model = ConvertStringToBSTR(blank);
- if (CompInfo)
- long_nComp = -1;
- FluidProp_COM->GetFluid( BSTR_Model, &long_nComp, &sa_Comp, &sa_Conc);
-
- // Convert model name from binary string to string
- string TmpName = ConvertBSTRToString(BSTR_Model);
- SysFreeString(BSTR_Model);
- *ModelName = TmpName;
-
- // Convert from long to int
- *nComp = long_nComp;
-
- // Put the values in the string array Comp
- for (long i = 1; i <= long_nComp; i++) {
- BSTR BSTR_Comp;
- SafeArrayGetElement(sa_Comp, &i, &BSTR_Comp);
- Comp[i-1] = ConvertBSTRToString(BSTR_Comp);
- SysFreeString(BSTR_Comp);
- }
- SafeArrayDestroy(sa_Comp);
-
- // Put the values in the double array Conc
- for (long i = 1; i <= long_nComp; i++)
- SafeArrayGetElement(sa_Conc, &i, &Conc[i-1]);
- SafeArrayDestroy(sa_Conc);
-}
-
-void TFluidProp::GetFluidNames( string LongShort, string ModelName, int* nFluids,
- string* FluidNames, string* ErrorMsg)
-{
- long long_nFluids;
-
- // Get available fluids
- BSTR BSTR_Model = ConvertStringToBSTR(ModelName);
- BSTR BSTR_LongShort = ConvertStringToBSTR(LongShort);
- BSTR BSTR_Error;
-
- // Convert character array FluidNames via binary strings (BSTR) into a SafeArray
- // This needs to be done because in the COM interface FluidNames is an inout argument,
- // because Visual Basic is not able to deal out arrays...
- SAFEARRAY* sa_FluidNames = SafeArrayCreateVector(VT_BSTR, 1, 250);
-
- FluidProp_COM->GetFluidNames(BSTR_LongShort, BSTR_Model, &long_nFluids, &sa_FluidNames, &BSTR_Error);
- SysFreeString(BSTR_Model);
- SysFreeString(BSTR_LongShort);
-
- // Retrieve array with components from SafeArray
- for (long i = 1; i <= long_nFluids; i++) {
- BSTR BSTR_Fluid;
- SafeArrayGetElement(sa_FluidNames, &i, &BSTR_Fluid);
- FluidNames[i-1] = ConvertBSTRToString(BSTR_Fluid);
- SysFreeString(BSTR_Fluid);
- }
- SafeArrayDestroy(sa_FluidNames);
- *nFluids = long_nFluids;
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-}
-
-void TFluidProp::GetCompSet( string ModelName, int* nComps, string* CompSet, string* ErrorMsg)
-{
- long long_nComps;
-
- // Get available fluids
- BSTR BSTR_Model = ConvertStringToBSTR(ModelName);
- BSTR BSTR_Error;
-
- // Convert character array CompSet via binary strings (BSTR) into a SafeArray
- // This needs to be done because in the COM interface CompSet is an inout argument,
- // because Visual Basic is not able to deal out arrays...
- SAFEARRAY* sa_CompSet = SafeArrayCreateVector(VT_BSTR, 1, 250);
-
- FluidProp_COM->GetCompSet( BSTR_Model, &long_nComps, &sa_CompSet, &BSTR_Error);
- SysFreeString(BSTR_Model);
-
- // Retrieve array with components from SafeArray
- for (long i = 1; i <= long_nComps; i++) {
- BSTR BSTR_Comp;
- SafeArrayGetElement(sa_CompSet, &i, &BSTR_Comp);
- CompSet[i-1] = ConvertBSTRToString(BSTR_Comp);
- SysFreeString(BSTR_Comp);
- }
- SafeArrayDestroy(sa_CompSet);
- *nComps = long_nComps;
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-}
-
-double TFluidProp::Pressure( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Pressure( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Temperature( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Temperature( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::SpecVolume( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->SpecVolume( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Density( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Density( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Enthalpy( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Enthalpy( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Entropy( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Entropy( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::IntEnergy( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->IntEnergy( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::VaporQual( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->VaporQual( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double* TFluidProp::LiquidCmp( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double* Output = new double[20];
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Convert the double array Conc into a SafeArray
- SAFEARRAY* sa_Output = SafeArrayCreateVector(VT_R8, 1, 20);
-
- FluidProp_COM->LiquidCmp( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Retrieve array with concentrations from SafeArray
- for (long i = 1; i <= 20; i++)
- SafeArrayGetElement(sa_Output, &i, &Output[i-1]);
- SafeArrayDestroy(sa_Output);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double* TFluidProp::VaporCmp( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double* Output = new double[20];
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Convert the double array Conc into a SafeArray
- SAFEARRAY* sa_Output = SafeArrayCreateVector(VT_R8, 1, 20);
-
- FluidProp_COM->VaporCmp( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Retrieve array with concentrations from SafeArray
- for (long i = 1; i <= 20; i++)
- SafeArrayGetElement(sa_Output, &i, &Output[i-1]);
- SafeArrayDestroy(sa_Output);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::HeatCapV( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->HeatCapV( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::HeatCapP( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->HeatCapP( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::SoundSpeed( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->SoundSpeed( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Alpha( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Alpha( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Beta( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Beta( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Chi( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Chi( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Fi( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Fi( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Ksi( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Ksi( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Psi( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Psi( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Zeta( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Zeta( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Theta( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Theta( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Kappa( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Kappa( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Gamma( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Gamma( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Viscosity( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Viscosity( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::ThermCond( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->ThermCond( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-void TFluidProp::AllProps( string InputSpec, double Input1, double Input2, double& P, double& T,
- double& v, double& d, double& h, double& s, double& u, double& q,
- double* x, double* y, double& cv, double& cp, double& c, double& alpha,
- double& beta, double& chi, double& fi, double& ksi, double& psi,
- double& zeta, double& theta, double& kappa, double& gamma, double& eta,
- double& lambda, string* ErrorMsg)
-{
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Convert double arrays with liquid and vapor phase compositions x and y into SafeArrays
- SAFEARRAY *sa_x = SafeArrayCreateVector(VT_R8, 1, 20);
- SAFEARRAY *sa_y = SafeArrayCreateVector(VT_R8, 1, 20);
-
- FluidProp_COM->AllProps( BSTR_InputSpec, Input1, Input2, &P, &T, &v, &d, &h, &s, &u, &q, &sa_x,
- &sa_y, &cv, &cp, &c, &alpha, &beta, &chi, &fi, &ksi, &psi, &zeta,
- &theta, &kappa, &gamma, &eta, &lambda, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Retrieve array with liquid and vapor phase compositions from SafeArrays
- for (long i = 1; i <= 20; i++)
- SafeArrayGetElement(sa_x, &i, &x[i-1]);
- SafeArrayDestroy(sa_x);
-
- for (long i = 1; i <= 20; i++)
- SafeArrayGetElement(sa_y, &i, &y[i-1]);
- SafeArrayDestroy(sa_y);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-}
-
-void TFluidProp::AllPropsSat( string InputSpec, double Input1, double Input2, double& P, double& T,
- double& v, double& d, double& h, double& s, double& u, double& q,
- double* x, double* y, double& cv, double& cp, double& c, double& alpha,
- double& beta, double& chi, double& fi, double& ksi, double& psi,
- double& zeta, double& theta, double& kappa, double& gamma, double& eta,
- double& lambda, double& d_liq, double& d_vap, double& h_liq, double& h_vap,
- double& T_sat, double& dd_liq_dP, double& dd_vap_dP, double& dh_liq_dP,
- double& dh_vap_dP, double& dT_sat_dP, string* ErrorMsg)
-{
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Convert double arrays with liquid and vapor phase compositions x and y into SafeArrays
- SAFEARRAY *sa_x = SafeArrayCreateVector(VT_R8, 1, 20);
- SAFEARRAY *sa_y = SafeArrayCreateVector(VT_R8, 1, 20);
-
- FluidProp_COM->AllPropsSat( BSTR_InputSpec, Input1, Input2, &P, &T, &v, &d, &h, &s, &u, &q, &sa_x,
- &sa_y, &cv, &cp, &c, &alpha, &beta, &chi, &fi, &ksi, &psi, &zeta,
- &theta, &kappa, &gamma, &eta, &lambda, &d_liq, &d_vap, &h_liq, &h_vap,
- &T_sat, &dd_liq_dP, &dd_vap_dP, &dh_liq_dP, &dh_vap_dP, &dT_sat_dP,
- &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Retrieve array with liquid and vapor phase compositions from SafeArrays
- for (long i = 1; i <= 20; i++)
- SafeArrayGetElement(sa_x, &i, &x[i-1]);
- SafeArrayDestroy(sa_x);
-
- for (long i = 1; i <= 20; i++)
- SafeArrayGetElement(sa_y, &i, &y[i-1]);
- SafeArrayDestroy(sa_y);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-}
-
-
-double TFluidProp::Solve( string FuncSpec, double FuncVal, string InputSpec, long Target,
- double FixedVal, double MinVal, double MaxVal, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_FuncSpec = ConvertStringToBSTR(FuncSpec);
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->Solve( BSTR_FuncSpec, FuncVal, BSTR_InputSpec, Target, FixedVal, MinVal,
- MaxVal, &Output, &BSTR_Error);
- SysFreeString(BSTR_FuncSpec);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Mmol( string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_Error;
-
- FluidProp_COM->Mmol( &Output, &BSTR_Error);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Tcrit( string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_Error;
-
- FluidProp_COM->Tcrit( &Output, &BSTR_Error);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Pcrit( string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_Error;
-
- FluidProp_COM->Pcrit( &Output, &BSTR_Error);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Tmin( string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_Error;
-
- FluidProp_COM->Tmin( &Output, &BSTR_Error);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::Tmax( string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_Error;
-
- FluidProp_COM->Tmax( &Output, &BSTR_Error);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-void TFluidProp::AllInfo( double& Mmol, double& Tcrit, double& Pcrit, double& Tmin, double& Tmax,
- string* ErrorMsg)
-{
- BSTR BSTR_Error;
-
- FluidProp_COM->AllInfo( &Mmol, &Tcrit, &Pcrit, &Tmin, &Tmax, &BSTR_Error);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-}
-
-void TFluidProp::SetUnits( string UnitSet, string MassOrMole, string Properties, string Units,
- string* ErrorMsg)
-{
- BSTR BSTR_Error;
- BSTR BSTR_UnitSet = ConvertStringToBSTR(UnitSet);
- BSTR BSTR_MassOrMole = ConvertStringToBSTR(MassOrMole);
- BSTR BSTR_Properties = ConvertStringToBSTR(Properties);
- BSTR BSTR_Units = ConvertStringToBSTR(Units);
-
- FluidProp_COM->SetUnits( BSTR_UnitSet, BSTR_MassOrMole, BSTR_Properties, BSTR_Units, &BSTR_Error);
- SysFreeString(BSTR_UnitSet);
- SysFreeString(BSTR_MassOrMole);
- SysFreeString(BSTR_Properties);
- SysFreeString(BSTR_Units);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-}
-
-void TFluidProp::SetRefState( double T_ref, double P_ref, string* ErrorMsg)
-{
- BSTR BSTR_Error;
-
- FluidProp_COM->SetRefState( T_ref, P_ref, &BSTR_Error);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-}
-
-void TFluidProp::GetVersion(string ModelName, int* version)
-{
- // Convert model name to binary string
- BSTR BSTR_Model = ConvertStringToBSTR(ModelName);
-
- // Now get the version for the model selected
- SAFEARRAY* sa_version;
- FluidProp_COM->GetVersion(BSTR_Model, &sa_version);
- SysFreeString(BSTR_Model);
-
- for (long i = 1; i <= 4; i++) {
- SafeArrayGetElement(sa_version, &i, &version[i-1]);
- }
- SafeArrayDestroyData(sa_version);
- SafeArrayDestroyDescriptor(sa_version);
-}
-
-double* TFluidProp::FugaCoef( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double* Output = new double[20];
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Convert the double array Conc into a SafeArray
- SAFEARRAYBOUND sa_bounds_Output[1];
- sa_bounds_Output[0].lLbound = 0;
- sa_bounds_Output[0].cElements = 20;
- SAFEARRAY* sa_Output;
- sa_Output = SafeArrayCreate(VT_R8, 1, sa_bounds_Output);
-
- FluidProp_COM->FugaCoef( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Retrieve array with concentrations from SafeArray
- for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++)
- SafeArrayGetElement(sa_Output, &i, &Output[i]);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::SurfTens( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->SurfTens( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double TFluidProp::GibbsEnergy( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double Output;
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- FluidProp_COM->GibbsEnergy( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-void TFluidProp::CapeOpenDeriv( string InputSpec, double Input1, double Input2, double* v, double* h,
- double* s, double* G, double* lnphi, string* ErrorMsg)
-{
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Create safe arrays for double arrays v[2n+2], h[2n+2], s[2n+2], G[2n+2] and lnphi[n,2n+2], where n_max = 20.
- SAFEARRAYBOUND sa_bnd_vhsG[1];
- sa_bnd_vhsG[0].lLbound = 0;
- sa_bnd_vhsG[0].cElements = 100;
- SAFEARRAY *sa_v, *sa_h, *sa_s, *sa_G;
- sa_v = SafeArrayCreate(VT_R8, 1, sa_bnd_vhsG);
- sa_h = SafeArrayCreate(VT_R8, 1, sa_bnd_vhsG);
- sa_s = SafeArrayCreate(VT_R8, 1, sa_bnd_vhsG);
- sa_G = SafeArrayCreate(VT_R8, 1, sa_bnd_vhsG);
-
- SAFEARRAYBOUND sa_bnd_lnphi[2];
- sa_bnd_lnphi[0].lLbound = 0;
- sa_bnd_lnphi[0].cElements = 20;
- sa_bnd_lnphi[1].lLbound = 0;
- sa_bnd_lnphi[1].cElements = 100;
- SAFEARRAY *sa_lnphi;
- sa_lnphi = SafeArrayCreate(VT_R8, 2, sa_bnd_lnphi);
-
- FluidProp_COM->CapeOpenDeriv(BSTR_InputSpec, Input1, Input2, &sa_v, &sa_h, &sa_s, &sa_G, &sa_lnphi, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Put the values from safearray's in the double array's v, h, s, and G
- for (long i = 0; i < (signed)sa_bnd_vhsG[0].cElements; i++) {
- SafeArrayGetElement(sa_v, &i, &v[i]);
- SafeArrayGetElement(sa_h, &i, &h[i]);
- SafeArrayGetElement(sa_s, &i, &s[i]);
- SafeArrayGetElement(sa_G, &i, &G[i]);
- }
-
- // Put the values from safearray's sa_lnphi into double array lnphi
- for (long i = 0; i < (signed)sa_bnd_lnphi[1].cElements; i++) {
- for (long j = 0; j < (signed)sa_bnd_lnphi[0].cElements; i++) {
- long idx_bnd[2];
- idx_bnd[1] = i;
- idx_bnd[0] = j;
- SafeArrayGetElement(sa_lnphi, &idx_bnd[0], &lnphi[i*20+j]);
- }
- }
-
- // Destroy the SafeArrays
- SafeArrayDestroy(sa_v);
- SafeArrayDestroy(sa_h);
- SafeArrayDestroy(sa_s);
- SafeArrayDestroy(sa_G);
- SafeArrayDestroy(sa_lnphi);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-}
-
-
-double* TFluidProp::SpecVolume_Deriv( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double* Output = new double[42];
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Convert the double array Conc into a SafeArray
- SAFEARRAYBOUND sa_bounds_Output[1];
- sa_bounds_Output[0].lLbound = 0;
- sa_bounds_Output[0].cElements = 42;
- SAFEARRAY* sa_Output;
- sa_Output = SafeArrayCreate(VT_R8, 1, sa_bounds_Output);
-
- FluidProp_COM->SpecVolume_Deriv( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Retrieve array with concentrations from SafeArray
- for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++)
- SafeArrayGetElement(sa_Output, &i, &Output[i]);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double* TFluidProp::Enthalpy_Deriv( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double* Output = new double[42];
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Convert the double array Conc into a SafeArray
- SAFEARRAYBOUND sa_bounds_Output[1];
- sa_bounds_Output[0].lLbound = 0;
- sa_bounds_Output[0].cElements = 42;
- SAFEARRAY* sa_Output;
- sa_Output = SafeArrayCreate(VT_R8, 1, sa_bounds_Output);
-
- FluidProp_COM->Enthalpy_Deriv( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Retrieve array with concentrations from SafeArray
- for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++)
- SafeArrayGetElement(sa_Output, &i, &Output[i]);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double* TFluidProp::Entropy_Deriv( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double* Output = new double[42];
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Convert the double array Conc into a SafeArray
- SAFEARRAYBOUND sa_bounds_Output[1];
- sa_bounds_Output[0].lLbound = 0;
- sa_bounds_Output[0].cElements = 42;
- SAFEARRAY* sa_Output;
- sa_Output = SafeArrayCreate(VT_R8, 1, sa_bounds_Output);
-
- FluidProp_COM->Entropy_Deriv( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Retrieve array with concentrations from SafeArray
- for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++)
- SafeArrayGetElement(sa_Output, &i, &Output[i]);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double* TFluidProp::GibbsEnergy_Deriv( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double* Output = new double[42];
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Convert the double array Conc into a SafeArray
- SAFEARRAYBOUND sa_bounds_Output[1];
- sa_bounds_Output[0].lLbound = 0;
- sa_bounds_Output[0].cElements = 42;
- SAFEARRAY* sa_Output;
- sa_Output = SafeArrayCreate(VT_R8, 1, sa_bounds_Output);
-
- FluidProp_COM->GibbsEnergy_Deriv( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Retrieve array with concentrations from SafeArray
- for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++)
- SafeArrayGetElement(sa_Output, &i, &Output[i]);
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-
-double* TFluidProp::FugaCoef_Deriv( string InputSpec, double Input1, double Input2, string* ErrorMsg)
-{
- double* Output = new double[20*42];
-
- BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
- BSTR BSTR_Error;
-
- // Convert the double array Conc into a SafeArray
- SAFEARRAYBOUND sa_bounds_Output[2];
- sa_bounds_Output[0].lLbound = 0;
- sa_bounds_Output[0].cElements = 20;
- sa_bounds_Output[1].lLbound = 0;
- sa_bounds_Output[1].cElements = 42;
- SAFEARRAY* sa_Output;
- sa_Output = SafeArrayCreate(VT_R8, 2, sa_bounds_Output);
-
- FluidProp_COM->FugaCoef_Deriv( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
- SysFreeString(BSTR_InputSpec);
-
- // Retrieve array with concentrations from SafeArray
- for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++) {
- for (long j = 0; j < (signed)sa_bounds_Output[1].cElements; j++) {
- long idx[2] = {i,j};
- double f;
- SafeArrayGetElement(sa_Output, idx, (void*)&f);
- // Storage in Output
- // 1) first 20 elements : derivatives wrt T (dlnphi_1/dT, dlnphi_2/dT, ... dlnphi_20/dT)
- // 2) second 20 elements : derivatives wrt P (dlnphi_1/dP, dlnphi_2/dP, ... dlnphi_20/dP)
- // 3) next 20*20 elements: derivatives wrt x (dlnphi_1/dx_1, dlnphi_2/dx_1, ... dlnphi_20/dx_1, dlnphi_1/dx_2, etc.)
- // 4) next 20*20 elements: derivatives wrt n (dlnphi_1/dn_1, dlnphi_2/dn_1, ... dlnphi_20/dn_1, dlnphi_1/dn_2, etc.)
- Output[i+j*20] = f;
- }
- }
-
- *ErrorMsg = ConvertBSTRToString(BSTR_Error);
- SysFreeString(BSTR_Error);
-
- return Output;
-}
-//==================================================================================== EOF ===//
+//============================================================================//
+// //
+// FluidProp C++ interface //
+// ----------------------- //
+// //
+// The class defined in this file, TFluidProp, is as a wrapper class for //
+// the IFluidProp_COM interface. TFluidProp hides COM specific details //
+// like safe arrays (SAFEARRAY) and binary strings (BSTR) in IFluidProp_COM. //
+// In the TFluidProp class only standard C++ data types are used. This is //
+// the recommended way working with the FluidProp COM server in C++. //
+// //
+// July, 2004, for FluidProp 1 //
+// January, 2006, for FluidProp 2 //
+// April, 2007, for FluidProp 2.3 //
+// November, 2012, for FluidProp 2.5 //
+// //
+//============================================================================//
+
+#include
+#include "include.h"
+#include "FluidProp_IF.h"
+
+#if defined(__MINGW32__)
+#include
+#endif
+
+// Conversion of a binary string BSTR to a string.
+static inline string ConvertBSTRToString(BSTR BString)
+{
+ char* tmp_string = _com_util::ConvertBSTRToString(BString);
+ string retval = tmp_string;
+ delete[] tmp_string;
+ return retval;
+}
+// Conversion of a string to a binary string BSTR.
+static inline BSTR ConvertStringToBSTR(string &String)
+{
+ return _com_util::ConvertStringToBSTR(String.c_str());
+}
+
+
+// {F30D147D-1F7C-4092-B481-ADE326A2ECD5}
+static const GUID CLSID_FluidProp =
+{ 0xF30D147DL, 0x1F7C, 0x4092,
+{ 0xB4, 0x81, 0xAD, 0xE3, 0x26, 0xA2, 0xEC, 0xD5 } };
+
+// {2430EE09-2C1E-4A86-AB62-CB67AEF6E484}
+static const IID IID_IFluidProp =
+{ 0x2430EE09L, 0x2C1E, 0x4A86,
+{ 0xAB, 0x62, 0xCB, 0x67, 0xAE, 0xF6, 0xE4, 0x84 } };
+
+
+TFluidProp::TFluidProp() : FluidProp_COM(NULL)
+{
+ // Init COM
+ CoInitialize(0);
+
+ // Retrieve class factory interface pointer to our FluidProp COM object
+ HRESULT hr = CoGetClassObject(CLSID_FluidProp, CLSCTX_INPROC_SERVER, 0, IID_IClassFactory, (void**) &ClassFactory);
+
+ // Have class factory make the object for us - then release factory
+ if (SUCCEEDED(hr)) {
+ HRESULT hr2 = ClassFactory->CreateInstance(0, IID_IFluidProp, (void**) &FluidProp_COM);
+ ClassFactory->Release();
+ ClassFactory = 0;
+ if (FAILED(hr2)) {
+ if (hr2 == CLASS_E_NOTLICENSED)
+ std::cout << "FluidProp license not valid." << std::endl;
+ std::cout << "Failed to create FluidProp COM object" << std::endl;
+ }
+ }
+}
+
+TFluidProp::~TFluidProp()
+{
+ // Free FluidProp object
+ if (FluidProp_COM)
+ FluidProp_COM->Release();
+
+ // Unitialize COM
+ CoUninitialize();
+}
+
+bool TFluidProp::IsValid()
+{
+ return !!FluidProp_COM;
+}
+
+void TFluidProp::CreateObject( string ModelName, string* ErrorMsg)
+{
+ BSTR BSTR_Model = ConvertStringToBSTR(ModelName);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->CreateObject(BSTR_Model, &BSTR_Error);
+ SysFreeString(BSTR_Model);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+}
+
+void TFluidProp::ReleaseObjects()
+{
+ FluidProp_COM->ReleaseObjects();
+}
+
+void TFluidProp::SetFluid( string ModelName, int nComp, string* Comp, double* Conc, string* ErrorMsg)
+{
+ // Convert model name to binary string
+ BSTR BSTR_Model = ConvertStringToBSTR(ModelName);
+
+ // Convert character array Comp via binary strings (BSTR) into a SafeArray
+ SAFEARRAY FAR* sa_Comp = SafeArrayCreateVector(VT_BSTR, 1, nComp);
+ for (long i = 1; i <= (long)nComp; i++) {
+ BSTR BSTR_Comp = ConvertStringToBSTR(Comp[i-1]);
+ SafeArrayPutElement(sa_Comp, &i, BSTR_Comp);
+ SysFreeString(BSTR_Comp);
+ }
+
+ // Convert the double array Conc into a SafeArray
+ SAFEARRAY FAR* sa_Conc = SafeArrayCreateVector(VT_R8, 1, nComp);
+ for (long i = 1; i <= (long)nComp; i++)
+ SafeArrayPutElement(sa_Conc, &i, &Conc[i-1]);
+
+ // Now load the fluid parameters for the model selected.
+ BSTR BSTR_Error;
+ FluidProp_COM->SetFluid( BSTR_Model, nComp, &sa_Comp, &sa_Conc, &BSTR_Error);
+ SysFreeString(BSTR_Model);
+ SafeArrayDestroy(sa_Comp);
+ SafeArrayDestroy(sa_Conc);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+}
+
+void TFluidProp::GetFluid( string* ModelName, int* nComp, string* Comp, double* Conc, bool CompInfo)
+{
+ // When CompInfo is true, the components and their concentrations in the mixture are returned
+ // instead of the mixture name.
+
+ long long_nComp = *nComp;
+
+ // Convert character array Comp via binary strings (BSTR) into a SafeArray
+ // This needs to be done because in the COM interface Comp is an inout argument,
+ // because for out arguments an assumed array size is not allowed...
+ SAFEARRAY FAR* sa_Comp = SafeArrayCreateVector(VT_BSTR, 1, long_nComp);
+ for (long i = 1; i <= long_nComp; i++) {
+ BSTR BSTR_Comp = ConvertStringToBSTR(Comp[i-1]);
+ SafeArrayPutElement(sa_Comp, &i, BSTR_Comp);
+ SysFreeString(BSTR_Comp);
+ }
+
+ // Convert the double array Conc into a SafeArray
+ // This needs to be done because in the COM interface Conc is an inout argument,
+ // because for out arguments an assumed array size is not allowed...
+ SAFEARRAY FAR* sa_Conc = SafeArrayCreateVector(VT_R8, 1, long_nComp);
+ for (long i = 1; i <= long_nComp; i++)
+ SafeArrayPutElement(sa_Conc, &i, &Conc[i-1]);
+
+ // Now retrieve the fluid parameters set wit SetFluid
+ string blank = string(" ");
+ BSTR BSTR_Model = ConvertStringToBSTR(blank);
+ if (CompInfo)
+ long_nComp = -1;
+ FluidProp_COM->GetFluid( BSTR_Model, &long_nComp, &sa_Comp, &sa_Conc);
+
+ // Convert model name from binary string to string
+ string TmpName = ConvertBSTRToString(BSTR_Model);
+ SysFreeString(BSTR_Model);
+ *ModelName = TmpName;
+
+ // Convert from long to int
+ *nComp = long_nComp;
+
+ // Put the values in the string array Comp
+ for (long i = 1; i <= long_nComp; i++) {
+ BSTR BSTR_Comp;
+ SafeArrayGetElement(sa_Comp, &i, &BSTR_Comp);
+ Comp[i-1] = ConvertBSTRToString(BSTR_Comp);
+ SysFreeString(BSTR_Comp);
+ }
+ SafeArrayDestroy(sa_Comp);
+
+ // Put the values in the double array Conc
+ for (long i = 1; i <= long_nComp; i++)
+ SafeArrayGetElement(sa_Conc, &i, &Conc[i-1]);
+ SafeArrayDestroy(sa_Conc);
+}
+
+void TFluidProp::GetFluidNames( string LongShort, string ModelName, int* nFluids,
+ string* FluidNames, string* ErrorMsg)
+{
+ long long_nFluids;
+
+ // Get available fluids
+ BSTR BSTR_Model = ConvertStringToBSTR(ModelName);
+ BSTR BSTR_LongShort = ConvertStringToBSTR(LongShort);
+ BSTR BSTR_Error;
+
+ // Convert character array FluidNames via binary strings (BSTR) into a SafeArray
+ // This needs to be done because in the COM interface FluidNames is an inout argument,
+ // because Visual Basic is not able to deal out arrays...
+ SAFEARRAY* sa_FluidNames = SafeArrayCreateVector(VT_BSTR, 1, 250);
+
+ FluidProp_COM->GetFluidNames(BSTR_LongShort, BSTR_Model, &long_nFluids, &sa_FluidNames, &BSTR_Error);
+ SysFreeString(BSTR_Model);
+ SysFreeString(BSTR_LongShort);
+
+ // Retrieve array with components from SafeArray
+ for (long i = 1; i <= long_nFluids; i++) {
+ BSTR BSTR_Fluid;
+ SafeArrayGetElement(sa_FluidNames, &i, &BSTR_Fluid);
+ FluidNames[i-1] = ConvertBSTRToString(BSTR_Fluid);
+ SysFreeString(BSTR_Fluid);
+ }
+ SafeArrayDestroy(sa_FluidNames);
+ *nFluids = long_nFluids;
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+}
+
+void TFluidProp::GetCompSet( string ModelName, int* nComps, string* CompSet, string* ErrorMsg)
+{
+ long long_nComps;
+
+ // Get available fluids
+ BSTR BSTR_Model = ConvertStringToBSTR(ModelName);
+ BSTR BSTR_Error;
+
+ // Convert character array CompSet via binary strings (BSTR) into a SafeArray
+ // This needs to be done because in the COM interface CompSet is an inout argument,
+ // because Visual Basic is not able to deal out arrays...
+ SAFEARRAY* sa_CompSet = SafeArrayCreateVector(VT_BSTR, 1, 250);
+
+ FluidProp_COM->GetCompSet( BSTR_Model, &long_nComps, &sa_CompSet, &BSTR_Error);
+ SysFreeString(BSTR_Model);
+
+ // Retrieve array with components from SafeArray
+ for (long i = 1; i <= long_nComps; i++) {
+ BSTR BSTR_Comp;
+ SafeArrayGetElement(sa_CompSet, &i, &BSTR_Comp);
+ CompSet[i-1] = ConvertBSTRToString(BSTR_Comp);
+ SysFreeString(BSTR_Comp);
+ }
+ SafeArrayDestroy(sa_CompSet);
+ *nComps = long_nComps;
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+}
+
+double TFluidProp::Pressure( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Pressure( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Temperature( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Temperature( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::SpecVolume( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->SpecVolume( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Density( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Density( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Enthalpy( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Enthalpy( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Entropy( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Entropy( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::IntEnergy( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->IntEnergy( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::VaporQual( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->VaporQual( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double* TFluidProp::LiquidCmp( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double* Output = new double[20];
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Convert the double array Conc into a SafeArray
+ SAFEARRAY* sa_Output = SafeArrayCreateVector(VT_R8, 1, 20);
+
+ FluidProp_COM->LiquidCmp( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Retrieve array with concentrations from SafeArray
+ for (long i = 1; i <= 20; i++)
+ SafeArrayGetElement(sa_Output, &i, &Output[i-1]);
+ SafeArrayDestroy(sa_Output);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double* TFluidProp::VaporCmp( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double* Output = new double[20];
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Convert the double array Conc into a SafeArray
+ SAFEARRAY* sa_Output = SafeArrayCreateVector(VT_R8, 1, 20);
+
+ FluidProp_COM->VaporCmp( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Retrieve array with concentrations from SafeArray
+ for (long i = 1; i <= 20; i++)
+ SafeArrayGetElement(sa_Output, &i, &Output[i-1]);
+ SafeArrayDestroy(sa_Output);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::HeatCapV( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->HeatCapV( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::HeatCapP( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->HeatCapP( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::SoundSpeed( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->SoundSpeed( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Alpha( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Alpha( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Beta( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Beta( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Chi( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Chi( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Fi( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Fi( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Ksi( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Ksi( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Psi( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Psi( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Zeta( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Zeta( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Theta( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Theta( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Kappa( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Kappa( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Gamma( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Gamma( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Viscosity( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Viscosity( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::ThermCond( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->ThermCond( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+void TFluidProp::AllProps( string InputSpec, double Input1, double Input2, double& P, double& T,
+ double& v, double& d, double& h, double& s, double& u, double& q,
+ double* x, double* y, double& cv, double& cp, double& c, double& alpha,
+ double& beta, double& chi, double& fi, double& ksi, double& psi,
+ double& zeta, double& theta, double& kappa, double& gamma, double& eta,
+ double& lambda, string* ErrorMsg)
+{
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Convert double arrays with liquid and vapor phase compositions x and y into SafeArrays
+ SAFEARRAY *sa_x = SafeArrayCreateVector(VT_R8, 1, 20);
+ SAFEARRAY *sa_y = SafeArrayCreateVector(VT_R8, 1, 20);
+
+ FluidProp_COM->AllProps( BSTR_InputSpec, Input1, Input2, &P, &T, &v, &d, &h, &s, &u, &q, &sa_x,
+ &sa_y, &cv, &cp, &c, &alpha, &beta, &chi, &fi, &ksi, &psi, &zeta,
+ &theta, &kappa, &gamma, &eta, &lambda, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Retrieve array with liquid and vapor phase compositions from SafeArrays
+ for (long i = 1; i <= 20; i++)
+ SafeArrayGetElement(sa_x, &i, &x[i-1]);
+ SafeArrayDestroy(sa_x);
+
+ for (long i = 1; i <= 20; i++)
+ SafeArrayGetElement(sa_y, &i, &y[i-1]);
+ SafeArrayDestroy(sa_y);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+}
+
+void TFluidProp::AllPropsSat( string InputSpec, double Input1, double Input2, double& P, double& T,
+ double& v, double& d, double& h, double& s, double& u, double& q,
+ double* x, double* y, double& cv, double& cp, double& c, double& alpha,
+ double& beta, double& chi, double& fi, double& ksi, double& psi,
+ double& zeta, double& theta, double& kappa, double& gamma, double& eta,
+ double& lambda, double& d_liq, double& d_vap, double& h_liq, double& h_vap,
+ double& T_sat, double& dd_liq_dP, double& dd_vap_dP, double& dh_liq_dP,
+ double& dh_vap_dP, double& dT_sat_dP, string* ErrorMsg)
+{
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Convert double arrays with liquid and vapor phase compositions x and y into SafeArrays
+ SAFEARRAY *sa_x = SafeArrayCreateVector(VT_R8, 1, 20);
+ SAFEARRAY *sa_y = SafeArrayCreateVector(VT_R8, 1, 20);
+
+ FluidProp_COM->AllPropsSat( BSTR_InputSpec, Input1, Input2, &P, &T, &v, &d, &h, &s, &u, &q, &sa_x,
+ &sa_y, &cv, &cp, &c, &alpha, &beta, &chi, &fi, &ksi, &psi, &zeta,
+ &theta, &kappa, &gamma, &eta, &lambda, &d_liq, &d_vap, &h_liq, &h_vap,
+ &T_sat, &dd_liq_dP, &dd_vap_dP, &dh_liq_dP, &dh_vap_dP, &dT_sat_dP,
+ &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Retrieve array with liquid and vapor phase compositions from SafeArrays
+ for (long i = 1; i <= 20; i++)
+ SafeArrayGetElement(sa_x, &i, &x[i-1]);
+ SafeArrayDestroy(sa_x);
+
+ for (long i = 1; i <= 20; i++)
+ SafeArrayGetElement(sa_y, &i, &y[i-1]);
+ SafeArrayDestroy(sa_y);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+}
+
+
+double TFluidProp::Solve( string FuncSpec, double FuncVal, string InputSpec, long Target,
+ double FixedVal, double MinVal, double MaxVal, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_FuncSpec = ConvertStringToBSTR(FuncSpec);
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Solve( BSTR_FuncSpec, FuncVal, BSTR_InputSpec, Target, FixedVal, MinVal,
+ MaxVal, &Output, &BSTR_Error);
+ SysFreeString(BSTR_FuncSpec);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Mmol( string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Mmol( &Output, &BSTR_Error);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Tcrit( string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Tcrit( &Output, &BSTR_Error);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Pcrit( string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Pcrit( &Output, &BSTR_Error);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Tmin( string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Tmin( &Output, &BSTR_Error);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::Tmax( string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_Error;
+
+ FluidProp_COM->Tmax( &Output, &BSTR_Error);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+void TFluidProp::AllInfo( double& Mmol, double& Tcrit, double& Pcrit, double& Tmin, double& Tmax,
+ string* ErrorMsg)
+{
+ BSTR BSTR_Error;
+
+ FluidProp_COM->AllInfo( &Mmol, &Tcrit, &Pcrit, &Tmin, &Tmax, &BSTR_Error);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+}
+
+void TFluidProp::SetUnits( string UnitSet, string MassOrMole, string Properties, string Units,
+ string* ErrorMsg)
+{
+ BSTR BSTR_Error;
+ BSTR BSTR_UnitSet = ConvertStringToBSTR(UnitSet);
+ BSTR BSTR_MassOrMole = ConvertStringToBSTR(MassOrMole);
+ BSTR BSTR_Properties = ConvertStringToBSTR(Properties);
+ BSTR BSTR_Units = ConvertStringToBSTR(Units);
+
+ FluidProp_COM->SetUnits( BSTR_UnitSet, BSTR_MassOrMole, BSTR_Properties, BSTR_Units, &BSTR_Error);
+ SysFreeString(BSTR_UnitSet);
+ SysFreeString(BSTR_MassOrMole);
+ SysFreeString(BSTR_Properties);
+ SysFreeString(BSTR_Units);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+}
+
+void TFluidProp::SetRefState( double T_ref, double P_ref, string* ErrorMsg)
+{
+ BSTR BSTR_Error;
+
+ FluidProp_COM->SetRefState( T_ref, P_ref, &BSTR_Error);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+}
+
+void TFluidProp::GetVersion(string ModelName, int* version)
+{
+ // Convert model name to binary string
+ BSTR BSTR_Model = ConvertStringToBSTR(ModelName);
+
+ // Now get the version for the model selected
+ SAFEARRAY* sa_version;
+ FluidProp_COM->GetVersion(BSTR_Model, &sa_version);
+ SysFreeString(BSTR_Model);
+
+ for (long i = 1; i <= 4; i++) {
+ SafeArrayGetElement(sa_version, &i, &version[i-1]);
+ }
+ SafeArrayDestroyData(sa_version);
+ SafeArrayDestroyDescriptor(sa_version);
+}
+
+double* TFluidProp::FugaCoef( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double* Output = new double[20];
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Convert the double array Conc into a SafeArray
+ SAFEARRAYBOUND sa_bounds_Output[1];
+ sa_bounds_Output[0].lLbound = 0;
+ sa_bounds_Output[0].cElements = 20;
+ SAFEARRAY* sa_Output;
+ sa_Output = SafeArrayCreate(VT_R8, 1, sa_bounds_Output);
+
+ FluidProp_COM->FugaCoef( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Retrieve array with concentrations from SafeArray
+ for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++)
+ SafeArrayGetElement(sa_Output, &i, &Output[i]);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::SurfTens( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->SurfTens( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double TFluidProp::GibbsEnergy( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double Output;
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ FluidProp_COM->GibbsEnergy( BSTR_InputSpec, Input1, Input2, &Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+void TFluidProp::CapeOpenDeriv( string InputSpec, double Input1, double Input2, double* v, double* h,
+ double* s, double* G, double* lnphi, string* ErrorMsg)
+{
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Create safe arrays for double arrays v[2n+2], h[2n+2], s[2n+2], G[2n+2] and lnphi[n,2n+2], where n_max = 20.
+ SAFEARRAYBOUND sa_bnd_vhsG[1];
+ sa_bnd_vhsG[0].lLbound = 0;
+ sa_bnd_vhsG[0].cElements = 100;
+ SAFEARRAY *sa_v, *sa_h, *sa_s, *sa_G;
+ sa_v = SafeArrayCreate(VT_R8, 1, sa_bnd_vhsG);
+ sa_h = SafeArrayCreate(VT_R8, 1, sa_bnd_vhsG);
+ sa_s = SafeArrayCreate(VT_R8, 1, sa_bnd_vhsG);
+ sa_G = SafeArrayCreate(VT_R8, 1, sa_bnd_vhsG);
+
+ SAFEARRAYBOUND sa_bnd_lnphi[2];
+ sa_bnd_lnphi[0].lLbound = 0;
+ sa_bnd_lnphi[0].cElements = 20;
+ sa_bnd_lnphi[1].lLbound = 0;
+ sa_bnd_lnphi[1].cElements = 100;
+ SAFEARRAY *sa_lnphi;
+ sa_lnphi = SafeArrayCreate(VT_R8, 2, sa_bnd_lnphi);
+
+ FluidProp_COM->CapeOpenDeriv(BSTR_InputSpec, Input1, Input2, &sa_v, &sa_h, &sa_s, &sa_G, &sa_lnphi, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Put the values from safearray's in the double array's v, h, s, and G
+ for (long i = 0; i < (signed)sa_bnd_vhsG[0].cElements; i++) {
+ SafeArrayGetElement(sa_v, &i, &v[i]);
+ SafeArrayGetElement(sa_h, &i, &h[i]);
+ SafeArrayGetElement(sa_s, &i, &s[i]);
+ SafeArrayGetElement(sa_G, &i, &G[i]);
+ }
+
+ // Put the values from safearray's sa_lnphi into double array lnphi
+ for (long i = 0; i < (signed)sa_bnd_lnphi[1].cElements; i++) {
+ for (long j = 0; j < (signed)sa_bnd_lnphi[0].cElements; i++) {
+ long idx_bnd[2];
+ idx_bnd[1] = i;
+ idx_bnd[0] = j;
+ SafeArrayGetElement(sa_lnphi, &idx_bnd[0], &lnphi[i*20+j]);
+ }
+ }
+
+ // Destroy the SafeArrays
+ SafeArrayDestroy(sa_v);
+ SafeArrayDestroy(sa_h);
+ SafeArrayDestroy(sa_s);
+ SafeArrayDestroy(sa_G);
+ SafeArrayDestroy(sa_lnphi);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+}
+
+
+double* TFluidProp::SpecVolume_Deriv( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double* Output = new double[42];
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Convert the double array Conc into a SafeArray
+ SAFEARRAYBOUND sa_bounds_Output[1];
+ sa_bounds_Output[0].lLbound = 0;
+ sa_bounds_Output[0].cElements = 42;
+ SAFEARRAY* sa_Output;
+ sa_Output = SafeArrayCreate(VT_R8, 1, sa_bounds_Output);
+
+ FluidProp_COM->SpecVolume_Deriv( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Retrieve array with concentrations from SafeArray
+ for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++)
+ SafeArrayGetElement(sa_Output, &i, &Output[i]);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double* TFluidProp::Enthalpy_Deriv( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double* Output = new double[42];
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Convert the double array Conc into a SafeArray
+ SAFEARRAYBOUND sa_bounds_Output[1];
+ sa_bounds_Output[0].lLbound = 0;
+ sa_bounds_Output[0].cElements = 42;
+ SAFEARRAY* sa_Output;
+ sa_Output = SafeArrayCreate(VT_R8, 1, sa_bounds_Output);
+
+ FluidProp_COM->Enthalpy_Deriv( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Retrieve array with concentrations from SafeArray
+ for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++)
+ SafeArrayGetElement(sa_Output, &i, &Output[i]);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double* TFluidProp::Entropy_Deriv( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double* Output = new double[42];
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Convert the double array Conc into a SafeArray
+ SAFEARRAYBOUND sa_bounds_Output[1];
+ sa_bounds_Output[0].lLbound = 0;
+ sa_bounds_Output[0].cElements = 42;
+ SAFEARRAY* sa_Output;
+ sa_Output = SafeArrayCreate(VT_R8, 1, sa_bounds_Output);
+
+ FluidProp_COM->Entropy_Deriv( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Retrieve array with concentrations from SafeArray
+ for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++)
+ SafeArrayGetElement(sa_Output, &i, &Output[i]);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double* TFluidProp::GibbsEnergy_Deriv( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double* Output = new double[42];
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Convert the double array Conc into a SafeArray
+ SAFEARRAYBOUND sa_bounds_Output[1];
+ sa_bounds_Output[0].lLbound = 0;
+ sa_bounds_Output[0].cElements = 42;
+ SAFEARRAY* sa_Output;
+ sa_Output = SafeArrayCreate(VT_R8, 1, sa_bounds_Output);
+
+ FluidProp_COM->GibbsEnergy_Deriv( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Retrieve array with concentrations from SafeArray
+ for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++)
+ SafeArrayGetElement(sa_Output, &i, &Output[i]);
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+
+double* TFluidProp::FugaCoef_Deriv( string InputSpec, double Input1, double Input2, string* ErrorMsg)
+{
+ double* Output = new double[20*42];
+
+ BSTR BSTR_InputSpec = ConvertStringToBSTR(InputSpec);
+ BSTR BSTR_Error;
+
+ // Convert the double array Conc into a SafeArray
+ SAFEARRAYBOUND sa_bounds_Output[2];
+ sa_bounds_Output[0].lLbound = 0;
+ sa_bounds_Output[0].cElements = 20;
+ sa_bounds_Output[1].lLbound = 0;
+ sa_bounds_Output[1].cElements = 42;
+ SAFEARRAY* sa_Output;
+ sa_Output = SafeArrayCreate(VT_R8, 2, sa_bounds_Output);
+
+ FluidProp_COM->FugaCoef_Deriv( BSTR_InputSpec, Input1, Input2, &sa_Output, &BSTR_Error);
+ SysFreeString(BSTR_InputSpec);
+
+ // Retrieve array with concentrations from SafeArray
+ for (long i = 0; i < (signed)sa_bounds_Output[0].cElements; i++) {
+ for (long j = 0; j < (signed)sa_bounds_Output[1].cElements; j++) {
+ long idx[2] = {i,j};
+ double f;
+ SafeArrayGetElement(sa_Output, idx, (void*)&f);
+ // Storage in Output
+ // 1) first 20 elements : derivatives wrt T (dlnphi_1/dT, dlnphi_2/dT, ... dlnphi_20/dT)
+ // 2) second 20 elements : derivatives wrt P (dlnphi_1/dP, dlnphi_2/dP, ... dlnphi_20/dP)
+ // 3) next 20*20 elements: derivatives wrt x (dlnphi_1/dx_1, dlnphi_2/dx_1, ... dlnphi_20/dx_1, dlnphi_1/dx_2, etc.)
+ // 4) next 20*20 elements: derivatives wrt n (dlnphi_1/dn_1, dlnphi_2/dn_1, ... dlnphi_20/dn_1, dlnphi_1/dn_2, etc.)
+ Output[i+j*20] = f;
+ }
+ }
+
+ *ErrorMsg = ConvertBSTRToString(BSTR_Error);
+ SysFreeString(BSTR_Error);
+
+ return Output;
+}
+//==================================================================================== EOF ===//
diff --git a/Projects/Sources/Makefile b/Projects/Sources/Makefile
deleted file mode 100644
index 14ad2160..00000000
--- a/Projects/Sources/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# quick and dirty makefile for OpenModelica
-# Adrian.Pop@liu.se
-
-CFLAGS = -O2 -loleaut32
-SOURCES=FluidProp_IF.cpp basesolver.cpp errorhandling.cpp externalmedialib.cpp fluidpropsolver.cpp solvermap.cpp testsolver.cpp mingw_gcc_comutil.cpp
-
-all:
- gcc ${CFLAGS} -c ${SOURCES}
- ar -r libExternalMediaLib.a *.o
- ranlib libExternalMediaLib.a
-
-clean:
- rm -f *.o *.a
\ No newline at end of file
diff --git a/Projects/Sources/ModelicaUtilities.h b/Projects/Sources/ModelicaUtilities.h
index 90d9226f..fc237b46 100644
--- a/Projects/Sources/ModelicaUtilities.h
+++ b/Projects/Sources/ModelicaUtilities.h
@@ -1,113 +1,113 @@
-#ifndef MODELICA_UTILITIES_H
-#define MODELICA_UTILITIES_H
-
-#include
-#include
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* Utility functions which can be called by external Modelica functions.
-
- These functions are defined in section 12.8.6 of the
- Modelica Specification 3.0 and section 12.9.6 of the
- Modelica Specification 3.1 and 3.2.
-
- A generic C-implementation of these functions cannot be given,
- because it is tool dependent how strings are output in a
- window of the respective simulation tool. Therefore, only
- this header file is shipped with the Modelica Standard Library.
-*/
-
-/*
- * Some of the functions never return to the caller. In order to compile
- * external Modelica C-code in most compilers, noreturn attributes need to
- * be present to avoid warnings or errors.
- *
- * The following macros handle noreturn attributes according to the latest
- * C11/C++11 standard with fallback to GNU or MSVC extensions if using an
- * older compiler.
- */
-#if __STDC_VERSION__ >= 201112L
-#define MODELICA_NORETURN _Noreturn
-#define MODELICA_NORETURNATTR
-#elif __cplusplus >= 201103L
-#define MODELICA_NORETURN [[noreturn]]
-#define MODELICA_NORETURNATTR
-#elif defined(__GNUC__)
-#define MODELICA_NORETURN
-#define MODELICA_NORETURNATTR __attribute__((noreturn))
-#elif defined(_MSC_VER)
-#define MODELICA_NORETURN __declspec(noreturn)
-#define MODELICA_NORETURNATTR
-#else
-#define MODELICA_NORETURN
-#define MODELICA_NORETURNATTR
-#endif
-
-void ModelicaMessage(const char *string);
-/*
-Output the message string (no format control).
-*/
-
-
-void ModelicaFormatMessage(const char *string,...);
- /*
-Output the message under the same format control as the C-function printf.
- */
-
-
-void ModelicaVFormatMessage(const char *string, va_list);
- /*
-Output the message under the same format control as the C-function vprintf.
- */
-
-
-MODELICA_NORETURN void ModelicaError(const char *string) MODELICA_NORETURNATTR;
-/*
-Output the error message string (no format control). This function
-never returns to the calling function, but handles the error
-similarly to an assert in the Modelica code.
-*/
-
-
-MODELICA_NORETURN void ModelicaFormatError(const char *string,...) MODELICA_NORETURNATTR;
-/*
-Output the error message under the same format control as the C-function
-printf. This function never returns to the calling function,
-but handles the error similarly to an assert in the Modelica code.
-*/
-
-
-MODELICA_NORETURN void ModelicaVFormatError(const char *string, va_list) MODELICA_NORETURNATTR;
-/*
-Output the error message under the same format control as the C-function
-vprintf. This function never returns to the calling function,
-but handles the error similarly to an assert in the Modelica code.
-*/
-
-
-char* ModelicaAllocateString(size_t len);
-/*
-Allocate memory for a Modelica string which is used as return
-argument of an external Modelica function. Note, that the storage
-for string arrays (= pointer to string array) is still provided by the
-calling program, as for any other array. If an error occurs, this
-function does not return, but calls "ModelicaError".
-*/
-
-
-char* ModelicaAllocateStringWithErrorReturn(size_t len);
-/*
-Same as ModelicaAllocateString, except that in case of error, the
-function returns 0. This allows the external function to close files
-and free other open resources in case of error. After cleaning up
-resources use ModelicaError or ModelicaFormatError to signal
-the error.
-*/
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif
+#ifndef MODELICA_UTILITIES_H
+#define MODELICA_UTILITIES_H
+
+#include
+#include
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Utility functions which can be called by external Modelica functions.
+
+ These functions are defined in section 12.8.6 of the
+ Modelica Specification 3.0 and section 12.9.6 of the
+ Modelica Specification 3.1 and 3.2.
+
+ A generic C-implementation of these functions cannot be given,
+ because it is tool dependent how strings are output in a
+ window of the respective simulation tool. Therefore, only
+ this header file is shipped with the Modelica Standard Library.
+*/
+
+/*
+ * Some of the functions never return to the caller. In order to compile
+ * external Modelica C-code in most compilers, noreturn attributes need to
+ * be present to avoid warnings or errors.
+ *
+ * The following macros handle noreturn attributes according to the latest
+ * C11/C++11 standard with fallback to GNU or MSVC extensions if using an
+ * older compiler.
+ */
+#if __STDC_VERSION__ >= 201112L
+#define MODELICA_NORETURN _Noreturn
+#define MODELICA_NORETURNATTR
+#elif __cplusplus >= 201103L
+#define MODELICA_NORETURN [[noreturn]]
+#define MODELICA_NORETURNATTR
+#elif defined(__GNUC__)
+#define MODELICA_NORETURN
+#define MODELICA_NORETURNATTR __attribute__((noreturn))
+#elif defined(_MSC_VER)
+#define MODELICA_NORETURN __declspec(noreturn)
+#define MODELICA_NORETURNATTR
+#else
+#define MODELICA_NORETURN
+#define MODELICA_NORETURNATTR
+#endif
+
+void ModelicaMessage(const char *string);
+/*
+Output the message string (no format control).
+*/
+
+
+void ModelicaFormatMessage(const char *string,...);
+ /*
+Output the message under the same format control as the C-function printf.
+ */
+
+
+void ModelicaVFormatMessage(const char *string, va_list);
+ /*
+Output the message under the same format control as the C-function vprintf.
+ */
+
+
+MODELICA_NORETURN void ModelicaError(const char *string) MODELICA_NORETURNATTR;
+/*
+Output the error message string (no format control). This function
+never returns to the calling function, but handles the error
+similarly to an assert in the Modelica code.
+*/
+
+
+MODELICA_NORETURN void ModelicaFormatError(const char *string,...) MODELICA_NORETURNATTR;
+/*
+Output the error message under the same format control as the C-function
+printf. This function never returns to the calling function,
+but handles the error similarly to an assert in the Modelica code.
+*/
+
+
+MODELICA_NORETURN void ModelicaVFormatError(const char *string, va_list) MODELICA_NORETURNATTR;
+/*
+Output the error message under the same format control as the C-function
+vprintf. This function never returns to the calling function,
+but handles the error similarly to an assert in the Modelica code.
+*/
+
+
+char* ModelicaAllocateString(size_t len);
+/*
+Allocate memory for a Modelica string which is used as return
+argument of an external Modelica function. Note, that the storage
+for string arrays (= pointer to string array) is still provided by the
+calling program, as for any other array. If an error occurs, this
+function does not return, but calls "ModelicaError".
+*/
+
+
+char* ModelicaAllocateStringWithErrorReturn(size_t len);
+/*
+Same as ModelicaAllocateString, except that in case of error, the
+function returns 0. This allows the external function to close files
+and free other open resources in case of error. After cleaning up
+resources use ModelicaError or ModelicaFormatError to signal
+the error.
+*/
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/Projects/Sources/README-DOXYGEN.txt b/Projects/Sources/README-DOXYGEN.txt
deleted file mode 100644
index e0cf4c7a..00000000
--- a/Projects/Sources/README-DOXYGEN.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-Generating the documentation using DOXYGEN
-==================================================
-Christoph Richter, ch.richter@tu-bs.de, 2007-01-19
-
-1. Get the latest version of doxygen that can be found at
- http://www.stack.nl/~dimitri/doxygen/
- and install it on your system
-
-2. Open a command line shell and go to
- \path-to-external-media-library\Projects\Sources
-
-3. Type in the following command
- doxygen Doxyfile
- This will create the html documentation in
- \path-to-external-media-library\Documentation\html
- and the LaTeX documentation in
- \path-to-external-media-library\Documentation\latex
-
-Note that the first chapter of the documentation can be found in "documentation.h".
\ No newline at end of file
diff --git a/Projects/Sources/basesolver.cpp b/Projects/Sources/basesolver.cpp
index 289f6721..aa08a549 100644
--- a/Projects/Sources/basesolver.cpp
+++ b/Projects/Sources/basesolver.cpp
@@ -1,714 +1,714 @@
-#include "basesolver.h"
-#include
-#include "externalmedialib.h"
-
-//! Constructor.
-/*!
- The constructor is copying the medium name, library name and substance name
- to the locally defined variables.
- @param mediumName Arbitrary medium name
- @param libraryName Name of the external fluid property library
- @param substanceName Substance name
-*/
-BaseSolver::BaseSolver(const string &mediumName, const string &libraryName, const string &substanceName)
- : mediumName(mediumName), libraryName(libraryName), substanceName(substanceName){
-}
-
-//! Destructor
-/*!
- The destructor for the base solver if currently not doing anything.
-*/
-BaseSolver::~BaseSolver(){
-}
-
-//! Return molar mass (Default implementation provided)
-double BaseSolver::molarMass() const{
- return _fluidConstants.MM;
-}
-
-//! Return temperature at critical point (Default implementation provided)
-double BaseSolver::criticalTemperature() const{
- return _fluidConstants.Tc;
-}
-
-//! Return pressure at critical point (Default implementation provided)
-double BaseSolver::criticalPressure() const{
- return _fluidConstants.pc;
-}
-
-//! Return molar volume at critical point (Default implementation provided)
-double BaseSolver::criticalMolarVolume() const{
- return _fluidConstants.MM/_fluidConstants.dc;
-}
-
-//! Return density at critical point (Default implementation provided)
-double BaseSolver::criticalDensity() const{
- return _fluidConstants.dc;
-}
-
-//! Return specific enthalpy at critical point (Default implementation provided)
-double BaseSolver::criticalEnthalpy() const{
- return _fluidConstants.hc;
-}
-
-//! Return specific entropy at critical point (Default implementation provided)
-double BaseSolver::criticalEntropy() const{
- return _fluidConstants.sc;
-}
-
-//! Set fluid constants
-/*!
- This function sets the fluid constants which are defined in the
- FluidConstants record in Modelica. It should be called when a new
- solver is created.
-
- Must be re-implemented in the specific solver
-*/
-void BaseSolver::setFluidConstants(){
-}
-
-//! Set state from p, h, and phase
-/*!
- This function sets the thermodynamic state record for the given pressure
- p, the specific enthalpy h and the specified phase. The computed values are
- written to the ExternalThermodynamicState property struct.
-
- Must be re-implemented in the specific solver
- @param p Pressure
- @param h Specific enthalpy
- @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
- @param properties ExternalThermodynamicState property struct
-*/
-void BaseSolver::setState_ph(double &p, double &h, int &phase, ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: setState_ph() not implemented in the Solver object");
-}
-
-//! Set state from p and T
-/*!
- This function sets the thermodynamic state record for the given pressure
- p and the temperature T. The computed values are
- written to the ExternalThermodynamicState property struct.
-
- Must be re-implemented in the specific solver
- @param p Pressure
- @param T Temperature
- @param properties ExternalThermodynamicState property struct
-*/
-void BaseSolver::setState_pT(double &p, double &T, ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: setState_pT() not implemented in the Solver object");
-}
-
-//! Set state from d, T, and phase
-/*!
- This function sets the thermodynamic state record for the given density
- d, the temperature T and the specified phase. The computed values are
- written to the ExternalThermodynamicState property struct.
-
- Must be re-implemented in the specific solver
- @param d Density
- @param T Temperature
- @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
- @param properties ExternalThermodynamicState property struct
-*/
-void BaseSolver::setState_dT(double &d, double &T, int &phase, ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: setState_dT() not implemented in the Solver object");
-}
-
-//! Set state from p, s, and phase
-/*!
- This function sets the thermodynamic state record for the given pressure
- p, the specific entropy s and the specified phase. The computed values are
- written to the ExternalThermodynamicState property struct.
-
- Must be re-implemented in the specific solver
- @param p Pressure
- @param s Specific entropy
- @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
- @param properties ExternalThermodynamicState property struct
-*/
-void BaseSolver::setState_ps(double &p, double &s, int &phase, ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: setState_ps() not implemented in the Solver object");
-}
-
-//! Set state from h, s, and phase
-/*!
- This function sets the thermodynamic state record for the given specific enthalpy
- p, the specific entropy s and the specified phase. The computed values are
- written to the ExternalThermodynamicState property struct.
-
- Must be re-implemented in the specific solver
- @param h Specific enthalpy
- @param s Specific entropy
- @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
- @param properties ExternalThermodynamicState property struct
-*/
-void BaseSolver::setState_hs(double &h, double &s, int &phase, ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: setState_hs() not implemented in the Solver object");
-}
-
-//! Compute partial derivative from a populated state record
-/*!
- This function computes the derivative of the specified input. Note that it requires
- a populated state record as input.
-
- @param of Property to differentiate
- @param wrt Property to differentiate in
- @param cst Property to remain constant
- @param state Pointer to input values in state record
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-double BaseSolver::partialDeriv_state(const string &of, const string &wrt, const string &cst, ExternalThermodynamicState *const properties){
-//double BaseSolver::partialDeriv_state(const char *of, const char *wrt, const char *cst, ExternalThermodynamicState *const properties){
- errorMessage((char*)"Internal error: partialDeriv_state() not implemented in the Solver object");
- return 0.;
-}
-
-//! Compute Prandtl number
-/*!
- This function returns the Prandtl number
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::Pr(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: Pr() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute temperature
-/*!
- This function returns the temperature
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::T(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: T() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute velocity of sound
-/*!
- This function returns the velocity of sound
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::a(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: a() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute isobaric expansion coefficient
-/*!
- This function returns the isobaric expansion coefficient
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::beta(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: beta() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute specific heat capacity cp
-/*!
- This function returns the specific heat capacity cp
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::cp(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: cp() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute specific heat capacity cv
-/*!
- This function returns the specific heat capacity cv
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::cv(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: cv() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute density
-/*!
- This function returns the density
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::d(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: d() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute derivative of density wrt enthalpy at constant pressure
-/*!
- This function returns the derivative of density wrt enthalpy at constant pressure
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::ddhp(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: ddhp() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute derivative of density wrt pressure at constant enthalpy
-/*!
- This function returns the derivative of density wrt pressure at constant enthalpy
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::ddph(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: ddph() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute dynamic viscosity
-/*!
- This function returns the dynamic viscosity
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::eta(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: eta() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute specific enthalpy
-/*!
- This function returns the specific enthalpy
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::h(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: h() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute compressibility
-/*!
- This function returns the compressibility
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::kappa(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: kappa() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute thermal conductivity
-/*!
- This function returns the thermal conductivity
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::lambda(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: lambda() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute pressure
-/*!
- This function returns the pressure
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::p(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: p() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute phase flag
-/*!
- This function returns the phase flag
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-int BaseSolver::phase(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: phase() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute specific entropy
-/*!
- This function returns the specific entropy
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::s(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: s() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute total derivative of density ph
-/*!
- This function returns the total derivative of density ph
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::d_der(ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: d_der() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute isentropic enthalpy
-/*!
- This function returns the enthalpy at pressure p after an isentropic
- transformation from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param p New pressure
- @param properties ExternalThermodynamicState property struct corresponding to current state
-*/
-double BaseSolver::isentropicEnthalpy(double &p, ExternalThermodynamicState *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: isentropicEnthalpy() not implemented in the Solver object");
- return 0;
-}
-
-//! Set saturation properties from p
-/*!
- This function sets the saturation properties for the given pressure p.
- The computed values are written to the ExternalSaturationProperties propery struct.
-
- Must be re-implemented in the specific solver
- @param p Pressure
- @param properties ExternalSaturationProperties property struct
-*/
-void BaseSolver::setSat_p(double &p, ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: setSat_p() not implemented in the Solver object");
-}
-
-//! Set saturation properties from T
-/*!
- This function sets the saturation properties for the given temperature T.
- The computed values are written to the ExternalSaturationProperties propery struct.
-
- Must be re-implemented in the specific solver
- @param T Temperature
- @param properties ExternalSaturationProperties property struct
-*/
-void BaseSolver::setSat_T(double &T, ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: setSat_T() not implemented in the Solver object");
-}
-
-//! Set bubble state
-/*!
- This function sets the bubble state record bubbleProperties corresponding to the
- saturation data contained in the properties record.
-
- The default implementation of the setBubbleState function is relying on the correct
- behaviour of setState_ph with respect to the state input. Can be overridden
- in the specific solver code to get more efficient or correct handling of this situation.
- @param properties ExternalSaturationProperties record with saturation properties data
- @param phase Phase (1: one-phase, 2: two-phase)
- @param bubbleProperties ExternalThermodynamicState record where to write the bubble point properties
-*/
-void BaseSolver::setBubbleState(ExternalSaturationProperties *const properties, int phase,
- ExternalThermodynamicState *const bubbleProperties){
- // Set the bubble state property record based on the saturation properties record
- setState_ph(properties->psat, properties->hl, phase, bubbleProperties);
-}
-
-//! Set dew state
-/*!
- This function sets the dew state record dewProperties corresponding to the
- saturation data contained in the properties record.
-
- The default implementation of the setDewState function is relying on the correct
- behaviour of setState_ph with respect to the state input. Can be overridden
- in the specific solver code to get more efficient or correct handling of this situation.
- @param properties ExternalSaturationProperties record with saturation properties data
- @param phase Phase (1: one-phase, 2: two-phase)
- @param dewProperties ExternalThermodynamicState record where to write the dew point properties
-*/
-void BaseSolver::setDewState(ExternalSaturationProperties *const properties, int phase,
- ExternalThermodynamicState *const dewProperties){
- // Set the dew state property record based on the saturation properties record
- setState_ph(properties->psat, properties->hv, phase, dewProperties);
-}
-
-//! Compute derivative of Ts wrt pressure
-/*!
- This function returns the derivative of Ts wrt pressure
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::dTp(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: dTp() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute derivative of dls wrt pressure
-/*!
- This function returns the derivative of dls wrt pressure
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::ddldp(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: ddldp() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute derivative of dvs wrt pressure
-/*!
- This function returns the derivative of dvs wrt pressure
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::ddvdp(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: ddvdp() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute derivative of hls wrt pressure
-/*!
- This function returns the derivative of hls wrt pressure
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::dhldp(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: dhldp() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute derivative of hvs wrt pressure
-/*!
- This function returns the derivative of hvs wrt pressure
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::dhvdp(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: dhvdp() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute density at bubble line
-/*!
- This function returns the density at bubble line
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::dl(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: dl() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute density at dew line
-/*!
- This function returns the density at dew line
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::dv(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: dv() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute enthalpy at bubble line
-/*!
- This function returns the enthalpy at bubble line
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::hl(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: hl() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute enthalpy at dew line
-/*!
- This function returns the enthalpy at dew line
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::hv(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: hv() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute surface tension
-/*!
- This function returns the surface tension
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::sigma(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: sigma() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute entropy at bubble line
-/*!
- This function returns the entropy at bubble line
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::sl(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: sl() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute entropy at dew line
-/*!
- This function returns the entropy at dew line
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::sv(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: sv() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute derivatives
-/*!
- This function computes the derivatives according to the Bridgman's table.
- The computed values are written to the two phase medium property struct.
- This function can be called from within the setState_XX routines
- when implementing a new solver. Please be aware that cp, beta and
- kappa have to be provided to allow the computation of the derivatives. It
- returns false if the computation failed.
-
- Default implementation provided.
- @param properties ExternalThermodynamicState property record
-*/
-bool BaseSolver::computeDerivatives(ExternalThermodynamicState *const properties){
- // Check whether cp is equal to zero
- if (properties->cp == 0.0)
- return false;
- // Check whether density is equal to zero
- if (properties->d == 0.0)
- return false;
- // Compute ddph
- properties->ddph = -(properties->T*properties->beta*properties->beta -
- properties->beta -
- properties->kappa*properties->d*properties->cp)/
- properties->cp;
- // Compute ddhp
- properties->ddhp = -properties->beta*properties->d/properties->cp;
- return true;
-}
-
-//! Compute saturation pressure
-/*!
- This function returns the saturation pressure
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::psat(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: psat() not implemented in the Solver object");
- return 0;
-}
-
-//! Compute saturation temperature
-/*!
- This function returns the saturation temperature
- from the state specified by the properties input
-
- Must be re-implemented in the specific solver
- @param properties ExternalSaturationProperties property struct corresponding to current state
-*/
-double BaseSolver::Tsat(ExternalSaturationProperties *const properties){
- // Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: Tsat() not implemented in the Solver object");
- return 0;
-}
-
+#include "basesolver.h"
+#include
+#include "externalmedialib.h"
+
+//! Constructor.
+/*!
+ The constructor is copying the medium name, library name and substance name
+ to the locally defined variables.
+ @param mediumName Arbitrary medium name
+ @param libraryName Name of the external fluid property library
+ @param substanceName Substance name
+*/
+BaseSolver::BaseSolver(const string &mediumName, const string &libraryName, const string &substanceName)
+ : mediumName(mediumName), libraryName(libraryName), substanceName(substanceName){
+}
+
+//! Destructor
+/*!
+ The destructor for the base solver if currently not doing anything.
+*/
+BaseSolver::~BaseSolver(){
+}
+
+//! Return molar mass (Default implementation provided)
+double BaseSolver::molarMass() const{
+ return _fluidConstants.MM;
+}
+
+//! Return temperature at critical point (Default implementation provided)
+double BaseSolver::criticalTemperature() const{
+ return _fluidConstants.Tc;
+}
+
+//! Return pressure at critical point (Default implementation provided)
+double BaseSolver::criticalPressure() const{
+ return _fluidConstants.pc;
+}
+
+//! Return molar volume at critical point (Default implementation provided)
+double BaseSolver::criticalMolarVolume() const{
+ return _fluidConstants.MM/_fluidConstants.dc;
+}
+
+//! Return density at critical point (Default implementation provided)
+double BaseSolver::criticalDensity() const{
+ return _fluidConstants.dc;
+}
+
+//! Return specific enthalpy at critical point (Default implementation provided)
+double BaseSolver::criticalEnthalpy() const{
+ return _fluidConstants.hc;
+}
+
+//! Return specific entropy at critical point (Default implementation provided)
+double BaseSolver::criticalEntropy() const{
+ return _fluidConstants.sc;
+}
+
+//! Set fluid constants
+/*!
+ This function sets the fluid constants which are defined in the
+ FluidConstants record in Modelica. It should be called when a new
+ solver is created.
+
+ Must be re-implemented in the specific solver
+*/
+void BaseSolver::setFluidConstants(){
+}
+
+//! Set state from p, h, and phase
+/*!
+ This function sets the thermodynamic state record for the given pressure
+ p, the specific enthalpy h and the specified phase. The computed values are
+ written to the ExternalThermodynamicState property struct.
+
+ Must be re-implemented in the specific solver
+ @param p Pressure
+ @param h Specific enthalpy
+ @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
+ @param properties ExternalThermodynamicState property struct
+*/
+void BaseSolver::setState_ph(double &p, double &h, int &phase, ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: setState_ph() not implemented in the Solver object");
+}
+
+//! Set state from p and T
+/*!
+ This function sets the thermodynamic state record for the given pressure
+ p and the temperature T. The computed values are
+ written to the ExternalThermodynamicState property struct.
+
+ Must be re-implemented in the specific solver
+ @param p Pressure
+ @param T Temperature
+ @param properties ExternalThermodynamicState property struct
+*/
+void BaseSolver::setState_pT(double &p, double &T, ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: setState_pT() not implemented in the Solver object");
+}
+
+//! Set state from d, T, and phase
+/*!
+ This function sets the thermodynamic state record for the given density
+ d, the temperature T and the specified phase. The computed values are
+ written to the ExternalThermodynamicState property struct.
+
+ Must be re-implemented in the specific solver
+ @param d Density
+ @param T Temperature
+ @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
+ @param properties ExternalThermodynamicState property struct
+*/
+void BaseSolver::setState_dT(double &d, double &T, int &phase, ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: setState_dT() not implemented in the Solver object");
+}
+
+//! Set state from p, s, and phase
+/*!
+ This function sets the thermodynamic state record for the given pressure
+ p, the specific entropy s and the specified phase. The computed values are
+ written to the ExternalThermodynamicState property struct.
+
+ Must be re-implemented in the specific solver
+ @param p Pressure
+ @param s Specific entropy
+ @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
+ @param properties ExternalThermodynamicState property struct
+*/
+void BaseSolver::setState_ps(double &p, double &s, int &phase, ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: setState_ps() not implemented in the Solver object");
+}
+
+//! Set state from h, s, and phase
+/*!
+ This function sets the thermodynamic state record for the given specific enthalpy
+ p, the specific entropy s and the specified phase. The computed values are
+ written to the ExternalThermodynamicState property struct.
+
+ Must be re-implemented in the specific solver
+ @param h Specific enthalpy
+ @param s Specific entropy
+ @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
+ @param properties ExternalThermodynamicState property struct
+*/
+void BaseSolver::setState_hs(double &h, double &s, int &phase, ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: setState_hs() not implemented in the Solver object");
+}
+
+//! Compute partial derivative from a populated state record
+/*!
+ This function computes the derivative of the specified input. Note that it requires
+ a populated state record as input.
+
+ @param of Property to differentiate
+ @param wrt Property to differentiate in
+ @param cst Property to remain constant
+ @param state Pointer to input values in state record
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+double BaseSolver::partialDeriv_state(const string &of, const string &wrt, const string &cst, ExternalThermodynamicState *const properties){
+//double BaseSolver::partialDeriv_state(const char *of, const char *wrt, const char *cst, ExternalThermodynamicState *const properties){
+ errorMessage((char*)"Internal error: partialDeriv_state() not implemented in the Solver object");
+ return 0.;
+}
+
+//! Compute Prandtl number
+/*!
+ This function returns the Prandtl number
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::Pr(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: Pr() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute temperature
+/*!
+ This function returns the temperature
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::T(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: T() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute velocity of sound
+/*!
+ This function returns the velocity of sound
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::a(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: a() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute isobaric expansion coefficient
+/*!
+ This function returns the isobaric expansion coefficient
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::beta(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: beta() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute specific heat capacity cp
+/*!
+ This function returns the specific heat capacity cp
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::cp(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: cp() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute specific heat capacity cv
+/*!
+ This function returns the specific heat capacity cv
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::cv(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: cv() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute density
+/*!
+ This function returns the density
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::d(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: d() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute derivative of density wrt enthalpy at constant pressure
+/*!
+ This function returns the derivative of density wrt enthalpy at constant pressure
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::ddhp(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: ddhp() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute derivative of density wrt pressure at constant enthalpy
+/*!
+ This function returns the derivative of density wrt pressure at constant enthalpy
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::ddph(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: ddph() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute dynamic viscosity
+/*!
+ This function returns the dynamic viscosity
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::eta(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: eta() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute specific enthalpy
+/*!
+ This function returns the specific enthalpy
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::h(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: h() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute compressibility
+/*!
+ This function returns the compressibility
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::kappa(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: kappa() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute thermal conductivity
+/*!
+ This function returns the thermal conductivity
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::lambda(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: lambda() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute pressure
+/*!
+ This function returns the pressure
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::p(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: p() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute phase flag
+/*!
+ This function returns the phase flag
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+int BaseSolver::phase(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: phase() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute specific entropy
+/*!
+ This function returns the specific entropy
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::s(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: s() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute total derivative of density ph
+/*!
+ This function returns the total derivative of density ph
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::d_der(ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: d_der() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute isentropic enthalpy
+/*!
+ This function returns the enthalpy at pressure p after an isentropic
+ transformation from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param p New pressure
+ @param properties ExternalThermodynamicState property struct corresponding to current state
+*/
+double BaseSolver::isentropicEnthalpy(double &p, ExternalThermodynamicState *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: isentropicEnthalpy() not implemented in the Solver object");
+ return 0;
+}
+
+//! Set saturation properties from p
+/*!
+ This function sets the saturation properties for the given pressure p.
+ The computed values are written to the ExternalSaturationProperties propery struct.
+
+ Must be re-implemented in the specific solver
+ @param p Pressure
+ @param properties ExternalSaturationProperties property struct
+*/
+void BaseSolver::setSat_p(double &p, ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: setSat_p() not implemented in the Solver object");
+}
+
+//! Set saturation properties from T
+/*!
+ This function sets the saturation properties for the given temperature T.
+ The computed values are written to the ExternalSaturationProperties propery struct.
+
+ Must be re-implemented in the specific solver
+ @param T Temperature
+ @param properties ExternalSaturationProperties property struct
+*/
+void BaseSolver::setSat_T(double &T, ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: setSat_T() not implemented in the Solver object");
+}
+
+//! Set bubble state
+/*!
+ This function sets the bubble state record bubbleProperties corresponding to the
+ saturation data contained in the properties record.
+
+ The default implementation of the setBubbleState function is relying on the correct
+ behaviour of setState_ph with respect to the state input. Can be overridden
+ in the specific solver code to get more efficient or correct handling of this situation.
+ @param properties ExternalSaturationProperties record with saturation properties data
+ @param phase Phase (1: one-phase, 2: two-phase)
+ @param bubbleProperties ExternalThermodynamicState record where to write the bubble point properties
+*/
+void BaseSolver::setBubbleState(ExternalSaturationProperties *const properties, int phase,
+ ExternalThermodynamicState *const bubbleProperties){
+ // Set the bubble state property record based on the saturation properties record
+ setState_ph(properties->psat, properties->hl, phase, bubbleProperties);
+}
+
+//! Set dew state
+/*!
+ This function sets the dew state record dewProperties corresponding to the
+ saturation data contained in the properties record.
+
+ The default implementation of the setDewState function is relying on the correct
+ behaviour of setState_ph with respect to the state input. Can be overridden
+ in the specific solver code to get more efficient or correct handling of this situation.
+ @param properties ExternalSaturationProperties record with saturation properties data
+ @param phase Phase (1: one-phase, 2: two-phase)
+ @param dewProperties ExternalThermodynamicState record where to write the dew point properties
+*/
+void BaseSolver::setDewState(ExternalSaturationProperties *const properties, int phase,
+ ExternalThermodynamicState *const dewProperties){
+ // Set the dew state property record based on the saturation properties record
+ setState_ph(properties->psat, properties->hv, phase, dewProperties);
+}
+
+//! Compute derivative of Ts wrt pressure
+/*!
+ This function returns the derivative of Ts wrt pressure
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::dTp(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: dTp() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute derivative of dls wrt pressure
+/*!
+ This function returns the derivative of dls wrt pressure
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::ddldp(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: ddldp() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute derivative of dvs wrt pressure
+/*!
+ This function returns the derivative of dvs wrt pressure
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::ddvdp(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: ddvdp() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute derivative of hls wrt pressure
+/*!
+ This function returns the derivative of hls wrt pressure
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::dhldp(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: dhldp() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute derivative of hvs wrt pressure
+/*!
+ This function returns the derivative of hvs wrt pressure
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::dhvdp(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: dhvdp() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute density at bubble line
+/*!
+ This function returns the density at bubble line
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::dl(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: dl() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute density at dew line
+/*!
+ This function returns the density at dew line
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::dv(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: dv() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute enthalpy at bubble line
+/*!
+ This function returns the enthalpy at bubble line
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::hl(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: hl() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute enthalpy at dew line
+/*!
+ This function returns the enthalpy at dew line
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::hv(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: hv() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute surface tension
+/*!
+ This function returns the surface tension
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::sigma(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: sigma() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute entropy at bubble line
+/*!
+ This function returns the entropy at bubble line
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::sl(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: sl() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute entropy at dew line
+/*!
+ This function returns the entropy at dew line
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::sv(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: sv() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute derivatives
+/*!
+ This function computes the derivatives according to the Bridgman's table.
+ The computed values are written to the two phase medium property struct.
+ This function can be called from within the setState_XX routines
+ when implementing a new solver. Please be aware that cp, beta and
+ kappa have to be provided to allow the computation of the derivatives. It
+ returns false if the computation failed.
+
+ Default implementation provided.
+ @param properties ExternalThermodynamicState property record
+*/
+bool BaseSolver::computeDerivatives(ExternalThermodynamicState *const properties){
+ // Check whether cp is equal to zero
+ if (properties->cp == 0.0)
+ return false;
+ // Check whether density is equal to zero
+ if (properties->d == 0.0)
+ return false;
+ // Compute ddph
+ properties->ddph = -(properties->T*properties->beta*properties->beta -
+ properties->beta -
+ properties->kappa*properties->d*properties->cp)/
+ properties->cp;
+ // Compute ddhp
+ properties->ddhp = -properties->beta*properties->d/properties->cp;
+ return true;
+}
+
+//! Compute saturation pressure
+/*!
+ This function returns the saturation pressure
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::psat(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: psat() not implemented in the Solver object");
+ return 0;
+}
+
+//! Compute saturation temperature
+/*!
+ This function returns the saturation temperature
+ from the state specified by the properties input
+
+ Must be re-implemented in the specific solver
+ @param properties ExternalSaturationProperties property struct corresponding to current state
+*/
+double BaseSolver::Tsat(ExternalSaturationProperties *const properties){
+ // Base function returns an error if called - should be redeclared by the solver object
+ errorMessage((char*)"Internal error: Tsat() not implemented in the Solver object");
+ return 0;
+}
+
diff --git a/Projects/Sources/basesolver.h b/Projects/Sources/basesolver.h
index fda9a8a0..0594bdbe 100644
--- a/Projects/Sources/basesolver.h
+++ b/Projects/Sources/basesolver.h
@@ -1,105 +1,105 @@
-#ifndef BASESOLVER_H_
-#define BASESOLVER_H_
-
-#include "include.h"
-#include "fluidconstants.h"
-#include "externalmedialib.h"
-#include
-#include
-#include
-
-struct FluidConstants;
-
-//! Base solver class.
-/*!
- This is the base class for all external solver objects
- (e.g. TestSolver, FluidPropSolver). A solver object
- encapsulates the interface to external fluid property
- computation routines
-
- Francesco Casella, Christoph Richter, Roberto Bonifetto
- 2006-2012
- Copyright Politecnico di Milano, TU Braunschweig, Politecnico
- di Torino
-*/
-class BaseSolver{
-public:
- BaseSolver(const string &mediumName, const string &libraryName, const string &substanceName);
- virtual ~BaseSolver();
-
- double molarMass() const;
- double criticalTemperature() const;
- double criticalPressure() const;
- double criticalMolarVolume() const;
- double criticalDensity() const;
- double criticalEnthalpy() const;
- double criticalEntropy() const;
-
- virtual void setFluidConstants();
-
- virtual void setState_ph(double &p, double &h, int &phase, ExternalThermodynamicState *const properties);
- virtual void setState_pT(double &p, double &T, ExternalThermodynamicState *const properties);
- virtual void setState_dT(double &d, double &T, int &phase, ExternalThermodynamicState *const properties);
- virtual void setState_ps(double &p, double &s, int &phase, ExternalThermodynamicState *const properties);
- virtual void setState_hs(double &h, double &s, int &phase, ExternalThermodynamicState *const properties);
-
- virtual double partialDeriv_state(const string &of, const string &wrt, const string &cst, ExternalThermodynamicState *const properties);
-
- virtual double Pr(ExternalThermodynamicState *const properties);
- virtual double T(ExternalThermodynamicState *const properties);
- virtual double a(ExternalThermodynamicState *const properties);
- virtual double beta(ExternalThermodynamicState *const properties);
- virtual double cp(ExternalThermodynamicState *const properties);
- virtual double cv(ExternalThermodynamicState *const properties);
- virtual double d(ExternalThermodynamicState *const properties);
- virtual double ddhp(ExternalThermodynamicState *const properties);
- virtual double ddph(ExternalThermodynamicState *const properties);
- virtual double eta(ExternalThermodynamicState *const properties);
- virtual double h(ExternalThermodynamicState *const properties);
- virtual double kappa(ExternalThermodynamicState *const properties);
- virtual double lambda(ExternalThermodynamicState *const properties);
- virtual double p(ExternalThermodynamicState *const properties);
- virtual int phase(ExternalThermodynamicState *const properties);
- virtual double s(ExternalThermodynamicState *const properties);
- virtual double d_der(ExternalThermodynamicState *const properties);
- virtual double isentropicEnthalpy(double &p, ExternalThermodynamicState *const properties);
-
- virtual void setSat_p(double &p, ExternalSaturationProperties *const properties);
- virtual void setSat_T(double &T, ExternalSaturationProperties *const properties);
-
- virtual void setBubbleState(ExternalSaturationProperties *const properties, int phase,
- ExternalThermodynamicState *const bubbleProperties);
- virtual void setDewState(ExternalSaturationProperties *const properties, int phase,
- ExternalThermodynamicState *const bubbleProperties);
-
- virtual double dTp(ExternalSaturationProperties *const properties);
- virtual double ddldp(ExternalSaturationProperties *const properties);
- virtual double ddvdp(ExternalSaturationProperties *const properties);
- virtual double dhldp(ExternalSaturationProperties *const properties);
- virtual double dhvdp(ExternalSaturationProperties *const properties);
- virtual double dl(ExternalSaturationProperties *const properties);
- virtual double dv(ExternalSaturationProperties *const properties);
- virtual double hl(ExternalSaturationProperties *const properties);
- virtual double hv(ExternalSaturationProperties *const properties);
- virtual double sigma(ExternalSaturationProperties *const properties);
- virtual double sl(ExternalSaturationProperties *const properties);
- virtual double sv(ExternalSaturationProperties *const properties);
-
- virtual bool computeDerivatives(ExternalThermodynamicState *const properties);
-
- virtual double psat(ExternalSaturationProperties *const properties);
- virtual double Tsat(ExternalSaturationProperties *const properties);
-
- //! Medium name
- string mediumName;
- //! Library name
- string libraryName;
- //! Substance name
- string substanceName;
-
-protected:
- //! Fluid constants
- FluidConstants _fluidConstants;
-};
-
-#endif // BASESOLVER_H_
+#ifndef BASESOLVER_H_
+#define BASESOLVER_H_
+
+#include "include.h"
+#include "fluidconstants.h"
+#include "externalmedialib.h"
+#include
+#include
+#include
+
+struct FluidConstants;
+
+//! Base solver class.
+/*!
+ This is the base class for all external solver objects
+ (e.g. TestSolver, FluidPropSolver). A solver object
+ encapsulates the interface to external fluid property
+ computation routines
+
+ Francesco Casella, Christoph Richter, Roberto Bonifetto
+ 2006-2012
+ Copyright Politecnico di Milano, TU Braunschweig, Politecnico
+ di Torino
+*/
+class BaseSolver{
+public:
+ BaseSolver(const string &mediumName, const string &libraryName, const string &substanceName);
+ virtual ~BaseSolver();
+
+ double molarMass() const;
+ double criticalTemperature() const;
+ double criticalPressure() const;
+ double criticalMolarVolume() const;
+ double criticalDensity() const;
+ double criticalEnthalpy() const;
+ double criticalEntropy() const;
+
+ virtual void setFluidConstants();
+
+ virtual void setState_ph(double &p, double &h, int &phase, ExternalThermodynamicState *const properties);
+ virtual void setState_pT(double &p, double &T, ExternalThermodynamicState *const properties);
+ virtual void setState_dT(double &d, double &T, int &phase, ExternalThermodynamicState *const properties);
+ virtual void setState_ps(double &p, double &s, int &phase, ExternalThermodynamicState *const properties);
+ virtual void setState_hs(double &h, double &s, int &phase, ExternalThermodynamicState *const properties);
+
+ virtual double partialDeriv_state(const string &of, const string &wrt, const string &cst, ExternalThermodynamicState *const properties);
+
+ virtual double Pr(ExternalThermodynamicState *const properties);
+ virtual double T(ExternalThermodynamicState *const properties);
+ virtual double a(ExternalThermodynamicState *const properties);
+ virtual double beta(ExternalThermodynamicState *const properties);
+ virtual double cp(ExternalThermodynamicState *const properties);
+ virtual double cv(ExternalThermodynamicState *const properties);
+ virtual double d(ExternalThermodynamicState *const properties);
+ virtual double ddhp(ExternalThermodynamicState *const properties);
+ virtual double ddph(ExternalThermodynamicState *const properties);
+ virtual double eta(ExternalThermodynamicState *const properties);
+ virtual double h(ExternalThermodynamicState *const properties);
+ virtual double kappa(ExternalThermodynamicState *const properties);
+ virtual double lambda(ExternalThermodynamicState *const properties);
+ virtual double p(ExternalThermodynamicState *const properties);
+ virtual int phase(ExternalThermodynamicState *const properties);
+ virtual double s(ExternalThermodynamicState *const properties);
+ virtual double d_der(ExternalThermodynamicState *const properties);
+ virtual double isentropicEnthalpy(double &p, ExternalThermodynamicState *const properties);
+
+ virtual void setSat_p(double &p, ExternalSaturationProperties *const properties);
+ virtual void setSat_T(double &T, ExternalSaturationProperties *const properties);
+
+ virtual void setBubbleState(ExternalSaturationProperties *const properties, int phase,
+ ExternalThermodynamicState *const bubbleProperties);
+ virtual void setDewState(ExternalSaturationProperties *const properties, int phase,
+ ExternalThermodynamicState *const bubbleProperties);
+
+ virtual double dTp(ExternalSaturationProperties *const properties);
+ virtual double ddldp(ExternalSaturationProperties *const properties);
+ virtual double ddvdp(ExternalSaturationProperties *const properties);
+ virtual double dhldp(ExternalSaturationProperties *const properties);
+ virtual double dhvdp(ExternalSaturationProperties *const properties);
+ virtual double dl(ExternalSaturationProperties *const properties);
+ virtual double dv(ExternalSaturationProperties *const properties);
+ virtual double hl(ExternalSaturationProperties *const properties);
+ virtual double hv(ExternalSaturationProperties *const properties);
+ virtual double sigma(ExternalSaturationProperties *const properties);
+ virtual double sl(ExternalSaturationProperties *const properties);
+ virtual double sv(ExternalSaturationProperties *const properties);
+
+ virtual bool computeDerivatives(ExternalThermodynamicState *const properties);
+
+ virtual double psat(ExternalSaturationProperties *const properties);
+ virtual double Tsat(ExternalSaturationProperties *const properties);
+
+ //! Medium name
+ string mediumName;
+ //! Library name
+ string libraryName;
+ //! Substance name
+ string substanceName;
+
+protected:
+ //! Fluid constants
+ FluidConstants _fluidConstants;
+};
+
+#endif // BASESOLVER_H_
diff --git a/Projects/Sources/coolpropsolver.cpp b/Projects/Sources/coolpropsolver.cpp
index 3988d02b..5cc2c36c 100755
--- a/Projects/Sources/coolpropsolver.cpp
+++ b/Projects/Sources/coolpropsolver.cpp
@@ -1,8 +1,12 @@
#include "coolpropsolver.h"
+
+#include "include.h"
+#if (EXTERNALMEDIA_COOLPROP == 1)
+
#include "CoolPropTools.h"
-#include "CoolPropDLL.h"
+#include "CoolPropLib.h"
#include "CoolProp.h"
-#include "CPState.h"
+#include "AbstractState.h"
#include
#include
#include
@@ -18,9 +22,9 @@ CoolPropSolver::CoolPropSolver(const std::string &mediumName, const std::string
// Fluid name can be used to pass in other parameters.
// The string can be composed like "Propane|enable_TTSE=1|calc_transport=0"
std::vector name_options = strsplit(substanceName,'|');
+ std::vector library_options = strsplit(libraryName,'|');
// Set the defaults
- fluidType = -1;
enable_TTSE = false;
enable_BICUBIC = false;
debug_level = 0;
@@ -29,6 +33,29 @@ CoolPropSolver::CoolPropSolver(const std::string &mediumName, const std::string
twophase_derivsmoothing_xend = 0;
rho_smoothing_xend = 0;
+ //Check if a backend has been added to the fluid name (ex: REFPROP::Propane)
+ std::string backend;
+ CoolProp::extract_backend(name_options[0], backend, this->substanceName);
+
+ // Set the default composition
+ std::vector fractions(1, 1.0);
+ const std::vector *fractions_ptr = NULL;
+ this->substanceName = CoolProp::extract_fractions(this->substanceName, fractions);
+ fractions_ptr = &fractions;
+
+ if (backend == "?") // If no backend found in the fluid name
+ {
+ if (library_options.size() > 1) //Check if an option has been added to libraryName (should be the case for all incompressible)
+ {
+ backend = library_options[1]; // [0] is always "CoolProp", [1] should be the option if any
+ }
+ else
+ {
+ //No backend found, default to HEOS
+ backend = "HEOS";
+ }
+ }
+
// Initialise the saturation and near-critical variables
_p_eps = 1e-3; // relative tolerance margin for subcritical pressure conditions
_delta_h = 1e-1; // delta_h for one-phase/two-phase discrimination
@@ -51,6 +78,7 @@ CoolPropSolver::CoolPropSolver(const std::string &mediumName, const std::string
{
std::cout << "TTSE is on\n";
enable_TTSE = true;
+ backend = "TTSE&" + backend;
}
else if (!param_val[1].compare("0") || !param_val[1].compare("false"))
{
@@ -67,6 +95,7 @@ CoolPropSolver::CoolPropSolver(const std::string &mediumName, const std::string
{
std::cout << "BICUBIC is on\n";
enable_BICUBIC = true;
+ backend = "BICUBIC&" + backend;
}
else if (!param_val[1].compare("0") || !param_val[1].compare("false"))
{
@@ -126,177 +155,202 @@ CoolPropSolver::CoolPropSolver(const std::string &mediumName, const std::string
std::cout << param_val[0] << " has the value of " << param_val[1] << std::endl;
}
}
- // Handle the name and fill the fluid type
- if (debug_level > 5) std::cout << "Checking fluid " << name_options[0] << " against database." << std::endl;
- fluidType = getFluidType(name_options[0]); // Throws an error if unknown fluid
- if (debug_level > 5) std::cout << "Check passed, reducing " << substanceName << " to " << name_options[0] << std::endl;
- this->substanceName = name_options[0];
- state = new CoolPropStateClassSI(name_options[0]);
+
+ // Handle the name
+ if (debug_level > 5) std::cout << "Check passed, reducing " << substanceName << " to fluid " << this->substanceName << ", with " << backend << " backend."<< std::endl;
+
+ // Check if incompressible
+ isCompressible = (backend.find("INCOMP") == std::string::npos);
+
+ // Create the state class
+ //this->state = CoolProp::AbstractState::factory(backend, this->substanceName);
+ this->state.reset(CoolProp::AbstractState::factory(backend, this->substanceName));
+ if (this->state->using_mole_fractions()){
+ // Skip predefined mixtures and pure fluids
+ if (this->state->get_mole_fractions().empty()){
+ this->state->set_mole_fractions(*fractions_ptr);
+ }
+ } else if (this->state->using_mass_fractions()){
+ this->state->set_mass_fractions(*fractions_ptr);
+ } else if (this->state->using_volu_fractions()){
+ this->state->set_volu_fractions(*fractions_ptr);
+ } else {
+ if (debug_level > 5) std::cout << format("%s:%d: CoolPropSolver could not set composition, defaulting to mole fractions.\n",__FILE__,__LINE__);
+ this->state->set_mole_fractions(*fractions_ptr);
+ }
+
+ // ... all is set, start using the state class.
this->setFluidConstants();
}
CoolPropSolver::~CoolPropSolver(){
- delete state;
- //delete _satPropsClose2Crit;
+ //delete state;
};
void CoolPropSolver::setFluidConstants(){
- if ((fluidType==FLUID_TYPE_PURE)||(fluidType==FLUID_TYPE_PSEUDOPURE)||(fluidType==FLUID_TYPE_REFPROP)){
+ if (isCompressible){
if (debug_level > 5) std::cout << format("Setting constants for fluid %s \n",substanceName.c_str());
- _fluidConstants.pc = PropsSI((char *)"pcrit" ,(char *)"T",0,(char *)"P",0,(char *)substanceName.c_str());
- _fluidConstants.Tc = PropsSI((char *)"Tcrit" ,(char *)"T",0,(char *)"P",0,(char *)substanceName.c_str());
- _fluidConstants.MM = PropsSI((char *)"molemass",(char *)"T",0,(char *)"P",0,(char *)substanceName.c_str());
- /* TODO: Fix this dirty, dirty workaround */
- if (_fluidConstants.MM > 1.0) _fluidConstants.MM *= 1e-3;
- _fluidConstants.dc = PropsSI((char *)"rhocrit" ,(char *)"T",0,(char *)"P",0,(char *)substanceName.c_str());
+ // Theses values are part of the `trivial_keyed_output` and do not require a state update.
+ _fluidConstants.pc = state->p_critical();
+ _fluidConstants.Tc = state->T_critical();
+ _fluidConstants.MM = state->molar_mass();
+ _fluidConstants.dc = state->rhomass_critical();
// Now we fill the close to crit record
if (debug_level > 5) std::cout << format("Setting near-critical saturation conditions for fluid %s \n",substanceName.c_str());
_satPropsClose2Crit.psat = _fluidConstants.pc*(1.0-_p_eps); // Needs update, setSat_p relies on it
setSat_p(_satPropsClose2Crit.psat, &_satPropsClose2Crit);
}
- else if ((fluidType==FLUID_TYPE_INCOMPRESSIBLE_LIQUID)||(fluidType==FLUID_TYPE_INCOMPRESSIBLE_SOLUTION)){
+ else { // incompressible
if (debug_level > 5) std::cout << format("Setting constants for incompressible fluid %s \n",substanceName.c_str());
_fluidConstants.pc = NAN;
_fluidConstants.Tc = NAN;
- _fluidConstants.MM = NAN;// throws a warning in Modelica
+ _fluidConstants.MM = NAN; //state->molar_mass(); //NAN
_fluidConstants.dc = NAN;
}
}
-void CoolPropSolver::preStateChange(void) {
- /// Some common code to avoid pitfalls from incompressibles
- if ((fluidType==FLUID_TYPE_PURE)||(fluidType==FLUID_TYPE_PSEUDOPURE)||(fluidType==FLUID_TYPE_REFPROP)){
- try {
- if (enable_TTSE)
- state->enable_TTSE_LUT();
- else
- state->disable_TTSE_LUT();
-
- if (enable_BICUBIC)
- {
- state->enable_TTSE_LUT();
- state->pFluid->TTSESinglePhase.set_mode(TTSE_MODE_BICUBIC);
- }
-
- if (extend_twophase)
- state->enable_EXTTP();
- else
- state->disable_EXTTP();
- }
- catch(std::exception &e)
- {
- errorMessage((char*)e.what());
- std::cout << format("Exception from state object: %s \n",(char*)e.what());
- }
- }
-}
-
void CoolPropSolver::postStateChange(ExternalThermodynamicState *const properties) {
- /// Some common code to avoid pitfalls from incompressibles
- switch (fluidType) {
- case FLUID_TYPE_PURE:
- case FLUID_TYPE_PSEUDOPURE:
- case FLUID_TYPE_REFPROP:
- try{
- // Set the values in the output structure
- properties->p = state->p();
- properties->T = state->T();
- properties->d = state->rho();
- properties->h = state->h();
- properties->s = state->s();
- if (state->TwoPhase){
- properties->phase = 2;
- }
- else{
- properties->phase = 1;
- }
- properties->cp = state->cp();
- properties->cv = state->cv();
+ /// Some common code to avoid pitfalls from incompressibles
+ if (isCompressible)
+ {
+ try{
+ // Set the values in the output structure
+ properties->p = state->p();
+ properties->T = state->T();
+ properties->d = state->rhomass();
+ properties->h = state->hmass();
+ properties->s = state->smass();
+ if (state->phase() == CoolProp::iphase_twophase){
+ properties->phase = 2;
+ }
+ else{
+ properties->phase = 1;
+ }
+ if ((state->phase() == CoolProp::iphase_twophase) && state->Q() >= 0 && state->Q() <= twophase_derivsmoothing_xend && twophase_derivsmoothing_xend > 0.0)
+ {
+ // Use the smoothed derivatives between a quality of 0 and twophase_derivsmoothing_xend
+ properties->ddph = state->first_two_phase_deriv_splined(CoolProp::iDmass, CoolProp::iP, CoolProp::iHmass, twophase_derivsmoothing_xend); // [1/(kJ/kg) -- > 1/(J/kg)]
+ properties->ddhp = state->first_two_phase_deriv_splined(CoolProp::iDmass, CoolProp::iHmass, CoolProp::iP, twophase_derivsmoothing_xend); // [1/kPa -- > 1/Pa]
+ }
+ else if ((state->phase() == CoolProp::iphase_twophase) && state->Q() >= 0 && state->Q() <= rho_smoothing_xend && rho_smoothing_xend > 0.0)
+ {
+ // Use the smoothed density between a quality of 0 and rho_smoothing_xend
+ properties->ddph = state->first_two_phase_deriv_splined(CoolProp::iDmass, CoolProp::iP, CoolProp::iHmass, rho_smoothing_xend);
+ properties->ddhp = state->first_two_phase_deriv_splined(CoolProp::iDmass, CoolProp::iHmass, CoolProp::iP, rho_smoothing_xend);
+ properties->d = state->first_two_phase_deriv_splined(CoolProp::iDmass, CoolProp::iDmass, CoolProp::iDmass, rho_smoothing_xend);
+ }
+ else if (state->phase() == CoolProp::iphase_twophase)
+ {
+ properties->ddhp = state->first_two_phase_deriv(CoolProp::iDmass, CoolProp::iHmass, CoolProp::iP);
+ properties->ddph = state->first_two_phase_deriv(CoolProp::iDmass, CoolProp::iP, CoolProp::iHmass);
+ }
+ else
+ {
+ properties->ddhp = state->first_partial_deriv(CoolProp::iDmass, CoolProp::iHmass, CoolProp::iP);
+ properties->ddph = state->first_partial_deriv(CoolProp::iDmass, CoolProp::iP, CoolProp::iHmass);
+ }
+ // When two phases and EXTTP activated, interpolate some values from the saturated ones.
+ // Theses values have generally no physical meaning in this area.
+ if (state->phase() == CoolProp::iphase_twophase){
+ if (extend_twophase)
+ {
+ // Interpolation
+ properties->cv = interp_linear(state->Q(), state->saturated_liquid_keyed_output(CoolProp::iCvmass), state->saturated_vapor_keyed_output(CoolProp::iCvmass));
+ properties->a = interp_linear(state->Q(), state->saturated_liquid_keyed_output(CoolProp::ispeed_sound), state->saturated_vapor_keyed_output(CoolProp::ispeed_sound));
+ properties->cp = interp_linear(state->Q(), state->saturated_liquid_keyed_output(CoolProp::iCpmass), state->saturated_vapor_keyed_output(CoolProp::iCpmass));
+ //properties->kappa = interp_linear(state->Q(), state->saturated_liquid_keyed_output(CoolProp::iisothermal_compressibility), state->saturated_vapor_keyed_output(CoolProp::iisothermal_compressibility));
+ //properties->beta = interp_linear(state->Q(), state->saturated_liquid_keyed_output(CoolProp::iisobaric_expansion_coefficient), state->saturated_vapor_keyed_output(CoolProp::iisobaric_expansion_coefficient));
+ properties->kappa = NAN;
+ properties->beta = NAN;
+
+ if (calc_transport)
+ {
+ properties->eta = interp_recip(state->Q(), state->saturated_liquid_keyed_output(CoolProp::iviscosity), state->saturated_vapor_keyed_output(CoolProp::iviscosity));
+ properties->lambda = interp_linear(state->Q(), state->saturated_liquid_keyed_output(CoolProp::iconductivity), state->saturated_vapor_keyed_output(CoolProp::iconductivity));
+ }
+ else {
+ properties->eta = NAN;
+ properties->lambda = NAN;
+ }
+
+ }
+ else {
+ // No interpolation
+ properties->cv = NAN;
+ properties->a = NAN;
+ properties->cp = NAN;
+ properties->kappa = NAN;
+ properties->beta = NAN;
+ properties->eta = NAN;
+ properties->lambda = NAN;
+ }
+ }
+ else{
+ properties->cv = state->cvmass();
properties->a = state->speed_sound();
- if (state->TwoPhase && state->Q() >= 0 && state->Q() <= twophase_derivsmoothing_xend && twophase_derivsmoothing_xend > 0.0)
- {
- // Use the smoothed derivatives between a quality of 0 and twophase_derivsmoothing_xend
- properties->ddhp = state->drhodh_constp_smoothed(twophase_derivsmoothing_xend); // [1/kPa -- > 1/Pa]
- properties->ddph = state->drhodp_consth_smoothed(twophase_derivsmoothing_xend); // [1/(kJ/kg) -- > 1/(J/kg)]
- }
- else if (state->TwoPhase && state->Q() >= 0 && state->Q() <= rho_smoothing_xend && rho_smoothing_xend > 0.0)
- {
- // Use the smoothed density between a quality of 0 and rho_smoothing_xend
- double rho_spline;
- double dsplinedh;
- double dsplinedp;
- state->rho_smoothed(rho_smoothing_xend, rho_spline, dsplinedh, dsplinedp) ;
- properties->ddhp = dsplinedh;
- properties->ddph = dsplinedp;
- properties->d = rho_spline;
- }
- else
- {
- properties->ddhp = state->drhodh_constp();
- properties->ddph = state->drhodp_consth();
- }
- properties->kappa = state->isothermal_compressibility();
- properties->beta = state->isobaric_expansion_coefficient();
-
- if (calc_transport)
- {
- properties->eta = state->viscosity();
- properties->lambda = state->conductivity(); //[kW/m/K --> W/m/K]
- } else {
- properties->eta = NAN;
- properties->lambda = NAN;
- }
- }
- catch(std::exception &e)
- {
- errorMessage((char*)e.what());
- }
- break;
- case FLUID_TYPE_INCOMPRESSIBLE_LIQUID:
- case FLUID_TYPE_INCOMPRESSIBLE_SOLUTION:
- try{
- // Set the values in the output structure
- properties->p = state->p();
- properties->T = state->T();
- properties->d = state->rho();
- properties->h = state->h();
- properties->s = state->s();
- properties->phase = 1;
- properties->cp = state->cp();
- properties->cv = state->cv();
- properties->a = NAN;
- properties->ddhp = state->drhodh_constp();
- properties->ddph = 0.0; // TODO: Fix this
- properties->kappa = NAN;
- properties->beta = NAN;
- if (calc_transport)
- {
- properties->eta = state->viscosity();
- properties->lambda = state->conductivity(); //[kW/m/K --> W/m/K]
- } else {
- properties->eta = NAN;
- properties->lambda = NAN;
- }
- }
- catch(std::exception &e)
- {
- errorMessage((char*)e.what());
- }
- break;
- default:
- errorMessage((char*)"Invalid fluid type!");
- break;
- }
- if (debug_level > 50) std::cout << format("At the end of %s \n","postStateChange");
- if (debug_level > 50) std::cout << format("Setting pressure to %f \n",properties->p);
- if (debug_level > 50) std::cout << format("Setting temperature to %f \n",properties->T);
- if (debug_level > 50) std::cout << format("Setting density to %f \n",properties->d);
- if (debug_level > 50) std::cout << format("Setting enthalpy to %f \n",properties->h);
- if (debug_level > 50) std::cout << format("Setting entropy to %f \n",properties->s);
+ properties->cp = state->cpmass();
+ properties->kappa = state->isothermal_compressibility();
+ properties->beta = state->isobaric_expansion_coefficient();
+
+ if (calc_transport)
+ {
+ properties->eta = state->viscosity();
+ properties->lambda = state->conductivity(); //[kW/m/K --> W/m/K]
+ } else {
+ properties->eta = NAN;
+ properties->lambda = NAN;
+ }
+ }
+ }
+ catch(std::exception &e)
+ {
+ errorMessage((char*)e.what());
+ }
+ }
+ else // incompressible
+ {
+ try{
+ // Set the values in the output structure
+ properties->p = state->p();
+ properties->T = state->T();
+ properties->d = state->rhomass();
+ properties->h = state->hmass();
+ properties->s = state->smass();
+ properties->phase = 1;
+ properties->cp = state->cpmass();
+ properties->cv = state->cvmass();
+ properties->a = NAN;
+ properties->ddhp = state->first_partial_deriv(CoolProp::iDmass, CoolProp::iHmass, CoolProp::iP);
+ properties->ddph = state->first_partial_deriv(CoolProp::iDmass, CoolProp::iP, CoolProp::iHmass);
+ properties->kappa = NAN;
+ properties->beta = NAN;
+ if (calc_transport)
+ {
+ properties->eta = state->viscosity();
+ properties->lambda = state->conductivity(); //[kW/m/K --> W/m/K]
+ } else {
+ properties->eta = NAN;
+ properties->lambda = NAN;
+ }
+ }
+ catch(std::exception &e)
+ {
+ errorMessage((char*)e.what());
+ }
+ }
+ if (debug_level > 50)
+ {
+ std::cout << format("At the end of %s \n","postStateChange");
+ std::cout << format("Setting pressure to %f \n",properties->p);
+ std::cout << format("Setting temperature to %f \n",properties->T);
+ std::cout << format("Setting density to %f \n",properties->d);
+ std::cout << format("Setting enthalpy to %f \n",properties->h);
+ std::cout << format("Setting entropy to %f \n",properties->s);
+ }
}
@@ -321,37 +375,58 @@ void CoolPropSolver::setSat_p(double &p, ExternalSaturationProperties *const pro
properties->sl = _satPropsClose2Crit.sl; // Specific entropy at bubble line (for pressure ps)
properties->sv = _satPropsClose2Crit.sv; // Specific entropy at dew line (for pressure ps)
} else {
- this->preStateChange();
+ //this->preStateChange();
try {
- state->update(iP,p,iQ,0); // quality only matters for pseudo-pure fluids
- //! Saturation temperature
- properties->Tsat = state->TL(); // Not correct for pseudo-pure fluids
- //! Derivative of Ts wrt pressure
- properties->dTp = state->dTdp_along_sat();
- //! Derivative of dls wrt pressure
- properties->ddldp = state->drhodp_along_sat_liquid();
- //! Derivative of dvs wrt pressure
- properties->ddvdp = state->drhodp_along_sat_vapor();
- //! Derivative of hls wrt pressure
- properties->dhldp = state->dhdp_along_sat_liquid();
- //! Derivative of hvs wrt pressure
- properties->dhvdp = state->dhdp_along_sat_vapor();
- //! Density at bubble line (for pressure ps)
- properties->dl = state->rhoL();
- //! Density at dew line (for pressure ps)
- properties->dv = state->rhoV();
- //! Specific enthalpy at bubble line (for pressure ps)
- properties->hl = state->hL();
- //! Specific enthalpy at dew line (for pressure ps)
- properties->hv = state->hV();
- //! Saturation pressure
- properties->psat = p;
- //! Surface tension
- properties->sigma = state->surface_tension();
- //! Specific entropy at bubble line (for pressure ps)
- properties->sl = state->sL();
- //! Specific entropy at dew line (for pressure ps)
- properties->sv = state->sV();
+ /* Use of ancillary equations possible - fast but not 100% consistent with the rest **
+ ** properties->dl = state->saturation_ancillary(CoolProp::iDmass,0,CoolProp::iT,T); **
+ ** properties->dl = state->saturation_ancillary(CoolProp::iDmolar,0,CoolProp::iT,T)/state->molar_mass(); */
+
+ /* Use of **
+ ** state->saturated_liquid_keyed_output(CoolProp::iDmass) **
+ ** state->saturated_vapor_keyed_output(CoolProp::iDmass) **
+ ** would be interesting but this doesn't solve the derivatives */
+
+ // At bubble line:
+ state->specify_phase(CoolProp::iphase_liquid);
+ state->update(CoolProp::PQ_INPUTS,p,0);
+ //! Saturation temperature
+ properties->Tsat = state->T(); // At bubble line! (mather for pseudo-pure fluids)
+ //! Derivative of Ts wrt pressure
+ properties->dTp = state->first_saturation_deriv(CoolProp::iT, CoolProp::iP);
+ //! Derivative of dls wrt pressure
+ properties->ddldp = state->first_saturation_deriv(CoolProp::iDmass, CoolProp::iP);
+ //! Derivative of hls wrt pressure
+ properties->dhldp = state->first_saturation_deriv(CoolProp::iHmass, CoolProp::iP);
+ //! Density at bubble line (for pressure ps)
+ properties->dl = state->rhomass();
+ //! Specific enthalpy at bubble line (for pressure ps)
+ properties->hl = state->hmass();
+ //! Saturation pressure
+ properties->psat = p;
+ //! Surface tension
+ properties->sigma = state->surface_tension();
+ //! Specific entropy at bubble line (for pressure ps)
+ properties->sl = state->smass();
+
+ // At dew line:
+ state->specify_phase(CoolProp::iphase_gas);
+ state->update(CoolProp::PQ_INPUTS,p,1);
+ //! Derivative of dvs wrt pressure
+ properties->ddvdp = state->first_saturation_deriv(CoolProp::iDmass, CoolProp::iP);
+ //! Derivative of hvs wrt pressure
+ properties->dhvdp = state->first_saturation_deriv(CoolProp::iHmass, CoolProp::iP);
+ //! Density at dew line (for pressure ps)
+ properties->dv = state->rhomass();
+ //! Specific enthalpy at dew line (for pressure ps)
+ properties->hv = state->hmass();
+ //! Specific entropy at dew line (for pressure ps)
+ properties->sv = state->smass();
+ // state->specify_phase(CoolProp::iphase_not_imposed);
+
+ // Reset the state (to be sure a new one is created before computing new values):
+ state->clear();
+ state->unspecify_phase();
+
} catch(std::exception &e) {
errorMessage((char*)e.what());
}
@@ -379,28 +454,35 @@ void CoolPropSolver::setSat_T(double &T, ExternalSaturationProperties *const pro
properties->sl = _satPropsClose2Crit.sl; // Specific entropy at bubble line (for pressure ps)
properties->sv = _satPropsClose2Crit.sv; // Specific entropy at dew line (for pressure ps)
} else {
- this->preStateChange();
+ //this->preStateChange();
try
{
- state->update(iT,T,iQ,0); // Quality only matters for pseudo-pure fluids
-
- properties->Tsat = T;
- properties->psat = state->pL();
- properties->dl = state->rhoL();
- properties->dv = state->rhoV();
- properties->hl = state->hL();
- properties->hv = state->hV();
- properties->dTp = state->dTdp_along_sat();
-
- properties->ddldp = state->drhodp_along_sat_liquid();
- properties->ddvdp = state->drhodp_along_sat_vapor();
- properties->dhldp = state->dhdp_along_sat_liquid();
- properties->dhvdp = state->dhdp_along_sat_vapor();
-
- properties->sigma = state->surface_tension(); // Surface tension
- properties->sl = state->sL(); // Specific entropy at bubble line (for pressure ps)
- properties->sv = state->sV(); // Specific entropy at dew line (for pressure ps)
-
+ // Ancillary equations - fast but not 100% consistent with the rest
+ //properties->dl = state->saturation_ancillary(CoolProp::iDmass,0,CoolProp::iT,T);
+ //properties->dl = state->saturation_ancillary(CoolProp::iDmolar,0,CoolProp::iT,T)/state->molar_mass();
+
+ // At bubble line:
+ state->specify_phase(CoolProp::iphase_liquid);
+ state->update(CoolProp::QT_INPUTS,0,T);
+ properties->Tsat = T;
+ properties->psat = state->p(); // At bubble line! (mather for pseudo-pure fluids)
+ properties->dl = state->rhomass();
+ properties->hl = state->hmass();
+ properties->dTp = state->first_saturation_deriv(CoolProp::iT, CoolProp::iP);
+ properties->ddldp = state->first_saturation_deriv(CoolProp::iDmass, CoolProp::iP);
+ properties->dhldp = state->first_saturation_deriv(CoolProp::iHmass, CoolProp::iP);
+ properties->sigma = state->surface_tension(); // Surface tension
+ properties->sl = state->smass(); // Specific entropy at bubble line (for pressure ps)
+
+ // At dew line:
+ state->specify_phase(CoolProp::iphase_gas);
+ state->update(CoolProp::QT_INPUTS,1,T);
+ properties->dv = state->rhomass();
+ properties->hv = state->hmass();
+ properties->ddvdp = state->first_saturation_deriv(CoolProp::iDmass, CoolProp::iP);
+ properties->dhvdp = state->first_saturation_deriv(CoolProp::iHmass, CoolProp::iP);
+ properties->sv = state->smass(); // Specific entropy at dew line (for pressure ps)
+ // state->specify_phase(CoolProp::iphase_not_imposed);
} catch(std::exception &e) {
errorMessage((char*)e.what());
@@ -440,15 +522,15 @@ void CoolPropSolver::setState_ph(double &p, double &h, int &phase, ExternalTherm
if (debug_level > 5)
std::cout << format("setState_ph(p=%0.16e,h=%0.16e)\n",p,h);
- this->preStateChange();
+ //this->preStateChange();
try{
// Update the internal variables in the state instance
- state->update(iP,p,iH,h);
+ state->update(CoolProp::HmassP_INPUTS,h,p);
- if (!ValidNumber(state->rho()) || !ValidNumber(state->T()))
+ if (!ValidNumber(state->rhomass()) || !ValidNumber(state->T()))
{
- throw ValueError(format("p-h [%g, %g] failed for update",p,h));
+ throw CoolProp::ValueError(format("p-h [%g, %g] failed for update",p,h));
}
// Set the values in the output structure
@@ -465,11 +547,11 @@ void CoolPropSolver::setState_pT(double &p, double &T, ExternalThermodynamicStat
if (debug_level > 5)
std::cout << format("setState_pT(p=%0.16e,T=%0.16e)\n",p,T);
- this->preStateChange();
+ //this->preStateChange();
try{
// Update the internal variables in the state instance
- state->update(iP,p,iT,T);
+ state->update(CoolProp::PT_INPUTS,p,T);
// Set the values in the output structure
this->postStateChange(properties);
@@ -487,12 +569,12 @@ void CoolPropSolver::setState_dT(double &d, double &T, int &phase, ExternalTherm
if (debug_level > 5)
std::cout << format("setState_dT(d=%0.16e,T=%0.16e)\n",d,T);
- this->preStateChange();
+ //this->preStateChange();
try{
// Update the internal variables in the state instance
- state->update(iD,d,iT,T);
+ state->update(CoolProp::DmassT_INPUTS,d,T);
// Set the values in the output structure
this->postStateChange(properties);
@@ -509,11 +591,11 @@ void CoolPropSolver::setState_ps(double &p, double &s, int &phase, ExternalTherm
if (debug_level > 5)
std::cout << format("setState_ps(p=%0.16e,s=%0.16e)\n",p,s);
- this->preStateChange();
+ //this->preStateChange();
try{
// Update the internal variables in the state instance
- state->update(iP,p,iS,s);
+ state->update(CoolProp::PSmass_INPUTS,p,s);
// Set the values in the output structure
this->postStateChange(properties);
@@ -531,11 +613,11 @@ void CoolPropSolver::setState_hs(double &h, double &s, int &phase, ExternalTherm
if (debug_level > 5)
std::cout << format("setState_hs(h=%0.16e,s=%0.16e)\n",h,s);
- this->preStateChange();
+ //this->preStateChange();
try{
// Update the internal variables in the state instance
- state->update(iH,h,iS,s);
+ state->update(CoolProp::HmassSmass_INPUTS,h,s);
// Set the values in the output structure
this->postStateChange(properties);
@@ -555,9 +637,9 @@ double CoolPropSolver::partialDeriv_state(const string &of, const string &wrt, c
try{
//res = DerivTerms(derivTerm, properties->d, properties->T, this->substanceName);
- state->update(iT,properties->T,iD,properties->d);
+ state->update(CoolProp::DmassT_INPUTS,properties->d,properties->T);
// Get the output value
- res = state->keyed_output(derivTerm);
+ res = state->keyed_output(static_cast(derivTerm));
} catch(std::exception &e) {
errorMessage((char*)e.what());
}
@@ -583,7 +665,7 @@ long CoolPropSolver::makeDerivString(const string &of, const string &wrt, const
else {
errorMessage((char*) format("Internal error: Derivatives at constant %s are not defined in the Solver object.",cst.c_str()).c_str());
}
- long iOutput = get_param_index(derivTerm);
+ long iOutput = CoolProp::get_parameter_index(derivTerm.c_str());
return iOutput;
}
@@ -618,15 +700,15 @@ double CoolPropSolver::beta(ExternalThermodynamicState *const properties){
double CoolPropSolver::cp(ExternalThermodynamicState *const properties){
// Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: cp() not implemented in the Solver object");
- //throw NotImplementedError((char*)"Internal error: cp() not implemented in the Solver object");
+ errorMessage((char*)"Internal error: cpmass() not implemented in the Solver object");
+ //throw NotImplementedError((char*)"Internal error: cpmass() not implemented in the Solver object");
return NAN;
}
double CoolPropSolver::cv(ExternalThermodynamicState *const properties){
// Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: cv() not implemented in the Solver object");
- //throw NotImplementedError((char*)"Internal error: cv() not implemented in the Solver object");
+ errorMessage((char*)"Internal error: cvmass() not implemented in the Solver object");
+ //throw NotImplementedError((char*)"Internal error: cvmass() not implemented in the Solver object");
return NAN;
}
@@ -660,8 +742,8 @@ double CoolPropSolver::eta(ExternalThermodynamicState *const properties){
double CoolPropSolver::h(ExternalThermodynamicState *const properties){
// Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: h() not implemented in the Solver object");
- //throw NotImplementedError((char*)"Internal error: h() not implemented in the Solver object");
+ errorMessage((char*)"Internal error: hmass() not implemented in the Solver object");
+ //throw NotImplementedError((char*)"Internal error: hmass() not implemented in the Solver object");
return NAN;
}
@@ -695,8 +777,8 @@ int CoolPropSolver::phase(ExternalThermodynamicState *const properties){
double CoolPropSolver::s(ExternalThermodynamicState *const properties){
// Base function returns an error if called - should be redeclared by the solver object
- errorMessage((char*)"Internal error: s() not implemented in the Solver object");
- //throw NotImplementedError((char*)"Internal error: s() not implemented in the Solver object");
+ errorMessage((char*)"Internal error: smass() not implemented in the Solver object");
+ //throw NotImplementedError((char*)"Internal error: smass() not implemented in the Solver object");
return NAN;
}
@@ -812,3 +894,12 @@ double CoolPropSolver::Tsat(ExternalSaturationProperties *const properties){
return NAN;
}
+/// Interpolation routines
+double CoolPropSolver::interp_linear(double Q, double valueL, double valueV) {
+ return valueL+Q*(valueV-valueL);
+}
+double CoolPropSolver::interp_recip(double Q, double valueL, double valueV){
+ return 1.0 / interp_linear(Q, 1.0/valueL, 1.0/valueV);
+}
+
+#endif
diff --git a/Projects/Sources/coolpropsolver.h b/Projects/Sources/coolpropsolver.h
index e79c3e98..9ec011ea 100755
--- a/Projects/Sources/coolpropsolver.h
+++ b/Projects/Sources/coolpropsolver.h
@@ -1,7 +1,12 @@
#ifndef COOLPROPSOLVER_H_
#define COOLPROPSOLVER_H_
+#include "include.h"
+#if (EXTERNALMEDIA_COOLPROP == 1)
+
#include "basesolver.h"
+#include "AbstractState.h"
+#include "crossplatform_shared_ptr.h"
//! CoolProp solver class
/*!
@@ -25,19 +30,20 @@
class CoolPropSolver : public BaseSolver{
protected:
- class CoolPropStateClassSI *state;
- bool enable_TTSE, enable_BICUBIC, calc_transport, extend_twophase;
+ //class CoolProp::AbstractState *state;
+ shared_ptr state;
+ bool enable_TTSE, enable_BICUBIC, calc_transport, extend_twophase, isCompressible;
int debug_level;
double twophase_derivsmoothing_xend;
double rho_smoothing_xend;
- long fluidType;
double _p_eps ; // relative tolerance margin for subcritical pressure conditions
double _delta_h ; // delta_h for one-phase/two-phase discrimination
ExternalSaturationProperties _satPropsClose2Crit; // saturation properties close to critical conditions
- virtual void preStateChange(void);
virtual void postStateChange(ExternalThermodynamicState *const properties);
long makeDerivString(const string &of, const string &wrt, const string &cst);
+ double interp_linear(double Q, double valueL, double valueV);
+ double interp_recip(double Q, double valueL, double valueV);
public:
CoolPropSolver(const std::string &mediumName, const std::string &libraryName, const std::string &substanceName);
@@ -95,4 +101,6 @@ class CoolPropSolver : public BaseSolver{
};
+#endif
+
#endif // COOLPROPSOLVER_H_
diff --git a/Projects/Sources/documentation.h b/Projects/Sources/documentation.h
deleted file mode 100644
index 42475b7c..00000000
--- a/Projects/Sources/documentation.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/*!
- \mainpage External Media HowTo
-
- \section intro_sec Introduction
-
- The ExternalMedia project was started in 2006 by Francesco Casella and
- Christoph Richter, with the aim of providing a framework for interfacing
- external codes computing fluid properties to Modelica.Media-compatible
- component models. The two main requirements are: maximizing the efficiency
- of the code and minimizing the amount of extra code required to use your
- own external code within the framework.
-
- The first implementation featured a hidden cache in the C++ layer and used
- integer unique IDs to reference that cache. This architecture worked well
- if the models did not contain implicit algebraic equations involving medium
- properties, but had serious issues when such equations were involved, which
- is often the case when solving steady-state initialization problems.
-
- The library has been restructured in 2012 by Francesco Casella and Roberto
- Bonifetto. The main idea has been to get rid of the hidden cache and of the
- unique ID references and use the Modelica state records for caching. In this
- way, all optimizations performed by Modelica tools are guaranteed to give
- correct results, which was previously not the case. The current
- version implements the Modelica.Media.Interfaces.PartialTwoPhaseMedium
- interface, so it can handle pure fluids, either one-phase or two-phase,
- and is compatible with Modelica and Modelica Standard Library 3.2. Please note
- that the paths of the medium packages have been changed from the previous
- versions, so you might need some small changes if you want to upgrade your
- models from previous versions of the ExternalMedia library.
-
- There are two ways to use this library. The easiest way is to use the
- releases available on the Modelica website, which include a pre-compiled
- interface to the FluidProp tool (http://www.fluidprop.com). FluidProp features
- many built-in fluid models, and can optionally be used to access the whole
- NIST RefProp database, thus giving easy access to a wide range of fluid models
- with state-of-the-art accuracy. If you want to use your own fluid property
- computation code instead, then you need to check out the source code and
- add the interface to it, as described in this manual.
-
- Please contact the main developer, Francesco Casella
- (casella@elet.polimi.it)
- if you have questions or suggestions for improvement.
-
- Licensed by the Modelica Association under the Modelica License 2
-
- Copyright (c) 2006-2012, Politecnico di Milano, TU Braunschweig, Politecnico
- di Torino.
-
- \section releases_sec Using the pre-packaged releases with FluidProp
-
- Download and install the latest version of FluidProp from
- http://www.fluidprop.com.
- If you want to use the RefProp fluid models,
- you need to get the full version of FluidProp, which has an extra license fee.
-
- Download and unzip the library corresponding to the version of Microsoft Visual Studio
- that you use to compile your Modelica models, in order to avoid linker errors.
- Make sure that you load the ExternalMedia library in your Modelica tool
- workspace, e.g. by opening the main package.mo file.
-
- You can now define medium models for the different libraries supported by FluidProp,
- by extending the ExternalMedia.Media.FluidPropMedium package. Please note that
- only single-component fluids are supported. Set libraryName
- to "FluidProp.RefProp", "FluidProp.StanMix", "FluidProp.TPSI", or "FluidProp.IF97",
- depending on the specific library you need to use.
- Set substanceNames to a single-element string array containing the name
- of the specific medium, as specified by the FluidProp documentation. Set
- mediumName to a string that describes the medium (this only used for
- documentation purposes but has no effect in selecting the medium model).
- See ExternalMedia.Examples for examples.
-
- Please note that the medium model IF97 is already available
- natively in Modelica.Media as Water.StandardWater, which is much faster than
- the FluidProp version. If you need ideal gas models (single-component or
- mixtures), use the medium packages contained in Modelica.Media.IdealGases.
-
- \section architecture_sec Architecture of the package
-
- This section gives an overview of the package structure, in order to help
- you understand how to interface your own code to Modelica using it.
-
- At the top level there is a Modelica package (ExternalMedia), which
- contains all the basic infrastructure needed to use external fluid
- properties computation software through a Modelica.Media compliant
- interface. In particular, the
- ExternalMedia.Media.ExternalTwoPhaseMedium package is a full-fledged
- implementation of a two-phase medium model, compliant with the
- Modelica.Media.Interfaces.PartialTwoPhaseMedium interface. The
- ExternalTwoPhaseMedium package can be used with any external fluid
- property computation software; the specific software to be used is
- specified by changing the libraryName package constant, which is then
- handled by the underlying C code to select the appropriate external
- code to use.
-
- The Modelica functions within ExternalTwoPhaseMedium communicate to a
- C/C++ interface layer (called externalmedialib.cpp) via external C functions
- calls, which in turn make use of C++ objects. This layer takes care of
- initializing the external fluid computation codes, called solvers from now on.
- Every solver is wrapped by a C++ class, inheriting from the BaseSolver C++
- class. The C/C++ layer maintains a set of active solvers, one for each
- different combination of the libraryName and mediumName strings, by means of
- the SolverMap C++ class. The key to each solver in the map is given by those
- strings. It is then possible to use multiple instances of many solvers in the
- same Modelica model at the same time.
-
- All the external C functions pass the libraryName, mediumName and substanceNames
- strings to the corresponding functions of the interface layer. These in turn
- use the SolverMap object to look for an active solver in the solver map,
- corresponding to those strings. If one is found, the corresponding function
- of the solver is called, otherwise a new solver object is instantiated and
- added to the map, before calling the corresponding function of the solver.
-
- The default implementation of an external medium model is implemented by the
- ExternalTwoPhaseMedium Modelica package. The setState_xx() and setSat_x()
- function calls are rerouted to the corresponding functions of the solver
- object. These compute all the required properties and return them in the
- ExternalThermodynamicState and ExternalSaturationProperties C structs, which
- map onto the corresponding ThermodynamicState and SaturationProperties
- records defined in ExternalTwoPhaseMedium. All the functions returning
- properties as a function of the state records are implemented in Modelica and
- simply return the corresponding element in the state record, which acts as
- a cache. This is an efficient implementation for many complex fluid models,
- where most of the CPU time is spent solving the basic equation of state, while
- the computation of all derived properties adds a minor overhead, so it makes
- sense to compute them once and for all when the setState_XX() or setSat_xx()
- functions are called.
-
- In case some of the thermodynamic properties require a significant amount of
- CPU time on their own, it is possible to override this default implementation.
- On one hand, it is necessary to extend the ExternalTwoPhaseMedium Modelica
- package and redeclare those functions, so that they call the corresponding
- external C functions defined in externalmedium.cpp, instead of returning the
- value cached in the state record. On the other hand, it
- is also necessary to provide an implementation of the corresponding functions
- in the C++ solver object, by overriding the virtual functions of the
- BaseSolver object. In this case, the setState_xx() and setSat_X() functions
- need not compute all the values of the cache state records; uncomputed
- properties might be set to zero. This is not a problem, since Modelica.Media
- compatible models should never access the elements of the state records
- directly, but only through the appropriate functions, so these values should
- never be actually used by component models using the medium package.
-
- \section development_sec Developing your own external medium package
-
- The ExternalMedia package has been designed to ease your task, so that
- you will only have to write the mimum amount of code which is strictly
- specific to your external code - everything else is already provided.
- The following instructions apply if you want to develop an external
- medium model which include a (sub)set of the functions defined in
- Modelica.Media.Interfaces.PartialTwoPhaseMedium.
-
- The most straightforward implementation is the one in which all fluid
- properties are computed at once by the setState_XX() and setSat_X() functions
- and all the other functions return the values cached in the state records.
-
- Get the source code from the SVN repository of the Modelica Association:
-
- https://svn.modelica.org/projects/ExternalMediaLibrary/trunk.
-
- First of all, you have to write you own solver object code: you can
- look at the code of the TestMedium and FluidPropMedium code as
- examples. Inherit from the BaseSolver object, which provides default
- implementations for most of the required functions, and then just add
- your own implementation for the following functions: object
- constructor, object destructor, setMediumConstants(), setSat_p(),
- setSat_T(), setState_ph(), setState_pT(), setState_ps(), setState_dT().
- Note that the setState and setSat functions need to compute and fill in all
- the fields of the corresponding C structs for the library to work correctly.
- On the other hand, you don't necessarily need to implement all of the four
- setState functions: if you know in advance that your models will only
- use certain combinations of variables as inputs (e.g. p, h), then
- you might omit implementing the setState and setSat functions corresponding
- to the other ones.
-
- Then you must modify the SolverMap::addSolver() function, so that it
- will instantiate your new solver when it is called with the appropriate
- libraryName string. You are free to invent you own syntax for the
- libraryName string, in case you'd like to be able to set up the
- external medium with some additional configuration data from within
- Modelica - it is up to you to decode that syntax within the addSolver()
- function, and within the constructor of your solver object. Look at how the
- FluidProp solver is implemented for an example.
-
- Finally, add the .cpp and .h files of the solver object to the C/C++ project,
- set the include.h file according to your needs and recompile it to a
- static library (or to a DLL). The compiled libraries and the externalmedialib.h
- files must then be copied into the Include subdirectory of the Modelica package
- so that the Modelica tool can link them when compiling the models.
-
- As already mentioned in the previous section, you might provide customized
- implementations where some of the properties are not computed by the setState
- and setSat functions and stored in the cache records, but rather computed
- on demand, based on a smaller set of thermodynamic properties computed by the
- setState and setSat functions and stored in the state C struct.
-
- Please note that compiling ExternalMedia from source code might require
- the professional version of Microsoft Visual Studio, which includes the
- COM libraries used by the FluidProp interface. However, if you remove
- all the FluidProp files and references from the project, then you should be
- able to compile the source code with the Express edition, or possibly also
- with gcc.
-*/
\ No newline at end of file
diff --git a/Projects/Sources/errorhandling.cpp b/Projects/Sources/errorhandling.cpp
index 261efc87..45e4a865 100644
--- a/Projects/Sources/errorhandling.cpp
+++ b/Projects/Sources/errorhandling.cpp
@@ -1,51 +1,45 @@
-/* *****************************************************************
- * Implementation of the error reporting functions
- *
- * The actual implementation depends on the selected preprocessor
- * variable defined in include.h
- *
- * Francesco Casella, Christoph Richter, Nov 2006
- ********************************************************************/
-
-#include "errorhandling.h"
-#include
-#include
-#include
-
-#if (DYMOLA == 1) || (OPENMODELICA == 1)
-#if (BUILD_DLL == 0)
-// This implementation uses the native Modelica tool log and error window to report errors
-void errorMessage(char *errorMessage){
- ModelicaError(errorMessage);
-}
-
-void warningMessage(char *warningMessage){
- ModelicaMessage(warningMessage);
-}
-#else
-// The Dymola specific implementation does currently not work for dynmic link libraries
-void errorMessage(char *errorMessage){
- printf("\a%s\nPress the Stop button in Dymola to end the simulation!\n", errorMessage);
- getchar();
- exit(1);
-}
-
-void warningMessage(char *warningMessage){
- strcat(warningMessage, "\n");
- printf("%s",warningMessage);
-}
-#endif
-#else
-// This is the default section
-// Error and warnings are sent to the standard output
-void errorMessage(char *errorMessage){
- printf("\a%s\nPress the stop button in Dymola to end the simulation!\n", errorMessage);
- getchar();
- exit(1);
-}
-
-void warningMessage(char *warningMessage){
- strcat(warningMessage, "\n");
- printf("%s",warningMessage);
-}
-#endif
+/* *****************************************************************
+ * Implementation of the error reporting functions
+ *
+ * The actual implementation depends on the selected preprocessor
+ * variable defined in include.h
+ *
+ * Francesco Casella, Christoph Richter, Nov 2006
+ ********************************************************************/
+
+#include "errorhandling.h"
+#include "include.h"
+#include
+#include
+#include
+
+#ifndef EXTERNALMEDIA_MODELICA_ERRORS
+#define EXTERNALMEDIA_MODELICA_ERRORS 1
+#endif
+// The Dymola specific implementation does currently not work for dynamic link libraries
+#if (EXTERNALMEDIA_MODELICA_ERRORS == 1)
+extern "C" {
+#include "ModelicaUtilities.h"
+}
+// This implementation uses the native Modelica tool log and error window to report errors
+void errorMessage(char *errorMessage){
+ ModelicaError(errorMessage);
+}
+
+void warningMessage(char *warningMessage){
+ ModelicaMessage(warningMessage);
+}
+#else
+// This is the default section
+// Error and warnings are sent to the standard output
+void errorMessage(char *errorMessage){
+ printf("\a%s\nAn error occurred and the calculation cannot continue, please terminate your simulation manually.\n", errorMessage);
+ getchar();
+ exit(1);
+}
+
+void warningMessage(char *warningMessage){
+ strcat(warningMessage, "\n");
+ printf("%s",warningMessage);
+}
+#endif
\ No newline at end of file
diff --git a/Projects/Sources/errorhandling.h b/Projects/Sources/errorhandling.h
index f3db2d0b..ae2d85a1 100644
--- a/Projects/Sources/errorhandling.h
+++ b/Projects/Sources/errorhandling.h
@@ -1,40 +1,30 @@
-/*!
- \file errorhandling.h
- \brief Error handling for external library
-
- Errors in the external fluid property library have to be reported
- to the Modelica layer. This class defines the required interface
- functions.
-
- Francesco Casella, Christoph Richter, Nov 2006
- Copyright Politecnico di Milano and TU Braunschweig
-*/
-
-#ifndef ERRORHANDLING_H_
-#define ERRORHANDLING_H_
-
-#include "include.h"
-
-#if (DYMOLA == 1)
-#if (BUILD_DLL == 0)
-extern "C" {
-#include "ModelicaUtilities.h"
-}
-#endif // BUILD_DLL == 0
-#endif
-
-//! Function to display error message
-/*!
- Calling this function will display the specified error message and will
- terminate the simulation.
- @param errorMessage Error message to be displayed
-*/
-void errorMessage(char *errorMessage);
-//! Function to display warning message
-/*!
- Calling this function will display the specified warning message.
- @param warningMessage Warning message to be displayed
-*/
-void warningMessage(char *warningMessage);
-
-#endif // ERRORHANDLING_H_
+/*!
+ \file errorhandling.h
+ \brief Error handling for external library
+
+ Errors in the external fluid property library have to be reported
+ to the Modelica layer. This class defines the required interface
+ functions.
+
+ Francesco Casella, Christoph Richter, Nov 2006
+ Copyright Politecnico di Milano and TU Braunschweig
+*/
+
+#ifndef ERRORHANDLING_H_
+#define ERRORHANDLING_H_
+
+//! Function to display error message
+/*!
+ Calling this function will display the specified error message and will
+ terminate the simulation.
+ @param errorMessage Error message to be displayed
+*/
+void errorMessage(char *errorMessage);
+//! Function to display warning message
+/*!
+ Calling this function will display the specified warning message.
+ @param warningMessage Warning message to be displayed
+*/
+void warningMessage(char *warningMessage);
+
+#endif // ERRORHANDLING_H_
diff --git a/Projects/Sources/externalmedialib.cpp b/Projects/Sources/externalmedialib.cpp
index 8fc9a86d..285e1125 100644
--- a/Projects/Sources/externalmedialib.cpp
+++ b/Projects/Sources/externalmedialib.cpp
@@ -1,537 +1,537 @@
-/*
- C/C++ layer for external medium models extending from
- PartialExternalTwoPhaseMedium.
-*/
-
-#include "externalmedialib.h"
-#include "basesolver.h"
-#include "solvermap.h"
-#include
-
-//! Get molar mass
-/*!
- This function returns the molar mass of the specified medium.
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-double TwoPhaseMedium_getMolarMass_C_impl(const char *mediumName, const char *libraryName, const char *substanceName){
- // Return molar mass
- return SolverMap::getSolver(mediumName, libraryName, substanceName)->molarMass();
-}
-
-//! Get critical temperature
-/*!
- This function returns the critical temperature of the specified medium.
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-double TwoPhaseMedium_getCriticalTemperature_C_impl(const char *mediumName, const char *libraryName, const char *substanceName){
- // Return critical temperature
- return SolverMap::getSolver(mediumName, libraryName, substanceName)->criticalTemperature();
-}
-
-//! Get critical pressure
-/*!
- This function returns the critical pressure of the specified medium.
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-double TwoPhaseMedium_getCriticalPressure_C_impl(const char *mediumName, const char *libraryName, const char *substanceName){
- // Return critical pressure
- return SolverMap::getSolver(mediumName, libraryName, substanceName)->criticalPressure();
-}
-
-//! Get critical molar volume
-/*!
- This function returns the critical molar volume of the specified medium.
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-double TwoPhaseMedium_getCriticalMolarVolume_C_impl(const char *mediumName, const char *libraryName, const char *substanceName){
- // Return critical molar volume
- return SolverMap::getSolver(mediumName, libraryName, substanceName)->criticalMolarVolume();
-}
-
-//! Compute properties from p, h, and phase
-/*!
- This function computes the properties for the specified inputs.
- @param p Pressure
- @param h Specific enthalpy
- @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
- @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-void TwoPhaseMedium_setState_ph_C_impl(double p, double h, int phase, ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- solver->setState_ph(p, h, phase, state);
-}
-
-//! Compute properties from p and T
-/*!
- This function computes the properties for the specified inputs.
-
- Attention: The phase input is ignored for this function!
- @param p Pressure
- @param T Temperature
- @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-void TwoPhaseMedium_setState_pT_C_impl(double p, double T, ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- solver->setState_pT(p, T, state);
-}
-
-//! Compute properties from d, T, and phase
-/*!
- This function computes the properties for the specified inputs.
- @param d Density
- @param T Temperature
- @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
- @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-void TwoPhaseMedium_setState_dT_C_impl(double d, double T, int phase, ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- solver->setState_dT(d, T, phase, state);
-}
-
-//! Compute properties from p, s, and phase
-/*!
- This function computes the properties for the specified inputs.
- @param p Pressure
- @param s Specific entropy
- @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
- @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-void TwoPhaseMedium_setState_ps_C_impl(double p, double s, int phase, ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- solver->setState_ps(p, s, phase, state);
-}
-
-//! Compute properties from h, s, and phase
-/*!
- This function computes the properties for the specified inputs.
- @param h Specific enthalpy
- @param s Specific entropy
- @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
- @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-void TwoPhaseMedium_setState_hs_C_impl(double h, double s, int phase, ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- solver->setState_hs(h, s, phase, state);
-}
-
-//! Compute partial derivative from a populated state record
-/*!
- This function computes the derivative of the specified input.
- @param of Property to differentiate
- @param wrt Property to differentiate in
- @param cst Property to remain constant
- @param state Pointer to input values in state record
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-double TwoPhaseMedium_partialDeriv_state_C_impl(const char *of, const char *wrt, const char *cst,
- ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->partialDeriv_state(of, wrt, cst, state);
-}
-
-
-//! Return Prandtl number of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_prandtlNumber_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->Pr(state);
-}
-
-//! Return temperature of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_temperature_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->T(state);
-}
-
-//! Return velocity of sound of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_velocityOfSound_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->a(state);
-}
-
-//! Return isobaric expansion coefficient of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_isobaricExpansionCoefficient_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->beta(state);
-}
-
-//! Return specific heat capacity cp of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_specificHeatCapacityCp_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->cp(state);
-}
-
-//! Return specific heat capacity cv of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_specificHeatCapacityCv_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->cv(state);
-}
-
-//! Return density of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_density_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->d(state);
-}
-
-//! Return derivative of density wrt specific enthalpy at constant pressure of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_density_derh_p_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->ddhp(state);
-}
-
-//! Return derivative of density wrt pressure at constant specific enthalpy of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_density_derp_h_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->ddph(state);
-}
-
-//! Return dynamic viscosity of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_dynamicViscosity_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->eta(state);
-}
-
-//! Return specific enthalpy of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_specificEnthalpy_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->h(state);
-}
-
-//! Return isothermal compressibility of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_isothermalCompressibility_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->kappa(state);
-}
-
-//! Return thermal conductivity of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_thermalConductivity_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->lambda(state);
-}
-
-//! Return pressure of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_pressure_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->p(state);
-}
-
-//! Return specific entropy of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_specificEntropy_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->s(state);
-}
-
-//! Return derivative of density wrt pressure and specific enthalpy of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_density_ph_der_C_impl(ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->d_der(state);
-}
-
-//! Return the enthalpy at pressure p after an isentropic transformation from the specified medium state
-double TwoPhaseMedium_isentropicEnthalpy_C_impl(double p_downstream, ExternalThermodynamicState *refState,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->isentropicEnthalpy(p_downstream, refState);
-}
-
-//! Compute saturation properties from p
-/*!
- This function computes the saturation properties for the specified inputs.
- @param p Pressure
- @param ExternalSaturationProperties Pointer to return values for ExternalSaturationProperties struct
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-void TwoPhaseMedium_setSat_p_C_impl(double p, ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- solver->setSat_p(p, sat);
-}
-
-//! Compute saturation properties from T
-/*!
- This function computes the saturation properties for the specified inputs.
- @param T Temperature
- @param ExternalSaturationProperties Pointer to return values for ExternalSaturationProperties struct
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-void TwoPhaseMedium_setSat_T_C_impl(double T, ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- solver->setSat_T(T, sat);
-}
-
-//! Compute bubble state
-/*!
- This function computes the bubble state for the specified medium.
- @param ExternalSaturationProperties Pointer to values of ExternalSaturationProperties struct
- @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
- @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-void TwoPhaseMedium_setBubbleState_C_impl(ExternalSaturationProperties *sat, int phase, ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- solver->setBubbleState(sat, phase, state);
-}
-
-//! Compute dew state
-/*!
- This function computes the dew state for the specified medium.
- @param ExternalSaturationProperties Pointer to values of ExternalSaturationProperties struct
- @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
- @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
- @param mediumName Medium name
- @param libraryName Library name
- @param substanceName Substance name
-*/
-void TwoPhaseMedium_setDewState_C_impl(ExternalSaturationProperties *sat, int phase, ExternalThermodynamicState *state,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- solver->setDewState(sat, phase, state);
-}
-
-//! Compute saturation temperature for specified medium and pressure
-double TwoPhaseMedium_saturationTemperature_C_impl(double p, const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- ExternalSaturationProperties sat;
- solver->setSat_p(p, &sat);
- return sat.Tsat;
-}
-
-//! Compute derivative of saturation temperature for specified medium and pressure
-double TwoPhaseMedium_saturationTemperature_derp_C_impl(double p, const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- ExternalSaturationProperties sat;
- solver->setSat_p(p, &sat);
- return sat.dTp;
-}
-
-//! Return derivative of saturation temperature of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_saturationTemperature_derp_sat_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->dTp(sat);
-}
-
-//! Return derivative of bubble density wrt pressure of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_dBubbleDensity_dPressure_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->ddldp(sat);
-}
-
-//! Return derivative of dew density wrt pressure of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_dDewDensity_dPressure_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->ddvdp(sat);
-}
-
-//! Return derivative of bubble specific enthalpy wrt pressure of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_dBubbleEnthalpy_dPressure_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->dhldp(sat);
-}
-
-//! Return derivative of dew specific enthalpy wrt pressure of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_dDewEnthalpy_dPressure_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->dhvdp(sat);
-}
-
-//! Return bubble density of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_bubbleDensity_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->dl(sat);
-}
-
-//! Return dew density of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_dewDensity_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->dv(sat);
-}
-
-//! Return bubble specific enthalpy of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_bubbleEnthalpy_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->hl(sat);
-}
-
-//! Return dew specific enthalpy of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_dewEnthalpy_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->hv(sat);
-}
-
-//! Compute saturation pressure for specified medium and temperature
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_saturationPressure_C_impl(double T, const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- ExternalSaturationProperties sat;
- solver->setSat_T(T, &sat);
- return sat.psat;
-}
-
-//! Return surface tension of specified medium
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_surfaceTension_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->sigma(sat);
-}
-
-//! Return bubble specific entropy of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_bubbleEntropy_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->sl(sat);
-}
-
-//! Return dew specific entropy of specified medium from saturation properties
-/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
- It might be used by external medium models customized solvers redeclaring the default functions
-*/
-double TwoPhaseMedium_dewEntropy_C_impl(ExternalSaturationProperties *sat,
- const char *mediumName, const char *libraryName, const char *substanceName){
- BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
- return solver->sv(sat);
-}
+/*
+ C/C++ layer for external medium models extending from
+ PartialExternalTwoPhaseMedium.
+*/
+
+#include "externalmedialib.h"
+#include "basesolver.h"
+#include "solvermap.h"
+#include
+
+//! Get molar mass
+/*!
+ This function returns the molar mass of the specified medium.
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+double TwoPhaseMedium_getMolarMass_C_impl(const char *mediumName, const char *libraryName, const char *substanceName){
+ // Return molar mass
+ return SolverMap::getSolver(mediumName, libraryName, substanceName)->molarMass();
+}
+
+//! Get critical temperature
+/*!
+ This function returns the critical temperature of the specified medium.
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+double TwoPhaseMedium_getCriticalTemperature_C_impl(const char *mediumName, const char *libraryName, const char *substanceName){
+ // Return critical temperature
+ return SolverMap::getSolver(mediumName, libraryName, substanceName)->criticalTemperature();
+}
+
+//! Get critical pressure
+/*!
+ This function returns the critical pressure of the specified medium.
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+double TwoPhaseMedium_getCriticalPressure_C_impl(const char *mediumName, const char *libraryName, const char *substanceName){
+ // Return critical pressure
+ return SolverMap::getSolver(mediumName, libraryName, substanceName)->criticalPressure();
+}
+
+//! Get critical molar volume
+/*!
+ This function returns the critical molar volume of the specified medium.
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+double TwoPhaseMedium_getCriticalMolarVolume_C_impl(const char *mediumName, const char *libraryName, const char *substanceName){
+ // Return critical molar volume
+ return SolverMap::getSolver(mediumName, libraryName, substanceName)->criticalMolarVolume();
+}
+
+//! Compute properties from p, h, and phase
+/*!
+ This function computes the properties for the specified inputs.
+ @param p Pressure
+ @param h Specific enthalpy
+ @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
+ @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+void TwoPhaseMedium_setState_ph_C_impl(double p, double h, int phase, ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ solver->setState_ph(p, h, phase, state);
+}
+
+//! Compute properties from p and T
+/*!
+ This function computes the properties for the specified inputs.
+
+ Attention: The phase input is ignored for this function!
+ @param p Pressure
+ @param T Temperature
+ @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+void TwoPhaseMedium_setState_pT_C_impl(double p, double T, ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ solver->setState_pT(p, T, state);
+}
+
+//! Compute properties from d, T, and phase
+/*!
+ This function computes the properties for the specified inputs.
+ @param d Density
+ @param T Temperature
+ @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
+ @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+void TwoPhaseMedium_setState_dT_C_impl(double d, double T, int phase, ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ solver->setState_dT(d, T, phase, state);
+}
+
+//! Compute properties from p, s, and phase
+/*!
+ This function computes the properties for the specified inputs.
+ @param p Pressure
+ @param s Specific entropy
+ @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
+ @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+void TwoPhaseMedium_setState_ps_C_impl(double p, double s, int phase, ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ solver->setState_ps(p, s, phase, state);
+}
+
+//! Compute properties from h, s, and phase
+/*!
+ This function computes the properties for the specified inputs.
+ @param h Specific enthalpy
+ @param s Specific entropy
+ @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
+ @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+void TwoPhaseMedium_setState_hs_C_impl(double h, double s, int phase, ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ solver->setState_hs(h, s, phase, state);
+}
+
+//! Compute partial derivative from a populated state record
+/*!
+ This function computes the derivative of the specified input.
+ @param of Property to differentiate
+ @param wrt Property to differentiate in
+ @param cst Property to remain constant
+ @param state Pointer to input values in state record
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+double TwoPhaseMedium_partialDeriv_state_C_impl(const char *of, const char *wrt, const char *cst,
+ ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->partialDeriv_state(of, wrt, cst, state);
+}
+
+
+//! Return Prandtl number of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_prandtlNumber_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->Pr(state);
+}
+
+//! Return temperature of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_temperature_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->T(state);
+}
+
+//! Return velocity of sound of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_velocityOfSound_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->a(state);
+}
+
+//! Return isobaric expansion coefficient of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_isobaricExpansionCoefficient_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->beta(state);
+}
+
+//! Return specific heat capacity cp of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_specificHeatCapacityCp_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->cp(state);
+}
+
+//! Return specific heat capacity cv of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_specificHeatCapacityCv_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->cv(state);
+}
+
+//! Return density of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_density_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->d(state);
+}
+
+//! Return derivative of density wrt specific enthalpy at constant pressure of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_density_derh_p_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->ddhp(state);
+}
+
+//! Return derivative of density wrt pressure at constant specific enthalpy of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_density_derp_h_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->ddph(state);
+}
+
+//! Return dynamic viscosity of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_dynamicViscosity_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->eta(state);
+}
+
+//! Return specific enthalpy of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_specificEnthalpy_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->h(state);
+}
+
+//! Return isothermal compressibility of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_isothermalCompressibility_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->kappa(state);
+}
+
+//! Return thermal conductivity of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_thermalConductivity_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->lambda(state);
+}
+
+//! Return pressure of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_pressure_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->p(state);
+}
+
+//! Return specific entropy of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_specificEntropy_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->s(state);
+}
+
+//! Return derivative of density wrt pressure and specific enthalpy of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_density_ph_der_C_impl(ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->d_der(state);
+}
+
+//! Return the enthalpy at pressure p after an isentropic transformation from the specified medium state
+double TwoPhaseMedium_isentropicEnthalpy_C_impl(double p_downstream, ExternalThermodynamicState *refState,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->isentropicEnthalpy(p_downstream, refState);
+}
+
+//! Compute saturation properties from p
+/*!
+ This function computes the saturation properties for the specified inputs.
+ @param p Pressure
+ @param ExternalSaturationProperties Pointer to return values for ExternalSaturationProperties struct
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+void TwoPhaseMedium_setSat_p_C_impl(double p, ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ solver->setSat_p(p, sat);
+}
+
+//! Compute saturation properties from T
+/*!
+ This function computes the saturation properties for the specified inputs.
+ @param T Temperature
+ @param ExternalSaturationProperties Pointer to return values for ExternalSaturationProperties struct
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+void TwoPhaseMedium_setSat_T_C_impl(double T, ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ solver->setSat_T(T, sat);
+}
+
+//! Compute bubble state
+/*!
+ This function computes the bubble state for the specified medium.
+ @param ExternalSaturationProperties Pointer to values of ExternalSaturationProperties struct
+ @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
+ @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+void TwoPhaseMedium_setBubbleState_C_impl(ExternalSaturationProperties *sat, int phase, ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ solver->setBubbleState(sat, phase, state);
+}
+
+//! Compute dew state
+/*!
+ This function computes the dew state for the specified medium.
+ @param ExternalSaturationProperties Pointer to values of ExternalSaturationProperties struct
+ @param phase Phase (2 for two-phase, 1 for one-phase, 0 if not known)
+ @param ExternalThermodynamicState Pointer to return values for ExternalThermodynamicState struct
+ @param mediumName Medium name
+ @param libraryName Library name
+ @param substanceName Substance name
+*/
+void TwoPhaseMedium_setDewState_C_impl(ExternalSaturationProperties *sat, int phase, ExternalThermodynamicState *state,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ solver->setDewState(sat, phase, state);
+}
+
+//! Compute saturation temperature for specified medium and pressure
+double TwoPhaseMedium_saturationTemperature_C_impl(double p, const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ ExternalSaturationProperties sat;
+ solver->setSat_p(p, &sat);
+ return sat.Tsat;
+}
+
+//! Compute derivative of saturation temperature for specified medium and pressure
+double TwoPhaseMedium_saturationTemperature_derp_C_impl(double p, const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ ExternalSaturationProperties sat;
+ solver->setSat_p(p, &sat);
+ return sat.dTp;
+}
+
+//! Return derivative of saturation temperature of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_saturationTemperature_derp_sat_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->dTp(sat);
+}
+
+//! Return derivative of bubble density wrt pressure of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_dBubbleDensity_dPressure_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->ddldp(sat);
+}
+
+//! Return derivative of dew density wrt pressure of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_dDewDensity_dPressure_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->ddvdp(sat);
+}
+
+//! Return derivative of bubble specific enthalpy wrt pressure of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_dBubbleEnthalpy_dPressure_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->dhldp(sat);
+}
+
+//! Return derivative of dew specific enthalpy wrt pressure of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_dDewEnthalpy_dPressure_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->dhvdp(sat);
+}
+
+//! Return bubble density of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_bubbleDensity_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->dl(sat);
+}
+
+//! Return dew density of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_dewDensity_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->dv(sat);
+}
+
+//! Return bubble specific enthalpy of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_bubbleEnthalpy_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->hl(sat);
+}
+
+//! Return dew specific enthalpy of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_dewEnthalpy_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->hv(sat);
+}
+
+//! Compute saturation pressure for specified medium and temperature
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_saturationPressure_C_impl(double T, const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ ExternalSaturationProperties sat;
+ solver->setSat_T(T, &sat);
+ return sat.psat;
+}
+
+//! Return surface tension of specified medium
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_surfaceTension_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->sigma(sat);
+}
+
+//! Return bubble specific entropy of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_bubbleEntropy_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->sl(sat);
+}
+
+//! Return dew specific entropy of specified medium from saturation properties
+/*! Note: This function is not used by the default implementation of ExternalTwoPhaseMedium class.
+ It might be used by external medium models customized solvers redeclaring the default functions
+*/
+double TwoPhaseMedium_dewEntropy_C_impl(ExternalSaturationProperties *sat,
+ const char *mediumName, const char *libraryName, const char *substanceName){
+ BaseSolver *solver = SolverMap::getSolver(mediumName, libraryName, substanceName);
+ return solver->sv(sat);
+}
diff --git a/Projects/Sources/externalmedialib.h b/Projects/Sources/externalmedialib.h
index 8690e47f..546da894 100644
--- a/Projects/Sources/externalmedialib.h
+++ b/Projects/Sources/externalmedialib.h
@@ -1,195 +1,222 @@
-/*!
- \file externalmedialib.h
- \brief Header file to be included in the Modelica tool, with external function interfaces
-
- C/C++ layer for external medium models extending from
- PartialExternalTwoPhaseMedium.
-
- Francesco Casella, Christoph Richter, Roberto Bonifetto
- 2006-2012
- Copyright Politecnico di Milano, TU Braunschweig, Politecnico di Torino
-
- Minor additions in 2014 to make ExternalMedia compatible
- with GCC on Linux operating systems
- Jorrit Wronski (Technical University of Denmark)
-*/
-
-#ifndef EXTERNALMEDIALIB_H_
-#define EXTERNALMEDIALIB_H_
-
-// Constants for input choices (see ExternalMedia.Common.InputChoices)
-#define CHOICE_dT 1
-#define CHOICE_hs 2
-#define CHOICE_ph 3
-#define CHOICE_ps 4
-#define CHOICE_pT 5
-
-/*! Detect the platform in order to avoid the DLL commands from
- * making g++ choke. Code taken from CoolProp...
- */
-#if defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__)
-# define __ISWINDOWS__
-#elif __APPLE__
-# define __ISAPPLE__
-#elif __linux
-# define __ISLINUX__
-#endif
-
-/*!
-Portable definitions of the EXPORT macro
- */
-#ifndef EXPORT
-# if defined(__ISLINUX__)
-# define EXPORT
-# elif defined(__ISAPPLE__)
-# define EXPORT
-# else
-# define EXPORT __declspec(dllexport)
-# endif
-#endif
-
-// Define struct
-//! ExternalThermodynamicState property struct
-/*!
- The ExternalThermodynamicState propery struct defines all the properties that
- are computed by external Modelica medium models extending from
- PartialExternalTwoPhaseMedium.
-*/
-
-typedef struct {
-
- //! Temperature
- double T;
- //! Velocity of sound
- double a;
- //! Isobaric expansion coefficient
- double beta;
- //! Specific heat capacity cp
- double cp;
- //! Specific heat capacity cv
- double cv;
- //! Density
- double d;
- //! Derivative of density wrt enthalpy at constant pressure
- double ddhp;
- //! Derivative of density wrt pressure at constant enthalpy
- double ddph;
- //! Dynamic viscosity
- double eta;
- //! Specific enthalpy
- double h;
- //! Compressibility
- double kappa;
- //! Thermal conductivity
- double lambda;
- //! Pressure
- double p;
- //! Phase flag: 2 for two-phase, 1 for one-phase
- int phase;
- //! Specific entropy
- double s;
-
-} ExternalThermodynamicState;
-
-//! ExternalSaturationProperties property struct
-/*!
- The ExternalSaturationProperties propery struct defines all the saturation properties
- for the dew and the bubble line that are computed by external Modelica medium models
- extending from PartialExternalTwoPhaseMedium.
-*/
-
-typedef struct {
- //! Saturation temperature
- double Tsat;
- //! Derivative of Ts wrt pressure
- double dTp;
- //! Derivative of dls wrt pressure
- double ddldp;
- //! Derivative of dvs wrt pressure
- double ddvdp;
- //! Derivative of hls wrt pressure
- double dhldp;
- //! Derivative of hvs wrt pressure
- double dhvdp;
- //! Density at bubble line (for pressure ps)
- double dl;
- //! Density at dew line (for pressure ps)
- double dv;
- //! Specific enthalpy at bubble line (for pressure ps)
- double hl;
- //! Specific enthalpy at dew line (for pressure ps)
- double hv;
- //! Saturation pressure
- double psat;
- //! Surface tension
- double sigma;
- //! Specific entropy at bubble line (for pressure ps)
- double sl;
- //! Specific entropy at dew line (for pressure ps)
- double sv;
-
-} ExternalSaturationProperties;
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
- EXPORT double TwoPhaseMedium_getMolarMass_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_getCriticalTemperature_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_getCriticalPressure_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_getCriticalMolarVolume_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT void TwoPhaseMedium_setState_ph_C_impl(double p, double h, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setState_pT_C_impl(double p, double T, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setState_dT_C_impl(double d, double T, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setState_ps_C_impl(double p, double s, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setState_hs_C_impl(double h, double s, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT double TwoPhaseMedium_partialDeriv_state_C_impl(const char *of, const char *wrt, const char *cst, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT double TwoPhaseMedium_prandtlNumber_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_temperature_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_velocityOfSound_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_isobaricExpansionCoefficient_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_specificHeatCapacityCp_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_specificHeatCapacityCv_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_density_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_density_derh_p_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_density_derp_h_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dynamicViscosity_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_specificEnthalpy_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_isothermalCompressibility_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_thermalConductivity_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_pressure_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_specificEntropy_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_density_ph_der_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_isentropicEnthalpy_C_impl(double p_downstream, ExternalThermodynamicState *refState, const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT void TwoPhaseMedium_setSat_p_C_impl(double p, ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setSat_T_C_impl(double T, ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setBubbleState_C_impl(ExternalSaturationProperties *sat, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT void TwoPhaseMedium_setDewState_C_impl(ExternalSaturationProperties *sat, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT double TwoPhaseMedium_saturationTemperature_C_impl(double p, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_saturationTemperature_derp_C_impl(double p, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_saturationTemperature_derp_sat_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
-
- EXPORT double TwoPhaseMedium_dBubbleDensity_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dDewDensity_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dBubbleEnthalpy_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dDewEnthalpy_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_bubbleDensity_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dewDensity_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_bubbleEnthalpy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dewEnthalpy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_saturationPressure_C_impl(double T, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_surfaceTension_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_bubbleEntropy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
- EXPORT double TwoPhaseMedium_dewEntropy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#endif /*EXTERNALMEDIALIB_H_*/
+/*!
+ \file externalmedialib.h
+ \brief Header file to be included in the Modelica tool, with external function interfaces
+
+ C/C++ layer for external medium models extending from
+ PartialExternalTwoPhaseMedium.
+
+ Francesco Casella, Christoph Richter, Roberto Bonifetto
+ 2006-2012
+ Copyright Politecnico di Milano, TU Braunschweig, Politecnico di Torino
+
+ Minor additions in 2014 to make ExternalMedia compatible
+ with GCC on Linux operating systems
+ Jorrit Wronski (Technical University of Denmark)
+*/
+
+#ifndef EXTERNALMEDIALIB_H_
+#define EXTERNALMEDIALIB_H_
+
+// Constants for input choices (see ExternalMedia.Common.InputChoices)
+#define CHOICE_dT 1
+#define CHOICE_hs 2
+#define CHOICE_ph 3
+#define CHOICE_ps 4
+#define CHOICE_pT 5
+
+/*!
+Portable definitions of the EXPORT macro
+ */
+#if !defined(EXTERNALMEDIA_EXPORT)
+# if !defined(EXTERNALMEDIA_LIBRARY_EXPORTS)
+# define EXTERNALMEDIA_EXPORT
+# else
+# if (EXTERNALMEDIA_LIBRARY_EXPORTS == 1)
+# if defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__)
+# if !defined(__EXTERNALMEDIA_ISWINDOWS__)
+# define __EXTERNALMEDIA_ISWINDOWS__
+# endif
+# elif __APPLE__
+# if !defined(__EXTERNALMEDIA_ISAPPLE__)
+# define __EXTERNALMEDIA_ISAPPLE__
+# endif
+# elif __linux
+# if !defined(__EXTERNALMEDIA_ISLINUX__)
+# define __EXTERNALMEDIA_ISLINUX__
+# endif
+# endif
+#
+# if defined(__EXTERNALMEDIA_ISLINUX__)
+# define EXTERNALMEDIA_EXPORT
+# elif defined(__EXTERNALMEDIA_ISAPPLE__)
+# define EXTERNALMEDIA_EXPORT
+# else
+# define EXTERNALMEDIA_EXPORT __declspec(dllexport)
+# endif
+# else
+# define EXTERNALMEDIA_EXPORT
+# endif
+# endif
+#endif
+
+// Define struct
+//! ExternalThermodynamicState property struct
+/*!
+ The ExternalThermodynamicState propery struct defines all the properties that
+ are computed by external Modelica medium models extending from
+ PartialExternalTwoPhaseMedium.
+*/
+
+typedef struct ExternalThermodynamicState {
+
+ //! Temperature
+ double T;
+ //! Velocity of sound
+ double a;
+ //! Isobaric expansion coefficient
+ double beta;
+ //! Specific heat capacity cp
+ double cp;
+ //! Specific heat capacity cv
+ double cv;
+ //! Density
+ double d;
+ //! Derivative of density wrt enthalpy at constant pressure
+ double ddhp;
+ //! Derivative of density wrt pressure at constant enthalpy
+ double ddph;
+ //! Dynamic viscosity
+ double eta;
+ //! Specific enthalpy
+ double h;
+ //! Compressibility
+ double kappa;
+ //! Thermal conductivity
+ double lambda;
+ //! Pressure
+ double p;
+ //! Phase flag: 2 for two-phase, 1 for one-phase
+ int phase;
+ //! Specific entropy
+ double s;
+
+ //! Constructor.
+ /*!
+ The constructor only initializes the variables.
+ */
+ #ifdef __cplusplus
+ ExternalThermodynamicState() : T(-1), a(-1), beta(-1), cp(-1), cv(-1), d(-1), ddhp(-1), ddph(-1), eta(-1), h(-1), kappa(-1), lambda(-1), p(-1), phase(-1), s(-1) {};
+ #endif
+
+} ExternalThermodynamicState;
+
+//! ExternalSaturationProperties property struct
+/*!
+ The ExternalSaturationProperties propery struct defines all the saturation properties
+ for the dew and the bubble line that are computed by external Modelica medium models
+ extending from PartialExternalTwoPhaseMedium.
+*/
+
+typedef struct ExternalSaturationProperties {
+ //! Saturation temperature
+ double Tsat;
+ //! Derivative of Ts wrt pressure
+ double dTp;
+ //! Derivative of dls wrt pressure
+ double ddldp;
+ //! Derivative of dvs wrt pressure
+ double ddvdp;
+ //! Derivative of hls wrt pressure
+ double dhldp;
+ //! Derivative of hvs wrt pressure
+ double dhvdp;
+ //! Density at bubble line (for pressure ps)
+ double dl;
+ //! Density at dew line (for pressure ps)
+ double dv;
+ //! Specific enthalpy at bubble line (for pressure ps)
+ double hl;
+ //! Specific enthalpy at dew line (for pressure ps)
+ double hv;
+ //! Saturation pressure
+ double psat;
+ //! Surface tension
+ double sigma;
+ //! Specific entropy at bubble line (for pressure ps)
+ double sl;
+ //! Specific entropy at dew line (for pressure ps)
+ double sv;
+
+ //! Constructor.
+ /*!
+ The constructor only initializes the variables.
+ */
+ #ifdef __cplusplus
+ ExternalSaturationProperties() : Tsat(-1), dTp(-1), ddldp(-1), ddvdp(-1), dhldp(-1), dhvdp(-1), dl(-1), dv(-1), hl(-1), hv(-1), psat(-1), sigma(-1), sl(-1), sv(-1) {};
+ #endif
+
+} ExternalSaturationProperties;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_getMolarMass_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_getCriticalTemperature_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_getCriticalPressure_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_getCriticalMolarVolume_C_impl(const char *mediumName, const char *libraryName, const char *substanceName);
+
+ EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setState_ph_C_impl(double p, double h, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setState_pT_C_impl(double p, double T, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setState_dT_C_impl(double d, double T, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setState_ps_C_impl(double p, double s, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setState_hs_C_impl(double h, double s, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_partialDeriv_state_C_impl(const char *of, const char *wrt, const char *cst, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_prandtlNumber_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_temperature_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_velocityOfSound_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_isobaricExpansionCoefficient_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_specificHeatCapacityCp_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_specificHeatCapacityCv_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_density_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_density_derh_p_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_density_derp_h_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_dynamicViscosity_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_specificEnthalpy_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_isothermalCompressibility_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_thermalConductivity_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_pressure_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_specificEntropy_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_density_ph_der_C_impl(ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_isentropicEnthalpy_C_impl(double p_downstream, ExternalThermodynamicState *refState, const char *mediumName, const char *libraryName, const char *substanceName);
+
+ EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setSat_p_C_impl(double p, ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setSat_T_C_impl(double T, ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setBubbleState_C_impl(ExternalSaturationProperties *sat, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setDewState_C_impl(ExternalSaturationProperties *sat, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
+
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_saturationTemperature_C_impl(double p, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_saturationTemperature_derp_C_impl(double p, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_saturationTemperature_derp_sat_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_dBubbleDensity_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_dDewDensity_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_dBubbleEnthalpy_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_dDewEnthalpy_dPressure_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_bubbleDensity_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_dewDensity_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_bubbleEnthalpy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_dewEnthalpy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_saturationPressure_C_impl(double T, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_surfaceTension_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_bubbleEntropy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+ EXTERNALMEDIA_EXPORT double TwoPhaseMedium_dewEntropy_C_impl(ExternalSaturationProperties *sat, const char *mediumName, const char *libraryName, const char *substanceName);
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif /*EXTERNALMEDIALIB_H_*/
diff --git a/Projects/Sources/fluidconstants.h b/Projects/Sources/fluidconstants.h
index e6e3d9c3..6c8ac140 100644
--- a/Projects/Sources/fluidconstants.h
+++ b/Projects/Sources/fluidconstants.h
@@ -1,35 +1,41 @@
-#ifndef FLUIDCONSTANTS_H_
-#define FLUIDCONSTANTS_H_
-
-#include "include.h"
-
-//! Fluid constants struct
-/*!
- The fluid constants struct contains all the constant fluid properties
- that are returned by the external solver.
-
- Francesco Casella, Christoph Richter, Roberto Bonifetto
- 2006-2012
- Copyright Politecnico di Milano, TU Braunschweig, Politecnico
- di Torino
-*/
-
-struct FluidConstants{
- //! Molar mass
- double MM;
- //! Pressure at critical point
- double pc;
- //! Temperature at critical point
- double Tc;
- //! Density at critical point
- double dc;
- // The following two functions are currently only available internally
- // but do not have the required interface functions to be accessible from
- // Modelica.
- //! Specific enthalpy at critical point
- double hc;
- //! Specific entropy at critical point
- double sc;
-};
-
-#endif // FLUIDCONSTANTS_H_
+#ifndef FLUIDCONSTANTS_H_
+#define FLUIDCONSTANTS_H_
+
+#include "include.h"
+
+//! Fluid constants struct
+/*!
+ The fluid constants struct contains all the constant fluid properties
+ that are returned by the external solver.
+
+ Francesco Casella, Christoph Richter, Roberto Bonifetto
+ 2006-2012
+ Copyright Politecnico di Milano, TU Braunschweig, Politecnico
+ di Torino
+*/
+
+struct FluidConstants{
+ //! Molar mass
+ double MM;
+ //! Pressure at critical point
+ double pc;
+ //! Temperature at critical point
+ double Tc;
+ //! Density at critical point
+ double dc;
+ // The following two functions are currently only available internally
+ // but do not have the required interface functions to be accessible from
+ // Modelica.
+ //! Specific enthalpy at critical point
+ double hc;
+ //! Specific entropy at critical point
+ double sc;
+
+ //! Constructor.
+ /*!
+ The constructor only initializes the variables.
+ */
+ FluidConstants() : MM(-1), pc(-1), Tc(-1), dc(-1), hc(-1), sc(-1) {};
+};
+
+#endif // FLUIDCONSTANTS_H_
diff --git a/Projects/Sources/fluidpropsolver.cpp b/Projects/Sources/fluidpropsolver.cpp
index 8c7f2fab..79d38426 100644
--- a/Projects/Sources/fluidpropsolver.cpp
+++ b/Projects/Sources/fluidpropsolver.cpp
@@ -1,501 +1,504 @@
-/* *****************************************************************
- * Implementation of class FluidProp solver
- *
- * Francesco Casella, Christoph Richter, Roberto Bonifetto
- * 2006 - 2014
- ********************************************************************/
-
-#include "include.h"
-#include "fluidpropsolver.h"
-#include
-
-#define _AFXDLL
-
-ExternalSaturationProperties satPropClose2Crit; // saturation properties close to critical conditions
-double p_eps; // relative tolerance margin for subcritical pressure conditions
-double T_eps; // relative tolerance margin for supercritical temperature conditions
-double delta_h = 1e-2; // delta_h for one-phase/two-phase discrimination
-
-FluidPropSolver::FluidPropSolver(const string &mediumName,
- const string &libraryName,
- const string &substanceName)
- : BaseSolver(mediumName, libraryName, substanceName){
-
- string ErrorMsg;
- string Comp[20];
- double Conc[20];
-
- // Build FluidProp object with the libraryName and substanceName info
- Comp[0] = substanceName.c_str();
- Conc[0] = 1.0;
- FluidProp.SetFluid(libraryName.substr(libraryName.find(".")+1), 1, Comp, Conc, &ErrorMsg);
- if (isError(ErrorMsg)) // An error occurred
- {
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error: %s\n", ErrorMsg.c_str());
- errorMessage(error);
- }
-
- // Set SI units
- FluidProp.SetUnits("SI", " ", " ", " ", &ErrorMsg);
- if (isError(ErrorMsg)) // An error occurred
- {
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error: %s\n", ErrorMsg.c_str());
- errorMessage(error);
- }
-
- // Set fluid constants
- setFluidConstants();
-}
-
-FluidPropSolver::~FluidPropSolver(){
-}
-
-void FluidPropSolver::setFluidConstants(){
- string ErrorMsg;
-
- _fluidConstants.MM = FluidProp.Mmol(&ErrorMsg);
- if (isError(ErrorMsg)) { // An error occurred
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setFluidConstants: can't compute molar mass\n %s\n", ErrorMsg.c_str());
- errorMessage(error);
- }
-
- _fluidConstants.Tc = FluidProp.Tcrit(&ErrorMsg);
- if (isError(ErrorMsg)) { // An error occurred
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setFluidConstants: can't compute critical temperature\n %s\n", ErrorMsg.c_str());
- errorMessage(error);
- }
-
- _fluidConstants.pc = FluidProp.Pcrit(&ErrorMsg);
- if (isError(ErrorMsg)) { // An error occurred
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setFluidConstants: can't compute critical pressure\n %s\n", ErrorMsg.c_str());
- errorMessage(error);
- }
-
- // Computation of critical density with slightly supercritical temperature to avoid convergence problems
- // T_eps is kept as a static variable
- for(T_eps = 1e-5;; T_eps *= 3)
- {
- if (T_eps > 1e-3) {
- // Superheating is too large:
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setFluidConstants: can't compute critical density\n %s\n", ErrorMsg.c_str());
- errorMessage(error);
- }
- _fluidConstants.dc = FluidProp.Density("PT", _fluidConstants.pc, _fluidConstants.Tc*(1.0 + T_eps), &ErrorMsg);
- if (!isError(ErrorMsg)) // computation succeeded
- break;
- }
-
- // Temporary variables for calling AllPropSat in slightly subcritical conditions
- double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
- cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
- psi_, zeta_, theta_, kappa_, gamma_, eta_, lambda_,
- d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
- dh_vap_dP_, dT_sat_dP_;
- int failed = false;
-
- // Computation of limit saturation properties at slightly subcritical pressure
- // p_eps is kept as a static variable
- for(p_eps = 1e-5;; p_eps *= 2)
- {
- if (p_eps > 2e-2) {
- // subcritical pressure limit too low:
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setFluidConstants:\nCannot compute saturation conditions at p = p_crit*(1 - %f)\n",
- p_eps);
- errorMessage(error);
- }
- // Compute saturation properties at pc*(1-p_eps)
- FluidProp.AllPropsSat("Pq", _fluidConstants.pc*(1-p_eps) , 0.0, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
- alpha_, beta_, chi_, fi_, ksi_, psi_, zeta_, theta_, kappa_, gamma_, eta_, lambda_,
- d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
- dh_vap_dP_, dT_sat_dP_, &ErrorMsg);
- if (!isError(ErrorMsg))
- break; // computation succeeded
- if (licenseError(ErrorMsg)){
- char error[300];
- sprintf(error, "%s", ErrorMsg.c_str());
- errorMessage(error); // a license error has been generated
- }
- }
- // Fill in the satPropClose2Crit record
- satPropClose2Crit.Tsat = T_sat_; // saturation temperature
- satPropClose2Crit.dTp = dT_sat_dP_; // derivative of Ts by pressure
- satPropClose2Crit.ddldp = dd_liq_dP_; // derivative of dls by pressure
- satPropClose2Crit.ddvdp = dd_vap_dP_; // derivative of dvs by pressure
- satPropClose2Crit.dhldp = dh_liq_dP_; // derivative of hls by pressure
- satPropClose2Crit.dhvdp = dh_vap_dP_; // derivative of hvs by pressure
- satPropClose2Crit.dl = d_liq_; // bubble density
- satPropClose2Crit.dv = d_vap_; // dew density
- satPropClose2Crit.hl = h_liq_; // bubble specific enthalpy
- satPropClose2Crit.hv = h_vap_; // dew specific enthalpy
- satPropClose2Crit.psat = _fluidConstants.pc*(1-p_eps); // saturation pressure
- }
-
-void FluidPropSolver::setSat_p(double &p, ExternalSaturationProperties *const properties){
- string ErrorMsg;
- // FluidProp variables (in SI units)
- double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
- cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
- psi_, zeta_, theta_, kappa_, gamma_, eta_, lambda_,
- d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
- dh_vap_dP_, dT_sat_dP_;
-
- // Compute all FluidProp variables at pressure p and steam quality 0
- if (p < _fluidConstants.pc*(1-p_eps)) // subcritical conditions
- {
- FluidProp.AllPropsSat("Pq", p , 0.0, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
- alpha_, beta_, chi_, fi_, ksi_, psi_, zeta_, theta_, kappa_, gamma_, eta_, lambda_,
- d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
- dh_vap_dP_, dT_sat_dP_, &ErrorMsg);
- if (isError(ErrorMsg)) { // An error occurred
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setSat_p(%f)\n %s\n", p, ErrorMsg.c_str());
- errorMessage(error);
- }
- // Fill in the ExternalSaturationProperties variables (in SI units)
- properties->Tsat = T_sat_; // saturation temperature
- properties->dTp = dT_sat_dP_; // derivative of Ts by pressure
- properties->ddldp = dd_liq_dP_; // derivative of dls by pressure
- properties->ddvdp = dd_vap_dP_; // derivative of dvs by pressure
- properties->dhldp = dh_liq_dP_; // derivative of hls by pressure
- properties->dhvdp = dh_vap_dP_; // derivative of hvs by pressure
- properties->dl = d_liq_; // bubble density
- properties->dv = d_vap_; // dew density
- properties->hl = h_liq_; // bubble specific enthalpy
- properties->hv = h_vap_; // dew specific enthalpy
- properties->psat = p; // saturation pressure
- }
- else // supercritical conditions, return slightly subcritical conditions for continuity
- {
- properties->Tsat = satPropClose2Crit.Tsat; // saturation temperature
- properties->dTp = satPropClose2Crit.dTp; // derivative of Ts by pressure
- properties->ddldp = satPropClose2Crit.ddldp; // derivative of dls by pressure
- properties->ddvdp = satPropClose2Crit.ddvdp; // derivative of dvs by pressure
- properties->dhldp = satPropClose2Crit.dhldp; // derivative of hls by pressure
- properties->dhvdp = satPropClose2Crit.dhvdp; // derivative of hvs by pressure
- properties->dl = satPropClose2Crit.dl; // bubble density
- properties->dv = satPropClose2Crit.dv; // dew density
- properties->hl = satPropClose2Crit.hl; // bubble specific enthalpy
- properties->hv = satPropClose2Crit.hv; // dew specific enthalpy
- properties->psat = satPropClose2Crit.psat; // saturation pressure
- }
-}
-
-void FluidPropSolver::setSat_T(double &T, ExternalSaturationProperties *const properties){
- string ErrorMsg;
- // FluidProp variables (in SI units)
- double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
- cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
- psi_, zeta_ , theta_, kappa_, gamma_, eta_, lambda_,
- d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
- dh_vap_dP_, dT_sat_dP_;
-
- if (T < satPropClose2Crit.Tsat) // subcritical conditions
- {
- // Compute all FluidProp variables at temperature T and steam quality 0
- FluidProp.AllPropsSat("Tq", T , 0.0, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
- alpha_, beta_, chi_, fi_, ksi_, psi_, zeta_, theta_, kappa_, gamma_, eta_, lambda_,
- d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
- dh_vap_dP_, dT_sat_dP_, &ErrorMsg);
- if (isError(ErrorMsg)) { // An error occurred
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setSat_T(%f)\n %s\n", T, ErrorMsg.c_str());
- errorMessage(error);
- }
- // Fill in the ExternalSaturationProperties variables (in SI units)
- properties->Tsat = T; // saturation temperature
- properties->dTp = dT_sat_dP_; // derivative of Ts by pressure
- properties->ddldp = dd_liq_dP_; // derivative of dls by pressure
- properties->ddvdp = dd_vap_dP_; // derivative of dvs by pressure
- properties->dhldp = dh_liq_dP_; // derivative of hls by pressure
- properties->dhvdp = dh_vap_dP_; // derivative of hvs by pressure
- properties->dl = d_liq_; // bubble density
- properties->dv = d_vap_; // dew density
- properties->hl = h_liq_; // bubble specific enthalpy
- properties->hv = h_vap_; // dew specific enthalpy
- properties->psat = P_; // saturation pressure
- }
- else // supercritical conditions, return slightly subcritical conditions for continuity
- {
- properties->Tsat = satPropClose2Crit.Tsat; // saturation temperature
- properties->dTp = satPropClose2Crit.dTp; // derivative of Ts by pressure
- properties->ddldp = satPropClose2Crit.ddldp; // derivative of dls by pressure
- properties->ddvdp = satPropClose2Crit.ddvdp; // derivative of dvs by pressure
- properties->dhldp = satPropClose2Crit.dhldp; // derivative of hls by pressure
- properties->dhvdp = satPropClose2Crit.dhvdp; // derivative of hvs by pressure
- properties->dl = satPropClose2Crit.dl; // bubble density
- properties->dv = satPropClose2Crit.dv; // dew density
- properties->hl = satPropClose2Crit.hl; // bubble specific enthalpy
- properties->hv = satPropClose2Crit.hv; // dew specific enthalpy
- properties->psat = satPropClose2Crit.psat; // saturation pressure
- }
-}
-
-//! Computes the properties of the state vector from p and h
-/*! Note: the phase input is currently not supported according to the standard,
- the phase input is returned in the state record
-*/
-void FluidPropSolver::setState_ph(double &p, double &h, int &phase, ExternalThermodynamicState *const properties){
- string ErrorMsg;
- // FluidProp variables (in SI units)
- double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
- cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
- psi_, zeta_ , theta_, kappa_, gamma_, eta_, lambda_;
-
- // Compute all FluidProp variables
- FluidProp.AllProps("Ph", p , h, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
- alpha_, beta_, chi_, fi_, ksi_, psi_,
- zeta_, theta_, kappa_, gamma_, eta_, lambda_, &ErrorMsg);
- if (isError(ErrorMsg)) { // An error occurred
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setState_ph(%f, %f)\n %s\n", p, h, ErrorMsg.c_str());
- errorMessage(error);
- }
-
- // Fill in the ExternalThermodynamicState variables (in SI units)
- properties->T = T_; // temperature
- properties->a = c_; // speed of sound
- properties->beta = theta_; // isothermal expansion coefficient
- properties->cp = cp_; // specific heat capacity cp
- properties->cv = cv_; // specific heat capacity cv
- properties->d = d_; // density
- properties->ddhp = ksi_; // derivative of density by enthalpy at constant p
- properties->ddph = psi_; // derivative of density by pressure at constant h
- properties->eta = eta_; // dynamic viscosity
- properties->h = h; // specific enthalpy
- properties->kappa = kappa_; // compressibility
- properties->lambda = lambda_; // thermal conductivity
- properties->p = p; // pressure
- properties->s = s_; // specific entropy
- properties->phase = phase; // phase
-
-}
-
-//! Computes the properties of the state vector from p and T
-void FluidPropSolver::setState_pT(double &p, double &T, ExternalThermodynamicState *const properties){
- string ErrorMsg;
- // FluidProp variables (in SI units)
- double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
- cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
- psi_, zeta_ , theta_, kappa_, gamma_, eta_, lambda_;
-
- // Compute all FluidProp variables
- FluidProp.AllProps("PT", p , T, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
- alpha_, beta_, chi_, fi_, ksi_, psi_,
- zeta_, theta_, kappa_, gamma_, eta_, lambda_, &ErrorMsg);
- if (isError(ErrorMsg)) { // An error occurred
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setState_pT(%f, %f)\n %s\n", p, T, ErrorMsg.c_str());
- errorMessage(error);
- }
-
- // Fill in the ExternalThermodynamicState variables (in SI units)
- properties->T = T_; // temperature
- properties->a = c_; // speed of sound
- properties->beta = theta_; // isothermal expansion coefficient
- properties->cp = cp_; // specific heat capacity cp
- properties->cv = cv_; // specific heat capacity cv
- properties->d = d_; // density
- properties->ddhp = ksi_; // derivative of density by enthalpy at constant p
- properties->ddph = psi_; // derivative of density by pressure at constant h
- properties->eta = eta_; // dynamic viscosity
- properties->h = h_; // specific enthalpy
- properties->kappa = kappa_; // compressibility
- properties->lambda = lambda_; // thermal conductivity
- properties->p = p; // pressure
- properties->s = s_; // specific entropy
- properties->phase = 1; // Always one-phase with pT inputs
-}
-
-// Computes the properties of the state vector from d and T
-/*! Note: the phase input is currently not supported according to the standard,
- the phase input is returned in the state record
-*/
-void FluidPropSolver::setState_dT(double &d, double &T, int &phase, ExternalThermodynamicState *const properties){
- string ErrorMsg;
- // FluidProp variables (in SI units)
- double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
- cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
- psi_, zeta_ , theta_, kappa_, gamma_, eta_, lambda_;
-
- // Compute all FluidProp variables
- FluidProp.AllProps("Td", T , d, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
- alpha_, beta_, chi_, fi_, ksi_, psi_,
- zeta_, theta_, kappa_, gamma_, eta_, lambda_, &ErrorMsg);
- if (isError(ErrorMsg)) { // An error occurred
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setState_dT(%f, %f)\n %s\n", d, T, ErrorMsg.c_str());
- errorMessage(error);
- }
-
- // Fill in the ExternalThermodynamicState variables (in SI units)
- properties->T = T; // temperature
- properties->a = c_; // speed of sound
- properties->beta = theta_; // isothermal expansion coefficient
- properties->cp = cp_; // specific heat capacity cp
- properties->cv = cv_; // specific heat capacity cv
- properties->d = d; // density
- properties->ddhp = ksi_; // derivative of density by enthalpy at constant p
- properties->ddph = psi_; // derivative of density by pressure at constant h
- properties->eta = eta_; // dynamic viscosity
- properties->h = h_; // specific enthalpy
- properties->kappa = kappa_; // compressibility
- properties->lambda = lambda_; // thermal conductivity
- properties->p = P_; // pressure
- properties->s = s_; // specific entropy
- properties->phase = phase; // phase
-}
-
-//! Computes the properties of the state vector from p and s
-/*! Note: the phase input is currently not supported according to the standard,
- the phase input is returned in the state record
-*/
-void FluidPropSolver::setState_ps(double &p, double &s, int &phase, ExternalThermodynamicState *const properties){
- string ErrorMsg;
- // FluidProp variables (in SI units)
- double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
- cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
- psi_, zeta_ , theta_, kappa_, gamma_, eta_, lambda_;
-
- // Compute all FluidProp variables
- FluidProp.AllProps("Ps", p , s, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
- alpha_, beta_, chi_, fi_, ksi_, psi_,
- zeta_, theta_, kappa_, gamma_, eta_, lambda_, &ErrorMsg);
- if (isError(ErrorMsg)) {
- // An error occurred
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::setState_ps(%f, %f)\n %s\n", p, s, ErrorMsg.c_str());
- errorMessage(error);
- }
-
- // Fill in the ExternalThermodynamicState variables (in SI units)
- properties->T = T_; // temperature
- properties->a = c_; // speed of sound
- properties->beta = theta_; // isothermal expansion coefficient
- properties->cp = cp_; // specific heat capacity cp
- properties->cv = cv_; // specific heat capacity cv
- properties->d = d_; // density
- properties->ddhp = ksi_; // derivative of density by enthalpy at constant p
- properties->ddph = psi_; // derivative of density by pressure at constant h
- properties->eta = eta_; // dynamic viscosity
- properties->h = h_; // specific enthalpy
- properties->kappa = kappa_; // compressibility
- properties->lambda = lambda_; // thermal conductivity
- properties->p = p; // pressure
- properties->s = s; // specific entropy
- properties->phase = phase; // phase
-}
-
-//! Set bubble state
-/*!
- This function sets the bubble state record bubbleProperties corresponding to the
- saturation data contained in the properties record.
-
- Due to current lack of direct control over the phase in FluidProp, a small delta is added to
- the dewpoint enthalpy to make sure the correct phase is selected.
- @param properties ExternalSaturationProperties record with saturation properties data
- @param phase Phase (1: one-phase, 2: two-phase)
- @param bubbleProperties ExternalThermodynamicState record where to write the bubble point properties
-*/
-void FluidPropSolver::setBubbleState(ExternalSaturationProperties *const properties, int phase,
- ExternalThermodynamicState *const bubbleProperties){
- // Set the bubble state property record based on the saturation properties record
- double hl;
-
- if (phase == 0)
- hl = properties->hl;
- else if (phase == 1) // liquid phase
- hl = properties->hl-delta_h;
- else // two-phase mixture
- hl = properties->hl+delta_h;
-
- setState_ph(properties->psat, hl, phase, bubbleProperties);
-}
-
-//! Set dew state
-/*!
- This function sets the dew state record dewProperties corresponding to the
- saturation data contained in the properties record.
-
- The default implementation of the setDewState function is relying on the correct
- behaviour of setState_ph with respect to the state input. Can be overridden
- in the specific solver code to get more efficient or correct handling of this situation.
- @param properties ExternalSaturationProperties record with saturation properties data
- @param phase Phase (1: one-phase, 2: two-phase)
- @param dewProperties ExternalThermodynamicState record where to write the dew point properties
-*/
-void FluidPropSolver::setDewState(ExternalSaturationProperties *const properties, int phase,
- ExternalThermodynamicState *const dewProperties){
- // Set the dew state property record based on the saturation properties record
- double hv;
-
- if (phase == 0)
- hv = properties->hv;
- else if (phase == 1) // liquid phase
- hv = properties->hv+delta_h;
- else // two-phase mixture
- hv = properties->hv-delta_h;
-
- setState_ph(properties->psat, hv, phase, dewProperties);
-}
-
-
-//! Compute isentropic enthalpy
-/*!
- This function returns the enthalpy at pressure p after an isentropic
- transformation from the state specified by the properties input
-
- @param p New pressure
- @param properties ExternalThermodynamicState property record corresponding to current state
-*/
-double FluidPropSolver::isentropicEnthalpy(double &p, ExternalThermodynamicState *const properties){
- string ErrorMsg;
- double h;
-
- h = FluidProp.Enthalpy("Ps", p , properties->s, &ErrorMsg);
- if (isError(ErrorMsg)) { // An error occurred
- // Build error message and pass it to the Modelica environment
- char error[300];
- sprintf(error, "FluidProp error in FluidPropSolver::isentropicEnthalpy(%f, %f)\n %s\n", p, properties->s, ErrorMsg.c_str());
- errorMessage(error);
- }
- return h;
-}
-
-//! Check if FluidProp returned an error
-bool FluidPropSolver::isError(string ErrorMsg)
-{
- if(ErrorMsg == "No errors")
- return false;
- else
- return true;
-}
-
-//! Check if FluidProp returned a license error
-bool FluidPropSolver::licenseError(string ErrorMsg)
-{
- if (ErrorMsg.find("license") != std::string::npos)
- return true;
- else
- return false;
-}
-
+/* *****************************************************************
+ * Implementation of class FluidProp solver
+ *
+ * Francesco Casella, Christoph Richter, Roberto Bonifetto
+ * 2006 - 2014
+ ********************************************************************/
+
+#include "include.h"
+#if (EXTERNALMEDIA_FLUIDPROP == 1)
+
+#include "fluidpropsolver.h"
+#include
+
+#define _AFXDLL
+
+ExternalSaturationProperties satPropClose2Crit; // saturation properties close to critical conditions
+double p_eps; // relative tolerance margin for subcritical pressure conditions
+double T_eps; // relative tolerance margin for supercritical temperature conditions
+double delta_h = 1e-2; // delta_h for one-phase/two-phase discrimination
+
+FluidPropSolver::FluidPropSolver(const string &mediumName,
+ const string &libraryName,
+ const string &substanceName)
+ : BaseSolver(mediumName, libraryName, substanceName){
+
+ string ErrorMsg;
+ string Comp[20];
+ double Conc[20];
+
+ // Build FluidProp object with the libraryName and substanceName info
+ Comp[0] = substanceName.c_str();
+ Conc[0] = 1.0;
+ FluidProp.SetFluid(libraryName.substr(libraryName.find(".")+1), 1, Comp, Conc, &ErrorMsg);
+ if (isError(ErrorMsg)) // An error occurred
+ {
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error: %s\n", ErrorMsg.c_str());
+ errorMessage(error);
+ }
+
+ // Set SI units
+ FluidProp.SetUnits("SI", " ", " ", " ", &ErrorMsg);
+ if (isError(ErrorMsg)) // An error occurred
+ {
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error: %s\n", ErrorMsg.c_str());
+ errorMessage(error);
+ }
+
+ // Set fluid constants
+ setFluidConstants();
+}
+
+FluidPropSolver::~FluidPropSolver(){
+}
+
+void FluidPropSolver::setFluidConstants(){
+ string ErrorMsg;
+
+ _fluidConstants.MM = FluidProp.Mmol(&ErrorMsg);
+ if (isError(ErrorMsg)) { // An error occurred
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setFluidConstants: can't compute molar mass\n %s\n", ErrorMsg.c_str());
+ errorMessage(error);
+ }
+
+ _fluidConstants.Tc = FluidProp.Tcrit(&ErrorMsg);
+ if (isError(ErrorMsg)) { // An error occurred
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setFluidConstants: can't compute critical temperature\n %s\n", ErrorMsg.c_str());
+ errorMessage(error);
+ }
+
+ _fluidConstants.pc = FluidProp.Pcrit(&ErrorMsg);
+ if (isError(ErrorMsg)) { // An error occurred
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setFluidConstants: can't compute critical pressure\n %s\n", ErrorMsg.c_str());
+ errorMessage(error);
+ }
+
+ // Computation of critical density with slightly supercritical temperature to avoid convergence problems
+ // T_eps is kept as a static variable
+ for(T_eps = 1e-5;; T_eps *= 3)
+ {
+ if (T_eps > 1e-3) {
+ // Superheating is too large:
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setFluidConstants: can't compute critical density\n %s\n", ErrorMsg.c_str());
+ errorMessage(error);
+ }
+ _fluidConstants.dc = FluidProp.Density("PT", _fluidConstants.pc, _fluidConstants.Tc*(1.0 + T_eps), &ErrorMsg);
+ if (!isError(ErrorMsg)) // computation succeeded
+ break;
+ }
+
+ // Temporary variables for calling AllPropSat in slightly subcritical conditions
+ double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
+ cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
+ psi_, zeta_, theta_, kappa_, gamma_, eta_, lambda_,
+ d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
+ dh_vap_dP_, dT_sat_dP_;
+ int failed = false;
+
+ // Computation of limit saturation properties at slightly subcritical pressure
+ // p_eps is kept as a static variable
+ for(p_eps = 1e-5;; p_eps *= 2)
+ {
+ if (p_eps > 2e-2) {
+ // subcritical pressure limit too low:
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setFluidConstants:\nCannot compute saturation conditions at p = p_crit*(1 - %f)\n",
+ p_eps);
+ errorMessage(error);
+ }
+ // Compute saturation properties at pc*(1-p_eps)
+ FluidProp.AllPropsSat("Pq", _fluidConstants.pc*(1-p_eps) , 0.0, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
+ alpha_, beta_, chi_, fi_, ksi_, psi_, zeta_, theta_, kappa_, gamma_, eta_, lambda_,
+ d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
+ dh_vap_dP_, dT_sat_dP_, &ErrorMsg);
+ if (!isError(ErrorMsg))
+ break; // computation succeeded
+ if (licenseError(ErrorMsg)){
+ char error[300];
+ sprintf(error, "%s", ErrorMsg.c_str());
+ errorMessage(error); // a license error has been generated
+ }
+ }
+ // Fill in the satPropClose2Crit record
+ satPropClose2Crit.Tsat = T_sat_; // saturation temperature
+ satPropClose2Crit.dTp = dT_sat_dP_; // derivative of Ts by pressure
+ satPropClose2Crit.ddldp = dd_liq_dP_; // derivative of dls by pressure
+ satPropClose2Crit.ddvdp = dd_vap_dP_; // derivative of dvs by pressure
+ satPropClose2Crit.dhldp = dh_liq_dP_; // derivative of hls by pressure
+ satPropClose2Crit.dhvdp = dh_vap_dP_; // derivative of hvs by pressure
+ satPropClose2Crit.dl = d_liq_; // bubble density
+ satPropClose2Crit.dv = d_vap_; // dew density
+ satPropClose2Crit.hl = h_liq_; // bubble specific enthalpy
+ satPropClose2Crit.hv = h_vap_; // dew specific enthalpy
+ satPropClose2Crit.psat = _fluidConstants.pc*(1-p_eps); // saturation pressure
+ }
+
+void FluidPropSolver::setSat_p(double &p, ExternalSaturationProperties *const properties){
+ string ErrorMsg;
+ // FluidProp variables (in SI units)
+ double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
+ cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
+ psi_, zeta_, theta_, kappa_, gamma_, eta_, lambda_,
+ d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
+ dh_vap_dP_, dT_sat_dP_;
+
+ // Compute all FluidProp variables at pressure p and steam quality 0
+ if (p < _fluidConstants.pc*(1-p_eps)) // subcritical conditions
+ {
+ FluidProp.AllPropsSat("Pq", p , 0.0, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
+ alpha_, beta_, chi_, fi_, ksi_, psi_, zeta_, theta_, kappa_, gamma_, eta_, lambda_,
+ d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
+ dh_vap_dP_, dT_sat_dP_, &ErrorMsg);
+ if (isError(ErrorMsg)) { // An error occurred
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setSat_p(%f)\n %s\n", p, ErrorMsg.c_str());
+ errorMessage(error);
+ }
+ // Fill in the ExternalSaturationProperties variables (in SI units)
+ properties->Tsat = T_sat_; // saturation temperature
+ properties->dTp = dT_sat_dP_; // derivative of Ts by pressure
+ properties->ddldp = dd_liq_dP_; // derivative of dls by pressure
+ properties->ddvdp = dd_vap_dP_; // derivative of dvs by pressure
+ properties->dhldp = dh_liq_dP_; // derivative of hls by pressure
+ properties->dhvdp = dh_vap_dP_; // derivative of hvs by pressure
+ properties->dl = d_liq_; // bubble density
+ properties->dv = d_vap_; // dew density
+ properties->hl = h_liq_; // bubble specific enthalpy
+ properties->hv = h_vap_; // dew specific enthalpy
+ properties->psat = p; // saturation pressure
+ }
+ else // supercritical conditions, return slightly subcritical conditions for continuity
+ {
+ properties->Tsat = satPropClose2Crit.Tsat; // saturation temperature
+ properties->dTp = satPropClose2Crit.dTp; // derivative of Ts by pressure
+ properties->ddldp = satPropClose2Crit.ddldp; // derivative of dls by pressure
+ properties->ddvdp = satPropClose2Crit.ddvdp; // derivative of dvs by pressure
+ properties->dhldp = satPropClose2Crit.dhldp; // derivative of hls by pressure
+ properties->dhvdp = satPropClose2Crit.dhvdp; // derivative of hvs by pressure
+ properties->dl = satPropClose2Crit.dl; // bubble density
+ properties->dv = satPropClose2Crit.dv; // dew density
+ properties->hl = satPropClose2Crit.hl; // bubble specific enthalpy
+ properties->hv = satPropClose2Crit.hv; // dew specific enthalpy
+ properties->psat = satPropClose2Crit.psat; // saturation pressure
+ }
+}
+
+void FluidPropSolver::setSat_T(double &T, ExternalSaturationProperties *const properties){
+ string ErrorMsg;
+ // FluidProp variables (in SI units)
+ double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
+ cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
+ psi_, zeta_ , theta_, kappa_, gamma_, eta_, lambda_,
+ d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
+ dh_vap_dP_, dT_sat_dP_;
+
+ if (T < satPropClose2Crit.Tsat) // subcritical conditions
+ {
+ // Compute all FluidProp variables at temperature T and steam quality 0
+ FluidProp.AllPropsSat("Tq", T , 0.0, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
+ alpha_, beta_, chi_, fi_, ksi_, psi_, zeta_, theta_, kappa_, gamma_, eta_, lambda_,
+ d_liq_, d_vap_, h_liq_, h_vap_, T_sat_, dd_liq_dP_, dd_vap_dP_, dh_liq_dP_,
+ dh_vap_dP_, dT_sat_dP_, &ErrorMsg);
+ if (isError(ErrorMsg)) { // An error occurred
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setSat_T(%f)\n %s\n", T, ErrorMsg.c_str());
+ errorMessage(error);
+ }
+ // Fill in the ExternalSaturationProperties variables (in SI units)
+ properties->Tsat = T; // saturation temperature
+ properties->dTp = dT_sat_dP_; // derivative of Ts by pressure
+ properties->ddldp = dd_liq_dP_; // derivative of dls by pressure
+ properties->ddvdp = dd_vap_dP_; // derivative of dvs by pressure
+ properties->dhldp = dh_liq_dP_; // derivative of hls by pressure
+ properties->dhvdp = dh_vap_dP_; // derivative of hvs by pressure
+ properties->dl = d_liq_; // bubble density
+ properties->dv = d_vap_; // dew density
+ properties->hl = h_liq_; // bubble specific enthalpy
+ properties->hv = h_vap_; // dew specific enthalpy
+ properties->psat = P_; // saturation pressure
+ }
+ else // supercritical conditions, return slightly subcritical conditions for continuity
+ {
+ properties->Tsat = satPropClose2Crit.Tsat; // saturation temperature
+ properties->dTp = satPropClose2Crit.dTp; // derivative of Ts by pressure
+ properties->ddldp = satPropClose2Crit.ddldp; // derivative of dls by pressure
+ properties->ddvdp = satPropClose2Crit.ddvdp; // derivative of dvs by pressure
+ properties->dhldp = satPropClose2Crit.dhldp; // derivative of hls by pressure
+ properties->dhvdp = satPropClose2Crit.dhvdp; // derivative of hvs by pressure
+ properties->dl = satPropClose2Crit.dl; // bubble density
+ properties->dv = satPropClose2Crit.dv; // dew density
+ properties->hl = satPropClose2Crit.hl; // bubble specific enthalpy
+ properties->hv = satPropClose2Crit.hv; // dew specific enthalpy
+ properties->psat = satPropClose2Crit.psat; // saturation pressure
+ }
+}
+
+//! Computes the properties of the state vector from p and h
+/*! Note: the phase input is currently not supported according to the standard,
+ the phase input is returned in the state record
+*/
+void FluidPropSolver::setState_ph(double &p, double &h, int &phase, ExternalThermodynamicState *const properties){
+ string ErrorMsg;
+ // FluidProp variables (in SI units)
+ double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
+ cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
+ psi_, zeta_ , theta_, kappa_, gamma_, eta_, lambda_;
+
+ // Compute all FluidProp variables
+ FluidProp.AllProps("Ph", p , h, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
+ alpha_, beta_, chi_, fi_, ksi_, psi_,
+ zeta_, theta_, kappa_, gamma_, eta_, lambda_, &ErrorMsg);
+ if (isError(ErrorMsg)) { // An error occurred
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setState_ph(%f, %f)\n %s\n", p, h, ErrorMsg.c_str());
+ errorMessage(error);
+ }
+
+ // Fill in the ExternalThermodynamicState variables (in SI units)
+ properties->T = T_; // temperature
+ properties->a = c_; // speed of sound
+ properties->beta = theta_; // isothermal expansion coefficient
+ properties->cp = cp_; // specific heat capacity cp
+ properties->cv = cv_; // specific heat capacity cv
+ properties->d = d_; // density
+ properties->ddhp = ksi_; // derivative of density by enthalpy at constant p
+ properties->ddph = psi_; // derivative of density by pressure at constant h
+ properties->eta = eta_; // dynamic viscosity
+ properties->h = h; // specific enthalpy
+ properties->kappa = kappa_; // compressibility
+ properties->lambda = lambda_; // thermal conductivity
+ properties->p = p; // pressure
+ properties->s = s_; // specific entropy
+ properties->phase = phase; // phase
+
+}
+
+//! Computes the properties of the state vector from p and T
+void FluidPropSolver::setState_pT(double &p, double &T, ExternalThermodynamicState *const properties){
+ string ErrorMsg;
+ // FluidProp variables (in SI units)
+ double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
+ cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
+ psi_, zeta_ , theta_, kappa_, gamma_, eta_, lambda_;
+
+ // Compute all FluidProp variables
+ FluidProp.AllProps("PT", p , T, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
+ alpha_, beta_, chi_, fi_, ksi_, psi_,
+ zeta_, theta_, kappa_, gamma_, eta_, lambda_, &ErrorMsg);
+ if (isError(ErrorMsg)) { // An error occurred
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setState_pT(%f, %f)\n %s\n", p, T, ErrorMsg.c_str());
+ errorMessage(error);
+ }
+
+ // Fill in the ExternalThermodynamicState variables (in SI units)
+ properties->T = T_; // temperature
+ properties->a = c_; // speed of sound
+ properties->beta = theta_; // isothermal expansion coefficient
+ properties->cp = cp_; // specific heat capacity cp
+ properties->cv = cv_; // specific heat capacity cv
+ properties->d = d_; // density
+ properties->ddhp = ksi_; // derivative of density by enthalpy at constant p
+ properties->ddph = psi_; // derivative of density by pressure at constant h
+ properties->eta = eta_; // dynamic viscosity
+ properties->h = h_; // specific enthalpy
+ properties->kappa = kappa_; // compressibility
+ properties->lambda = lambda_; // thermal conductivity
+ properties->p = p; // pressure
+ properties->s = s_; // specific entropy
+ properties->phase = 1; // Always one-phase with pT inputs
+}
+
+// Computes the properties of the state vector from d and T
+/*! Note: the phase input is currently not supported according to the standard,
+ the phase input is returned in the state record
+*/
+void FluidPropSolver::setState_dT(double &d, double &T, int &phase, ExternalThermodynamicState *const properties){
+ string ErrorMsg;
+ // FluidProp variables (in SI units)
+ double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
+ cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
+ psi_, zeta_ , theta_, kappa_, gamma_, eta_, lambda_;
+
+ // Compute all FluidProp variables
+ FluidProp.AllProps("Td", T , d, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
+ alpha_, beta_, chi_, fi_, ksi_, psi_,
+ zeta_, theta_, kappa_, gamma_, eta_, lambda_, &ErrorMsg);
+ if (isError(ErrorMsg)) { // An error occurred
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setState_dT(%f, %f)\n %s\n", d, T, ErrorMsg.c_str());
+ errorMessage(error);
+ }
+
+ // Fill in the ExternalThermodynamicState variables (in SI units)
+ properties->T = T; // temperature
+ properties->a = c_; // speed of sound
+ properties->beta = theta_; // isothermal expansion coefficient
+ properties->cp = cp_; // specific heat capacity cp
+ properties->cv = cv_; // specific heat capacity cv
+ properties->d = d; // density
+ properties->ddhp = ksi_; // derivative of density by enthalpy at constant p
+ properties->ddph = psi_; // derivative of density by pressure at constant h
+ properties->eta = eta_; // dynamic viscosity
+ properties->h = h_; // specific enthalpy
+ properties->kappa = kappa_; // compressibility
+ properties->lambda = lambda_; // thermal conductivity
+ properties->p = P_; // pressure
+ properties->s = s_; // specific entropy
+ properties->phase = phase; // phase
+}
+
+//! Computes the properties of the state vector from p and s
+/*! Note: the phase input is currently not supported according to the standard,
+ the phase input is returned in the state record
+*/
+void FluidPropSolver::setState_ps(double &p, double &s, int &phase, ExternalThermodynamicState *const properties){
+ string ErrorMsg;
+ // FluidProp variables (in SI units)
+ double P_, T_, v_, d_, h_, s_, u_, q_, x_[20], y_[20],
+ cv_, cp_, c_, alpha_, beta_, chi_, fi_, ksi_,
+ psi_, zeta_ , theta_, kappa_, gamma_, eta_, lambda_;
+
+ // Compute all FluidProp variables
+ FluidProp.AllProps("Ps", p , s, P_, T_, v_, d_, h_, s_, u_, q_, x_, y_, cv_, cp_, c_,
+ alpha_, beta_, chi_, fi_, ksi_, psi_,
+ zeta_, theta_, kappa_, gamma_, eta_, lambda_, &ErrorMsg);
+ if (isError(ErrorMsg)) {
+ // An error occurred
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::setState_ps(%f, %f)\n %s\n", p, s, ErrorMsg.c_str());
+ errorMessage(error);
+ }
+
+ // Fill in the ExternalThermodynamicState variables (in SI units)
+ properties->T = T_; // temperature
+ properties->a = c_; // speed of sound
+ properties->beta = theta_; // isothermal expansion coefficient
+ properties->cp = cp_; // specific heat capacity cp
+ properties->cv = cv_; // specific heat capacity cv
+ properties->d = d_; // density
+ properties->ddhp = ksi_; // derivative of density by enthalpy at constant p
+ properties->ddph = psi_; // derivative of density by pressure at constant h
+ properties->eta = eta_; // dynamic viscosity
+ properties->h = h_; // specific enthalpy
+ properties->kappa = kappa_; // compressibility
+ properties->lambda = lambda_; // thermal conductivity
+ properties->p = p; // pressure
+ properties->s = s; // specific entropy
+ properties->phase = phase; // phase
+}
+
+//! Set bubble state
+/*!
+ This function sets the bubble state record bubbleProperties corresponding to the
+ saturation data contained in the properties record.
+
+ Due to current lack of direct control over the phase in FluidProp, a small delta is added to
+ the dewpoint enthalpy to make sure the correct phase is selected.
+ @param properties ExternalSaturationProperties record with saturation properties data
+ @param phase Phase (1: one-phase, 2: two-phase)
+ @param bubbleProperties ExternalThermodynamicState record where to write the bubble point properties
+*/
+void FluidPropSolver::setBubbleState(ExternalSaturationProperties *const properties, int phase,
+ ExternalThermodynamicState *const bubbleProperties){
+ // Set the bubble state property record based on the saturation properties record
+ double hl;
+
+ if (phase == 0)
+ hl = properties->hl;
+ else if (phase == 1) // liquid phase
+ hl = properties->hl-delta_h;
+ else // two-phase mixture
+ hl = properties->hl+delta_h;
+
+ setState_ph(properties->psat, hl, phase, bubbleProperties);
+}
+
+//! Set dew state
+/*!
+ This function sets the dew state record dewProperties corresponding to the
+ saturation data contained in the properties record.
+
+ The default implementation of the setDewState function is relying on the correct
+ behaviour of setState_ph with respect to the state input. Can be overridden
+ in the specific solver code to get more efficient or correct handling of this situation.
+ @param properties ExternalSaturationProperties record with saturation properties data
+ @param phase Phase (1: one-phase, 2: two-phase)
+ @param dewProperties ExternalThermodynamicState record where to write the dew point properties
+*/
+void FluidPropSolver::setDewState(ExternalSaturationProperties *const properties, int phase,
+ ExternalThermodynamicState *const dewProperties){
+ // Set the dew state property record based on the saturation properties record
+ double hv;
+
+ if (phase == 0)
+ hv = properties->hv;
+ else if (phase == 1) // liquid phase
+ hv = properties->hv+delta_h;
+ else // two-phase mixture
+ hv = properties->hv-delta_h;
+
+ setState_ph(properties->psat, hv, phase, dewProperties);
+}
+
+
+//! Compute isentropic enthalpy
+/*!
+ This function returns the enthalpy at pressure p after an isentropic
+ transformation from the state specified by the properties input
+
+ @param p New pressure
+ @param properties ExternalThermodynamicState property record corresponding to current state
+*/
+double FluidPropSolver::isentropicEnthalpy(double &p, ExternalThermodynamicState *const properties){
+ string ErrorMsg;
+ double h;
+
+ h = FluidProp.Enthalpy("Ps", p , properties->s, &ErrorMsg);
+ if (isError(ErrorMsg)) { // An error occurred
+ // Build error message and pass it to the Modelica environment
+ char error[300];
+ sprintf(error, "FluidProp error in FluidPropSolver::isentropicEnthalpy(%f, %f)\n %s\n", p, properties->s, ErrorMsg.c_str());
+ errorMessage(error);
+ }
+ return h;
+}
+
+//! Check if FluidProp returned an error
+bool FluidPropSolver::isError(string ErrorMsg)
+{
+ if(ErrorMsg == "No errors")
+ return false;
+ else
+ return true;
+}
+
+//! Check if FluidProp returned a license error
+bool FluidPropSolver::licenseError(string ErrorMsg)
+{
+ if (ErrorMsg.find("license") != std::string::npos)
+ return true;
+ else
+ return false;
+}
+
+#endif
\ No newline at end of file
diff --git a/Projects/Sources/fluidpropsolver.h b/Projects/Sources/fluidpropsolver.h
index bc70d330..d8d09ed2 100644
--- a/Projects/Sources/fluidpropsolver.h
+++ b/Projects/Sources/fluidpropsolver.h
@@ -1,70 +1,72 @@
-//! FluidProp solver interface class
-/*!
- * This class defines a solver object encapsulating a FluidProp object
- *
- * The class will work if FluidProp is correctly installed, and if
- * the following files, defining the CFluidProp object, are included
- * in the C project:
- * - FluidProp_IF.h
- * - FluidProp_IF.cpp
- * - FluidProp_COM.h
- * These files are developed and maintained by TU Delft and distributed
- * as a part of the FluidProp suite http://www.fluidprop.com
- *
- * Compilation requires support of the COM libraries:
- * http://en.wikipedia.org/wiki/Component_Object_Model
- *
- * To instantiate a specific FluidProp fluid, it is necessary to set
- * the libraryName and substanceNames package constants as in the
- * following example:
- *
- * libraryName = "FluidProp.RefProp";
- * substanceNames = {"H2O"};
- *
- * Instead of RefProp, it is possible to indicate TPSI, StanMix, etc.
- * Instead of H2O, it is possible to indicate any supported substance
- *
- * See also the solvermap.cpp code
- *
- * Francesco Casella, Christoph Richter, Roberto Bonifetto
- * 2006 - 2012
- * Copyright Politecnico di Milano, TU Braunschweig,
- * Politecnico di Torino
- ********************************************************************/
-
-#ifndef FLUIDPROPSOLVER_H_
-#define FLUIDPROPSOLVER_H_
-
-#include "include.h"
-#include "basesolver.h"
-
-#include "FluidProp_IF.h"
-
-class FluidPropSolver : public BaseSolver{
-public:
- FluidPropSolver(const string &mediumName, const string &libraryName, const string &substanceName);
- ~FluidPropSolver();
- virtual void setFluidConstants();
-
- virtual void setSat_p(double &p, ExternalSaturationProperties *const properties);
- virtual void setSat_T(double &T, ExternalSaturationProperties *const properties);
-
- virtual void setState_ph(double &p, double &h, int &phase, ExternalThermodynamicState *const properties);
- virtual void setState_pT(double &p, double &T, ExternalThermodynamicState *const properties);
- virtual void setState_dT(double &d, double &T, int &phase, ExternalThermodynamicState *const properties);
- virtual void setState_ps(double &p, double &s, int &phase, ExternalThermodynamicState *const properties);
- virtual void setBubbleState(ExternalSaturationProperties *const properties, int phase,
- ExternalThermodynamicState *const bubbleProperties);
- virtual void setDewState(ExternalSaturationProperties *const properties, int phase,
- ExternalThermodynamicState *const dewProperties);
- virtual double isentropicEnthalpy(double &p, ExternalThermodynamicState *const properties);
-
-protected:
- TFluidProp FluidProp; // Instance of FluidProp wrapper object
- bool isError(string ErrorMsg);
- bool licenseError(string ErrorMsg);
-};
-
-
-
-#endif /*FLUIDPROPSOLVER_H_*/
+//! FluidProp solver interface class
+/*!
+ * This class defines a solver object encapsulating a FluidProp object
+ *
+ * The class will work if FluidProp is correctly installed, and if
+ * the following files, defining the CFluidProp object, are included
+ * in the C project:
+ * - FluidProp_IF.h
+ * - FluidProp_IF.cpp
+ * - FluidProp_COM.h
+ * These files are developed and maintained by TU Delft and distributed
+ * as a part of the FluidProp suite http://www.fluidprop.com
+ *
+ * Compilation requires support of the COM libraries:
+ * http://en.wikipedia.org/wiki/Component_Object_Model
+ *
+ * To instantiate a specific FluidProp fluid, it is necessary to set
+ * the libraryName and substanceNames package constants as in the
+ * following example:
+ *
+ * libraryName = "FluidProp.RefProp";
+ * substanceNames = {"H2O"};
+ *
+ * Instead of RefProp, it is possible to indicate TPSI, StanMix, etc.
+ * Instead of H2O, it is possible to indicate any supported substance
+ *
+ * See also the solvermap.cpp code
+ *
+ * Francesco Casella, Christoph Richter, Roberto Bonifetto
+ * 2006 - 2012
+ * Copyright Politecnico di Milano, TU Braunschweig,
+ * Politecnico di Torino
+ ********************************************************************/
+
+#ifndef FLUIDPROPSOLVER_H_
+#define FLUIDPROPSOLVER_H_
+
+#include "include.h"
+#if (EXTERNALMEDIA_FLUIDPROP == 1)
+
+#include "basesolver.h"
+
+#include "FluidProp_IF.h"
+
+class FluidPropSolver : public BaseSolver{
+public:
+ FluidPropSolver(const string &mediumName, const string &libraryName, const string &substanceName);
+ ~FluidPropSolver();
+ virtual void setFluidConstants();
+
+ virtual void setSat_p(double &p, ExternalSaturationProperties *const properties);
+ virtual void setSat_T(double &T, ExternalSaturationProperties *const properties);
+
+ virtual void setState_ph(double &p, double &h, int &phase, ExternalThermodynamicState *const properties);
+ virtual void setState_pT(double &p, double &T, ExternalThermodynamicState *const properties);
+ virtual void setState_dT(double &d, double &T, int &phase, ExternalThermodynamicState *const properties);
+ virtual void setState_ps(double &p, double &s, int &phase, ExternalThermodynamicState *const properties);
+ virtual void setBubbleState(ExternalSaturationProperties *const properties, int phase,
+ ExternalThermodynamicState *const bubbleProperties);
+ virtual void setDewState(ExternalSaturationProperties *const properties, int phase,
+ ExternalThermodynamicState *const dewProperties);
+ virtual double isentropicEnthalpy(double &p, ExternalThermodynamicState *const properties);
+
+protected:
+ TFluidProp FluidProp; // Instance of FluidProp wrapper object
+ bool isError(string ErrorMsg);
+ bool licenseError(string ErrorMsg);
+};
+
+#endif
+
+#endif /*FLUIDPROPSOLVER_H_*/
diff --git a/Projects/Sources/include.h b/Projects/Sources/include.h
index d75262e3..5d37e837 100644
--- a/Projects/Sources/include.h
+++ b/Projects/Sources/include.h
@@ -1,123 +1,70 @@
-/*!
- \file include.h
- \brief Main include file
-
- This is a main include file for the entire ExternalMediaPackage
- project. It defines some important preprocessor variables that might
- have to be changed by the user.
-
- Uncomment the define directives as appropriate
-
- Francesco Casella, Christoph Richter, Roberto Bonifetto
- 2006-2012
- Copyright Politecnico di Milano, TU Braunschweig, Politecnico di Torino
-*/
-#ifndef INCLUDE_H_
-#define INCLUDE_H_
-
-/********************************************************************
- * Start of user option selection
- ********************************************************************/
-
-// Selection of Modelica compiler
-//! Modelica compiler is Dymola
-/*!
- Set this preprocessor variable to 1 if Dymola is the Modelica
- compiler that is going to be used with the compiled library.
- \sa OPEN_MODELICA
-*/
-#define DYMOLA 1
-
-//! Modelica compiler is OpenModelica
-/*!
- Set this preprocessor variable to 1 if OpenModelica is the Modelica
- compiler that is going to be used with the compiled library.
- \sa DYMOLA
-*/
-#define OPEN_MODELICA 0
-
-// Selection of used external fluid property computation packages.
-//! FluidProp solver
-/*!
- Set this preprocessor variable to 1 to include the interface to the
- FluidProp solver developed and maintained by Francesco Casella.
-*/
-#define FLUIDPROP 1
-
-// Selection of used external fluid property computation packages.
-//! CoolProp solver
-/*!
- Set this preprocessor variable to 1 to include the interface to the
- CoolProp solver developed and maintained by Ian Bell et al.
-*/
-#define COOLPROP 1
-
-// Selection of build type for this project
-//! Build project into a DLL
-/*!
- Set this preprocessor variable to 1 if the project is built into a
- dynamic link library. This setting influences the error reporting
- mechanism as well as the export statement.
-*/
-#define BUILD_DLL 0
-
-//! Not a number
-/*!
- This value is used as not a number value. It can be changed by
- the user if there is a more appropriate value.
-*/
-#define NAN 0xffffffff
-#define ISNAN(x) (x == NAN)
-
-/********************************************************************
- * End of user option selection
- * Do not change anything below this line
- ********************************************************************/
-/*! Detect the platform in order to avoid the DLL commands from
- * making g++ choke. Code taken from CoolProp...
- */
-#if defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__)
-# define __ISWINDOWS__
-#elif __APPLE__
-# define __ISAPPLE__
-#elif __linux
-# define __ISLINUX__
-#endif
-
-/*!
-Portable definitions of the EXPORT macro
- */
-#ifndef EXPORT
-# if defined(__ISLINUX__)
-# define EXPORT
-# elif defined(__ISAPPLE__)
-# define EXPORT
-# else
-# define EXPORT __declspec(dllexport)
-# endif
-#endif
-
-/*!
-Overwrite FluidProp inclusion if not on Windows
- */
-#if defined(__ISLINUX__)
-# undef FLUIDPROP
-# define FLUIDPROP 0
-#elif defined(__ISAPPLE__)
-# undef FLUIDPROP
-# define FLUIDPROP 0
-#endif
-
-
-
-// General purpose includes
-#include