modified syntax for consistency with other code, added comment for interface_current

This commit is contained in:
Corey Randall
2022-10-07 13:11:17 -06:00
committed by Ingmar Schoegl
parent 9fa8d30ab4
commit ba5d5f892d
5 changed files with 28 additions and 19 deletions

View File

@@ -287,7 +287,16 @@ public:
*/
int phaseStability(const size_t iphase) const;
double InterfaceCurrent(int iPhase);
//! Gets the interface current for the ith phaseExistence
/*!
* @param iphase Phase Id
* @return The double specifying the interface current. The interface Current
* is useful when charge transfer reactions occur at an interface. It
* is defined here as the net positive charge entering the phase
* specified by the Phase Id. (Units: A/m^2 for a surface reaction,
* A/m for an edge reaction).
*/
double InterfaceCurrent(const size_t iphase);
protected:
//! Temporary work vector of length m_kk

View File

@@ -69,7 +69,7 @@ cdef extern from "cantera/kinetics/InterfaceKinetics.h":
cdef cppclass CxxInterfaceKinetics "Cantera::InterfaceKinetics":
void advanceCoverages(double, double, double, double, size_t, size_t) except +translate_exception
void solvePseudoSteadyStateProblem() except +translate_exception
double InterfaceCurrent(int) except +translate_exception
double InterfaceCurrent(size_t) except +translate_exception
cdef extern from "cantera/cython/kinetics_utils.h":

View File

@@ -886,8 +886,8 @@ cdef class InterfaceKinetics(Kinetics):
an interface. It is defined here as the net positive charge entering the
phase ``phase`` (Units: A/m^2 for a surface, A/m for an edge reaction).
"""
iPhase = self.phase_index(phase)
return (<CxxInterfaceKinetics*>self.kinetics).InterfaceCurrent(iPhase)
i_phase = self.phase_index(phase)
return (<CxxInterfaceKinetics*>self.kinetics).InterfaceCurrent(i_phase)
def write_yaml(self, filename, phases=None, units=None, precision=None,
skip_user_defined=None):

View File

@@ -595,30 +595,30 @@ void InterfaceKinetics::setPhaseStability(const size_t iphase, const int isStabl
}
}
double InterfaceKinetics::InterfaceCurrent(int iPhase)
double InterfaceKinetics::InterfaceCurrent(const size_t iphase)
{
int sp = thermo(iPhase).nSpecies();
double charge_k[sp];
double net_k[sp];
doublereal netprods[m_kk];
int nSp = thermo(iphase).nSpecies();
double charge_k[nSp];
double sdot_k[nSp];
doublereal netProdRates[m_kk];
thermo(iPhase).getCharges(charge_k);
thermo(iphase).getCharges(charge_k);
getNetProductionRates(netprods);
getNetProductionRates(netProdRates);
for(int k=0; k<sp; k++)
for(int k=0; k<nSp; k++)
{
net_k[k] = netprods[m_start[iPhase]+k];
sdot_k[k] = netProdRates[m_start[iphase]+k];
}
double out = 0.0;
double dotProduct = 0.0;
for(int k=0; k<sp; k++)
for(int k=0; k<nSp; k++)
{
out += charge_k[k]*net_k[k];
dotProduct += charge_k[k]*sdot_k[k];
}
return out*Faraday;
return dotProduct*Faraday;
}
}

View File

@@ -1083,11 +1083,11 @@ class TestLithiumIonBatteryKinetics(utilities.CanteraTest):
phases = [anode_int, anode, elect, elyte]
for p in phases:
productions = anode_int.get_net_production_rates(p)
net_prod_rates = anode_int.get_net_production_rates(p)
charges = p.charges
method = anode_int.interface_current(p)
manual = sum(productions*charges)*ct.faraday
manual = sum(net_prod_rates*charges)*ct.faraday
self.assertEqual(method,manual)