MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
Foam expansion

Predicts the evolution of PU foam properties using the combination of nano-, meso- and macro-scopic models. More...

Namespaces

 CFD_tool_0D.QmomKinetics
 Backward mapping Firetask for QmomKinetics model.
 
 CFD_tool_3D.CFD_tool_3D
 
 Kinetics.Kinetics
 
 Kinetics.PrediciKinetics
 
 Rheology.Rheology
 Backward mapping FireTask for rheology model.
 
 Rheology_Arrhenius.Rheology_Arrhenius
 

Detailed Description

Predicts the evolution of PU foam properties using the combination of nano-, meso- and macro-scopic models.

INPUTS

The recipe for the simulation is specified in the inputs directory. Several test cases are prepared in the examples directory. The unifiedInput.json file controls the Bubble growth model and the 0D simulation, , wallDrainage_inputs.json controls the Wall drainage simulation and the rest of the files and directories control the OpenFOAM simulation.

Preparing unifiedInput.json

The following key-pairs should be defined:

  • physicalBlowingAgent: name of blowing agent [n-pentane, R11]
  • initialConditions:
    • concentrations: initial concentrations of reactants and blowing agents (mol/m^3) (always water, PBL, CO2 and for Baser kinetics: isocyanate, polyol; for RF-1 kinetics: catalyst, polyol1, polyol2, amine, isocyanate1, isocyanate2, isocyanate3)
    • bubbleRadius: initial bubble radius (m),
    • bubbleRadiusDeviation: standard deviation of initial BSD,
    • numberBubbleDensity: initial number density of bubbles (1/m^3),
    • temperature: initial temperature (K)
  • kinetics:
    • kineticModel: name of kinetic model [Baser, RF-1],
    • useDilution: use correction for dilution in Baser model (t/f),
    • gelPoint: conversion at the gel point
    • gellingReaction: parameters of gelling reaction
      • frequentialFactor: pre-exponential factor for Baser model (m^3/mol/s),
      • activationEnergy: activation energy for Baser model (J/mol),
      • reactionEnthalpy: reaction enthalpy used in all models (J/mol)
    • blowingReaction:
      • frequentialFactor: pre-exponential factor for Baser model (1/s),
      • activationEnergy: activation energy for Baser model (J/mol),
      • reactionEnthalpy: reaction enthalpy used in all models (J/mol)
  • physicalProperties:
    • pressure: (Pa)
    • blowingAgents:
      • PBL:
        • molarMass: (kg/mol)
        • heatCapacityInLiquidPhase: (J/kg/K)
        • heatCapacityInGaseousPhase: (J/kg/K)
        • evaporationHeat: (J/kg)
        • density: (kg/m^3)
        • diffusivityModel: [constant,nanotools],
        • diffusivity: diffusivity when constant diffusivityModel is used (m^2/s)
        • solubilityModel: [constant, pcsaft, Gupta, Winkler, Baser] Gupta and Winkler are models for n-pentane, Baser is model for R11
      • CO2:
        • molarMass: (kg/mol)
        • heatCapacityInLiquidPhase: (J/kg/K)
        • heatCapacityInGaseousPhase: (J/kg/K)
        • evaporationHeat: (J/kg)
        • density: (kg/m^3)
        • diffusivityModel: [constant,nanotools],
        • diffusivity: diffusivity when constant diffusivityModel is used (m^2/s)
        • solubilityModel: [constant, pcsaft]
        • solubility: solubility when constant solubilityModel is used (mol/m^3/Pa)
    • air :
      • molarMass: (kg/mol)
    • polymer:
      • heatCapacity: (J/kg/K)
      • polymerDensityModel: [constant, nanotools, pcsaft],
      • density: when constant polymerDensityModel is used (kg/m^3)
      • viscosityModel: [CastroMacosko],
      • maxViscosity: maximum viscosity - for gel point detection (Pa s),
      • molarMassNCO: (kg/kmol)
    • surfaceTensionModel: [constant pcsaft],
    • surfaceTension: surface tension when constant is used (N/m)
    • ModenaFoamViscosityModel: use TUE model to calculate foam viscosity (t/f)
  • bubbleGrowth:
    • geometry: [3D,2D]
    • integrator: [dlsode, dlsodes, 'cvode'] dlsodes is recommended
    • method: [nonstiff, stiff] stiff is recommended
    • inertialTerm: [t/f] use inertial term in bubble growth model
    • solubilityCorrection: [t/f] use solubility correction on surface tension
    • meshCoarseningParameter: 1.02 is recommended
    • internalNodes: number of nodes in shell around the bubble, 200 is recommended
    • initialTime: (s)
    • finalTime: (s)
    • outerTimeSteps: number of outputs
    • maxInnerTimeSteps: maximum number of internal time steps of integrator
    • relativeTolerance: 1e-8 is recommended
    • absoluteTolerance: 1e-8 is recommended
  • QmomKinetics:
    • relativeTolerance: 1e-6 is recommended
    • absoluteTolerance: 1e-6 is recommended
    • timeStep: (s)
    • endTime: (s)
    • bubbleMode: [mean radius, two nodes]

Preparing the test case for OpenFOAM simulation

  • 0 directory: initial and boundary conditions can be defined. Further details can be found in OpenFOAM UserGuide
  • system directory: includes dictioneries to control the simulation details such as time discretization, solution methods and etc. For further details, one should consult with OpenFOAM UserGuide
  • constant directory: includes the mesh and and dictionaries to define the physical properties of fluid flow. There are also additional dictionaries, specifically for PU foam.
    • kineticsProperties: defines the details of kinetics scheme
      • liquidMixtureDensitySurrogate: enable the surrogate model for mixture density [on/off],
      • blowingAgent: name of blowing agent [n-pentane, R-11],
      • kineticsModel: name of kinetics model [generic, RF-1],
      • GellingConstants: constants for the gelling reaction
        • A_OH: pre-exponential factor (m^3/mol s),
        • E_OH: activation energy (J/mol),
        • initCOH: initial concentration of polyol OH groups in the mixutre (mol/m3),
        • initCNCO: initial concentration of isocianate NCO groups in the mixutre (mol/m3),
        • initCW: initial concentration of water in the mixture (mol/m3),
        • gellingPoint: gelling point
      • BlowingConstants constants for the blowing reaction
        • A_W: pre-exponential factor (m^3/mol s),
        • E_W: activation energy (J/mol)
      • GenericConstants: generic constants
        • idealGasCons: ideal gas constant (J/mol K),
        • rhoPolymer: density of the liquid polymer (kg/m^3),
        • rhoBlowingAgent: density of the blowing agent (kg/m3),
        • molecularMassCO2: molecular mass of carbon dioxide, (kg/kmol),
        • molecularMassBlowingAgent: molecular mass of blowing agent (kg/kmol),
        • molecularMassNCO: molecular weight of NCO (kg/kmol),
        • molecularMassLiquidFoam: molecular weight of liquid mixture (kg/kmol),
        • dissolvedCO2: weight fraction of dissolved CO2 in the mixture (kg/kg),
        • dxdTcons: model constant for the blowing agent (-0.01162790697 is recommended),
        • initBlowingAgent: initial weight fraction of blowing agent in the liquid (kg/kg),
        • initCO2: initial weight fraction of CO2 in the liquid (kg/kg),
        • surfaceTension: surface tension
EnthalpyConstants: constant for energy equation
  • deltaOH: reaction heat for the gelling reaction (J/mol),
  • deltaW: reaction heat for the blowing reaction (J/mol),
  • PUspecificHeat: polyurethane specific heat (J/kg K),
  • CO2specificHeat: CO2 specific heat (J/kg K),
  • BGspecificHeat: physical blowing agent in gas phase specific heat (J/kg K),
  • BLspecificHeat: physical blowing agent in liquid phase specific heat (J/kg K),
  • latentHeat: latent heat of blowing agent (J/kg)
PBEProperties: defines the details of population balance solution
  • PBESwitch: enbale PBE model [on/off],
  • PBEMethod: solution method for PBE. In the current version QMOM is available.
  • nNodes: number of quadrature approximation nodes [2-3],
  • bubbleGrowthSurrogateSwitch: enable bubble growth surrogate model [on/off],
  • bubbleGrowthMode: use of mean bubble radius or two nodes [meanRadius, twoNodes].
rheologyProperties: define the rheology model (further details)
  • viscosityModel: viscosity model [constant, castro-macosko, bird-carreau]
simulationMode: defines the how long the simulation should run
  • simulationTarget: two different modes for the simulation: mold-filling and validation. Mold-filling would disable the solution of equations when the mould is filled and validation would continue until the defined end time.

Preparing the test case for Wall drainage simulation

  • growthRateModel: fromFile uses evolution of bubble radius from Bubble growth model [constant,fromFile],
  • growthRate: growth rate when constant growth rate model is used (m/s),
  • initialConditions:
    • centerThickness: initial film half thickness at the center (m),
    • domainSize: initial size of the domain (m),
    • filmReduction: parameter influencing initial shape of wall and strut (0.0 = only wall, 1.0 = only strut), 1.0 is recommended,
  • physicalProperties:
    • viscosityModel: fromFile uses evolution of viscosity from Bubble growth model [constant,fromFile],
    • viscosity: viscosity when constant viscosity model is used (Pa s),
    • surfaceTension: (N/m),
    • disjoiningPressure: parameters of disjoining pressure, consult Schwarz and Roy (2003)
      • N: 4.0,
      • M: 3.0,
      • hst: 1.0e-7,
      • C: 0.05,
      • B1: 0, if B1=0 disjoining pressure is neglected
  • integration:
    • initialTime: (s),
    • timeStep: write interval (s),
    • outerTimeSteps: number of outputs,
    • method: stiff is recommended [nonstiff, stiff],
    • internalNodes: discretization - number of finite volumes,
    • maxInnerTimeSteps: maximum number of internal time steps of integrator,
    • relativeTolerance: 1e-8 is recommended,
    • absoluteTolerance: 0 is recommended
  • algebraicEquationSolver:
    • tolerance: 1e-4 is recommended
  • strutFilmParameter: parameter for detection of wall/strut 1.1 is recommended

Preparing init_foamConductivity.json

  • T: list of temperatures (K)
  • dcell: list of cell sizes (m)
  • eps: list of porosities
  • fstrut: list of strut contents
  • x[CO2]: list of CO2 molar fractions
  • x[CyP]: list of cyclopentane molar fractions
  • x[N2]: list of nitrogen molar fractions
  • x[O2]: list of carbon dioxide molar fractions

README

Foaming simulation

Collection of software tools for the simulation of polyurethane (PU) foaming process. Based on a recipe the model predicts the evolution of chemical kinetics, temperature, foam density, bubble size distribution, etc. This directory includes the foaming process in zero dimensional and three dimensional spaces. Additionally, a wall drainage simulation can be performed, which estimates the size and shape of strut and wall thickness profile. In order to run a test case, firstly the source codes should be compiled. The script build compiles the necessary models. The surrogate models will be loaded into the database by executing the two scripts provided: initModels and initBubbleGrowth. Finally, the scripts workflow* run the simulations and detailed model for bubble growth.

Dependencies and Installation

Several models need to be compiled. C++ and Fortran compilers are required. First the MoDeNa framework should be compiled. The following steps describe how to install MoDeNa framework.

1. Install OpenFOAM

The CFD solver is compiled with OpenFOAM 4.0 on Ubuntu 16.04. In order to install OpenFOAM, you can either follow the steps in OpenFOAM website or copy/paste the commands below which install OpenFOAM and ParaView:
sudo add-apt-repository http://dl.openfoam.org/ubuntu
sudo sh -c "wget -O - http://dl.openfoam.org/gpg.key | apt-key add -"
sudo apt-get update
sudo apt-get -y install openfoam4
mkdir -p $FOAM_RUN
mkdir -p $FOAM_USER_APPBIN
mkdir -p $FOAM_USER_LIBBIN

Note 1: This video demonstrates the installation process.Note 2: Consult with official webpage for installation problems.### 2. Install MongoDB C++ Driver

cd $HOME
git clone -b r1.3 https://github.com/mongodb/mongo-c-driver
cd mongo-c-driver
./autogen.sh
make
sudo make install
cd $HOME
git clone -b master https://github.com/mongodb/mongo-cxx-driver
cd mongo-cxx-driver/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
sudo make
sudo make install

### 3. Install boost, lapack, blas and veusz libraries

sudo apt-get install libboost-dev liblapack-dev libblas-dev veusz

### 4. Install PETSc globally:

sudo mkdir /opt/petsc
sudo chown user:group /opt/petsc
cd /opt/petsc
wget http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.4.5.tar.gz
tar -xzf petsc-3.4.5.tar.gz
cd petsc-3.4.5
./configure --with-cc=gcc --with-fc=gfortran --download-f-blas-lapack --download-mpich --download-scalapak=yes
make

Export variables in .bashrc

export PETSC_DIR=/opt/petsc/petsc-3.4.5
export PETSC_ARCH=arch-linux2-c-debug

### 5. Install rapidjson library

cd where-you-want-source-files
git clone https://github.com/miloyip/rapidjson.git
cd rapidjson
cmake .
make
sudo make install

6. Install fson library

The library is installed to {HOME}/lib and {HOME}/include

cd where-you-want-source-files
git clone https://github.com/japaf/fson.git
cd fson
cmake .
make
make install

7. Install bspline library

The library is installed to {HOME}/lib and {HOME}/include

cd where-you-want-source-files
git clone https://github.com/japaf/bspline-fortran.git
cd bspline-fortran
cmake .
make
make install

### 8. Install sundials library

cd where-you-want-source-files
git clone https://github.com/luca-heltai/sundials.git
cd sundials
mkdir build
cd build
cmake -DFCMIX_ENABLE=ON -DLAPACK_ENABLE=ON ..
make
sudo make install

### 9. Set the environmental variables for MoDeNa

user=$(whoami)
export LD_LIBRARY_PATH=/home/${user}/OpenFOAM/${user}-2.3.0/platforms/linux64GccDPDebug/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH:-}:${HOME}/lib/pkgconfig:/usr/local/lib/pkgconfig
export PYTHONPATH=${PYTHONPATH:-}:${HOME}/lib/python2.7/site-packages
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:${HOME}/lib/python2.7/site-packages:${HOME}/lib/modena:/usr/local/lib

### 10. Compile the models

./build

Please note that the output of build should not contain any error messages. Otherwise, the tool cannot work properly.

Run

In order to execute the program, you need to first provide the input variables for all the modelling tools. In the examples directory several cases have been provided. One can copy the inputs directory into the foamExpansion and modify it for the targeted recipe. The unifiedInput.json provides the input data for the bubble growth model and zero dimensional simulation, wallDrainage_inputs.json provides the inputs for the wall drainage simulation, init_foamConductivity.json provides initial points for the initialization of foamConductivity and the rest of input directory creates the test case for OpenFOAM simulation. The details of the input variables have been elaborated in INPUTS.md. After preparing the inputs the following steps should be executed:
  1. Initialize surrogate nano-scale models:
    ./initModels
    Note that foamConductivity takes initial points from init_foamConductivity.json. This file can be prepared using prep_init_foamConductivity.py.
  2. Execute meso-scopic bubble growth simulation:
    ./workflow_bubbleGrowth
  3. Initialize surrogate bubble growth model:
    ./initBubbleGrowth
  4. Run macroscopic simulation (0D or 3D):
    ./workflow_0D
    or
    ./workflow_3D
    Note:
    • In case of any changes in the input files steps 2-4 should repeated.
    • Initial moments of the bubble size distribution can be calculated by running initMoments. This script uses the mean, variance and initial number density of bubbles from unifiedInput.json.
    • If the following error occurs: ``` –> FOAM FATAL ERROR: Wrong number of arguments, expected 0 found 1

      FOAM exiting

      cannot find system Renviron Fatal error: unable to open the base package ``` The workaround is to set the R environment variable as below: ``` R_HOME=/usr/lib/R (where you have installed R) export R_HOME=/usr/lib/R ```

  • The wall drainage simulation can be executed anytime after running the ./workflow_bubbleGrowth by:
    ./workflow_wallDrainage

Results

Results of the last simulation are stored in the corresponding sub-directory of the results directory. We use VEUSZ to visualize some of the results. For example, to look at selected results for a 0D simulation, you can open plotQmom0D.vsz using VEUSZ. Further, the results of the 3D simulation (stored in the launcher directory) can be displayed using a third party software such as paraview. Additional results can be displayed through python scripts like plotWallDrainage.py.The Foam aging and Foam conductivity applications can read the final foam morphology from the results of Foam expansion. It is communicated through the after_foaming.txt file. In case of 3D simulation, average foam morphology is used, but user must specify several points in system/probes file.

README

Foaming simulation

Collection of software tools for the simulation of polyurethane (PU) foaming process. Based on a recipe the model predicts the evolution of chemical kinetics, temperature, foam density, bubble size distribution, etc.

Installation

Several models need to be compiled. C++ and Fortran compilers are required. Execute following command:

./build

(Optional)

Some results can be easily visualized using VEUSZ program. It can be installed in Ubuntu using:

sudo add-apt-repository ppa:jeremysanders/ppa
sudo apt-get update
sudo apt-get install veusz

Run

First, you need to specify recipe. Copy/create/modify unifiedInput.json. An example recipies can be found in "example inputs" folder. Create inputs to models:

./createInputs.py

Initialize surrogate nano-scale models:

./initModels

Execute meso-scopic bubble growth simulation:

./workflow1

Initialize surrogate bubble growth model:

./initBubbleGrowth

Run macroscopic simulation:

./workflow2
The above sequence can be performed by executing

./run

Results

Results are stored in the "results" folder. To look at selected macroscopic results you can use "plotQmom.vsz" and VEUSZ.