Skip to content

Commit

Permalink
Merge pull request #182 from pbauman/arrhenius-kineticsconditions-che…
Browse files Browse the repository at this point in the history
…rrypick

Cherrypicking of #136
  • Loading branch information
pbauman committed Feb 5, 2016
2 parents ed0d492 + 9b245dd commit b98de9d
Show file tree
Hide file tree
Showing 17 changed files with 1,400 additions and 602 deletions.
36 changes: 36 additions & 0 deletions src/kinetics/include/antioch/arrhenius_rate.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,30 @@ namespace Antioch
template <typename StateType>
void rate_and_derivative(const StateType& T, StateType& rate, StateType& drate_dT) const;

// KineticsConditions overloads

//! \return the rate evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
rate(const KineticsConditions<StateType,VectorStateType>& T) const
ANTIOCH_AUTOFUNC(StateType, _Cf * ant_exp(- _Ea/T.T()))

//! \return the rate evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
operator()(const KineticsConditions<StateType,VectorStateType>& T) const
ANTIOCH_AUTOFUNC(StateType, this->rate(T))

//! \return the derivative with respect to temperature evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
derivative( const KineticsConditions<StateType,VectorStateType>& T ) const
ANTIOCH_AUTOFUNC(StateType, (*this)(T) * (_Ea/T.temp_cache().T2) )

//! Simultaneously evaluate the rate and its derivative at \p T.
template <typename StateType,typename VectorStateType>
void rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& T, StateType& rate, StateType& drate_dT) const;

//! print equation
const std::string numeric() const;

Expand Down Expand Up @@ -307,6 +331,18 @@ namespace Antioch
return;
}

template<typename CoeffType>
template <typename StateType,typename VectorStateType>
inline
void ArrheniusRate<CoeffType>::rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& T,
StateType& rate,
StateType& drate_dT) const
{
rate = (*this)(T);
drate_dT = rate * _Ea/(T.temp_cache().T2);
return;
}

} // end namespace Antioch

#endif // ANTIOCH_ARRHENIUS_RATE_H
35 changes: 35 additions & 0 deletions src/kinetics/include/antioch/berthelot_rate.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,30 @@ namespace Antioch
template <typename StateType>
void rate_and_derivative(const StateType& T, StateType& rate, StateType& drate_dT) const;

// KineticsConditions overloads

//! \return the rate evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
rate(const KineticsConditions<StateType,VectorStateType>& T) const
ANTIOCH_AUTOFUNC(StateType, _Cf * ant_exp(_D * T.T()) )

//! \return the rate evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
operator()(const KineticsConditions<StateType,VectorStateType>& T) const
ANTIOCH_AUTOFUNC(StateType, this->rate(T))

//! \return the derivative with respect to temperature evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
derivative( const KineticsConditions<StateType,VectorStateType>& T ) const
ANTIOCH_AUTOFUNC(StateType, (*this)(T) * _D )

//! Simultaneously evaluate the rate and its derivative at \p T.
template <typename StateType,typename VectorStateType>
void rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& T, StateType& rate, StateType& drate_dT) const;

//! print equation
const std::string numeric() const;
};
Expand Down Expand Up @@ -249,6 +273,17 @@ namespace Antioch
return;
}

template<typename CoeffType>
template <typename StateType,typename VectorStateType>
inline
void BerthelotRate<CoeffType>::rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& T,
StateType& rate, StateType& drate_dT) const
{
rate = (*this)(T);
drate_dT = rate*_D;
return;
}

} // end namespace Antioch

#endif // ANTIOCH_BERTHELOT_RATE_H
35 changes: 35 additions & 0 deletions src/kinetics/include/antioch/constant_rate.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,29 @@ namespace Antioch
template <typename StateType>
void rate_and_derivative(const StateType& T, StateType& rate, StateType& drate_dT) const;

// KineticsConditions overloads
//! \return the rate evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
rate(const KineticsConditions<StateType,VectorStateType>& cond) const
ANTIOCH_AUTOFUNC(StateType, constant_clone(cond.T(),_Cf))

//! \return the rate evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
operator()(const KineticsConditions<StateType,VectorStateType>& cond) const
ANTIOCH_AUTOFUNC(StateType, this->rate(cond))

//! \return the derivative with respect to temperature evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
derivative( const KineticsConditions<StateType,VectorStateType>& cond ) const
ANTIOCH_AUTOFUNC(StateType, zero_clone(cond.T()))

//! Simultaneously evaluate the rate and its derivative at \p T.
template <typename StateType, typename VectorStateType>
void rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& cond, StateType& rate, StateType& drate_dT) const;

//! print equation
const std::string numeric() const;

Expand Down Expand Up @@ -193,6 +216,18 @@ namespace Antioch
return;
}

template<typename CoeffType>
template<typename StateType, typename VectorStateType>
inline
void ConstantRate<CoeffType>::rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& /*cond*/,
StateType& rate,
StateType& drate_dT) const
{
Antioch::constant_fill(rate, _Cf);
Antioch::set_zero(drate_dT);
return;
}

} // end namespace Antioch

#endif // ANTIOCH_HERCOURT_ESSEN_RATE_H
36 changes: 36 additions & 0 deletions src/kinetics/include/antioch/hercourtessen_rate.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@ namespace Antioch
template <typename StateType>
void rate_and_derivative(const StateType& T, StateType& rate, StateType& drate_dT) const;

// KineticsConditions overloads

//! \return the rate evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
rate(const KineticsConditions<StateType,VectorStateType>& T) const
ANTIOCH_AUTOFUNC(StateType, _Cf * ant_exp(_eta * T.temp_cache().lnT))

//! \return the rate evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
operator()(const KineticsConditions<StateType,VectorStateType>& T) const
ANTIOCH_AUTOFUNC(StateType, this->rate(T))

//! \return the derivative with respect to temperature evaluated at \p T.
template <typename StateType, typename VectorStateType>
ANTIOCH_AUTO(StateType)
derivative( const KineticsConditions<StateType,VectorStateType>& T ) const
ANTIOCH_AUTOFUNC(StateType, (*this)(T)/T.T()*(_eta))

//! Simultaneously evaluate the rate and its derivative at \p T.
template <typename StateType,typename VectorStateType>
void rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& T, StateType& rate, StateType& drate_dT) const;

//! print equation
const std::string numeric() const;

Expand Down Expand Up @@ -298,6 +322,18 @@ namespace Antioch
return;
}

template<typename CoeffType>
template <typename StateType,typename VectorStateType>
inline
void HercourtEssenRate<CoeffType>::rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& cond,
StateType& rate,
StateType& drate_dT) const
{
rate = (*this)(cond);
drate_dT = rate/cond.T() * _eta;
return;
}

} // end namespace Antioch

#endif // ANTIOCH_HERCOURT_ESSEN_RATE_H
24 changes: 12 additions & 12 deletions src/kinetics/include/antioch/kinetics_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,25 +184,25 @@ namespace Antioch{
{
case(KineticsModel::CONSTANT):
{
return (static_cast<const ConstantRate<CoeffType>*>(this))->rate(conditions.T());
return (static_cast<const ConstantRate<CoeffType>*>(this))->rate(conditions);
}
break;

case(KineticsModel::HERCOURT_ESSEN):
{
return (static_cast<const HercourtEssenRate<CoeffType>*>(this))->rate(conditions.T());
return (static_cast<const HercourtEssenRate<CoeffType>*>(this))->rate(conditions);
}
break;

case(KineticsModel::BERTHELOT):
{
return (static_cast<const BerthelotRate<CoeffType>*>(this))->rate(conditions.T());
return (static_cast<const BerthelotRate<CoeffType>*>(this))->rate(conditions);
}
break;

case(KineticsModel::ARRHENIUS):
{
return (static_cast<const ArrheniusRate<CoeffType>*>(this))->rate(conditions.T());
return (static_cast<const ArrheniusRate<CoeffType>*>(this))->rate(conditions);
}
break;

Expand Down Expand Up @@ -261,25 +261,25 @@ namespace Antioch{
{
case(KineticsModel::CONSTANT):
{
return (static_cast<const ConstantRate<CoeffType>*>(this))->derivative(conditions.T());
return (static_cast<const ConstantRate<CoeffType>*>(this))->derivative(conditions);
}
break;

case(KineticsModel::HERCOURT_ESSEN):
{
return (static_cast<const HercourtEssenRate<CoeffType>*>(this))->derivative(conditions.T());
return (static_cast<const HercourtEssenRate<CoeffType>*>(this))->derivative(conditions);
}
break;

case(KineticsModel::BERTHELOT):
{
return (static_cast<const BerthelotRate<CoeffType>*>(this))->derivative(conditions.T());
return (static_cast<const BerthelotRate<CoeffType>*>(this))->derivative(conditions);
}
break;

case(KineticsModel::ARRHENIUS):
{
return (static_cast<const ArrheniusRate<CoeffType>*>(this))->derivative(conditions.T());
return (static_cast<const ArrheniusRate<CoeffType>*>(this))->derivative(conditions);
}
break;

Expand Down Expand Up @@ -339,25 +339,25 @@ namespace Antioch{
{
case(KineticsModel::CONSTANT):
{
(static_cast<const ConstantRate<CoeffType>*>(this))->rate_and_derivative(conditions.T(),rate,drate_dT);
(static_cast<const ConstantRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
}
break;

case(KineticsModel::HERCOURT_ESSEN):
{
(static_cast<const HercourtEssenRate<CoeffType>*>(this))->rate_and_derivative(conditions.T(),rate,drate_dT);
(static_cast<const HercourtEssenRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
}
break;

case(KineticsModel::BERTHELOT):
{
(static_cast<const BerthelotRate<CoeffType>*>(this))->rate_and_derivative(conditions.T(),rate,drate_dT);
(static_cast<const BerthelotRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
}
break;

case(KineticsModel::ARRHENIUS):
{
(static_cast<const ArrheniusRate<CoeffType>*>(this))->rate_and_derivative(conditions.T(),rate,drate_dT);
(static_cast<const ArrheniusRate<CoeffType>*>(this))->rate_and_derivative(conditions,rate,drate_dT);
}
break;

Expand Down
Loading

0 comments on commit b98de9d

Please sign in to comment.