Skip to content

Commit 9cd3adb

Browse files
authored
Merge pull request #611 from bobmyhill/p_eos
fix BM4, MT pressure calcs
2 parents 4671699 + 415ab09 commit 9cd3adb

File tree

3 files changed

+49
-21
lines changed

3 files changed

+49
-21
lines changed

burnman/calibrants/Decker_1971.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from burnman.eos.mie_grueneisen_debye import MGDBase
1212
from burnman.classes.calibrant import Calibrant
13-
from burnman.eos.birch_murnaghan_4th import birch_murnaghan_fourth
13+
from burnman.eos.birch_murnaghan_4th import pressure_birch_murnaghan_fourth
1414

1515

1616
class NaCl_B1(Calibrant):
@@ -27,7 +27,7 @@ class NaCl_B1(Calibrant):
2727
def __init__(self):
2828
def _pressure_Decker_NaCl(volume, temperature, params):
2929
# Isothermal pressure (GPa)
30-
P0 = birch_murnaghan_fourth(params["V_0"] / volume, params)
30+
P0 = pressure_birch_murnaghan_fourth(params["V_0"] / volume, params)
3131

3232
# Thermal pressure
3333
thermal_model = MGDBase()

burnman/eos/birch_murnaghan_4th.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def bulk_modulus_fourth(volume, params):
1919
modulus. Pressure must be in :math:`[Pa]`.
2020
"""
2121

22-
x = params["V_0"] / volume
23-
f = 0.5 * (pow(x, 2.0 / 3.0) - 1.0)
22+
invVrel = params["V_0"] / volume
23+
f = 0.5 * (pow(invVrel, 2.0 / 3.0) - 1.0)
2424

2525
Xi = (3.0 / 4.0) * (4.0 - params["Kprime_0"])
2626
Zeta = (3.0 / 8.0) * (
@@ -45,24 +45,46 @@ def bulk_modulus_fourth(volume, params):
4545

4646

4747
def volume_fourth_order(pressure, params):
48-
func = lambda x: birch_murnaghan_fourth(params["V_0"] / x, params) - pressure
48+
"""
49+
Volume according to the fourth-order
50+
Birch-Murnaghan equation of state.
51+
52+
:param pressure: Pressure in the same units that are supplied for the reference bulk
53+
modulus (params['K_0'])
54+
:type pressure: float
55+
:param params: parameter dictionary
56+
:type params: dictionary
57+
:return: V/V_0
58+
:rtype: float
59+
"""
60+
61+
def delta_pressure(x):
62+
return pressure_birch_murnaghan_fourth(params["V_0"] / x, params) - pressure
63+
4964
try:
50-
sol = bracket(func, params["V_0"], 1.0e-2 * params["V_0"])
51-
except:
65+
sol = bracket(delta_pressure, params["V_0"], 1.0e-2 * params["V_0"])
66+
except ValueError:
5267
raise ValueError(
5368
"Cannot find a volume, perhaps you are outside of the range of validity for the equation of state?"
5469
)
55-
return opt.brentq(func, sol[0], sol[1])
70+
return opt.brentq(delta_pressure, sol[0], sol[1])
5671

5772

58-
def birch_murnaghan_fourth(x, params):
73+
def pressure_birch_murnaghan_fourth(invVrel, params):
5974
"""
60-
equation for the fourth order birch-murnaghan equation of state, returns
61-
pressure in the same units that are supplied for the reference bulk
75+
Pressure according to the fourth-order
76+
Birch-Murnaghan equation of state.
77+
78+
:param invVrel: V/V_0
79+
:type invVrel: float or numpy array
80+
:param params: parameter dictionary
81+
:type params: dictionary
82+
:return: Pressure in the same units that are supplied for the reference bulk
6283
modulus (params['K_0'])
84+
:rtype: float or numpy array
6385
"""
6486

65-
f = 0.5 * (pow(x, 2.0 / 3.0) - 1.0)
87+
f = 0.5 * (pow(invVrel, 2.0 / 3.0) - 1.0)
6688
Xi = (3.0 / 4.0) * (4.0 - params["Kprime_0"])
6789
Zeta = (3.0 / 8.0) * (
6890
(params["K_0"] * params["Kprime_prime_0"])
@@ -93,7 +115,7 @@ def volume(self, pressure, temperature, params):
93115
return volume_fourth_order(pressure, params)
94116

95117
def pressure(self, temperature, volume, params):
96-
return birch_murnaghan_fourth(volume / params["V_0"], params)
118+
return pressure_birch_murnaghan_fourth(params["V_0"] / volume, params)
97119

98120
def isothermal_bulk_modulus_reuss(self, pressure, temperature, volume, params):
99121
"""

burnman/eos/modified_tait.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,21 @@ def tait_constants(params):
3030
return a, b, c
3131

3232

33-
def modified_tait(x, params):
33+
def pressure_modified_tait(Vrel, params):
3434
"""
35-
equation for the modified Tait equation of state, returns
36-
pressure in the same units that are supplied for the reference bulk
37-
modulus (params['K_0'])
35+
Pressure according to the modified Tait equation of state.
3836
EQ 2 from Holland and Powell, 2011
37+
38+
:param Vrel: V/V_0
39+
:type Vrel: float or numpy array
40+
:param params: Parameter dictionary
41+
:type params: dictionary
42+
:return: pressure in the same units that are supplied for the reference bulk
43+
modulus (params['K_0'])
44+
:rtype: float or numpy array
3945
"""
4046
a, b, c = tait_constants(params)
41-
return (np.power((x + a - 1.0) / a, -1.0 / c) - 1.0) / b + params["P_0"]
47+
return (np.power((Vrel + a - 1.0) / a, -1.0 / c) - 1.0) / b + params["P_0"]
4248

4349

4450
def volume(pressure, params):
@@ -47,8 +53,8 @@ def volume(pressure, params):
4753
EQ 12
4854
"""
4955
a, b, c = tait_constants(params)
50-
x = 1 - a * (1.0 - np.power((1.0 + b * (pressure - params["P_0"])), -1.0 * c))
51-
return x * params["V_0"]
56+
Vrel = 1.0 - a * (1.0 - np.power((1.0 + b * (pressure - params["P_0"])), -1.0 * c))
57+
return Vrel * params["V_0"]
5258

5359

5460
def bulk_modulus(pressure, params):
@@ -113,7 +119,7 @@ def pressure(self, temperature, volume, params):
113119
"""
114120
Returns pressure [Pa] as a function of temperature [K] and volume[m^3]
115121
"""
116-
return modified_tait(params["V_0"] / volume, params)
122+
return pressure_modified_tait(volume / params["V_0"], params)
117123

118124
def isothermal_bulk_modulus_reuss(self, pressure, temperature, volume, params):
119125
"""

0 commit comments

Comments
 (0)