Fluid material selection ... CoolProp installation [Solved]

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
tpa
Posts: 49
Joined: Fri Mar 16, 2012 11:35 pm

Fluid material selection ... CoolProp installation [Solved]

Post by tpa »

Hello,

I just built Code_Saturne Version 8.0.2. and notice the very nice feature of a material library. Thank you very much for that. A really convenient addition.

I have started my first run, a gui case with water selected as fluid, But ... looking through the listing I see the following:

Code: Select all

   field                    minimum         maximum        set mean    spatial mean
-  ----------------  --------------  --------------  --------------  --------------
v  Velocity[X]               -0.798          3.4629          0.1593         0.17215
...
v  Density                   1.1786          1.1786          1.1786          1.1786
v  LamVisc               1.8334e-05      1.8334e-05      1.8334e-05      1.8334e-05
...
This looks very much like air to me. Any good suggestions as to what I am doing wrong?
The xml look like this:

Code: Select all

<fluid_properties>
<material choice="Water"/>
<method choice="CoolProp"/>
<property choice="thermal_law" label="Density" name="density">
<initial_value>1.17862</initial_value>
</property>
<property choice="constant" label="DiffDyn" name="dynamic_diffusion">
<initial_value>0.01</initial_value>
<listing_printing status="off"/>
<postprocessing_recording status="off"/>
</property>
<property choice="thermal_law" label="LamVisc" name="molecular_viscosity">
<initial_value>1.83e-05</initial_value>
</property>
<reference_pressure>101325</reference_pressure>
<reference_temperature>293.15</reference_temperature>
</fluid_properties>

So it may be something with how I use (or what I expect from) the GUI.
Last edited by tpa on Mon Oct 30, 2023 2:27 am, edited 1 time in total.
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Fluid material selection ...

Post by Yvan Fournier »

Hello,

If you build code_saturne with CoolProp support (requiring CoolProp 6.4 at least), things should work (I just checked on my side), unless there is à subtle install issue.

Could you post the installation steps config.log ?

Best regards,

Yvan
tpa
Posts: 49
Joined: Fri Mar 16, 2012 11:35 pm

Re: Fluid material selection ...

Post by tpa »

From "install_saturne.log"

Code: Select all

checking for CoolProp library)... no
So this seems is a required prerequisite and not installed via the setup file ... I was not aware of that :?
Apparently I can download the library from here: https://sourceforge.net/projects/coolpr ... nux/64bit/

But where do I put it to have "configure" find it?

I tried just to copy it to /usr/lib and put CoolPropLib.h in /usr/include but that did not work. Is there something I can do with the "setup" file to make it work?
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Fluid material selection ...

Post by Yvan Fournier »

Hello,

You need to use the low-level install script, as described in the detailed installation instructions.

Actually, you can start from the build you have with the high level script, go into the build directory, and re-run the configuration command liste at the top of the config.log file, adding --with-coolprop=<path>.

The run "make" and "make install".

In any case, if CoolProp is not available but requested in the case setup, the code should stop or warn the user, not silently use a default, so I will also look into that...

Best regards,

Yvan
tpa
Posts: 49
Joined: Fri Mar 16, 2012 11:35 pm

Re: Fluid material selection ...

Post by tpa »

Thank you again, Yvan.

Output from configure. Using Coolprop 6.5 I get a few warning which may or may not be of importance:

Code: Select all

configure:12932: gcc -o conftest -funsigned-char -W -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wunused -Wfloat-equal -Werror=implicit-function-declaration -fdiagnostics-color=auto -Werror=format-security  -fopenmp   -D_POSIX_C_SOURCE=200809L -DNDEBUG -I/opt/coolprop/include   -O -Wl,-export-dynamic -fopenmp -L/opt/coolprop/lib  conftest.c -lCoolProp   -ldl >&5
In file included from conftest.c:49:0:
/opt/coolprop/include/CoolPropLib.h:233:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
 EXPORT_CODE int CONVENTION get_debug_level();
 ^
conftest.c:51:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
 main ()
 ^
conftest.c: In function 'main':
conftest.c:53:8: warning: unused variable 'v' [-Wunused-variable]
 double v = PropsSI("o", "n1", 1., "n2", 1., "r");
        ^
/opt/coolprop/lib/libCoolProp.so: undefined reference to `stat64@GLIBC_2.33'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `dlclose@GLIBC_2.34'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `dlerror@GLIBC_2.34'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `__libc_single_threaded@GLIBC_2.32'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `log@GLIBC_2.29'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `dlsym@GLIBC_2.34'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `std::__throw_bad_array_new_length()@GLIBCXX_3.4.29'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `lstat@GLIBC_2.33'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()@GLIBCXX_3.4.26'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `dlopen@GLIBC_2.34'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `exp@GLIBC_2.29'
/opt/coolprop/lib/libCoolProp.so: undefined reference to `pow@GLIBC_2.29'
Can I bypass the warning checking?
tpa
Posts: 49
Joined: Fri Mar 16, 2012 11:35 pm

Re: Fluid material selection ...

Post by tpa »

I now have built the CoolProp library locally from source, and ./configure now seems to pass tests when issued manually with the "--with-coolprop=/opt/coolprop" option. Next step will be to find out to integrate it into code_saturne to avoid this error:

Code: Select all

configure:12913: checking for CoolProp library)
configure:12932: /usr/bin/mpicc -o conftest -funsigned-char -W -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wunused -Wfloat-equal -Werror=implicit-function-declaration -fdiagnostics-color=auto -Werror=format-security  -fopenmp   -D_POSIX_C_SOURCE=200809L -DNDEBUG    -O -Wl,-export-dynamic -fopenmp   conftest.c -lCoolProp   -ldl >&5
conftest.c:54:65: fatal error: CoolPropLib.h: No such file or directory
compilation terminated.
So - small steps - but the direction seems right :-)

The command "code_saturne info -g install" returns this error:

Code: Select all

File /opt/code_saturne-8.0.2/arch/Linux_x86_64/share/doc/code_saturne/install.pdf not found.
so I will search elsewhere for the installation manual.
tpa
Posts: 49
Joined: Fri Mar 16, 2012 11:35 pm

Re: Fluid material selection ...

Post by tpa »

So I ended up with presenting the CoolProp library to the Code_Saturne installation by pursuing my first approach of introducing the libraries and header files into the standard system tree, more specific in /usr/local/lib (library) and /usr/local/include (header). This way the installation process find the library and I can keep my customizations in the standard "setup" file.

Running a case with water now gives (from the listing file):

Code: Select all

 ** VARIABLES INITIALIZATION
    ------------------------

 -----------------------------------------
 Property           Min. value  Max. value
 -----------------------------------------
  density           0.9982E+03  0.9982E+03
  molecular_viscos  0.1024E-02  0.1024E-02
  turbulent_viscos  0.5268E+01  0.5268E+01
  specific_heat     0.4182E+04  0.4182E+04
 -----------------------------------------
which looks right. I also ran a testcase with dry air as medium. A rectangular duct with axial flow and one side cold and the other side warm, and it seems that temperature functions works as well when setting "Material Law" for the density function.
Fig1.png
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Fluid material selection ...

Post by Yvan Fournier »

Hello,

Great that you have it working. As we do not use this often in actual studies (and neptune_cfd uses another library, EOS, any feedback on performance compared to using formulas is welcome (it was very slow in v7.0, and should be faster in v8.0 as it now uses tabulations by default, but I have only updated and debugged this, not run any actual performance tests).

Best regards,

Yvan
tpa
Posts: 49
Joined: Fri Mar 16, 2012 11:35 pm

Re: Fluid material selection ... -> CoolProp installation HOWTO

Post by tpa »

Below I summarize the fruit of my struggles as it may be of use to others. Parts of the method requires write access to system directories and should therefore be in a "sudo" shell.

Download "CoolProp_sources.zip". I used this url: https://netix.dl.sourceforge.net/projec ... ources.zip. This link may or may not work for you and is release specific, so check the project status at sorceforge for relevant news etc.

Unzip directory "source"
Set "source" to be your working directory.
Edit CMakeLists.txt (Use "vi" or another source file editor) and change the below option from OFF to ON:

Code: Select all

option(COOLPROP_SHARED_LIBRARY "Build CoolProp as a shared library (.dll, .so)" ON)
run "cmake ." <- (remember the dot ".")
run "make"

This will take a little time and produce (at least) the following files and links in the working:

Code: Select all

       16 Oct 29 23:27 libCoolProp.so -> libCoolProp.so.6
       20 Oct 29 23:27 libCoolProp.so.6 -> libCoolProp.so.6.5.0
 22655336 Oct 29 23:27 libCoolProp.so.6.5.0
To install the relevant files in a location found by the code_saturne installation process put them in a standard location. As I like be be able to track my customizations involving system directories, I choose to put the CoolProp files physically in a dedicated folder in /opt and then make soft links to these files from the system folders:

Code: Select all

mkdir /opt/coolprop
mkdir /opt/coolprop/lib
mv libCoolProp.so libCoolProp.so.6 libCoolProp.so.6.5.0 /opt/coolprop/lib
mkdir /opt/coolprop/include
mv include/CoolPropLib.h /opt/coolprop/include
Now anything you need for code_saturne has been relocated to /opt/coolprop. You may now leave "source" and delete it if the code_saturne build has been finalized. Now to make the library and headers findable for the building of code_saturne:

Code: Select all

cd /usr/local/lib
ln -s /opt/coolprop/lib/libCoolProp.so* .
cd /usr/local/include
ln -s /opt/coolprop/include/CoolPropLib.h .
Install Code_Saturne the normal way and check install_saturne.log for the following message:

"checking for CoolProp library)... yes"

You can delete the "source" folder and its contents as the important parts have been moved to /opt/coolprop once you have verified that things work.

You may want to check the availability of CoolProp before building Code_Saturne. This can be done by setting the build directory (e.g. code_saturne-8.0.2.build) as working directory and running the configure command located in the distribution directory (e.g. ../code_saturne-8.0.2/configure) and check the "config.log" for errors.

There may be warnings but there should be no errors and somewhere a line saying "cs_have_coolprop='yes'"

Run some test cases.
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Fluid material selection ... CoolProp installation [Solved]

Post by Yvan Fournier »

Hello,

Also note that you can install CoolProp to a directory to which you have write access, so you do not need sudo access in that case. For this, there are installation instructions for CoolProp in code_saturne's main INSTALL.md documentation.

Best regards,

Yvan
Post Reply