Fix un-bracketed if, for, and else statements

This commit is contained in:
Ray Speth 2015-08-01 12:51:52 -04:00
parent 02f9497b20
commit 6a04193646
35 changed files with 123 additions and 83 deletions

View file

@ -383,14 +383,16 @@ public:
void incrementReaction(const doublereal* input,
doublereal* output) const {
for (size_t n = 0; n < m_n; n++) output[m_rxn]
+= m_stoich[n]*input[m_ic[n]];
for (size_t n = 0; n < m_n; n++) {
output[m_rxn] += m_stoich[n]*input[m_ic[n]];
}
}
void decrementReaction(const doublereal* input,
doublereal* output) const {
for (size_t n = 0; n < m_n; n++) output[m_rxn]
-= m_stoich[n]*input[m_ic[n]];
for (size_t n = 0; n < m_n; n++) {
output[m_rxn] -= m_stoich[n]*input[m_ic[n]];
}
}
private:
@ -598,9 +600,10 @@ public:
// instead of 'power'.
std::vector<size_t> kRep;
for (size_t n = 0; n < k.size(); n++) {
for (size_t i = 0; i < stoich[n]; i++)
for (size_t i = 0; i < stoich[n]; i++) {
kRep.push_back(k[n]);
}
}
switch (kRep.size()) {
case 1:

View file

@ -82,9 +82,10 @@ public:
//! Set the emissivity.
void setEmissivity(doublereal epsilon) {
if (epsilon > 1.0 || epsilon < 0.0)
if (epsilon > 1.0 || epsilon < 0.0) {
throw CanteraError("Wall::setEmissivity",
"emissivity must be between 0.0 and 1.0");
}
m_emiss = epsilon;
}

View file

@ -176,10 +176,11 @@ doublereal getFloat(const XML_Node& parent,
const std::string& name,
const std::string& type)
{
if (!parent.hasChild(name))
if (!parent.hasChild(name)) {
throw CanteraError("getFloat (called from XML Node \"" +
parent.name() + "\"): ",
"no child XML element named \"" + name + "\" exists");
}
const XML_Node& node = parent.child(name);
return getFloatCurrent(node, type);
}

View file

@ -107,10 +107,11 @@ static int lastChar(const std::string& s)
{
int i;
int n = static_cast<int>(s.size());
for (i = n-1; i >= 0; i--)
for (i = n-1; i >= 0; i--) {
if (s[i] != ' ' && isprint(s[i])) {
break;
}
}
return i;
}

View file

@ -548,13 +548,15 @@ extern "C" {
int th_set_HP(int n, double* vals)
{
try {
if (vals[1] < 0.0)
if (vals[1] < 0.0) {
throw CanteraError("th_set_HP",
"pressure cannot be negative");
}
ThermoCabinet::item(n).setState_HP(vals[0],vals[1]);
if (ThermoCabinet::item(n).temperature() < 0.0)
if (ThermoCabinet::item(n).temperature() < 0.0) {
throw CanteraError("th_set_HP",
"temperature cannot be negative");
}
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
@ -564,13 +566,15 @@ extern "C" {
int th_set_UV(int n, double* vals)
{
try {
if (vals[1] < 0.0)
if (vals[1] < 0.0) {
throw CanteraError("th_set_UV",
"specific volume cannot be negative");
}
ThermoCabinet::item(n).setState_UV(vals[0],vals[1]);
if (ThermoCabinet::item(n).temperature() < 0.0)
if (ThermoCabinet::item(n).temperature() < 0.0) {
throw CanteraError("th_set_UV",
"temperature cannot be negative");
}
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);

View file

@ -34,32 +34,37 @@ extern "C" {
} else if (type == ExpFuncType) {
r = new Exp1(params[0]);
} else if (type == PowFuncType) {
if (lenp < 1)
if (lenp < 1) {
throw CanteraError("func_new",
"exponent for pow must be supplied");
}
r = new Pow1(params[0]);
} else if (type == ConstFuncType) {
r = new Const1(params[0]);
} else if (type == FourierFuncType) {
if (lenp < 2*n + 2)
if (lenp < 2*n + 2) {
throw CanteraError("func_new",
"not enough Fourier coefficients");
}
r = new Fourier1(n, params[n+1], params[0], params + 1,
params + n + 2);
} else if (type == GaussianFuncType) {
if (lenp < 3)
if (lenp < 3) {
throw CanteraError("func_new",
"not enough Gaussian coefficients");
}
r = new Gaussian(params[0], params[1], params[2]);
} else if (type == PolyFuncType) {
if (lenp < n + 1)
if (lenp < n + 1) {
throw CanteraError("func_new",
"not enough polynomial coefficients");
}
r = new Poly1(n, params);
} else if (type == ArrheniusFuncType) {
if (lenp < 3*n)
if (lenp < 3*n) {
throw CanteraError("func_new",
"not enough Arrhenius coefficients");
}
r = new Arrhenius1(n, params);
} else if (type == PeriodicFuncType) {
r = new Periodic1(FuncCabinet::item(n), params[0]);

View file

@ -119,9 +119,10 @@ extern "C" {
if (node.hasAttrib(key)) {
string v = node[key];
strncpy(value, v.c_str(), 80);
} else
} else {
throw CanteraError("xml_attrib","node "
" has no attribute '"+string(key)+"'");
}
} catch (...) {
return handleAllExceptions(-1, ERR);
}
@ -213,9 +214,10 @@ extern "C" {
XML_Node* c = XmlCabinet::item(i).findByName(nm);
if (c) {
return XmlCabinet::add(c);
} else
} else {
throw CanteraError("xml_findByName","name "+string(nm)
+" not found");
}
} catch (...) {
return handleAllExceptions(-1, ERR);
}

View file

@ -108,15 +108,16 @@ void ChemEquil::initialize(thermo_t& s)
// if negative atom numbers have already been specified
// for some element other than this one, throw
// an exception
if (mneg != npos && mneg != m)
if (mneg != npos && mneg != m) {
throw CanteraError("ChemEquil::initialize",
"negative atom numbers allowed for only one element");
}
mneg = m;
ewt = s.atomicWeight(m);
// the element should be an electron... if it isn't
// print a warning.
if (ewt > 1.0e-3)
if (ewt > 1.0e-3) {
writelog(string("WARNING: species "
+s.speciesName(k)
+" has "+fp2str(s.nAtoms(k,m))
@ -126,6 +127,7 @@ void ChemEquil::initialize(thermo_t& s)
}
}
}
}
m_eloc = mneg;
// set up the elemental composition matrix
@ -141,10 +143,11 @@ void ChemEquil::setToEquilState(thermo_t& s,
{
// Construct the chemical potentials by summing element potentials
fill(m_mu_RT.begin(), m_mu_RT.end(), 0.0);
for (size_t k = 0; k < m_kk; k++)
for (size_t k = 0; k < m_kk; k++) {
for (size_t m = 0; m < m_mm; m++) {
m_mu_RT[k] += lambda_RT[m]*nAtoms(k,m);
}
}
// Set the temperature
s.setTemperature(t);
@ -620,8 +623,7 @@ int ChemEquil::equilibrate(thermo_t& s, const char* XYstr,
doublereal f, oldf;
doublereal fctr = 1.0, newval;
for (int iter = 0; iter < options.maxIterations; iter++)
{
for (int iter = 0; iter < options.maxIterations; iter++) {
// check for convergence.
equilResidual(s, x, elMolesGoal, res_trial, xval, yval);
f = 0.5*dot(res_trial.begin(), res_trial.end(), res_trial.begin());

View file

@ -927,8 +927,7 @@ void MultiPhase::updatePhases() const
loc += nsp;
m_phase[p]->setState_TPX(m_temp, m_press, x);
m_temp_OK[p] = true;
if (m_temp < m_phase[p]->minTemp()
|| m_temp > m_phase[p]->maxTemp()) {
if (m_temp < m_phase[p]->minTemp() || m_temp > m_phase[p]->maxTemp()) {
m_temp_OK[p] = false;
}
}

View file

@ -409,8 +409,7 @@ void MultiPhaseEquil::getComponents(const std::vector<size_t>& order)
for (j = 0; j < nFree(); j++) {
m_solnrxn[j] = false;
for (k = 0; k < m_nsp; k++) {
if (m_N(k, j) != 0)
if (m_mix->solutionSpecies(m_species[m_order[k]])) {
if (m_N(k, j) != 0 && m_mix->solutionSpecies(m_species[m_order[k]])) {
m_solnrxn[j] = true;
}
}

View file

@ -135,14 +135,15 @@ void VCS_SOLVE::vcs_inest(double* const aw, double* const sa, double* const sm,
for (size_t kspec = 0; kspec < nspecies; ++kspec) {
plogf("%s", pprefix);
plogf("%-12.12s", m_speciesName[kspec].c_str());
if (kspec < m_numComponents)
if (kspec < m_numComponents) {
plogf("fe* = %15.5g ff = %15.5g\n", m_feSpecies_new[kspec],
m_SSfeSpecies[kspec]);
else
} else {
plogf("fe* = %15.5g ff = %15.5g dg* = %15.5g\n",
m_feSpecies_new[kspec], m_SSfeSpecies[kspec], m_deltaGRxn_new[kspec-m_numComponents]);
}
}
}
/* ********************************************************** */
/* **** ESTIMATE REACTION ADJUSTMENTS *********************** */
/* ********************************************************** */

View file

@ -106,9 +106,10 @@ extern "C" {
if (node.hasAttrib(ky)) {
std::string v = node[ky];
strncpy(value, v.c_str(), valuelen);
} else
} else {
throw CanteraError("fxml_attrib","node "
" has no attribute '"+ky+"'");
}
} catch (...) {
return handleAllExceptions(-1, ERR);
}
@ -212,9 +213,10 @@ extern "C" {
XML_Node* c = node.findByName(f2string(nm, nmlen));
if (c) {
return XmlCabinet::add(c);
} else
} else {
throw CanteraError("fxml_findByName","name "+f2string(nm, nmlen)
+" not found");
}
} catch (...) {
return handleAllExceptions(-1, ERR);
}

View file

@ -22,12 +22,7 @@ Kinetics* BulkKinetics::duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVe
}
bool BulkKinetics::isReversible(size_t i) {
if (std::find(m_revindex.begin(), m_revindex.end(), i)
< m_revindex.end()) {
return true;
} else {
return false;
}
return std::find(m_revindex.begin(), m_revindex.end(), i) < m_revindex.end();
}
void BulkKinetics::getDeltaGibbs(doublereal* deltaG)

View file

@ -41,9 +41,10 @@ ImplicitSurfChem::ImplicitSurfChem(vector<InterfaceKinetics*> k) :
InterfaceKinetics* kinPtr = k[n];
m_vecKinPtrs.push_back(kinPtr);
ns = k[n]->surfacePhaseIndex();
if (ns == npos)
if (ns == npos) {
throw CanteraError("ImplicitSurfChem",
"kinetics manager contains no surface phase");
}
m_surfindex.push_back(ns);
m_surf.push_back((SurfPhase*)&k[n]->thermo(ns));
nsp = m_surf.back()->nSpecies();

View file

@ -833,16 +833,18 @@ void solveSP::printIteration(int ioflag, doublereal damp, int label_d,
}
if (do_time) {
printf("%9.4e %9.4e ", t_real, 1.0/inv_t);
} else
} else {
for (i = 0; i < 22; i++) {
printf(" ");
}
}
if (damp < 1.0) {
printf("%9.4e ", damp);
} else
} else {
for (i = 0; i < 11; i++) {
printf(" ");
}
}
printf("%9.4e %9.4e", update_norm, resid_norm);
if (do_time) {
k = m_kinSpecIndex[label_t];

View file

@ -264,10 +264,11 @@ int BandMatrix::solve(doublereal* b, size_t nrhs, size_t ldb)
if (ldb == 0) {
ldb = nColumns();
}
if (info == 0)
if (info == 0) {
ct_dgbtrs(ctlapack::NoTranspose, nColumns(), nSubDiagonals(),
nSuperDiagonals(), nrhs, DATA_PTR(ludata), ldim(),
DATA_PTR(ipiv()), b, ldb, info);
}
// error handling
if (info != 0) {

View file

@ -193,10 +193,11 @@ void MultiNewton::step(doublereal* x, doublereal* step,
iok--;
size_t nd = r.nDomains();
size_t n;
for (n = nd-1; n != npos; n--)
for (n = nd-1; n != npos; n--) {
if (iok >= r.start(n)) {
break;
}
}
Domain1D& dom = r.domain(n);
size_t offset = iok - r.start(n);
size_t pt = offset/dom.nComponents();
@ -207,10 +208,11 @@ void MultiNewton::step(doublereal* x, doublereal* step,
+dom.componentName(comp)+" at point "
+int2str(pt)+"\n(Matrix row "
+int2str(iok)+") \nsee file bandmatrix.csv\n");
} else if (int(iok) < 0)
} else if (int(iok) < 0) {
throw CanteraError("MultiNewton::step",
"iok = "+int2str(iok));
}
}
doublereal MultiNewton::boundStep(const doublereal* x0,
const doublereal* step0, const OneDim& r, int loglevel)

View file

@ -353,11 +353,12 @@ doublereal OneDim::timeStep(int nsteps, doublereal dt, doublereal* x,
// Decrease the stepsize and try again.
writelog("...failure.\n", loglevel);
dt *= m_tfactor;
if (dt < m_tmin)
if (dt < m_tmin) {
throw CanteraError("OneDim::timeStep",
"Time integration failed.");
}
}
}
// Prepare to solve the steady problem.
setSteadyMode();

View file

@ -107,9 +107,10 @@ void Sim1D::restore(const std::string& fname, const std::string& id,
int loglevel)
{
ifstream s(fname.c_str());
if (!s)
if (!s) {
throw CanteraError("Sim1D::restore",
"could not open input file "+fname);
}
XML_Node root;
root.build(s);

View file

@ -156,10 +156,11 @@ void StFlow::setTransport(Transport& trans, bool withSoret)
} else if (model == cMixtureAveraged || model == CK_MixtureAveraged) {
m_transport_option = c_Mixav_Transport;
m_diff.resize(m_nsp*m_points);
if (withSoret)
if (withSoret) {
throw CanteraError("setTransport",
"Thermal diffusion (the Soret effect) "
"requires using a multicomponent transport model.");
}
} else {
throw CanteraError("setTransport","unknown transport model.");
}

View file

@ -48,12 +48,13 @@ void Bdry1D::_init(size_t n)
m_left_loc = container().start(m_index-1);
m_left_nsp = m_left_nv - 4;
m_phase_left = &m_flow_left->phase();
} else
} else {
throw CanteraError("Bdry1D::_init",
"Boundary domains can only be "
"connected on the left to flow domains, not type "+int2str(r.domainType())
+ " domains.");
}
}
// if this is not the last domain, see what is connected on
// the right
@ -65,13 +66,14 @@ void Bdry1D::_init(size_t n)
m_right_loc = container().start(m_index+1);
m_right_nsp = m_right_nv - 4;
m_phase_right = &m_flow_right->phase();
} else
} else {
throw CanteraError("Bdry1D::_init",
"Boundary domains can only be "
"connected on the right to flow domains, not type "+int2str(r.domainType())
+ " domains.");
}
}
}
//----------------------------------------------------------
// Inlet1D methods

View file

@ -956,8 +956,7 @@ void DebyeHuckel::initThermoXML(XML_Node& phaseNode, const std::string& id_)
for (size_t k = 0; k < m_kk; k++) {
if (fabs(m_speciesCharge[k]) > 0.0001) {
m_electrolyteSpeciesType[k] = cEST_chargedSpecies;
if (fabs(m_speciesCharge_Stoich[k] - m_speciesCharge[k])
> 0.0001) {
if (fabs(m_speciesCharge_Stoich[k] - m_speciesCharge[k]) > 0.0001) {
m_electrolyteSpeciesType[k] = cEST_weakAcidAssociated;
}
} else if (fabs(m_speciesCharge_Stoich[k]) > 0.0001) {

View file

@ -1471,8 +1471,7 @@ void HMWSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_)
for (size_t k = 0; k < m_kk; k++) {
if (fabs(charge(k)) > 0.0001) {
m_electrolyteSpeciesType[k] = cEST_chargedSpecies;
if (fabs(m_speciesCharge_Stoich[k] - charge(k))
> 0.0001) {
if (fabs(m_speciesCharge_Stoich[k] - charge(k)) > 0.0001) {
m_electrolyteSpeciesType[k] = cEST_weakAcidAssociated;
}
} else if (fabs(m_speciesCharge_Stoich[k]) > 0.0001) {

View file

@ -93,10 +93,11 @@ void PureFluidPhase::setParametersFromXML(const XML_Node& eosdata)
{
eosdata._require("model","PureFluid");
m_subflag = atoi(eosdata["fluid_type"].c_str());
if (m_subflag < 0)
if (m_subflag < 0) {
throw CanteraError("PureFluidPhase::setParametersFromXML",
"missing or negative substance flag");
}
}
doublereal PureFluidPhase::enthalpy_mole() const
{

View file

@ -331,10 +331,11 @@ void importPhase(XML_Node& phase, ThermoPhase* th)
// Number of spatial dimensions. Defaults to 3 (bulk phase)
if (phase.hasAttrib("dim")) {
int idim = intValue(phase["dim"]);
if (idim < 1 || idim > 3)
if (idim < 1 || idim > 3) {
throw CanteraError("importPhase",
"phase, " + th->id() +
", has unphysical number of dimensions: " + phase["dim"]);
}
th->setNDim(idim);
} else {
th->setNDim(3); // default

View file

@ -229,11 +229,12 @@ void GasTransport::getBinaryDiffCoeffs(const size_t ld, doublereal* const d)
throw CanteraError(" MixTransport::getBinaryDiffCoeffs()", "ld is too small");
}
doublereal rp = 1.0/m_thermo->pressure();
for (size_t i = 0; i < m_nsp; i++)
for (size_t i = 0; i < m_nsp; i++) {
for (size_t j = 0; j < m_nsp; j++) {
d[ld*j + i] = rp * m_bdiff(i,j);
}
}
}
void GasTransport::getMixDiffCoeffs(doublereal* const d)
{

View file

@ -151,8 +151,7 @@ void HighPressureGasTransport::getBinaryDiffCoeffs(const size_t ld, doublereal*
throw CanteraError("HighPressureTransport::getBinaryDiffCoeffs()", "ld is too small");
}
doublereal rp = 1.0/m_thermo->pressure();
for (size_t i = 0; i < nsp; i++)
{
for (size_t i = 0; i < nsp; i++) {
for (size_t j = 0; j < nsp; j++) {
// Add an offset to avoid a condition where x_i and x_j both equal
// zero (this would lead to Pr_ij = Inf):
@ -221,8 +220,7 @@ void HighPressureGasTransport::getMultiDiffCoeffs(const size_t ld, doublereal* c
throw CanteraError("HighPressureTransport::getMultiDiffCoeffs()",
"ld is too small");
}
for (size_t i = 0; i < m_nsp; i++)
{
for (size_t i = 0; i < m_nsp; i++) {
for (size_t j = 0; j < m_nsp; j++) {
// Add an offset to avoid a condition where x_i and x_j both equal
// zero (this would lead to Pr_ij = Inf):

View file

@ -474,16 +474,18 @@ void LTI_Pairwise_Interaction::getMatrixTransProp(DenseMatrix& mat, doublereal*
m_thermo->getMoleFractions(&molefracs[0]);
mat.resize(nsp, nsp, 0.0);
for (size_t i = 0; i < nsp; i++)
for (size_t i = 0; i < nsp; i++) {
for (size_t j = 0; j < i; j++) {
mat(i,j) = mat(j,i) = exp(m_Eij(i,j) / temp) / m_Dij(i,j);
}
}
for (size_t i = 0; i < nsp; i++)
for (size_t i = 0; i < nsp; i++) {
if (mat(i,i) == 0.0 && m_diagonals[i]) {
mat(i,i) = 1.0 / m_diagonals[i]->getSpeciesTransProp() ;
}
}
}
void LTI_StefanMaxwell_PPN::setParameters(LiquidTransportParams& trParam)
{
@ -660,11 +662,12 @@ void LTI_StokesEinstein::getMatrixTransProp(DenseMatrix& mat, doublereal* specie
}
mat.resize(nsp,nsp, 0.0);
for (size_t i = 0; i < nsp; i++)
for (size_t i = 0; i < nsp; i++) {
for (size_t j = 0; j < nsp; j++) {
mat(i,j) = (6.0 * Pi * radiusSpec[i] * viscSpec[j]) / GasConstant / temp;
}
}
}
doublereal LTI_MoleFracs_ExpT::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight)
{

View file

@ -510,9 +510,10 @@ void LiquidTransport::getThermalDiffCoeffs(doublereal* const dt)
void LiquidTransport::getBinaryDiffCoeffs(size_t ld, doublereal* d)
{
if (ld != m_nsp)
if (ld != m_nsp) {
throw CanteraError("LiquidTransport::getBinaryDiffCoeffs",
"First argument does not correspond to number of species in model.\nDiff Coeff matrix may be misdimensioned");
}
update_T();
// if necessary, evaluate the binary diffusion coefficients
// from the polynomial fits
@ -902,13 +903,14 @@ void LiquidTransport::update_Grad_lnAC()
grad_T = m_Grad_T[k];
size_t start = m_nsp*k;
m_thermo->getdlnActCoeffds(grad_T, &m_Grad_X[start], &m_Grad_lnAC[start]);
for (size_t i = 0; i < m_nsp; i++)
for (size_t i = 0; i < m_nsp; i++) {
if (m_molefracs[i] < 1.e-15) {
m_Grad_lnAC[start+i] = 0;
} else {
m_Grad_lnAC[start+i] += m_Grad_X[start+i]/m_molefracs[i];
}
}
}
return;
}
@ -997,17 +999,18 @@ void LiquidTransport::stefan_maxwell_solve()
} else if (m_velocityBasis == VB_MASSAVG) {
m_A(0,j) = m_massfracs_tran[j];
} else if ((m_velocityBasis >= 0)
&& (m_velocityBasis < static_cast<int>(m_nsp)))
&& (m_velocityBasis < static_cast<int>(m_nsp))) {
// use species number m_velocityBasis as reference velocity
if (m_velocityBasis == static_cast<int>(j)) {
m_A(0,j) = 1.0;
} else {
m_A(0,j) = 0.0;
}
else
} else {
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
"Unknown reference velocity provided.");
}
}
for (size_t i = 1; i < m_nsp; i++) {
m_B(i,0) = m_Grad_mu[i] * invRT;
m_A(i,i) = 0.0;
@ -1037,17 +1040,18 @@ void LiquidTransport::stefan_maxwell_solve()
} else if (m_velocityBasis == VB_MASSAVG) {
m_A(0,j) = m_massfracs_tran[j];
} else if ((m_velocityBasis >= 0)
&& (m_velocityBasis < static_cast<int>(m_nsp)))
&& (m_velocityBasis < static_cast<int>(m_nsp))) {
// use species number m_velocityBasis as reference velocity
if (m_velocityBasis == static_cast<int>(j)) {
m_A(0,j) = 1.0;
} else {
m_A(0,j) = 0.0;
}
else
} else {
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
"Unknown reference velocity provided.");
}
}
for (size_t i = 1; i < m_nsp; i++) {
m_B(i,0) = m_Grad_mu[i] * invRT;
m_B(i,1) = m_Grad_mu[m_nsp + i] * invRT;
@ -1075,17 +1079,18 @@ void LiquidTransport::stefan_maxwell_solve()
} else if (m_velocityBasis == VB_MASSAVG) {
m_A(0,j) = m_massfracs_tran[j];
} else if ((m_velocityBasis >= 0)
&& (m_velocityBasis < static_cast<int>(m_nsp)))
&& (m_velocityBasis < static_cast<int>(m_nsp))) {
// use species number m_velocityBasis as reference velocity
if (m_velocityBasis == static_cast<int>(j)) {
m_A(0,j) = 1.0;
} else {
m_A(0,j) = 0.0;
}
else
} else {
throw CanteraError("LiquidTransport::stefan_maxwell_solve",
"Unknown reference velocity provided.");
}
}
for (size_t i = 1; i < m_nsp; i++) {
m_B(i,0) = m_Grad_mu[i] * invRT;
m_B(i,1) = m_Grad_mu[m_nsp + i] * invRT;

View file

@ -655,20 +655,22 @@ void MultiTransport::eval_L0001()
void MultiTransport::eval_L0100()
{
size_t n2 = 2*m_nsp;
for (size_t j = 0; j < m_nsp; j++)
for (size_t j = 0; j < m_nsp; j++) {
for (size_t i = 0; i < m_nsp; i++) {
m_Lmatrix(i+n2,j) = 0.0; // see Eq. (12.123)
}
}
}
void MultiTransport::eval_L0110()
{
size_t n2 = 2*m_nsp;
for (size_t j = 0; j < m_nsp; j++)
for (size_t j = 0; j < m_nsp; j++) {
for (size_t i = 0; i < m_nsp; i++) {
m_Lmatrix(i+n2,j+m_nsp) = m_Lmatrix(j+m_nsp,i+n2); // see Eq. (12.123)
}
}
}
void MultiTransport::eval_L0101(const doublereal* x)
{

View file

@ -104,10 +104,11 @@ void Transport::finalize()
{
if (!ready()) {
m_ready = true;
} else
} else {
throw CanteraError("Transport::finalize",
"finalize has already been called.");
}
}
void Transport::getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
size_t ldx, const doublereal* const grad_X,

View file

@ -75,10 +75,11 @@ void Reactor::initialize(doublereal t0)
m_sdot.resize(m_nsp, 0.0);
m_wdot.resize(m_nsp, 0.0);
m_nv = m_nsp + 3;
for (size_t w = 0; w < m_wall.size(); w++)
for (size_t w = 0; w < m_wall.size(); w++) {
if (m_wall[w]->surface(m_lr[w])) {
m_nv += m_wall[w]->surface(m_lr[w])->nSpecies();
}
}
m_enthalpy = m_thermo->enthalpy_mass();
m_pressure = m_thermo->pressure();
@ -323,9 +324,10 @@ double Reactor::evalSurfaces(double t, double* ydot)
void Reactor::addSensitivityReaction(size_t rxn)
{
if (rxn >= m_kin->nReactions())
if (rxn >= m_kin->nReactions()) {
throw CanteraError("Reactor::addSensitivityReaction",
"Reaction number out of range ("+int2str(rxn)+")");
}
network().registerSensitivityReaction(this, rxn,
name()+": "+m_kin->reactionString(rxn));

View file

@ -43,9 +43,10 @@ void ReactorNet::initialize()
char buf[100];
m_nv = 0;
writelog("Initializing reactor network.\n", m_verbose);
if (m_reactors.empty())
if (m_reactors.empty()) {
throw CanteraError("ReactorNet::initialize",
"no reactors in network!");
}
size_t sensParamNumber = 0;
m_start.assign(1, 0);
for (n = 0; n < m_reactors.size(); n++) {

View file

@ -141,9 +141,10 @@ void Wall::syncCoverages(int leftright)
void Wall::addSensitivityReaction(int leftright, size_t rxn)
{
if (rxn >= m_chem[leftright]->nReactions())
if (rxn >= m_chem[leftright]->nReactions()) {
throw CanteraError("Wall::addSensitivityReaction",
"Reaction number out of range ("+int2str(rxn)+")");
}
if (leftright == 0) {
m_left->network().registerSensitivityReaction(this, rxn,
m_chem[0]->reactionString(rxn), leftright);

View file

@ -30,10 +30,10 @@ int main()
cout << gas.speciesName(k) << " " << wdot[k] << endl;
}
for (size_t k = 0; k < surf.nSpecies(); k++)
for (size_t k = 0; k < surf.nSpecies(); k++) {
cout << surf.speciesName(k) << " "
<< wdot[k+gas.nSpecies()] << endl;
}
} catch (CanteraError& err) {
std::cout << err.what() << std::endl;
}