Skip to content

Commit

Permalink
[YAML] Add deprecated field to YAML files and phases
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanwweber committed Dec 18, 2019
1 parent d1e6511 commit 546223a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/argon.yaml
Expand Up @@ -2,6 +2,9 @@ description: >-
Pure argon phase. Thermo and transport properties are taken
from GRI-Mech 3.0.
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 had by loading air.yaml.
phases:
- name: argon
Expand All @@ -12,6 +15,8 @@ phases:
state:
T: 300.0
P: 1.01325e+05
kinetics: gas
reactions: none

species:
- name: AR
Expand Down
28 changes: 28 additions & 0 deletions data/gri30.yaml
Expand Up @@ -19,6 +19,34 @@ 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. Please see the webpage at https://github.com/Cantera/cantera/wiki/deprecate_gri30_phases
- 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. Please see the webpage at https://github.com/Cantera/cantera/wiki/deprecate_gri30_phases
species:
- name: H2
Expand Down
6 changes: 6 additions & 0 deletions src/base/AnyMap.cpp
Expand Up @@ -867,6 +867,12 @@ AnyMap AnyMap::fromYamlFile(const std::string& name,
}
cache_item.first["__file__"] = fullName;

if (cache_item.first.hasKey("deprecated")){
std::string msg = cache_item.first["deprecated"].asString();
std::string method = fmt::format("YAML file deprecation: '{}'", fullName);
warn_deprecated(method, msg);
}

// Return a copy of the AnyMap
return cache_item.first;
}
Expand Down
6 changes: 6 additions & 0 deletions src/thermo/ThermoFactory.cpp
Expand Up @@ -451,6 +451,12 @@ void setupPhase(ThermoPhase& thermo, AnyMap& phaseNode, const AnyMap& rootNode)
phaseNode["__file__"] = rootNode["__file__"];
}

if (phaseNode.hasKey("deprecated")) {
string msg = phaseNode["deprecated"].asString();
string method = fmt::format("Phase deprecation: '{}'", phaseNode["name"].asString());
warn_deprecated(method, msg);
}

// Add elements
if (phaseNode.hasKey("elements")) {
if (phaseNode.getBool("skip-undeclared-elements", false)) {
Expand Down

0 comments on commit 546223a

Please sign in to comment.