Hi Cantera Users,
I am trying to add a routine to StFlow.cpp that calculates surface reactions. For security reasons, I am not allowed to install/change the installed version of Cantera.
Anyway, the modification (mods are in bold) that I made below works like I intend it to. However, the command Interface surface("ptcombust.cti", "Pt_surf", phases); in equil_demo slows things down quite a bit. My intention is to create the surface earlier. In fact, I would like to do this right after the line vector<ThermoPhase*> phases; . When I try this, though, I get an error message that says the supplied phase is not found.
Can anyone out there please tell me how I can create this phase prior to the subroutine (or refer me to an example that does this)?
Thanks a lot!
/**
* @file StFlow.cpp
*/
// Copyright 2002 California Institute of Technology
#include <stdlib.h>
#include <time.h>
#include "cantera/oneD/StFlow.h"
#include "cantera/base/ctml.h"
#include "cantera/oneD/MultiJac.h"
#include "cantera/IdealGasMix.h" // ADDING DEFINING INTERFACE TO CREATE GAS PHASE TO CREATE SUBSEQUENT INTERFACE
#include "cantera/Interface.h" // ADDING DEFINING INTERFACE FOR SURFACE REACTIONS
#include "cantera/equilibrium.h" // ADDING...TRYING TO ADD A SIMPLE ROUTINE
#include "cantera/thermo.h" // ADDING...TRYING TO ADD A SIMPLE ROUTINE
#include <cmath> // ADDING MATH FUNCTION TO HANDLE pow(x,y)
#include <cstdio> // ADDING TO PRINT/DEBUG
using namespace ctml;
using namespace std;
namespace Cantera
{
ThermoPhase* wall = newPhase("h2o2.cti","ohmech"); //ADDING...CREATING A NEAR WALL GAS PHASE
vector<ThermoPhase*> phases; // ADDING...CREATIGN A VECTOR OF PHASES FOR INTERFACE
vector_fp surfdot(14);
// ADDING...THIS SECTION BORROWS HEAVILY FROM surfdemo.cpp.
//THE IDEA IS TO SET GAS PHASE AT THE WALL THEN FIND THE SURFACE
//PRODUCTION RATES.
void equil_demo(const doublereal* x, size_t j)
{
int nsp;
nsp = 9;
doublereal press = OneAtm;
doublereal ywall[nsp];
doublereal twall;
twall = x[(nsp+c_offset_Y+1)+(c_offset_Y+2*nsp+1)*j-1];
for(int k=0; k<nsp; k++){
ywall[k] = x[(nsp+c_offset_Y+1)+(c_offset_Y+2*nsp+1)*j+k];
}
wall->setTemperature(twall);
wall->setMassFractions(ywall);
wall->setPressure(press);
phases.push_back(wall);
doublereal cov[5];
cov[0]=0.2; cov[1]=0.2; cov[2]=0.2; cov[3]=0.2; cov[4]=0.2;
Interface surface("ptcombust.cti", "Pt_surf", phases);
surface.solvePseudoSteadyStateProblem();
surface.getNetProductionRates(DATA_PTR(surfdot));
}
...the remainder of StFlow.cpp