Skip to content

Commit 2804de8

Browse files
author
John Eslick
authored
Doc3 (#256)
* Add build doc * Remove return * Use putenv for mingw
1 parent aea41c9 commit 2804de8

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

src/general_helmholtz/doc/documentation.tex

+32-1
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,39 @@ \section{Deviation from Literature}
140140

141141
\chapter{Building the Library}
142142

143-
This section provides information about compiling the shared library for the HEoS functions. A fully automated build system has not yet be implemented.
143+
This section provides information about compiling the shared library for the HEoS functions. A fully automated build system has not yet be implemented, since the IDAES team uses specialized scripts for binary releases. The HEoS shared library can still be done independently.
144144

145+
\section{Prerequisites}
146+
147+
A C++ compiler is required. There are many option and the suggestions given are not hard requirements, just what the IDAES team uses and find convenient.
148+
\begin{itemize}
149+
\item Linux: GCC can be installed using the systems package manager.
150+
\item Windows: MinGW-w64 (https://www.mingw-w64.org) and MSYS2 (https://www.msys2.org)
151+
\item macOS: Xcode command-line tools (https://developer.apple.com/xcode/)
152+
\end{itemize}
153+
154+
Boost is used for equation solvers, hashing tuples, and reading json. Below are suggestions for installing
155+
\begin{itemize}
156+
\item Linux: Boost can be obtained via package manager
157+
\item Windows: Boost can be installed via the MSYS2 package manger, if you use it to run MinGW
158+
\item macOS: Boost can be installed via Hombrew (https://brew.sh)
159+
\end{itemize}
160+
161+
AMPL Solver Library (ASL) is required. The ASL is used to read arbitrary expressions into the C++ functions, and to make functions callable from AMPL solvers. The ASL is available on GitHub (https://github.com/ampl/asl).
162+
163+
\section{Build}
164+
165+
In the \texttt{general\_helmholtz} directory, edit the make file. There are a few commented out variables \texttt{BOOST}, \texttt{ASL}, and \texttt{ASL\_LIB}. Depending on the specific setup, these may or may not be needed. If the build does not find ASL or BOOST the problem can most likely be fixed by setting these.
166+
167+
Run \texttt{make} in the \texttt{general\_helmholtz} directory and the \texttt{general\_helmholtz.so} file should be built. If there is a problem try setting the variables in the previous paragraph.
168+
169+
\section{Test}
170+
171+
To test the build, set the \texttt{IDAES\_HELMHOLTZ\_DATA\_PATH} and \texttt{IDAES\_HELMHOLTZ\_TEST\_DATA\_PATH} variables to the \texttt{param\_data} and \texttt{param\_data} directories. Be sure to end the path in a file separator.
172+
173+
Run \texttt{make test}.
174+
175+
The command should run without returning an error code, even though it may generate a small number of error messages. The test data may not contain enough significant figures to calculate pressure from density accurately, and in the neighborhood of the critical point, rapid changes in properties may make matching the test data difficult.
145176

146177
\chapter{Property Functions}
147178

src/general_helmholtz/read_params.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ uint read_params(std::string comp, std::string data_path){
2525
nl_file_st_path,
2626
json_file_path,
2727
except_string;
28+
std::string env_data_path_put;
2829
if(data_path == ""){
2930
if(const char* env_data_path = getenv("IDAES_HELMHOLTZ_DATA_PATH")){
3031
data_path = env_data_path;
@@ -35,7 +36,12 @@ uint read_params(std::string comp, std::string data_path){
3536
// and this may spawn another process, I need to transfer the data path set in the
3637
// function call to the environment variable to ensure that the data files can be
3738
// located by the new process.
39+
#ifndef __MINGW64__
3840
setenv("IDAES_HELMHOLTZ_DATA_PATH", data_path.c_str(), 1);
41+
#else
42+
env_data_path_put = "IDAES_HELMHOLTZ_DATA_PATH=" + data_path;
43+
putenv(env_data_path_put.c_str());
44+
#endif
3945
}
4046
// I'll assume component names are not case sensitive, so get lower case name.
4147
std::string lower_comp = comp;

src/general_helmholtz/test_exec.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include"config.h"
33
#include"phi.h"
44
#include"props.h"
5+
#include"props_hp.h"
56
#include"sat.h"
67
#include"delta.h"
78
#include"read_params.h"
@@ -103,6 +104,12 @@ int main(){
103104
// double rho=458.75, T=400.00; // P = 6 MPa
104105
// double rho=1519.8, T=200.00;
105106
// double rho=1022.3, T=350.00;
107+
std::cout << "r134a properties" << std::endl;
108+
res = memo2_entropy_hp(comp, 221.21, 4200);
109+
std::cout << " s = " << res.f << std::endl;
110+
res = memo2_temperature_hp(comp, 221.21, 4200);
111+
std::cout << " s = " << res.f << std::endl;
112+
//return 0;
106113
std::cout << "r134a properties for rho = " << rho << " T = " << T << std::endl;
107114
res = memo2_pressure(comp, rho/pdat->rho_star, pdat->T_star/T);
108115
std::cout << " p = " << res.f << std::endl;

0 commit comments

Comments
 (0)