diff --git a/data/argon.yaml b/data/argon.yaml index 985390fb3..5f2e6067c 100644 --- a/data/argon.yaml +++ b/data/argon.yaml @@ -8,6 +8,9 @@ date: Wed, 11 Dec 2019 16:59:05 -0500 input-files: [argon.cti] units: {length: cm, quantity: mol, activation-energy: cal/mol} +deprecated: >- + The file 'argon.yaml' is deprecated and will be removed after Cantera 2.5. + A nearly equivalent phase can be obtained from 'air.yaml'. phases: - name: argon diff --git a/data/gri30.yaml b/data/gri30.yaml index 8b23a0f79..513457137 100644 --- a/data/gri30.yaml +++ b/data/gri30.yaml @@ -26,6 +26,45 @@ phases: kinetics: gas transport: mixture-averaged state: {T: 300.0, P: 1 atm} +- name: gri30_mix + thermo: ideal-gas + elements: [O, H, C, N, Ar] + species: [H2, H, O, O2, OH, H2O, HO2, H2O2, C, CH, CH2, CH2(S), CH3, CH4, + CO, CO2, HCO, CH2O, CH2OH, CH3O, CH3OH, C2H, C2H2, C2H3, C2H4, C2H5, + C2H6, HCCO, CH2CO, HCCOH, N, NH, NH2, NH3, NNH, NO, NO2, N2O, HNO, CN, + HCN, H2CN, HCNN, HCNO, HOCN, HNCO, NCO, N2, AR, C3H7, C3H8, CH2CHO, + CH3CHO] + kinetics: gas + transport: mixture-averaged + state: {T: 300.0, P: 1 atm} + deprecated: >- + The phase 'gri30_mix' in the file 'gri30.yaml' is deprecated and will be + removed after Cantera 2.5. The default phase 'gri30' now includes + mixture-averaged transport properties by default and should be preferred. + Please see the webpage at + https://github.com/Cantera/cantera/wiki/deprecate_gri30_phases for more + information. +- name: gri30_multi + thermo: ideal-gas + elements: [O, H, C, N, Ar] + species: [H2, H, O, O2, OH, H2O, HO2, H2O2, C, CH, CH2, CH2(S), CH3, CH4, + CO, CO2, HCO, CH2O, CH2OH, CH3O, CH3OH, C2H, C2H2, C2H3, C2H4, C2H5, + C2H6, HCCO, CH2CO, HCCOH, N, NH, NH2, NH3, NNH, NO, NO2, N2O, HNO, CN, + HCN, H2CN, HCNN, HCNO, HOCN, HNCO, NCO, N2, AR, C3H7, C3H8, CH2CHO, + CH3CHO] + kinetics: gas + transport: multicomponent + state: {T: 300.0, P: 1 atm} + deprecated: >- + The phase 'gri30_multi' in the file 'gri30.yaml' is deprecated and will be + removed after Cantera 2.5. You can use multi-component diffusion by including + an optional argument to 'Solution': + Python: ct.Solution('gri30.yaml', transport_model='Multi') + MATLAB: Solution('gri30.yaml','gri30','Multi') + C++: newSolution("gri30.yaml", "gri30", "Multi") + Please see the webpage at + https://github.com/Cantera/cantera/wiki/deprecate_gri30_phases for more + information. species: - name: H2 diff --git a/data/gri30_highT.yaml b/data/gri30_highT.yaml index ab67c427c..e76962faf 100644 --- a/data/gri30_highT.yaml +++ b/data/gri30_highT.yaml @@ -29,6 +29,7 @@ phases: CH3CHO] kinetics: gas reactions: all + transport: mixture-averaged state: T: 300.0 P: 1.01325e+05 @@ -46,6 +47,13 @@ phases: state: T: 300.0 P: 1.01325e+05 + deprecated: >- + The phase 'gri30_mix' in the file 'gri30_highT.yaml' is deprecated and will be + removed after Cantera 2.5. The default phase 'gri30' now includes + mixture-averaged transport properties by default and should be preferred. + Please see the webpage at + https://github.com/Cantera/cantera/wiki/deprecate_gri30_phases for more + information. - name: gri30_multi thermo: ideal-gas elements: [O, H, C, N, Ar] @@ -60,6 +68,16 @@ phases: state: T: 300.0 P: 1.01325e+05 + deprecated: >- + The phase 'gri30_multi' in the file 'gri30_highT.yaml' is deprecated and will be + removed after Cantera 2.5. You can use multi-component diffusion by including + an optional argument to 'Solution': + Python: ct.Solution('gri30.yaml', transport_model='Multi') + MATLAB: Solution('gri30.yaml','gri30','Multi') + C++: newSolution("gri30.yaml", "gri30", "Multi") + Please see the webpage at + https://github.com/Cantera/cantera/wiki/deprecate_gri30_phases for more + information. species: - name: H2 diff --git a/src/base/AnyMap.cpp b/src/base/AnyMap.cpp index ec79ee0dd..2c1d435ee 100644 --- a/src/base/AnyMap.cpp +++ b/src/base/AnyMap.cpp @@ -867,6 +867,10 @@ AnyMap AnyMap::fromYamlFile(const std::string& name, } cache_item.first["__file__"] = fullName; + if (cache_item.first.hasKey("deprecated")) { + warn_deprecated(fullName, cache_item.first["deprecated"].asString()); + } + // Return a copy of the AnyMap return cache_item.first; } diff --git a/src/thermo/ThermoFactory.cpp b/src/thermo/ThermoFactory.cpp index 6eb1233ce..27818f15f 100644 --- a/src/thermo/ThermoFactory.cpp +++ b/src/thermo/ThermoFactory.cpp @@ -451,6 +451,13 @@ void setupPhase(ThermoPhase& thermo, AnyMap& phaseNode, const AnyMap& rootNode) phaseNode["__file__"] = rootNode["__file__"]; } + if (phaseNode.hasKey("deprecated")) { + string msg = phaseNode["deprecated"].asString(); + string filename = phaseNode.getString("__file__", "unknown file"); + string method = fmt::format("{}/{}", filename, phaseNode["name"].asString()); + warn_deprecated(method, msg); + } + // Add elements if (phaseNode.hasKey("elements")) { if (phaseNode.getBool("skip-undeclared-elements", false)) { diff --git a/test/general/test_containers.cpp b/test/general/test_containers.cpp index 0591f50e2..d7a3ea300 100644 --- a/test/general/test_containers.cpp +++ b/test/general/test_containers.cpp @@ -205,3 +205,11 @@ TEST(AnyMap, loadYaml) EXPECT_EQ(coeffs[0].size(), (size_t) 7); EXPECT_DOUBLE_EQ(coeffs[1][2], -8.280690600E-07); } + +TEST(AnyMap, loadDeprecatedYaml) +{ + // The deprecation warning in this file is turned into an + // error by make_deprecation_warnings_fatal() called in main() + // for the test suite. + EXPECT_THROW(AnyMap::fromYamlFile("argon.yaml"), CanteraError); +} diff --git a/test/thermo/thermoFromYaml.cpp b/test/thermo/thermoFromYaml.cpp index 4a84b8e04..71a2366e0 100644 --- a/test/thermo/thermoFromYaml.cpp +++ b/test/thermo/thermoFromYaml.cpp @@ -387,3 +387,11 @@ TEST(ThermoFromYaml, BinarySolutionTabulatedThermo) thermo->setMoleFractionsByName("Li[anode]: 0.55, V[anode]: 0.45"); EXPECT_NEAR(thermo->gibbs_mass(), -87066.246182649265, 1e-9); } + +TEST(ThermoFromYaml, DeprecatedPhase) +{ + // The deprecation warning in this file is turned into an + // error by make_deprecation_warnings_fatal() called in main() + // for the test suite. + EXPECT_THROW(newThermo("gri30.yaml", "gri30_mix"), CanteraError); +}