Skip to content

Commit 4a21d16

Browse files
authored
Merge pull request #724 from bobmyhill/fix_H_elasticsolution
fix enthalpy calculation in ElasticSolution class, test consistency
2 parents 5355b58 + 6b7b201 commit 4a21d16

File tree

3 files changed

+12
-47
lines changed

3 files changed

+12
-47
lines changed

burnman/classes/elasticsolution.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -554,25 +554,15 @@ def excess_enthalpy(self):
554554
Returns excess molar enthalpy [J/mol].
555555
Property specific to solutions.
556556
"""
557-
return self.solution_model.excess_enthalpy(
558-
self.molar_volume, self.temperature, self.molar_fractions
559-
)
557+
return NotImplementedError
560558

561559
@material_property
562560
def molar_enthalpy(self):
563561
"""
564562
Returns molar enthalpy of the solution [J/mol].
565563
Aliased with self.H.
566564
"""
567-
return (
568-
sum(
569-
[
570-
self.solution_model.endmembers[i][0].H * self.molar_fractions[i]
571-
for i in range(self.n_endmembers)
572-
]
573-
)
574-
+ self.excess_enthalpy
575-
)
565+
return self.molar_gibbs + self.temperature * self.molar_entropy
576566

577567
@material_property
578568
def isothermal_bulk_modulus_reuss(self):

burnman/classes/elasticsolutionmodel.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -121,31 +121,6 @@ def excess_entropy(self, volume, temperature, molar_fractions):
121121
self.excess_partial_entropies(volume, temperature, molar_fractions),
122122
)
123123

124-
def excess_enthalpy(self, volume, temperature, molar_fractions):
125-
"""
126-
Given a list of molar fractions of different phases,
127-
compute the excess enthalpy of the solution.
128-
The base class implementation assumes that the excess enthalpy is zero.
129-
130-
:param volume: Volume at which to evaluate the solution model. [m^3/mol]
131-
:type volume: float
132-
133-
:param temperature: Temperature at which to evaluate the solution. [K]
134-
:type temperature: float
135-
136-
:param molar_fractions: List of molar fractions of the different
137-
endmembers in solution.
138-
:type molar_fractions: list of floats
139-
140-
:returns: The excess enthalpy of the solution.
141-
:rtype: float
142-
"""
143-
return (
144-
self.excess_helmholtz_energy(volume, temperature, molar_fractions)
145-
+ temperature * self.excess_entropy(volume, temperature, molar_fractions)
146-
- volume * self.excess_pressure(volume, temperature, molar_fractions)
147-
)
148-
149124
def excess_partial_helmholtz_energies(self, volume, temperature, molar_fractions):
150125
"""
151126
Given a list of molar fractions of different phases,
@@ -595,7 +570,7 @@ def __init__(
595570
self.Wijks = np.zeros_like(self.Wijke)
596571
self.Wijkp = np.zeros_like(self.Wijke)
597572

598-
# setup excess enthalpy interaction matrix
573+
# setup excess interaction matrices
599574
for i in range(self.n_endmembers):
600575
for j in range(i + 1, self.n_endmembers):
601576
w0 = energy_interaction[i][j - i - 1][0] / 2.0
@@ -647,7 +622,7 @@ def __init__(
647622

648623
if pressure_ternary_terms is not None:
649624
for i, j, k, v in pressure_ternary_terms:
650-
self.Wijkv[i, j, k] += v
625+
self.Wijkp[i, j, k] += v
651626

652627
# initialize ideal solution model
653628
ElasticIdealSolution.__init__(self, endmembers)

tests/test_elasticsolution.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,6 @@ def test_set_state_with_volume(self):
345345
m.set_state(P1, T1) # return to new state
346346
self.assertFloatEqual(V, m.V)
347347

348-
def test_gt_Wh(self):
349-
gt_ss = garnet_ss()
350-
H_excess = gt_ss.solution_model.excess_enthalpy(
351-
1.0e5, 1000.0, [0.5, 0.5]
352-
) # Hxs = Exs if Vxs=0
353-
We = gt_ss.solution_model.We[0][1]
354-
self.assertArraysAlmostEqual([We / 4.0], [H_excess])
355-
356348
def test_order_disorder(self):
357349
opx = orthopyroxene()
358350
opx.set_composition(np.array([0.0, 1.0]))
@@ -469,6 +461,14 @@ def test_subregular_model_ternary_partial_volume_multicomponent_change(self):
469461

470462
self.assertArraysAlmostEqual(dVdx, dVdx2)
471463

464+
def test_subregular_model_ternary_eos_consistency(self):
465+
ss = two_site_ss_subregular_ternary()
466+
f0 = np.array([0.25, 0.35, 0.4])
467+
ss.set_composition(f0)
468+
ss.set_state(1.0e9, 1000.0)
469+
470+
self.assertTrue(burnman.tools.eos.check_eos_consistency(ss))
471+
472472
def test_subregular(self):
473473
ss0 = two_site_ss()
474474
ss1 = two_site_ss_subregular()

0 commit comments

Comments
 (0)