Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate obsolete methods #1295

Merged
merged 6 commits into from May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Expand Up @@ -282,13 +282,14 @@ jobs:
- name: Install Apt dependencies
run: |
sudo apt update
sudo apt install libboost-dev gfortran graphviz liblapack-dev libblas-dev
sudo apt install libboost-dev gfortran graphviz liblapack-dev libblas-dev gcc-5 g++-5
- name: Upgrade pip
run: python3 -m pip install -U pip setuptools wheel
- name: Install Python dependencies
run: python3 -m pip install ruamel.yaml scons numpy cython h5py pandas matplotlib scipy
- name: Build Cantera
run: python3 `which scons` build -j2 debug=n
# compile with GCC 5.5.0 on ubuntu-18.04
run: python3 `which scons` build -j2 debug=n CC=gcc-5 CXX=g++-5
- name: Run the examples
# See https://unix.stackexchange.com/a/392973 for an explanation of the -exec part
run: |
Expand Down
8 changes: 6 additions & 2 deletions include/cantera/kinetics/ChebyshevRate.h
Expand Up @@ -124,11 +124,15 @@ class ChebyshevRate final : public ReactionRate
* @param units Unit definitions specific to rate information
*/
void setParameters(const AnyMap& node, const UnitStack& units);

void getParameters(AnyMap& rateNode) const;

//! @deprecated To be removed after Cantera 3.0.
void getParameters(AnyMap& rateNode, const Units& rate_units) const {
// @todo: deprecate, as second argument is no longer needed
warn_deprecated("ChebyshevRate:getParameters",
"To be removed after Cantera 3.0. Second argument is no longer needed.");
return getParameters(rateNode);
}
void getParameters(AnyMap& rateNode) const;

virtual void validate(const std::string& equation, const Kinetics& kin);

Expand Down
19 changes: 12 additions & 7 deletions include/cantera/kinetics/Falloff.h
Expand Up @@ -98,7 +98,7 @@ class FalloffRate : public ReactionRate
* @param c Vector of coefficients of the parameterization. The number and
* meaning of these coefficients is subclass-dependent.
*
* @todo deprecate; superseded by setFalloffCoeffs
* @deprecated To be removed after Cantera 3.0; superseded by setFalloffCoeffs()
*/
void init(const vector_fp& c);

Expand Down Expand Up @@ -161,9 +161,11 @@ class FalloffRate : public ReactionRate

//! The size of the work array required.
/**
* @todo deprecate; only used by legacy framework
* @deprecated To be removed after Cantera 3.0; unused.
*/
virtual size_t workSize() const {
warn_deprecated("FalloffRate::workSize",
"To be removed after Cantera 3.0; unused.");
return 0;
}

Expand All @@ -182,9 +184,12 @@ class FalloffRate : public ReactionRate
//! Get the values of the parameters for this object. *params* must be an
//! array of at least nParameters() elements.
/**
* @todo deprecate; superseded by getFalloffCoeffs
* @deprecated To be removed after Cantera 3.0; superseded by getFalloffCoeffs()
*/
virtual void getParameters(double* params) const {}
virtual void getParameters(double* params) const {
warn_deprecated("FalloffRate::getParameters",
"To be removed after Cantera 3.0; superseded by getFalloffCoeffs.");
}

virtual void getParameters(AnyMap& node) const;

Expand Down Expand Up @@ -392,7 +397,7 @@ class TroeRate final : public FalloffRate

//! Sets params to contain, in order, \f[ (A, T_3, T_1, T_2) \f]
/**
* @todo deprecate; superseded by getFalloffCoeffs
* @deprecated To be removed after Cantera 3.0; superseded by getFalloffCoeffs()
*/
virtual void getParameters(double* params) const;

Expand Down Expand Up @@ -495,7 +500,7 @@ class SriRate final : public FalloffRate

//! Sets params to contain, in order, \f[ (a, b, c, d, e) \f]
/**
* @todo deprecate; superseded by getFalloffCoeffs
* @deprecated To be removed after Cantera 3.0; superseded by getFalloffCoeffs()
*/
virtual void getParameters(double* params) const;

Expand Down Expand Up @@ -604,7 +609,7 @@ class TsangRate final : public FalloffRate

//! Sets params to contain, in order, \f[ (A, B) \f]
/**
* @todo deprecate; superseded by getFalloffCoeffs
* @deprecated To be removed after Cantera 3.0; superseded by getFalloffCoeffs()
*/
virtual void getParameters(double* params) const;

Expand Down
2 changes: 1 addition & 1 deletion include/cantera/kinetics/InterfaceRate.h
Expand Up @@ -110,7 +110,7 @@ class InterfaceRateBase
//! Store parameters needed to reconstruct coverage dependencies
//! @param dependencies AnyMap receiving coverage information
//! @param asVector Optional boolean flag to override map output
//! @todo Remove vector version (which currently only serves testing purposes)
//! @deprecated After Cantera 3.0, the optional asVector argument will be removed.
void getCoverageDependencies(AnyMap& dependencies, bool asVector=false) const;

//! Add a coverage dependency for species *sp*, with exponential dependence
Expand Down
6 changes: 3 additions & 3 deletions include/cantera/kinetics/PlogRate.h
Expand Up @@ -171,10 +171,10 @@ class PlogRate final : public ReactionRate
//! temperatures at each interpolation pressure. This is potentially an
//! issue when one of the Arrhenius expressions at a particular pressure
//! has a negative pre-exponential factor.
void validate(const std::string& equation, const Kinetics& kin) {
validate(equation);
}
void validate(const std::string& equation, const Kinetics& kin);

//! @deprecated To be removed after Cantera 3.0;
//! superseded by two-parameter version
void validate(const std::string& equation);

//! Return the pressures and Arrhenius expressions which comprise this
Expand Down
15 changes: 12 additions & 3 deletions include/cantera/kinetics/Reaction.h
Expand Up @@ -72,9 +72,18 @@ class Reaction
return calculateRateCoeffUnits(kin);
}

//! Ensure that the rate constant and other parameters for this reaction are
//! valid.
virtual void validate();
//! Ensure that the rate constant and other parameters for this reaction are valid.
//! @since New in Cantera 3.0.
virtual void check();

//! Ensure that the rate constant and other parameters for this reaction are valid.
//! @deprecated To be removed after Cantera 3.0. Replaceable by check.
virtual void validate() {
warn_deprecated("Reaction::validate",
"Deprecated in Cantera 3.0 and to be removed thereafter; replaceable "
"by Reaction::check.");
check();
}

//! Perform validation checks that need access to a complete Kinetics objects, for
// example to retrieve information about reactant / product species.
Expand Down
9 changes: 7 additions & 2 deletions include/cantera/kinetics/ReactionRate.h
Expand Up @@ -11,6 +11,7 @@
#include "MultiRateBase.h"
#include "cantera/base/AnyMap.h"
#include "cantera/base/Units.h"
#include "cantera/base/global.h"
#include "cantera/base/ctexceptions.h"

namespace Cantera
Expand Down Expand Up @@ -105,8 +106,12 @@ class ReactionRate
virtual void validate(const std::string& equation, const Kinetics& kin) {}

//! Validate the reaction rate expression (legacy call)
//! @todo deprecate in favor of two-parameter version
virtual void validate(const std::string& equation) {}
//! @deprecated To be removed after Cantera 3.0.
//! Superseded by two-parameter version
virtual void validate(const std::string& equation) {
warn_deprecated("ReactionRate::validate",
"To be removed after Cantera 3.0; superseded by two-parameter version.");
}

//! Reaction rate index within kinetics evaluator
size_t rateIndex() const {
Expand Down
1 change: 0 additions & 1 deletion interfaces/cython/cantera/_cantera.pxd
Expand Up @@ -602,7 +602,6 @@ cdef extern from "cantera/kinetics/Reaction.h" namespace "Cantera":
string equation()
void setEquation(const string&) except +translate_exception
string type()
void validate() except +translate_exception
CxxAnyMap parameters(cbool) except +translate_exception
CxxAnyMap input
Composition reactants
Expand Down
15 changes: 0 additions & 15 deletions platform/posix/SConscript
Expand Up @@ -11,21 +11,6 @@ if env['INSTALL_MANPAGES']:

### Generate customized scripts ###

# 'setup_cantera'
if localenv['layout'] != 'debian' and env['OS'] != 'Windows':

def copy_var(target, source, env):
if env['python_prefix'] == 'USER':
env['python_module_loc_sc'] = ''
else:
env['python_module_loc_sc'] = env['python_module_loc']

for script in ['setup_cantera', 'setup_cantera.csh']:
target = env.SubstFile(script, script + '.in')
localenv.AddPreAction(target, copy_var)
localenv.Depends(target, env['install_python_action'])
install('$inst_bindir', target)

# Cantera.mak include file for Makefile projects
# cantera.pc for use with pkg-config

Expand Down
41 changes: 0 additions & 41 deletions platform/posix/setup_cantera.csh.in

This file was deleted.

48 changes: 0 additions & 48 deletions platform/posix/setup_cantera.in

This file was deleted.

35 changes: 27 additions & 8 deletions src/kinetics/Falloff.cpp
Expand Up @@ -84,6 +84,8 @@ void FalloffData::restore()

void FalloffRate::init(const vector_fp& c)
{
warn_deprecated("FalloffRate::init",
"To be removed after Cantera 3.0; superseded by setFalloffCoeffs.");
setFalloffCoeffs(c);
}

Expand Down Expand Up @@ -244,11 +246,15 @@ void TroeRate::setFalloffCoeffs(const vector_fp& c)

void TroeRate::getFalloffCoeffs(vector_fp& c) const
{
c.resize(4, 0.);
getParameters(c.data());
if (std::abs(c[3]) < SmallNumber) {
if (std::abs(m_t2) < SmallNumber) {
c.resize(3);
} else {
c.resize(4, 0.);
c[3] = m_t2;
}
c[0] = m_a;
c[1] = 1.0 / m_rt3;
c[2] = 1.0 / m_rt1;
}

void TroeRate::updateTemp(double T, double* work) const
Expand Down Expand Up @@ -293,6 +299,8 @@ void TroeRate::setParameters(const AnyMap& node, const UnitStack& rate_units)
}

void TroeRate::getParameters(double* params) const {
warn_deprecated("TroeRate::getParameters",
"To be removed after Cantera 3.0; superseded by getFalloffCoeffs.");
params[0] = m_a;
params[1] = 1.0/m_rt3;
params[2] = 1.0/m_rt1;
Expand Down Expand Up @@ -356,11 +364,16 @@ void SriRate::setFalloffCoeffs(const vector_fp& c)

void SriRate::getFalloffCoeffs(vector_fp& c) const
{
c.resize(5, 0.);
getParameters(c.data());
if (m_e < SmallNumber && std::abs(m_e - 1.) < SmallNumber) {
c.resize(3);
} else {
c.resize(5, 0.);
c[3] = m_d;
c[4] = m_e;
}
c[0] = m_a;
c[1] = m_b;
c[2] = m_c;
}

void SriRate::updateTemp(double T, double* work) const
Expand Down Expand Up @@ -406,6 +419,8 @@ void SriRate::setParameters(const AnyMap& node, const UnitStack& rate_units)

void SriRate::getParameters(double* params) const
{
warn_deprecated("SriRate::getParameters",
"To be removed after Cantera 3.0; superseded by getFalloffCoeffs.");
params[0] = m_a;
params[1] = m_b;
params[2] = m_c;
Expand Down Expand Up @@ -460,11 +475,13 @@ void TsangRate::setFalloffCoeffs(const vector_fp& c)

void TsangRate::getFalloffCoeffs(vector_fp& c) const
{
c.resize(2, 0.);
getParameters(c.data());
if (m_b < SmallNumber) {
if (std::abs(m_b) < SmallNumber) {
c.resize(1);
} else {
c.resize(2, 0.);
c[1] = m_b;
}
c[0] = m_a;
}

void TsangRate::updateTemp(double T, double* work) const
Expand Down Expand Up @@ -502,6 +519,8 @@ void TsangRate::setParameters(const AnyMap& node, const UnitStack& rate_units)
}

void TsangRate::getParameters(double* params) const {
warn_deprecated("TsangRate::getParameters",
"To be removed after Cantera 3.0; superseded by getFalloffCoeffs.");
params[0] = m_a;
params[1] = m_b;
}
Expand Down
2 changes: 2 additions & 0 deletions src/kinetics/InterfaceRate.cpp
Expand Up @@ -168,6 +168,8 @@ void InterfaceRateBase::getCoverageDependencies(AnyMap& dependencies,
for (size_t k = 0; k < m_cov.size(); k++) {
if (asVector) {
// this preserves the previous 'coverage_deps' units
warn_deprecated("InterfaceRateBase::getCoverageDependencies",
"To be changed after Cantera 3.0: second argument will be removed.");
vector_fp dep(3);
dep[0] = m_ac[k];
dep[1] = m_mc[k];
Expand Down
2 changes: 1 addition & 1 deletion src/kinetics/Kinetics.cpp
Expand Up @@ -616,7 +616,7 @@ void Kinetics::resizeSpecies()

bool Kinetics::addReaction(shared_ptr<Reaction> r, bool resize)
{
r->validate();
r->check();
r->validate(*this);

if (m_kk == 0) {
Expand Down