Skip to content

Commit

Permalink
[1D] Throw an exception if transport state is inconsistent
Browse files Browse the repository at this point in the history
The user can enable Soret (thermal) diffusion or multicomponent
transport in either order, but attempts to solve flame problems with
Soret enabled and the mixture-averaged transport approximation will
result in an error
  • Loading branch information
bryanwweber committed Mar 13, 2018
1 parent c9b0bce commit a03afbd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
7 changes: 6 additions & 1 deletion include/cantera/oneD/StFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ class StFlow : public Domain1D
//! set the transport manager
void setTransport(Transport& trans);

void enableSoret(bool withSoret);
//! Enable thermal diffusion, also known as Soret diffusion.
//! Requires that multicomponent transport properties be
//! enabled to carry out calculations.
void enableSoret(bool withSoret) {
m_do_soret = withSoret;
}
bool withSoret() const {
return m_do_soret;
}
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/_cantera.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ cdef extern from "cantera/oneD/Sim1D.h":
void setMaxGridPoints(int, size_t) except +translate_exception
size_t maxGridPoints(size_t) except +translate_exception
void setGridMin(int, double) except +translate_exception
void setFixedTemperature(double)
void setFixedTemperature(double) except +translate_exception
void setInterrupt(CxxFunc1*) except +translate_exception
void setTimeStepCallback(CxxFunc1*)
void setSteadyCallback(CxxFunc1*)
Expand Down
19 changes: 7 additions & 12 deletions src/oneD/StFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void StFlow::setupGrid(size_t n, const doublereal* z)
}
}

void StFlow::resetBadValues(double* xg)
void StFlow::resetBadValues(double* xg)
{
double* x = xg + loc();
for (size_t j = 0; j < m_points; j++) {
Expand All @@ -154,17 +154,6 @@ void StFlow::setTransport(Transport& trans)
}
}

void StFlow::enableSoret(bool withSoret)
{
if (m_do_multicomponent) {
m_do_soret = withSoret;
} else {
throw CanteraError("setTransport",
"Thermal diffusion (the Soret effect) "
"requires using a multicomponent transport model.");
}
}

void StFlow::_getInitialSoln(double* x)
{
for (size_t j = 0; j < m_points; j++) {
Expand Down Expand Up @@ -195,6 +184,12 @@ void StFlow::setGasAtMidpoint(const doublereal* x, size_t j)

void StFlow::_finalize(const doublereal* x)
{
if (!m_do_multicomponent && m_do_soret) {
throw CanteraError("_finalize",
"Thermal diffusion (the Soret effect) is enabled, and requires "
"using a multicomponent transport model.");
}

size_t nz = m_zfix.size();
bool e = m_do_energy[0];
for (size_t j = 0; j < m_points; j++) {
Expand Down

0 comments on commit a03afbd

Please sign in to comment.