Skip to content

Convection-diffusion phase change solver for OpenFOAM 5.0

License

Notifications You must be signed in to change notification settings

geo-fluid-dynamics/CoMeTFoam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoMeTFoam

Build Status OpenFOAM 5.x

Convection-diffusion phase change solver for OpenFOAM 5.0. It is based on the official buoyantBoussinesqPimpleFoam solver.

Geo Fluid Dynamics - A research group at RWTH Aachen University
Author: Kai Schüller ([email protected])

Table of Contents

Current capabilities

  • Convection-diffusion phase change
  • Temperature dependent properties
    • density
    • thermal conductivity
    • specific heat
    • kinematic viscosity

Getting started

OpenFOAM

CoMeTFoam is a custom solver for OpenFOAM. Therefore it must be installed first. Depending on the operating system (Ubuntu, Linux, MacOS, Windows using Windows Subsystem for Linux with Ubuntu packs), different options are available, which are very good described on the official download page.

To give an example, we will summarize the steps, which are necessary to use the OpenFOAM 5.0 docker image on MacOS in the following:

  1. Install Docker for MacOS

  2. Download two scripts and make them executable

sudo curl --create-dirs -o /usr/local/bin/openfoam5-macos http://dl.openfoam.org/docker/openfoam5-macos
sudo chmod 755 /usr/local/bin/openfoam5-macos
sudo curl -o /usr/local/bin/openfoam-macos-file-system http://dl.openfoam.org/docker/openfoam-macos-file-system
sudo chmod 755 /usr/local/bin/openfoam-macos-file-system
  1. Create a 10GB file system (look here for other options)
openfoam-macos-file-system create
  1. Mount the file system
openfoam-macos-file-system mount
  1. Launching OpenFOAM
cd $HOME/openfoam
openfoam5-macos
  1. Test if OpenFOAM runs as expected
cd $FOAM_RUN
cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
cd pitzDaily
blockMesh
simpleFoam

CoMeTFoam

  1. Download CoMeTFoam
git clone [email protected]:geo-fluid-dynamics/CoMeTFoam.git
  1. Compile the solver
cd CoMeTFoam
wmake
  1. Test if CoMeTFoam runs as expected
cd ../tests
./Alltest

User instructions

The default thermo-physical properties are those of a pure water-ice PCM. All of them can be modified in constant/transportProperties, which will be described in the following subsections.

Setting the viscosity

CoMeTFoam provides the option to set a temperature dependent kinematic viscosity. This can be done by changing the values of nua, nub and nuc.

To give an example, we will now discuss how to choose the correct parameters for pure water. Its kinematic viscosity is summarized in the following table.

Temperature [K] kin. Viscosity [10^(-6) m^2/s]
273.15 (0 °C) 1.787
283.15 (10 °C) 1.307
293.15 (20 °C) 1.004
303.15 (30 °C) 0.801
313.15 (40 °C) 0.658
323.15 (50 °C) 0.553
333.15 (60 °C) 0.475
343.15 (70 °C) 0.413
353.15 (80 °C) 0.365
363.15 (90 °C) 0.326
373.15 (100 °C) 0.294

source: engineeringtoolbox

We can approximate those tabular values with the following equation

Curve fitting yields for the tabular data:

  • nua = -2.327547e+05 s/m^2
  • nub = -1.608951e+04 s/m^2/K
  • nuc = 6.931645e+01 s/m^2/K^2
  • TRef_nu = 0 K

Kinematic viscosity over temperature

Setting the density

The user has the option to set the densities (solid and liquid) in constant/transportProperties by changing the coefficients of polynomials.

Liquid density

For the liquid PCM, the density polynomial is

with:

  • rho_La = 999.79684 kg/m^3
  • rho_Lb = 0.068317355 kg/m^3/K
  • rho_Lc = -0.010740248 kg/m^3/K^2
  • rho_Ld = 0.00082140905 kg/m^3/K^2.5
  • rho_Le = -2.3030988e-5 kg/m^3/K^3
  • TRef_rho_L = 273.15 K

These values include the density anomaly (maximum density) of water near 4 °C.

source: Popiel, C. O., and J. Wojtkowiak. "Simple formulas for thermophysical properties of liquid water for heat transfer calculations (from 0 C to 150 C)." Heat transfer engineering 19.3 (1998): 87-101.

Solid density

Temperature [°C] Solid density [kg/m^3]
0 916.7
-10 918.7
-20 920.3
-30 921.6
-40 922.8
-50 924.0
-60 925.2
-80 927.4
-100 929.2

source: Lide, David R.: CRC Handbook of Chemistry and Physics. 90th Edition (Internet Version 2010). Boca Raton, FL. : CRC Press/Taylor and Francis, 2010.

Curve fitting yields for the tabular data:

  • rho_Sa = 9.169417e+2 kg/m^3
  • rho_Sb = -1.652339e-1 kg/m^3/K
  • rho_Sc = -4.320109e-4 kg/m^3/K^2
  • TRef_rho_S = 273.15 K

Setting the specific heat and thermal conductivity

The thermal conductivity and the specific heats are approximated by quadratic polynomials of degree that fit the following tabular data

Temperature [°C] Therm. conductivity [W/m/K] Specific heat [J/kg/K] Phase
90 0.6753 4205.2 Liquid
80 0.6700 4196.8 Liquid
70 0.6631 4190.1 Liquid
60 0.6544 4185.0 Liquid
50 0.6436 4181.3 Liquid
40 0.6306 4179.4 Liquid
30 0.6155 4179.8 Liquid
20 0.5985 4184.1 Liquid
10 0.5800 4195.2 Liquid
0.01 0.5611 4219.4 Liquid
0 2.14 2110 Solid
-10 2.3 2030 Solid
-20 2.4 1960 Solid
-30 2.5 1880 Solid
-40 2.6 1800 Solid
-50 2.8 1720 Solid
-60 3.0 1650 Solid
-80 3.3 1500 Solid
-100 3.7 1360 Solid

source: Lide, David R.: CRC Handbook of Chemistry and Physics. 90th Edition (Internet Version 2010). Boca Raton, FL. : CRC Press/Taylor and Francis, 2010.

The resulting coefficients for the quadratic polynomials are given in examples/cavity/constant/transportProperties

Developer instructions

  1. Fork this repository

  2. Check out the source code with:

git clone [email protected]:YOUR_GITHUB_USERNAME/CoMeTFoam.git
  1. Start a new branch with:
cd CoMeTFoam
git checkout -b yournewbranch
  1. Add new stuff

  2. Make sure that the tests passes

cd tests
./Alltest
  1. Add the changes, commit and push
git add CoMeTFoam/yourchanges
git commit -m 'describe the changes'
git push origin yournewbranch
  1. Finally, create a pull request.

RWTH Compute Cluster

In this section, we describe how to use CoMeTFoam on the RWTH Compute Cluster. If you don't have access, you can skip this section. However, if you have access to a different Compute Cluster some steps might be similar.

module load TECHNICS
module load openfoam/5.0

The Standard command to run an OpenFOAM solver in parallel does not work on the cluster. Therefore, the Allrun scripts do not work until the line

...
runParallel $(getApplication)
...

is replaced with

...
$MPIEXEC $FLAGS_MPI_BATCH foamExec CoMeTFoam -parallel
...

In order to replace this line in the Allrun script, run

mv Allrun AllrunOld
sed -e 's!runParallel $(getApplication)!$MPIEXEC $FLAGS_MPI_BATCH foamExec CoMeTFoam -parallel!g' AllrunOld > Allrun
chmod +x Allrun

And to revert this change

mv AllrunOld Allrun

A better practice is to submit a job to the cluster. An example of a job script is found in etc/job.sh. Make sure to change the line that sets the -n flag to the correct number of compute slots that are needed to run the case. Once the job script is copied to the case directory, run

bsub < job.sh

to submit the job.

Examples

The examples, which are shown here can be found in the examples folder.

Stefan problem

Stefan problem animation

The following plot shows a comparison between the solution of CoMeTFoam and the analytical solution to the Stefan problem using the same thermo-physical properties.

Stefan problem comparison

The plot can be repoduced by

cd examples/stefanProblem
./ConvergenceTestRun
python createPlots.py

The scripts first create copies of the folder stefanProblem with different number of cells (320, 640, 1280 cells) and then runs CoMeTFoam for each case. Additionally the order of grid convergence can be calculated using

python calcConvergence.py

which yields 1.45834902755 for the considered meshes (320, 640, 1280 cells).

Cavity melting

Two cavity melting examples are provided - cavity and cavityVarViscosity. The first one uses a constant kinematic viscosity, whereas the latter uses a temperature dependent kinematic viscosity. The following picture shows the difference of those two cases.

Comparison constant and variable viscosity cavity melting

References

  • Rösler, Fabian. Modellierung und simulation der phasenwechselvorgänge in makroverkapselten latenten thermischen speichern. Vol. 24. Logos Verlag Berlin GmbH, 2014.

About

Convection-diffusion phase change solver for OpenFOAM 5.0

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published