Skip to content

Commit 7f8820c

Browse files
committed
use adjacency list as the key of thermo cov dep models
1 parent 5e2477c commit 7f8820c

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

test/rmgpy/thermo/nasaTest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import rmgpy.constants as constants
4040
from rmgpy.quantity import ScalarQuantity
4141
from rmgpy.thermo.nasa import NASA, NASAPolynomial
42-
from rmgpy.quantity import Dimensionless
4342

4443

4544
class TestNASA:
@@ -70,7 +69,7 @@ def setup_class(self):
7069
self.Tmax = 3000.0
7170
self.Tint = 650.73
7271
self.E0 = -782292.0 # J/mol.
73-
self.thermo_coverage_dependence = {'OX':{'model':'polynomial', 'enthalpy-coefficients':[1,2,3], "entropy-coefficients":[1,2,3]}}
72+
self.thermo_coverage_dependence = {'1 O u0 p2 c0 {2,D} \n 2 X u0 p0 c0 {1,D}':{'model':'polynomial', 'enthalpy-coefficients':[1,2,3], "entropy-coefficients":[1,2,3]}}
7473
self.comment = "C2H6"
7574
self.nasa = NASA(
7675
polynomials=[
@@ -377,7 +376,11 @@ def test_nasa_as_dict_full(self):
377376
assert nasa_dict["E0"]["value"] == self.E0
378377
assert nasa_dict["Tmin"]["value"] == self.Tmin
379378
assert nasa_dict["Tmax"]["value"] == self.Tmax
380-
assert repr(nasa_dict["thermo_coverage_dependence"]) == "{'OX': {'model': 'polynomial', 'enthalpy-coefficients': [{'class': 'ScalarQuantity', 'value': 1.0}, {'class': 'ScalarQuantity', 'value': 2.0}, {'class': 'ScalarQuantity', 'value': 3.0}], 'entropy-coefficients': [{'class': 'ScalarQuantity', 'value': 1.0}, {'class': 'ScalarQuantity', 'value': 2.0}, {'class': 'ScalarQuantity', 'value': 3.0}]}}"
379+
assert nasa_dict["thermo_coverage_dependence"].keys() == self.thermo_coverage_dependence.keys()
380+
sp_name = list(self.thermo_coverage_dependence.keys())[0]
381+
assert nasa_dict['thermo_coverage_dependence'][sp_name]['model'] == self.thermo_coverage_dependence[sp_name]['model']
382+
assert nasa_dict['thermo_coverage_dependence'][sp_name]['enthalpy-coefficients']['object'] == self.thermo_coverage_dependence[sp_name]['enthalpy-coefficients']
383+
assert nasa_dict['thermo_coverage_dependence'][sp_name]['entropy-coefficients']['object'] == self.thermo_coverage_dependence[sp_name]['entropy-coefficients']
381384
assert nasa_dict["comment"] == self.comment
382385
assert tuple(nasa_dict["polynomials"]["polynomial1"]["coeffs"]["object"]) == tuple(self.coeffs_low)
383386
assert tuple(nasa_dict["polynomials"]["polynomial2"]["coeffs"]["object"]) == tuple(self.coeffs_high)

test/rmgpy/thermo/thermodataTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def setup_class(self):
5353
self.Tmin = 100.0
5454
self.Tmax = 3000.0
5555
self.E0 = -782292.0
56-
self.thermo_coverage_dependence = {'OX':{'model':'polynomial', 'enthalpy-coefficients':[1,2,3], "entropy-coefficients":[1,2,3]}}
56+
self.thermo_coverage_dependence = {'1 O u0 p2 c0 {2,D} \n 2 X u0 p0 c0 {1,D}':{'model':'polynomial', 'enthalpy-coefficients':[1,2,3], "entropy-coefficients":[1,2,3]}}
5757
self.comment = "C2H6"
5858
self.thermodata = ThermoData(
5959
Tdata=(self.Tdata, "K"),

test/rmgpy/thermo/wilhoitTest.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def setup_class(self):
5858
self.Tmin = 300.0
5959
self.Tmax = 3000.0
6060
self.comment = "C2H6"
61-
self.thermo_coverage_dependence = {'OX':{'model':'polynomial', 'enthalpy-coefficients':[1,2,3], "entropy-coefficients":[1,2,3]}}
61+
self.thermo_coverage_dependence = {'1 O u0 p2 c0 {2,D} \n 2 X u0 p0 c0 {1,D}':{'model':'polynomial', 'enthalpy-coefficients':[1,2,3], "entropy-coefficients":[1,2,3]}}
6262
self.wilhoit = Wilhoit(
6363
Cp0=(self.Cp0 * constants.R, "J/(mol*K)"),
6464
CpInf=(self.CpInf * constants.R, "J/(mol*K)"),
@@ -458,16 +458,11 @@ def test_wilhoit_as_dict(self):
458458
"value": 178.76114800000002,
459459
},
460460
"class": "Wilhoit",
461-
'thermo_coverage_dependence': {'OX': {
462-
'model': 'polynomial',
463-
'enthalpy-coefficients': [{'class': 'ScalarQuantity', 'value': 1.0},
464-
{'class': 'ScalarQuantity', 'value': 2.0},
465-
{'class': 'ScalarQuantity', 'value': 3.0}
466-
],
467-
'entropy-coefficients': [{'class': 'ScalarQuantity', 'value': 1.0},
468-
{'class': 'ScalarQuantity', 'value': 2.0},
469-
{'class': 'ScalarQuantity', 'value': 3.0}
470-
]}}
461+
'thermo_coverage_dependence': {'1 O u0 p2 c0 {2,D} \n 2 X u0 p0 c0 {1,D}': {
462+
'model': 'polynomial',
463+
'enthalpy-coefficients': {'class': 'np_array', 'object': [1, 2, 3]},
464+
'entropy-coefficients': {'class': 'np_array', 'object': [1, 2, 3]}}
465+
}
471466
}
472467

473468
def test_make_wilhoit(self):
@@ -476,6 +471,6 @@ def test_make_wilhoit(self):
476471
"""
477472
wilhoit_dict = self.wilhoit.as_dict()
478473
new_wilhoit = Wilhoit.__new__(Wilhoit)
479-
class_dictionary = {"ScalarQuantity": ScalarQuantity, "Wilhoit": Wilhoit}
474+
class_dictionary = {"ScalarQuantity": ScalarQuantity, "Wilhoit": Wilhoit, "np_array": np.array}
480475

481476
new_wilhoit.make_object(wilhoit_dict, class_dictionary)

0 commit comments

Comments
 (0)