orch:Usage

From orch
Revision as of 17:05, 3 March 2016 by Vervisch (Talk | contribs) (Created page with "== Reduce chemistry == * 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 = 'Fa...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Reduce chemistry

  • All the information necessary to run the subsequent steps of the reduction process are to be entered in the file: "conditions.h"
 new_mixing = 'False' or 'True'  
- 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 reference detailed scheme is entered here:
 mech_ref = "mechanisms/gri12.xml";  
Intermediate scheme from which the reduction should be pursued (after completing one of the steps), it must be updated at every stage:
  mech = "./outputs/mechanisms/drgepSpecies17.xml";  
If first run, use the same as the reference detailed mechanism:
    mech = "mechanisms/gri12.xml"; 
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):
  mech_desc = "gri12"; 
  • Targeted species
The species that you wish to reproduce with accuracy in the reduced scheme should be given in 'conditions.h' following the format:
 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.
 listTargets.push_back("H2O");
 listTargets.push_back("CH4");
 listTargets.push_back("CO");
 listTargets.push_back("CO2");  
  • 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.
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.
 double NbParticles1 = 22;
 //-- 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)); 
  • 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
 make clean 
 make 
  • 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:
First sub-step - select in 'conditions.h':
 step = "DRGEP_species"; 
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):
 nbSpeciesToKeep=20; nbSpeciesToKeep>15 
Here schemes will be built with a total number of species ranging between 20 and 15. Notice that the control of the threshold, TS, of Jaouen et al. (see references above) is automatically computed from 'nbSpeciesToKeep' and 'nbSpeciesToKeep>' in 'ORCh/main.cpp'.
Run
 ./main 
Once done, you need to go into the 'outputs' directory, there you can examine the trajectories with
 makeDRGEPSpecies.gnu 
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'
Select the best mechanism you like and put his name in 'conditions.h':
  mech = "./outputs/mechanisms/yourbestmechname.xml"; 
'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.
Then, it is time for further reducing the number of reactions:
Make sure that in 'conditions.h':
 new_mixing = 'False'  
Second sub-step - select in 'conditions.h':
 step = "DRGEP_reactions"; 
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):
 nbReactionsToKeep=nreac_ref-5; nbReactionsToKeep>35  
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, TR, of Jaouen et al. (see references above) is automatically computed from 'nbReactionsToKeep' and 'nbReactionsToKeep>' in 'ORCh/main.cpp'.
Once done, you need to go into the 'outputs' directory, there you can examine the trajectories with
 makeDRGEPReactions.gnu 
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'
Select the best mechanism you like and put his name in 'conditions.h':
  mech = "./outputs/mechanisms/yourbestmechname.xml"; 
'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'

 step = "computeQSSCriteria"; 
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.
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'

 step = "getQSSfile"; 
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):
  string array1[1] {"CH3O"};
  vector<string> vec(array1, array1 + sizeof(array1) /sizeof(array1[0]));
 string array2[3] {"CH3O", "HCO", "HO2"};  
 vector<string> vec2(array2, array2 + sizeof(array2) /sizeof(array2[0])); 
 listQSSscenarios.push_back(new QSSscenario(vec2));
For every QSS scenarios you wish to examine, the code will do two things for you:
  1. 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.
  2. 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:
 step = "getQSSfileFORTRAN"; 
Notice that the trajectories will not be computed and that only the first QSS scenario is applied.
  • Optimisation of the rates is the last stage to run:

Preliminary step - select in 'conditions.h'

 step = "Optimisation"; 
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.
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)
  mech = "./outputs/mechanisms/yourbestmechname.xml"; 
'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.
The parameters of the Genetic Algorithm must be given
  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; 
'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
 mpirun -np n_proc main 
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:
  1. Run for a given number of generation
  2. 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'
  3. If more generation are needed (i.e. continue the optimisation):
    1. Move the 'tool/analytic_schemes/Ref/chemistry_for_restart.xml' into 'tool/outputs/mechanism' and modify the name of 'mech=' in 'conditions.h'
    2. Decrease the 'Allowed variation' to narrow the research parameters area
    3. 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':
 step = "ComputeTrajectories"; 
in 'outputs' the name of the file is :