Skip to content

Commit

Permalink
WIP on HMW_NaCl test
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanwweber committed Oct 7, 2019
1 parent 00e1341 commit d012a38
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 12 additions & 3 deletions interfaces/cython/cantera/ctml2yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class Phase:
"idealsolidsolution": "ideal-condensed",
"fixedchempot": "fixed-chemical-potential",
"pureliquidwater": "liquid-water-IAPWS95",
"HMW": "HMW-electrolyte",
}
_kinetics_model_mapping = {
"gaskinetics": "gas",
Expand All @@ -154,6 +155,7 @@ class Phase:
"temperature": "T",
"pressure": "P",
"coverages": "coverages",
"soluteMolalities": "molalities",
}

_pure_fluid_mapping = {
Expand Down Expand Up @@ -270,10 +272,15 @@ def __init__(self, phase):

state_node = phase.find("state")
if state_node is not None:
phase_state = FlowMap({})
phase_state = FlowMap()
for prop in state_node:
property_name = self._state_properties_mapping[prop.tag]
if prop.tag in ["moleFractions", "massFractions", "coverages"]:
if prop.tag in [
"moleFractions",
"massFractions",
"coverages",
"soluteMolalities",
]:
value = split_species_value_string(prop.text)
else:
value = get_float_or_units(prop)
Expand Down Expand Up @@ -1011,7 +1018,9 @@ def convert(inpfile, outfile):
output_species.yaml_set_comment_before_after_key("species", before="\n")
else:
output_species[this_data_node_id] = species_data
output_species.yaml_set_comment_before_after_key(this_data_node_id, before="\n")
output_species.yaml_set_comment_before_after_key(
this_data_node_id, before="\n"
)

# Reactions
reaction_data = []
Expand Down
8 changes: 7 additions & 1 deletion interfaces/cython/cantera/test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,4 +1037,10 @@ def test_water_IAPWS95_thermo(self):
yamlWater.TD = T, dens
self.assertNear(ctmlWater.viscosity, yamlWater.viscosity)
self.assertNear(ctmlWater.thermal_conductivity,
yamlWater.thermal_conductivity)
yamlWater.thermal_conductivity)

# def test_hmw_nacl_phase(self):
# ctml2yaml.convert(Path(self.test_data_dir).joinpath("HMW_NaCl_sp1977_alt.xml"),
# Path(self.test_work_dir).joinpath("HMW_NaCl_sp1977_alt.yaml"))
# ctmlPhase, yamlPhase = self.checkConversion("HMW_NaCl_sp1977_alt")
# self.checkThermo(ctmlPhase, yamlPhase, [300, 500, 1300, 2000])

0 comments on commit d012a38

Please sign in to comment.