Difference between revisions of "orch:Installation Guide"

From orch
Jump to: navigation, search
(software used by Cantera 2.4)
 
(28 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  
== Reduce chemistry ==
+
=== Retrieve ORCh with Git ===
* All the information necessary to run the subsequent steps of the reduction process are to be entered in the file: "conditions.h"
+
<code> new_mixing = 'False' or 'True' </code>
+
: - if 'False': the stochastic mixing will follow the same pattern during trajectories (i.e. the same time history of random numbers are used along the composition space trajectories);
+
: - if 'True': the time history of the stochastic mixing differs from the previous run;
+
: This parameter must be 'True' for the first simulation of the composition space trajectories, then one may decide to perform the reduction and optimisation with the same, or a new, time history of random numbers controlling the stochastic mixing. So far, ORCh produced good results using 'False', but for the first run where it must be set to 'True'.
+
  
* Chemical scheme files:
+
The installation location should follow a given format. As the path to the orch folder must follow:
: The reference detailed scheme is entered here:
+
<code> mech_ref = "mechanisms/gri12.xml"; </code>
+
  
: Intermediate scheme from which the reduction should be pursued (after completing one of the steps), it must be updated at every stage:
+
<code>
<code> mech = "./outputs/mechanisms/drgepSpecies17.xml"; </code>  
+
./workdir/orch$
 +
</code>
  
: If first run, use the same as the reference detailed mechanism:
+
The orch repository should be positioned in a workdir folder. So create the workdir folder in which you clone the orch repository from the gitlab:
<code>    mech = "mechanisms/gri12.xml";</code>
+
: Always provide a cantera id for the chemical scheme (you can choose any, but it must be there and agrees between files, i.e. do not change it during the whole optimisation process):
+
<code>  mech_desc = "gri12";</code>
+
  
* Targeted species
+
<code>
: The species that you wish to reproduce with accuracy in the reduced scheme should be given in 'conditions.h' following the format:
+
/home/user/workdir$ git clone git@gitlab.coria-cfd.fr:orch/orch.git
 +
</code>
  
<code> listTargets.push_back("H2");
 
  listTargets.push_back("O2");
 
  
: Notice that this option does not lead to the calculation of the trajectories and only the first QSS scenario is applied.
+
=== Pre installation for Cantera 2.4===
  listTargets.push_back("H2O");
+
  listTargets.push_back("CH4");
+
  listTargets.push_back("CO");
+
  listTargets.push_back("CO2"); </code>
+
  
* Inlet of composition space trajectories
 
: You can prescribe as many inlets as you wish. For every inlet, you need to give the number of particles in 'NbParcilesi', where 'i' denotes the i-th inlet. Then, please provide for this inlet: Temperature, Pressure, Number of Particles, and then directly the composition, either in mole fractions (first set, see below), or mass fractions if you prefer those, the code will understand anyway.
 
  
: The last inlet must be composed of burnt gases, in which you need to give in addition: the mixing time, the time step and the number of iterations.
+
The 2.4 version of Cantera , downloaded with ORCh at workdir/orch/Cantera, needs :
  
: Of course, it will then be needed to check that, for these parameters, the solution is well captured and that you have reached the chemical equilibrium condition.
+
* C++ Boost librairies (Version 1.68, the newer don't work with Cantera) to run properly.  
 +
* SCONS compiler
  
<code> double NbParticles1 = 22;
+
==== SCONS ====
  //-- Temp, Pressure, number of particles, "moles fractions" or "mass fractions" leave empty the other one --//
+
  listInlets.push_back(new MultipleInlet(320, 1E+05, NbParticles1,
+
                        "O2:0.15, N2:0.52, H2O:0.0029, CH4:0.33", ""));
+
  //Inlet 2 //
+
  double NbParticles2 = 103;
+
  listInlets.push_back(new MultipleInlet(1350, 1E+05, NbParticles2,
+
                        "O2:0.12, N2:0.73, H2O:0.15, CH4:0.0003", ""));
+
  //-- The very last inlet must be burnt gases --//
+
  //-- Same as other inlet + mixing time tau_t, delta_t, number of iterations --//
+
  //BurnedGases
+
  double NbParticlesBurnedGases = 5;
+
  double tau_t = 2e-03;
+
  double delta_t = 5e-05;
+
  bool BurnedGases = true;
+
  listInlets.push_back(new Characteristics_MultipleInlet(2290, 1E+05, NbParticlesBurnedGases,
+
                        "N2:0.682, H2O:0.236, CO2:0.0539, CO:0.00823, H2:0.00647, O2:0.00516, OH:0.00431", "",
+
                        tau_t, delta_t, 400, BurnedGases)); </code>
+
  
* After any modification in 'conditions.h', the code must be re-compile, therefore this must be done between every step and sub-steps of the method
+
https://sourceforge.net/projects/scons/files/scons/3.0.3/scons-3.0.3.tar.gz/download
  
  <code> make clean
+
  cd scons-3.0.3
  make </code>
+
python setup.py install
  
* '''DRGEP''' is the first stage to run: it includes the computation of the trajectories with detailed chemistry and the DRGEP analysis to reduce the number of species and reactions:
+
==== BOOST LIBRARIES ====
  
: '''First sub-step''' - select in 'conditions.h':
+
https://www.boost.org/users/history/version_1_68_0.html
<code> step = "DRGEP_species"; </code>
+
  
: This first step provides a series of chemical schemes whose number of species ranges between parameters that need to be set in 'ORCh/main.cpp' (two occurrences):
+
cd boost_1_68_0
  <code> nbSpeciesToKeep=20; nbSpeciesToKeep>15</code>
+
sh bootstrap.sh
 +
  ./b2  install --libdir=yourPath/boost_1_68_0/lib  --includedir=<yourPath/boost_1_68_0/include
  
: Here schemes will be built with a total number of species ranging between 20 and 15. Notice that the control of the threshold, T<sub>S</sub>, of Jaouen et al. (see references above) is automatically computed from  'nbSpeciesToKeep' and 'nbSpeciesToKeep>' in 'ORCh/main.cpp'.
+
... patience ... the boost installation can be long
  
: Run
+
==== software used by Cantera 2.4 ====
<code> ./main </code>
+
  
: Once done, you need to go into the 'outputs' directory, there you can examine the trajectories with
+
If you don't already have Cantera 2.4 on your computer, you will need to get several external softwares (fmt, Eigen, googletest and sundials), located in orch/Cantera/ext/ :
<code> makeDRGEPSpecies.gnu </code>
+
  
: To find the positions of species in the files, you need to go into the reference and reduced mechanisms, which are stored in '../mechanisms/' and './outputs/mechanisms'
+
You can either download the ext.tar file and extract it in orch/Cantera/ext/ :
  
: Select the best mechanism you like and put his name in 'conditions.h':
+
[[File:ext.tar.gz]]
<code>  mech = "./outputs/mechanisms/yourbestmechname.xml"; </code>
+
  
: 'yourbestmechname.xml' is found in './outputs/mechanisms' and it looks like './outputs/mechanisms/drgepSpecies17.xml', here 17 means that this is a mechanism with 17 species.
+
Or directly download each software (could take some time ..)
  
: Then, it is time for further reducing the number of reactions:
+
* fmt
  
: Make sure that in 'conditions.h':
+
$ git clone https://github.com/fmtlib/fmt.git
  <code> new_mixing = 'False' </code>
+
  $ sudo mkdir /usr/local/include/fmt
 +
$ sudo cp fmt/fmt/format.* /usr/local/include/fmt/
 +
 +
* Google test
  
: '''Second sub-step''' - select in 'conditions.h':  
+
  get https://github.com/google/googletest/archive/release-1.8.0.tar.gz
<code> step = "DRGEP_reactions"; </code>
+
  
: This second step provides a series of chemical schemes whose number of reactions ranges between parameters that need to be set in 'ORCh/main.cpp' (two occurrences):
+
tar xf release-1.8.0.tar.gz
  <code> nbReactionsToKeep=nreac_ref-5; nbReactionsToKeep>35 </code>
+
  cd googletest-release-1.8.0
 +
  cmake -DBUILD_SHARED_LIBS=ON .
 +
make
  
: Here schemes will be built with a total number of reactions ranging between the number in the detailed scheme-5 and 35. Notice that the control of the threshold, T<sub>R</sub>, of Jaouen et al. (see references above) is automatically computed from  'nbReactionsToKeep' and 'nbReactionsToKeep>' in 'ORCh/main.cpp'.
+
then cp -r * ~/orch/Cantera/ext/googletest ...
  
: Once done, you need to go into the 'outputs' directory, there you can examine the trajectories with
+
* eigen
<code> makeDRGEPReactions.gnu </code>
+
  
: To find the positions of species in the files, you need to go into the reference and reduced mechanisms, which are stored in '../mechanisms/' and './outputs/mechanisms'
+
visit https://eigen.tuxfamily.org/index.php?title=Main_Page
 +
Download the 3.2.10 tar
 +
tar -xvf 3.2.10.tar
 +
cp file into orch/Cantera/ext
  
: Select the best mechanism you like and put his name in 'conditions.h':
+
* Sundials version 3.1
<code>  mech = "./outputs/mechanisms/yourbestmechname.xml"; </code>
+
  
: 'yourbestmechname.xml' is found in './outputs/mechanisms' and it looks like './outputs/mechanisms/drgepReactions36.xml', here 36 means that this is a mechanism with 36 reactions.
 
  
* '''Automated quasi-steady state''' is the second stage to run: it includes the determination of species in quasi-steady state and the building of the needed relations:
 
  
'''First sub-step''' - select in 'conditions.h'
+
MPI librairies will be also needed for Stochastic configurations.
<code> step = "computeQSSCriteria"; </code>
+
  
: The code will rerun trajectories from the specified mechanism and compute the QSS criteria, to provide in an online output an evaluation of the QSS criterion for every species, i.e. the ratio between the integral over the trajectory of the net variation rate of a species and the integral of the maximum between the production rate and the consumption rate of that given species.
+
=== Installation procedure ===
  
: In addition, the output provides the list of species which are related in a non-linear manner, to decide which species can be put in QSS.
 
  
'''Second sub-step''' - select in 'conditions.h'
 
<code> step = "getQSSfile"; </code>
 
  
: The user choose a set of QSS scenarios he wants to try, this information should be put in 'conditions.h' (information which can be left there or not for all runs, but which is mandatory for this step):
 
  
  <code> string array1[1] {"CH3O"};
 
  vector<string> vec(array1, array1 + sizeof(array1) /sizeof(array1[0]));
 
  
  string array2[3] {"CH3O", "HCO", "HO2"}; 
+
== Installation ==
  vector<string> vec2(array2, array2 + sizeof(array2) /sizeof(array2[0]));
+
The following steps must be completed before you can use ORCh:
  listQSSscenarios.push_back(new QSSscenario(vec2));</code>
+
* Compile Cantera :
 +
In the directory workdir/orch/Cantera, modify the paths in the file "cantera.conf" with the appropriate one.
 +
build with SCONS : "scons build"
 +
If the build fail, for any reason, use "scons clean" before doing again the previous step, after coping with problems indicated in the output.
  
: For every QSS scenarios you wish to examine, the code will do two things for you:
+
* Add to your .bashrc file:
  
# Generate the analytical relations between the species and write them ready for their use in a CFD software in the file 'analytic_schemes/RefQSSAnalysis0/mech_QSS.h', for the conditions you entered.
+
<code>export BOOSTPATH="/yourPath/boost_1_68_0"</code>
# Rerun the trajectories for these conditions, so that you can have a look and check which QSS hypotheses are best. The results for visualisation are in 'analytic_schemes/RefQSSAnalysis0', 'analytic_schemes/RefQSSAnalysis1', etc.
+
  
: If you need the QSS relations in fortran, after running as above (step = "getQSSfile"), you can run with the option:
+
<code>export GTCOMB_CT_HOME=/home/yourloggin/orch/Cantera</code>
 +
<code>export GTCOMB_CT_HOSTTYPE=$GTCOMB_CT_HOME/lib</code>
 +
<code>export GTCOMB_CT_DATA=$GTCOMB_CT_HOME/data</code>
  
  <code> step = "getQSSfileFORTRAN"; </code>
+
* All the openmpi and gcc-compiler libraries must be available on your machine, typically you need something like below in your .bashrc file (some may already be there no need to duplicate):
 +
  <code>source /opt/intel/composerxe/bin/compilervars.sh intel64</code>
 +
<code>export INTEL_HOME="/opt/intel/composerxe"</code>
 +
<code>export INTEL_INC="$INTEL_HOME/include"</code>
 +
<code>export INTEL_LIB="$INTEL_HOME/lib"</code>
 +
<code>export INTEL_BIN="$INTEL_HOME/bin"</code>
 +
<code>export INTEL_MAN="$INTEL_HOME/man"</code>
 +
<code>export PATH="$INTEL_BIN:$PATH"</code>
 +
<code>export LIBRARY_PATH="$INTEL_LIB:$LIBRARY_PATH"</code>
 +
<code>export LD_LIBRARY_PATH="$INTEL_LIB:$LD_LIBRARY_PATH"</code>
 +
<code>export MANPATH="$INTEL_MAN:$MANPATH"</code>
  
: Notice that the trajectories will not be computed and that only the first QSS scenario is applied.
+
<code>export MPI_HOME="/local/openmpi/intel-14.0.2/1.8.1"</code>
 +
<code>export MPI_INC="$MPI_HOME/include"</code>
 +
<code>export MPI_LIB="$MPI_HOME/lib"</code>
 +
<code>export MPI_BIN="$MPI_HOME/bin"</code>
 +
<code>export MPI_MAN="$MPI_HOME/share/man"</code>
 +
<code>export PATH="$MPI_BIN:$PATH"</code>
 +
<code>export LIBRARY_PATH="$MPI_LIB:$LIBRARY_PATH"</code>
 +
<code>export LD_LIBRARY_PATH="$MPI_LIB:$LD_LIBRARY_PATH"</code>
 +
<code>export MANPATH="$MPI_MAN:$MANPATH"</code>
  
* '''Optimisation of the rates''' is the last stage to run:  
+
<code>export HDF5_HOME="/local/hdf5/intel-14.0.2/1.8.12"</code>
 +
<code>export HDF5_INC="$HDF5_HOME/include"</code>
 +
<code>export HDF5_BIN="$HDF5_HOME/bin"</code>
 +
<code>export HDF5_LIB="$HDF5_HOME/lib"</code>
 +
<code>export PATH="$HDF5_BIN:$PATH"</code>
 +
<code>export LIBRARY_PATH="$HDF5_LIB:$LIBRARY_PATH"</code>
 +
<code>export LD_LIBRARY_PATH="$HDF5_LIB:$LD_LIBRARY_PATH"</code>
  
'''Preliminary step''' - select in 'conditions.h'
+
<code>export PAPI_HOME="/local/papi/intel-14.0.2/5.3.0"</code>
  <code> step = "Optimisation"; </code>
+
  <code>export LANG=C</code>
 +
<code>export LC_ALL=C</code>
 +
<code>export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/include/x86_64-linux-gnu/c++/4.8</code>
  
: The optimisation will proceed with the QSS conditions with the first QSS scenario given in 'conditions.h'. If one scenario exists, a QSS-step (above) must have been completed before. If none, the optimisation proceed for the full scheme without QSS.
+
* Check that the compilation of the ORCh package runs fine by testing one of the several test cases in orch/Tests/
  
: The corresponding mechanism mut be given in 'conditions.h' (if you have run the previous run with various scenario, make sure to put here the mechanism corresponding to the one you prefer)
 
<code>  mech = "./outputs/mechanisms/yourbestmechname.xml"; </code>
 
  
: 'yourbestmechname.xml' is found in './outputs/mechanisms' and it looks like './outputs/mechanisms/drgepReactions36.xml', here 36 means that this is a mechanism with 36 reactions.
+
  <code> make clean </code>
 
+
  <code> make </code>
: The parameters of the Genetic Algorithm must be given
+
  <code> ./mainProgram </code>
 
+
  <code> int PopSize = 100;
+
  int MaxAllowableGenerations = 150;
+
  int NbElitism = 1;
+
  double CrossoverRate = 0.75;
+
  double MutationRate = 0.02;
+
  double AllowedVariation_A = 0.03;
+
  double AllowedVariation_b = 0.03;
+
  double AllowedVariation_E = 0.03; </code>
+
 
+
: 'PopSize' is the number of chromosomes >= 100 is advised
+
: 'MaxAllowableGenerations' number of generation to be examined >= 150 is advised
+
: 'NbElitism' number of solution copied from previous generation to secure elitism, 1 is best choice
+
: 'CrossoverRate' % of crossover, 0.75 is best choice
+
: 'MutationRate' % of mutation, 0.02 is best choice
+
: 'AllowedVariation_A' % of variation for pre-exponential constant
+
: 'AllowedVariation_b' % of variation for temperature coefficient
+
: 'AllowedVariation_E' % of variation for activation energy
+
 
+
: This last step may be run in parallel, the number of processors used should be chosen so that PopSize/n_proc is an integer
+
 
+
  <code> mpirun -np n_proc main </code>
+
 
+
: During the run, temporary directories are created in 'tool/analytic_schemes/Ref#nbproc' to store all information concerning one chromosome (i.e. a trajectory obtained for one set of chemical parameters), with possibility to check corresponding trajectories.
+
: In 'tool/analytic_schemes/PLOTS' .eps files are automatically generated to visualise these trajectories, for each chromosomes.
+
: These .eps file read 'GEN#nb_POP0_FIT#value.eps', where #nb is the  generation number and #value is the fitness value. Looking at the latest generation gives an idea of the quality of the parameters.
+
 
+
: At each iteration (generation) in 'tool/analytic_schemes/Ref', the best chemical scheme is in 'chemistry_for_restart.xml'.
+
: In case of QSS the relations are in: 'best_mech_QSS.h'
+
 
+
* The procedure to run the GA is as follow:
+
# Run for a given number of generation
+
# Check 'GEN#nb_POP0_FIT#value.eps' to evaluate the quality of the result. More graphics can be obtained by enriching the gnuplot command in 'tool/ORCh/optimisation/CreateAnalyticDirectory.cpp'
+
# If more generation are needed (i.e. continue the optimisation):
+
##  Move the 'tool/analytic_schemes/Ref/chemistry_for_restart.xml' into 'tool/outputs/mechanism' and modify the name of 'mech=' in 'conditions.h'
+
## Decrease the 'Allowed variation' to narrow the research parameters area
+
## Relaunch
+
 
+
: This can be repeated up to a solution that suits you.
+
 
+
: Then, you may rerun the trajectory only, with the optimised mechanism, in order to plot all the variables, in 'conditions.h':
+
 
+
  <code> step = "ComputeTrajectories"; </code>
+
 
+
: in 'outputs' the name of the file is :
+

Latest revision as of 19:43, 29 June 2020

Retrieve ORCh with Git

The installation location should follow a given format. As the path to the orch folder must follow:

./workdir/orch$

The orch repository should be positioned in a workdir folder. So create the workdir folder in which you clone the orch repository from the gitlab:

/home/user/workdir$ git clone git@gitlab.coria-cfd.fr:orch/orch.git


Pre installation for Cantera 2.4

The 2.4 version of Cantera , downloaded with ORCh at workdir/orch/Cantera, needs :

  • C++ Boost librairies (Version 1.68, the newer don't work with Cantera) to run properly.
  • SCONS compiler

SCONS

https://sourceforge.net/projects/scons/files/scons/3.0.3/scons-3.0.3.tar.gz/download
cd scons-3.0.3
python setup.py install

BOOST LIBRARIES

https://www.boost.org/users/history/version_1_68_0.html

cd boost_1_68_0 
sh bootstrap.sh
./b2  install --libdir=yourPath/boost_1_68_0/lib   --includedir=<yourPath/boost_1_68_0/include

... patience ... the boost installation can be long

software used by Cantera 2.4

If you don't already have Cantera 2.4 on your computer, you will need to get several external softwares (fmt, Eigen, googletest and sundials), located in orch/Cantera/ext/ :

You can either download the ext.tar file and extract it in orch/Cantera/ext/ :

File:Ext.tar.gz

Or directly download each software (could take some time ..)

  • fmt
$ git clone https://github.com/fmtlib/fmt.git
$ sudo mkdir /usr/local/include/fmt
$ sudo cp fmt/fmt/format.* /usr/local/include/fmt/

  • Google test
get https://github.com/google/googletest/archive/release-1.8.0.tar.gz
tar xf release-1.8.0.tar.gz
cd googletest-release-1.8.0
cmake -DBUILD_SHARED_LIBS=ON .
make
then cp -r * ~/orch/Cantera/ext/googletest ...
  • eigen
visit https://eigen.tuxfamily.org/index.php?title=Main_Page
Download the 3.2.10 tar
tar -xvf 3.2.10.tar
cp file into orch/Cantera/ext
  • Sundials version 3.1


MPI librairies will be also needed for Stochastic configurations.

Installation procedure

Installation

The following steps must be completed before you can use ORCh:

  • Compile Cantera :
In the directory workdir/orch/Cantera, modify the paths in the file "cantera.conf" with the appropriate one.
build with SCONS : "scons build"
If the build fail, for any reason, use "scons clean" before doing again the previous step, after coping with problems indicated in the output.
  • Add to your .bashrc file:
export BOOSTPATH="/yourPath/boost_1_68_0"
export GTCOMB_CT_HOME=/home/yourloggin/orch/Cantera
export GTCOMB_CT_HOSTTYPE=$GTCOMB_CT_HOME/lib
export GTCOMB_CT_DATA=$GTCOMB_CT_HOME/data
  • All the openmpi and gcc-compiler libraries must be available on your machine, typically you need something like below in your .bashrc file (some may already be there no need to duplicate):
source /opt/intel/composerxe/bin/compilervars.sh intel64
export INTEL_HOME="/opt/intel/composerxe"
export INTEL_INC="$INTEL_HOME/include"
export INTEL_LIB="$INTEL_HOME/lib"
export INTEL_BIN="$INTEL_HOME/bin"
export INTEL_MAN="$INTEL_HOME/man"
export PATH="$INTEL_BIN:$PATH"
export LIBRARY_PATH="$INTEL_LIB:$LIBRARY_PATH"
export LD_LIBRARY_PATH="$INTEL_LIB:$LD_LIBRARY_PATH"
export MANPATH="$INTEL_MAN:$MANPATH"
export MPI_HOME="/local/openmpi/intel-14.0.2/1.8.1"
export MPI_INC="$MPI_HOME/include"
export MPI_LIB="$MPI_HOME/lib"
export MPI_BIN="$MPI_HOME/bin"
export MPI_MAN="$MPI_HOME/share/man"
export PATH="$MPI_BIN:$PATH"
export LIBRARY_PATH="$MPI_LIB:$LIBRARY_PATH"
export LD_LIBRARY_PATH="$MPI_LIB:$LD_LIBRARY_PATH"
export MANPATH="$MPI_MAN:$MANPATH"
export HDF5_HOME="/local/hdf5/intel-14.0.2/1.8.12"
export HDF5_INC="$HDF5_HOME/include"
export HDF5_BIN="$HDF5_HOME/bin"
export HDF5_LIB="$HDF5_HOME/lib"
export PATH="$HDF5_BIN:$PATH"
export LIBRARY_PATH="$HDF5_LIB:$LIBRARY_PATH"
export LD_LIBRARY_PATH="$HDF5_LIB:$LD_LIBRARY_PATH"
export PAPI_HOME="/local/papi/intel-14.0.2/5.3.0"
export LANG=C
export LC_ALL=C
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/include/x86_64-linux-gnu/c++/4.8
  • Check that the compilation of the ORCh package runs fine by testing one of the several test cases in orch/Tests/


 make clean 
 make 
 ./mainProgram