Skip to content

Commit

Permalink
moved mechanism data into single dedicated storage struct
Browse files Browse the repository at this point in the history
  • Loading branch information
DetlevCM committed Oct 30, 2017
1 parent 5f7cefc commit 02d86fe
Show file tree
Hide file tree
Showing 15 changed files with 275 additions and 250 deletions.
7 changes: 4 additions & 3 deletions headers/Get_Input.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
bool Handle_Mechanism_Input(
string ,
string ,
vector< string >& ,
vector< ThermodynamicData >& ,
vector< SingleReactionData >& ,
MechanismData& ,
//vector< string >& ,
//vector< ThermodynamicData >& ,
//vector< SingleReactionData >& ,
InitParam& ,
vector< double >&,
PressureVesselCalc &
Expand Down
1 change: 1 addition & 0 deletions headers/MyHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ using std::istringstream;

// structs definitions
#include "structs/Structs.h"
#include "structs/mechanism_storage.h"
#include "structs/initial_conditions_parameters.h"

// namespaces with global variables for performance reasons
Expand Down
30 changes: 12 additions & 18 deletions headers/run_integrator/Run_Integrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
void Choose_Integrator(
Filenames,
vector< double >,
vector< string > ,
vector< ThermodynamicData > ,
vector< SingleReactionData > &,
MechanismData ,
//vector< string > ,vector< ThermodynamicData > , vector< SingleReactionData > &,
InitParam,
vector< double >&,
PressureVesselCalc,
Expand All @@ -25,9 +24,8 @@ void Choose_Integrator(
void Integrate_Liquid_Phase_Intel(
Filenames,
vector< double >,
vector< string > ,
vector< ThermodynamicData > ,
vector< SingleReactionData > &,
MechanismData ,
//vector< string > , vector< ThermodynamicData > , vector< SingleReactionData > &,
InitParam,
vector< double >&,
vector< vector < str_RatesAnalysis > > &
Expand All @@ -37,9 +35,8 @@ void Integrate_Liquid_Phase_Intel(
void Integrate_Pressure_Vessel_Liquid_Phase_Intel(
Filenames,
vector< double >,
vector< string > ,
vector< ThermodynamicData > ,
vector< SingleReactionData > &,
MechanismData ,
//vector< string > , vector< ThermodynamicData > , vector< SingleReactionData > &,
InitParam,
vector< double >&,
PressureVesselCalc,
Expand All @@ -50,9 +47,8 @@ void Integrate_Pressure_Vessel_Liquid_Phase_Intel(
void Integrate_Liquid_Phase_Odepack_LSODA(
Filenames,
vector< double >,
vector< string > ,
vector< ThermodynamicData > ,
vector< SingleReactionData > &,
MechanismData ,
//vector< string > ,vector< ThermodynamicData > ,vector< SingleReactionData > &,
InitParam,
vector< double >&,
vector< vector < str_RatesAnalysis > > &
Expand All @@ -61,9 +57,8 @@ void Integrate_Liquid_Phase_Odepack_LSODA(
void Integrate_Gas_Phase_Odepack_LSODA(
Filenames,
vector< double >,
vector< string > ,
vector< ThermodynamicData > ,
vector< SingleReactionData > &,
MechanismData ,
//vector< string > ,vector< ThermodynamicData > ,vector< SingleReactionData > &,
InitParam,
vector< double >&,
vector< vector < str_RatesAnalysis > > &
Expand All @@ -73,9 +68,8 @@ void Integrate_Gas_Phase_Odepack_LSODA(
void Integrate_Pressure_Vessel_Liquid_Phase_Odepack_LSODA(
Filenames,
vector< double >,
vector< string > ,
vector< ThermodynamicData > ,
vector< SingleReactionData > &,
MechanismData ,
//vector< string > ,vector< ThermodynamicData > ,vector< SingleReactionData > &,
InitParam,
vector< double >&,
PressureVesselCalc,
Expand Down
30 changes: 2 additions & 28 deletions headers/structs/Structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ struct JacobianData {



struct SingleReactionData {
bool Reversible;
bool IsDuplicate;
double paramA;
double paramN;
double paramEa;
vector<double> Reactants;
vector<double> Products;
};



struct ReactionParameter {
Expand Down Expand Up @@ -122,25 +114,7 @@ struct MechanismAnalysisConfig {
};


struct ThermodynamicData {
double TLow;
double THigh;
double TChange;
double NasaLow1;
double NasaLow2;
double NasaLow3;
double NasaLow4;
double NasaLow5;
double NasaLow6;
double NasaLow7;
double NasaHigh1;
double NasaHigh2;
double NasaHigh3;
double NasaHigh4;
double NasaHigh5;
double NasaHigh6;
double NasaHigh7;
};



struct str_RatesAnalysis
Expand Down
4 changes: 3 additions & 1 deletion headers/structs/initial_conditions_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct InitParam {
bool PrintReacRates;

bool EnforceStability;
int nrspec;
//int nrspec;
vector< double > TimeEnd;
vector< double > TimeStep;
double temperature;
Expand All @@ -86,6 +86,8 @@ struct InitParam {
vector< InitSpecies > InitialGasSpecies;

// a block for mechanism reduction
// weirdly enough, this must be located after the initial species, as the code fails otherwise...
// for reasons unknownm, some parameters in this struct are apparently position dependant...
mechanism_reduction MechanismReduction;


Expand Down
49 changes: 49 additions & 0 deletions headers/structs/mechanism_storage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* mechanism_storage.h
*
* Created on: 30 Oct 2017
* Author: detlevcm
*/

#ifndef HEADERS_STRUCTS_MECHANISM_STORAGE_H_
#define HEADERS_STRUCTS_MECHANISM_STORAGE_H_

struct SingleReactionData {
bool Reversible;
bool IsDuplicate;
double paramA;
double paramN;
double paramEa;
vector<double> Reactants;
vector<double> Products;
};

struct ThermodynamicData {
double TLow;
double THigh;
double TChange;
double NasaLow1;
double NasaLow2;
double NasaLow3;
double NasaLow4;
double NasaLow5;
double NasaLow6;
double NasaLow7;
double NasaHigh1;
double NasaHigh2;
double NasaHigh3;
double NasaHigh4;
double NasaHigh5;
double NasaHigh6;
double NasaHigh7;
};

struct MechanismData {

vector< string > Species;
vector< ThermodynamicData > Thermodynamics;
vector< SingleReactionData > Reactions;
};


#endif /* HEADERS_STRUCTS_MECHANISM_STORAGE_H_ */
46 changes: 26 additions & 20 deletions source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ int main(int argc, char* argv[])
// The main variables that store the information from a reaction mechanism after
// it is read in, namely the species, thermodynamic data and reactions.

vector< string > Species; // Species list
vector< ThermodynamicData > Thermodynamics; // Thermodynamic Data
vector< SingleReactionData > Reactions; // Reactions
//vector< string > Species; // Species list
//vector< ThermodynamicData > Thermodynamics; // Thermodynamic Data
//vector< SingleReactionData > Reactions; // Reactions


InitParam InitialParameters; // Initial Conditions/Parameters
vector< double > InitialSpeciesConcentration;
PressureVesselCalc PetroOxyDataInitial; // PetroOxy Specific Initial Data

MechanismData Reaction_Mechanism;

// Handle All the Data Input - The Arrays Contain the required information
// "chem.inp",
bool Mechanism_Read_In = Handle_Mechanism_Input(
mechanism_filename,
initial_data_filename,
Species,
Thermodynamics,
Reactions,
Reaction_Mechanism,
//Species,Thermodynamics,Reactions,
InitialParameters,
InitialSpeciesConcentration,
PetroOxyDataInitial
Expand All @@ -93,19 +93,19 @@ int main(int argc, char* argv[])
Write_Stoichiometric_Matrix_For_Opt
(
"stoichiometry_matrix.txt" ,
Reactions
Reaction_Mechanism.Reactions
);
Input_File_For_Ehsan_Opt
(
"mechanism.txt" ,
Reactions
Reaction_Mechanism.Reactions
);
}


int i; // useful counter
int Number_Species = (int) Species.size();
int Number_Reactions = (int) Reactions.size();
int Number_Species = (int) Reaction_Mechanism.Species.size();
int Number_Reactions = (int) Reaction_Mechanism.Reactions.size();
vector< double > KeyRates; // for mechanism reduction

// We have now pre-processed all information, time to set up the ODEs and the solver
Expand All @@ -117,7 +117,7 @@ int main(int argc, char* argv[])
if(InitialParameters.MechanismAnalysis.MaximumRates)
{
// Initialise array
vector < str_RatesAnalysis > temp((int) Reactions.size());
vector < str_RatesAnalysis > temp((int) Reaction_Mechanism.Reactions.size());
for(i=0;i<Number_Species;i++)
{
RatesAnalysisData.push_back(temp);
Expand All @@ -128,7 +128,7 @@ int main(int argc, char* argv[])

if(InitialParameters.MechanismAnalysis.StreamRatesAnalysis)
{
PrepareStreamRatesAnalysis(Species,"");
PrepareStreamRatesAnalysis(Reaction_Mechanism.Species,"");
}


Expand All @@ -149,7 +149,7 @@ int main(int argc, char* argv[])
OutputFilenames.Species,
InitialParameters.Solver_Parameters.separator,
Number_Species,
Species,
Reaction_Mechanism.Species,
InitialParameters.GasPhase
);

Expand All @@ -174,7 +174,8 @@ int main(int argc, char* argv[])
Choose_Integrator(
OutputFilenames,
InitialSpeciesConcentration,
Species,Thermodynamics,Reactions,
Reaction_Mechanism,
//Species,Thermodynamics,Reactions,
InitialParameters,
KeyRates,
PetroOxyDataInitial,
Expand All @@ -185,8 +186,12 @@ int main(int argc, char* argv[])
if(InitialParameters.MechanismReduction.ReduceReactions != 0)
{
vector< SingleReactionData > ReducedReactions;
ReducedReactions = ReduceReactionsNew(Species, Reactions, KeyRates);
ReducedReactions = ReduceReactionsNew(Reaction_Mechanism.Species, Reaction_Mechanism.Reactions, KeyRates);

MechanismData Reduced_Reaction_Mechanism;
Reduced_Reaction_Mechanism.Species = Reaction_Mechanism.Species;
Reduced_Reaction_Mechanism.Thermodynamics = Reaction_Mechanism.Thermodynamics;
Reduced_Reaction_Mechanism.Reactions = ReducedReactions;

// start a second run only if reduced scheme is not empty and has size different
// to original scheme
Expand All @@ -200,7 +205,7 @@ int main(int argc, char* argv[])

Number_Reactions = (int) ReducedReactions.size();

WriteReactions("reduced_scheme.txt", Species, ReducedReactions);
WriteReactions("reduced_scheme.txt", Reduced_Reaction_Mechanism.Species, ReducedReactions);

InitialParameters.MechanismReduction.ReduceReactions = 0; // switch off reduction...

Expand Down Expand Up @@ -229,14 +234,14 @@ int main(int argc, char* argv[])

if(InitialParameters.MechanismAnalysis.StreamRatesAnalysis)
{
PrepareStreamRatesAnalysis(Species,OutputFilenames.Prefix);
PrepareStreamRatesAnalysis(Reduced_Reaction_Mechanism.Species,OutputFilenames.Prefix);
}

WriteNewLabelsSpecies(
OutputFilenames.Species,
InitialParameters.Solver_Parameters.separator,
Number_Species,
Species,
Reduced_Reaction_Mechanism.Species,
InitialParameters.GasPhase
);
WriteLabelsReactionRates(
Expand All @@ -250,7 +255,8 @@ int main(int argc, char* argv[])
Choose_Integrator(
OutputFilenames,
InitialSpeciesConcentration,
Species,Thermodynamics,ReducedReactions,
Reduced_Reaction_Mechanism,
//Species,Thermodynamics,ReducedReactions,
InitialParameters,
KeyRates,
PetroOxyDataInitial,
Expand All @@ -262,7 +268,7 @@ int main(int argc, char* argv[])
ReportAccuracy(
InitialParameters.Solver_Parameters.separator,
Number_Species,
Species,
Reduced_Reaction_Mechanism.Species,
"reduction_accuracy_report.txt",
"concentrations.txt",
"reduced_concentrations.txt"
Expand Down
2 changes: 1 addition & 1 deletion source/get_input/Get_Initial_Conditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void Get_Initial_Conditions(


/* Other functions */
InitialParameters.nrspec = 0;
//InitialParameters.nrspec = 0;

/* Code extension for Gas Phase */
InitialParameters.GasPhase = false; // default not gas phase
Expand Down
Loading

0 comments on commit 02d86fe

Please sign in to comment.