Skip to content

Commit

Permalink
Sensitivity analysis enabled for 0-d, but output not written
Browse files Browse the repository at this point in the history
  • Loading branch information
mbkumar committed Apr 1, 2020
1 parent 7a89a48 commit bd8f347
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions src/zerodReactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,40 @@ void run_0d_reactor(ReactorParser& rctr_parser,
}
}

/* Sensitivity Analysis */
bool sens_on = rctr_parser.SAEnabled();
vector<string> rxnids;

if (sens_on) {
rxnids = rctr_parser.getSAReactions();
for (auto& id : rxnids){
// Identify which kinetics the reaction belong to
// First gas phase kinetics
bool rxnConsumed = false;
for (size_t i = 0; i < gas->nReactions(); i++){
if (gas->reaction(i)->id == id){
rctr->addSensitivityReaction(i);
rxnConsumed = true;
break;
}
}
size_t kin_ind = 0;
while(!rxnConsumed && kin_ind < surfaces.size()) {
for (size_t i = 0; i < surfaces[kin_ind]->nReactions(); i++){
if (surfaces[kin_ind]->reaction(i)->id == id){
cat_surfs[kin_ind]->addSensitivityReaction(i);
rxnConsumed = true;
break;
}
}
kin_ind++;
}
if(!rxnConsumed) {
throw CanteraError("Sensitivity reaction id {} not found in any mechanism", id);
}
}

}
// Read simulation parameters
double end_time = 0;
if (mode == "tpd"){
Expand Down Expand Up @@ -304,11 +338,11 @@ void run_0d_reactor(ReactorParser& rctr_parser,
ofstream rates_out ((out_dir / "rates_ss.out").string(), ios::out);

if (data_format == OutputFormat::DAT) {
gas_ss_mole_out << "Gas Mole fractions at Steady State\n";
gas_ss_mass_out << "Gas Mass fractions at Steady State\n";
gas_ss_msdot_out << "Surface Production Rates of Gas Species at Steady State\n";
surf_ss_out << "Surace Coverages at Steady State\n";
state_var_ss_out << "Steady State Reactor State\n";
gas_ss_mole_out << "#Gas Mole fractions at Steady State\n";
gas_ss_mass_out << "#Gas Mass fractions at Steady State\n";
gas_ss_msdot_out << "#Surface Production Rates of Gas Species at Steady State\n";
surf_ss_out << "#Surace Coverages at Steady State\n";
state_var_ss_out << "#Steady State Reactor State\n";
}

// Reaction path analysis (RPA) data, consisting of rates of progress.
Expand Down

0 comments on commit bd8f347

Please sign in to comment.