[Reactor] Change 'species' to 'component' in context of sensitivities

Change the variable named *species* to be named *component*. This
better matches the utility of this variable, since it can be used to
retrieve any of the state variables. Also, update the corresponding
documentation.
This commit is contained in:
Bryan W. Weber 2013-12-16 23:22:04 +00:00
parent 1a2404aea5
commit fc2d7e4ce0
3 changed files with 18 additions and 19 deletions

View file

@ -152,10 +152,10 @@ public:
return m_integ->sensitivity(k, m_sensIndex[p])/m_integ->solution(k);
}
//! Return the sensitivity of the species named *species* with respect to
//! Return the sensitivity of the component named *component* with respect to
//! the *p*-th sensitivity parameter.
double sensitivity(const std::string& species, size_t p, int reactor=0) {
size_t k = globalComponentIndex(species, reactor);
double sensitivity(const std::string& component, size_t p, int reactor=0) {
size_t k = globalComponentIndex(component, reactor);
return sensitivity(k, p);
}
@ -182,10 +182,10 @@ public:
return m_ntotpar;
}
//! Return the index corresponding to the species named *species* in the
//! Return the index corresponding to the component named *component* in the
//! reactor with index *reactor* in the global state vector for the
//! reactor network.
size_t globalComponentIndex(const std::string& species, size_t reactor=0);
size_t globalComponentIndex(const std::string& component, size_t reactor=0);
//! Used by Reactor and Wall objects to register the addition of
//! sensitivity reactions so that the ReactorNet can keep track of the

23
interfaces/cython/cantera/reactor.pyx Executable file → Normal file
View file

@ -817,20 +817,19 @@ cdef class ReactorNet:
def __set__(self, pybool v):
self.net.setVerbose(v)
def sensitivity(self, species, int p, int r=0):
def sensitivity(self, component, int p, int r=0):
"""
Returns the sensitivity of the solution variable *species* in reactor
*r* with respect to the parameter *p*. Returns an empty array until the
first time step is taken. See `ReactorNet.component_index` and
`sensitivities` to determine the integer index for the variables.
Otherwise, a string can be passed into *species* to automatically look
up the index.
Returns the sensitivity of the solution variable *component* in
reactor *r* with respect to the parameter *p*. *component* can be a
string or an integer. See `component_index` and `sensitivities` to
determine the integer index for the variables. If it is not given, *r*
defaults to the first reactor. Returns an empty array until the first
time step is taken.
"""
if isinstance(species, int):
return self.net.sensitivity(species,p)
elif isinstance(species, (str, unicode)):
return self.net.sensitivity(stringify(species), p, r)
if isinstance(component, int):
return self.net.sensitivity(component, p)
elif isinstance(component, (str, unicode)):
return self.net.sensitivity(stringify(component), p, r)
def sensitivities(self):
"""

View file

@ -254,7 +254,7 @@ void ReactorNet::getInitialConditions(doublereal t0,
}
}
size_t ReactorNet::globalComponentIndex(const string& species, size_t reactor)
size_t ReactorNet::globalComponentIndex(const string& component, size_t reactor)
{
if (!m_init) {
initialize();
@ -264,7 +264,7 @@ size_t ReactorNet::globalComponentIndex(const string& species, size_t reactor)
for (n = 0; n < reactor; n++) {
start += m_size[n];
}
return start + m_reactors[n]->componentIndex(species);
return start + m_reactors[n]->componentIndex(component);
}
void ReactorNet::registerSensitivityReaction(void* reactor,