*** empty log message ***
This commit is contained in:
parent
a5ad3cb463
commit
b21ad9c412
5 changed files with 138 additions and 83 deletions
|
|
@ -1,3 +1,8 @@
|
|||
! This module is the only 'public' one - i.e., the only one visible in
|
||||
! an application program. It's primary purpose is to provide generic
|
||||
! procedure names that map to specific procedures depending on the
|
||||
! argument types.
|
||||
|
||||
MODULE CANTERA
|
||||
|
||||
USE cantera_thermo
|
||||
|
|
@ -348,6 +353,11 @@ MODULE CANTERA
|
|||
MODULE PROCEDURE ctstring_setState_TPX
|
||||
END INTERFACE setState_TPX
|
||||
|
||||
INTERFACE setState_TRY
|
||||
MODULE PROCEDURE ctthermo_setState_TRY
|
||||
MODULE PROCEDURE ctstring_setState_TRY
|
||||
END INTERFACE setState_TRY
|
||||
|
||||
INTERFACE setState_UV
|
||||
MODULE PROCEDURE ctthermo_setState_UV
|
||||
END INTERFACE setState_UV
|
||||
|
|
|
|||
|
|
@ -342,6 +342,29 @@ contains
|
|||
call ctthermo_setPressure(self, p)
|
||||
end subroutine ctstring_setState_TPX
|
||||
|
||||
subroutine ctthermo_setState_TRY(self, t, rho, y)
|
||||
implicit none
|
||||
type(phase_t), intent(inout) :: self
|
||||
double precision, intent(in) :: t
|
||||
double precision, intent(in) :: rho
|
||||
double precision, intent(in) :: y(*)
|
||||
call ctthermo_setTemperature(self, t)
|
||||
call ctthermo_setMassFractions(self, y)
|
||||
call ctthermo_setDensity(self, rho)
|
||||
end subroutine ctthermo_setState_TRY
|
||||
|
||||
subroutine ctstring_setState_TRY(self, t, rho, y)
|
||||
implicit none
|
||||
type(phase_t), intent(inout) :: self
|
||||
double precision, intent(in) :: t
|
||||
double precision, intent(in) :: rho
|
||||
character*(*), intent(in) :: y
|
||||
call ctthermo_setTemperature(self, t)
|
||||
call ctthermo_setMassFractionsByName(self, y)
|
||||
call ctthermo_setDensity(self, rho)
|
||||
end subroutine ctstring_setState_TRY
|
||||
|
||||
|
||||
subroutine ctthermo_setState_HP(self, h, p)
|
||||
implicit none
|
||||
type(phase_t), intent(inout) :: self
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ for n = 1:100
|
|||
tim(n) = t;
|
||||
temp(n) = temperature(r);
|
||||
pres(n) = pressure(r);
|
||||
cov(n,:) = coverages(surf)';
|
||||
cov(n,:) = coverages(surf)';
|
||||
x(n,:) = moleFraction(gas,names);
|
||||
end
|
||||
disp(['CPU time = ' num2str(cputime - t0)]);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ namespace Cantera {
|
|||
/// that manage homogeneous chemistry within one phase, or
|
||||
/// heterogeneous chemistry at one interface.
|
||||
///
|
||||
|
||||
// Note: Implementations for methods not implemented here may be
|
||||
// found in KineticsFactory.cpp
|
||||
|
||||
class Kinetics {
|
||||
|
||||
public:
|
||||
|
|
@ -190,15 +194,7 @@ namespace Cantera {
|
|||
* the kinetics manager. If k is out of bounds, the string
|
||||
* "<unknown>" is returned.
|
||||
*/
|
||||
string kineticsSpeciesName(int k) const {
|
||||
int np = m_start.size();
|
||||
for (int n = np-1; n >= 0; n--) {
|
||||
if (k >= m_start[n]) {
|
||||
return thermo(n).speciesName(k - m_start[n]);
|
||||
}
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
string kineticsSpeciesName(int k) const;
|
||||
|
||||
/**
|
||||
* This routine will look up a species number based on
|
||||
|
|
@ -214,28 +210,7 @@ namespace Cantera {
|
|||
* the value -1 is returned.
|
||||
* - If no match is found in any phase, the value -2 is returned.
|
||||
*/
|
||||
int kineticsSpeciesIndex(string nm, string ph = "<any>") const {
|
||||
int np = static_cast<int>(m_thermo.size());
|
||||
int k;
|
||||
string id;
|
||||
for (int n = 0; n < np; n++) {
|
||||
id = thermo(n).id();
|
||||
if (ph == id) {
|
||||
k = thermo(n).speciesIndex(nm);
|
||||
if (k < 0) return -1;
|
||||
return k + m_start[n];
|
||||
}
|
||||
else if (ph == "<any>") {
|
||||
/*
|
||||
* Call the speciesIndex() member function of the
|
||||
* ThermoPhase object to find a match.
|
||||
*/
|
||||
k = thermo(n).speciesIndex(nm);
|
||||
if (k >= 0) return k + m_start[n];
|
||||
}
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
int kineticsSpeciesIndex(string nm, string ph = "<any>") const;
|
||||
|
||||
/**
|
||||
* This function looks up the string name of a species and
|
||||
|
|
@ -243,16 +218,7 @@ namespace Cantera {
|
|||
* phase where the species resides.
|
||||
* Will throw an error if the species string doesn't match.
|
||||
*/
|
||||
thermo_t& speciesPhase(string nm) {
|
||||
int np = static_cast<int>(m_thermo.size());
|
||||
int k;
|
||||
string id;
|
||||
for (int n = 0; n < np; n++) {
|
||||
k = thermo(n).speciesIndex(nm);
|
||||
if (k >= 0) return thermo(n);
|
||||
}
|
||||
throw CanteraError("speciesPhase", "unknown species "+nm);
|
||||
}
|
||||
thermo_t& speciesPhase(string nm);
|
||||
|
||||
/**
|
||||
* This function takes as an argument the kineticsSpecies index
|
||||
|
|
@ -269,16 +235,7 @@ namespace Cantera {
|
|||
* manager) and returns the index of the phase owning the
|
||||
* species.
|
||||
*/
|
||||
int speciesPhaseIndex(int k) {
|
||||
int np = m_start.size();
|
||||
for (int n = np-1; n >= 0; n--) {
|
||||
if (k >= m_start[n]) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
throw CanteraError("speciesPhaseIndex",
|
||||
"illegal species index: "+int2str(k));
|
||||
}
|
||||
int speciesPhaseIndex(int k);
|
||||
|
||||
//@}
|
||||
|
||||
|
|
@ -561,32 +518,7 @@ namespace Cantera {
|
|||
* index of the phase within the kinetics
|
||||
* manager object as the value.
|
||||
*/
|
||||
void addPhase(thermo_t& thermo) {
|
||||
|
||||
// if not the first thermo object, set the start position
|
||||
// to that of the last object added + the number of its species
|
||||
if (m_thermo.size() > 0) {
|
||||
m_start.push_back(m_start.back()
|
||||
+ m_thermo.back()->nSpecies());
|
||||
}
|
||||
// otherwise start at 0
|
||||
else {
|
||||
m_start.push_back(0);
|
||||
}
|
||||
// there should only be one surface phase
|
||||
int ptype = -100;
|
||||
if (type() == cEdgeKinetics) ptype = cEdge;
|
||||
else if (type() == cInterfaceKinetics) ptype = cSurf;
|
||||
if (thermo.eosType() == ptype) {
|
||||
if (m_surfphase >= 0) {
|
||||
throw CanteraError("Kinetics::addPhase",
|
||||
"cannot add more than one surface phase");
|
||||
}
|
||||
m_surfphase = nPhases();
|
||||
}
|
||||
m_thermo.push_back(&thermo);
|
||||
m_phaseindex[m_thermo.back()->id()] = nPhases();
|
||||
}
|
||||
void addPhase(thermo_t& thermo);
|
||||
|
||||
/**
|
||||
* Prepare the class for the addition of reactions. This function
|
||||
|
|
@ -725,11 +657,8 @@ namespace Cantera {
|
|||
private:
|
||||
|
||||
vector<grouplist_t> m_dummygroups;
|
||||
void err(string m) const {
|
||||
throw CanteraError("Kinetics::" + m,
|
||||
"The default Base class method was called, when "
|
||||
"the inherited class's method should have been called");
|
||||
}
|
||||
void err(string m) const;
|
||||
|
||||
};
|
||||
|
||||
typedef Kinetics kinetics_t;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,99 @@
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
|
||||
//---------- class Kinetics methods ------------------
|
||||
string Kinetics::kineticsSpeciesName(int k) const {
|
||||
int np = m_start.size();
|
||||
for (int n = np-1; n >= 0; n--) {
|
||||
if (k >= m_start[n]) {
|
||||
return thermo(n).speciesName(k - m_start[n]);
|
||||
}
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
|
||||
int Kinetics::kineticsSpeciesIndex(string nm, string ph) const {
|
||||
int np = static_cast<int>(m_thermo.size());
|
||||
int k;
|
||||
string id;
|
||||
for (int n = 0; n < np; n++) {
|
||||
id = thermo(n).id();
|
||||
if (ph == id) {
|
||||
k = thermo(n).speciesIndex(nm);
|
||||
if (k < 0) return -1;
|
||||
return k + m_start[n];
|
||||
}
|
||||
else if (ph == "<any>") {
|
||||
/*
|
||||
* Call the speciesIndex() member function of the
|
||||
* ThermoPhase object to find a match.
|
||||
*/
|
||||
k = thermo(n).speciesIndex(nm);
|
||||
if (k >= 0) return k + m_start[n];
|
||||
}
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
thermo_t& Kinetics::speciesPhase(string nm) {
|
||||
int np = static_cast<int>(m_thermo.size());
|
||||
int k;
|
||||
string id;
|
||||
for (int n = 0; n < np; n++) {
|
||||
k = thermo(n).speciesIndex(nm);
|
||||
if (k >= 0) return thermo(n);
|
||||
}
|
||||
throw CanteraError("speciesPhase", "unknown species "+nm);
|
||||
}
|
||||
|
||||
int Kinetics::speciesPhaseIndex(int k) {
|
||||
int np = m_start.size();
|
||||
for (int n = np-1; n >= 0; n--) {
|
||||
if (k >= m_start[n]) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
throw CanteraError("speciesPhaseIndex",
|
||||
"illegal species index: "+int2str(k));
|
||||
}
|
||||
|
||||
void Kinetics::addPhase(thermo_t& thermo) {
|
||||
|
||||
// if not the first thermo object, set the start position
|
||||
// to that of the last object added + the number of its species
|
||||
if (m_thermo.size() > 0) {
|
||||
m_start.push_back(m_start.back()
|
||||
+ m_thermo.back()->nSpecies());
|
||||
}
|
||||
// otherwise start at 0
|
||||
else {
|
||||
m_start.push_back(0);
|
||||
}
|
||||
// there should only be one surface phase
|
||||
int ptype = -100;
|
||||
if (type() == cEdgeKinetics) ptype = cEdge;
|
||||
else if (type() == cInterfaceKinetics) ptype = cSurf;
|
||||
if (thermo.eosType() == ptype) {
|
||||
if (m_surfphase >= 0) {
|
||||
throw CanteraError("Kinetics::addPhase",
|
||||
"cannot add more than one surface phase");
|
||||
}
|
||||
m_surfphase = nPhases();
|
||||
}
|
||||
m_thermo.push_back(&thermo);
|
||||
m_phaseindex[m_thermo.back()->id()] = nPhases();
|
||||
}
|
||||
|
||||
void Kinetics::err(string m) const {
|
||||
throw CanteraError("Kinetics::" + m,
|
||||
"The default Base class method was called, when "
|
||||
"the inherited class's method should have been called");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
||||
KineticsFactory* KineticsFactory::__factory = 0;
|
||||
|
||||
static int ntypes = 5;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue