Skip to content

Commit

Permalink
enable python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
bobmyhill committed Feb 11, 2024
1 parent cc5e857 commit d6773d0
Show file tree
Hide file tree
Showing 25 changed files with 93 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
python-versions: ['3.11']
python-versions: ['3.12']

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:

strategy:
matrix:
python-versions: ['3.8', '3.9', '3.10', '3.11']
python-versions: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
Expand Down
18 changes: 9 additions & 9 deletions burnman/eos/aa.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ class AA(eos.EquationOfState):
which gives volume as a function of pressure,
coupled with the thermodynamic identity:
:math:`-\partial E/ \partial V |_S = P`.
:math:`-\\partial E/ \\partial V |_S = P`.
The temperature along the isentrope is calculated via
:math:`\partial (\ln T)/\partial (\ln \\rho) |_S = \gamma`
:math:`\\partial (\\ln T)/\\partial (\\ln \\rho) |_S = \\gamma`
which gives:
:math:`T_S/T_0 = \exp(\int( \gamma/\\rho ) d \\rho)`
:math:`T_S/T_0 = \\exp(\\int( \\gamma/\\rho ) d \\rho)`
The thermal effect on internal energy is calculated at constant volume
using expressions for the kinetic, electronic and potential contributions
to the volumetric heat capacity, which can then be integrated with respect
to temperature:
:math:`\partial E/\partial T |_V = C_V`
:math:`\\partial E/\\partial T |_V = C_V`
:math:`\partial E/\partial S |_V = T`
:math:`\\partial E/\\partial S |_V = T`
We note that :cite:`AA1994` also include a detailed description
of the Gruneisen parameter as a function of volume and energy (Equation 15),
Expand All @@ -50,16 +50,16 @@ class AA(eos.EquationOfState):
1) As energy and entropy are defined by the equation of state at any
temperature and volume, pressure can be found by via the expression:
:math:`\partial E/\partial V |_S = P`
:math:`\\partial E/\\partial V |_S = P`
2) The Grueneisen parameter can now be determined as
:math:`\gamma = V \partial P/\partial E |_V`
:math:`\\gamma = V \\partial P/\\partial E |_V`
To reiterate: away from the reference isentrope, the Grueneisen parameter
calculated using these expressions is *not* equal to the
(thermodynamically inconsistent) analytical expression given by :cite:`AA1994`.
A final note: the expression for :math:`\Lambda` (Equation 17).
A final note: the expression for :math:`\\Lambda` (Equation 17).
does not reproduce Figure 5. We assume here that the figure matches the model
actually used by :cite:`AA1994`, which has the form:
:math:`F(-325.23 + 302.07 (\\rho/\\rho_0) + 30.45 (\\rho/\\rho_0)^{0.4})`.
Expand Down Expand Up @@ -249,7 +249,7 @@ def pressure(self, temperature, volume, params):
E1 = self._isentropic_energy_change(volume, params) - params['E_0']
E2 = E1 + dE
# Integrate at constant volume (V \int dP = \int gr dE)
# Integrate at constant volume (V \\int dP = \\int gr dE)
dP = (params['grueneisen_0']*(E2 - E1) +
(0.5*params['grueneisen_prime'] *
np.power(params['V_0']/volume, params['grueneisen_n']) *
Expand Down
6 changes: 3 additions & 3 deletions burnman/eos/birch_murnaghan.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ def shear_modulus(self, pressure, temperature, volume, params):

def entropy(self, pressure, temperature, volume, params):
"""
Returns the molar entropy :math:`\mathcal{S}` of the mineral. :math:`[J/K/mol]`
Returns the molar entropy :math:`\\mathcal{S}` of the mineral. :math:`[J/K/mol]`
"""
return 0.0

def molar_internal_energy(self, pressure, temperature, volume, params):
"""
Returns the internal energy :math:`\mathcal{E}` of the mineral. :math:`[J/mol]`
Returns the internal energy :math:`\\mathcal{E}` of the mineral. :math:`[J/mol]`
"""
x = np.power(volume / params["V_0"], -1.0 / 3.0)
x2 = x * x
Expand All @@ -184,7 +184,7 @@ def molar_internal_energy(self, pressure, temperature, volume, params):

def gibbs_free_energy(self, pressure, temperature, volume, params):
"""
Returns the Gibbs free energy :math:`\mathcal{G}` of the mineral. :math:`[J/mol]`
Returns the Gibbs free energy :math:`\\mathcal{G}` of the mineral. :math:`[J/mol]`
"""
# G = int VdP = [PV] - int PdV = E + PV

Expand Down
6 changes: 3 additions & 3 deletions burnman/eos/birch_murnaghan_4th.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ def shear_modulus(self, pressure, temperature, volume, params):

def entropy(self, pressure, temperature, volume, params):
"""
Returns the molar entropy :math:`\mathcal{S}` of the mineral. :math:`[J/K/mol]`
Returns the molar entropy :math:`\\mathcal{S}` of the mineral. :math:`[J/K/mol]`
"""
return 0.0

def molar_internal_energy(self, pressure, temperature, volume, params):
"""
Returns the internal energy :math:`\mathcal{E}` of the mineral. :math:`[J/mol]`
Returns the internal energy :math:`\\mathcal{E}` of the mineral. :math:`[J/mol]`
"""
x = np.power(volume / params["V_0"], -1.0 / 3.0)
x2 = x * x
Expand Down Expand Up @@ -157,7 +157,7 @@ def molar_internal_energy(self, pressure, temperature, volume, params):

def gibbs_free_energy(self, pressure, temperature, volume, params):
"""
Returns the Gibbs free energy :math:`\mathcal{G}` of the mineral. :math:`[J/mol]`
Returns the Gibbs free energy :math:`\\mathcal{G}` of the mineral. :math:`[J/mol]`
"""
# G = int VdP = [PV] - int PdV = E + PV

Expand Down
6 changes: 3 additions & 3 deletions burnman/eos/modified_tait.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ def shear_modulus(self, pressure, temperature, volume, params):

def entropy(self, pressure, temperature, volume, params):
"""
Returns the molar entropy :math:`\mathcal{S}` of the mineral. :math:`[J/K/mol]`
Returns the molar entropy :math:`\\mathcal{S}` of the mineral. :math:`[J/K/mol]`
"""
return 0.0

def molar_internal_energy(self, pressure, temperature, volume, params):
"""
Returns the internal energy :math:`\mathcal{E}` of the mineral. :math:`[J/mol]`
Returns the internal energy :math:`\\mathcal{E}` of the mineral. :math:`[J/mol]`
"""

return (
Expand All @@ -153,7 +153,7 @@ def molar_internal_energy(self, pressure, temperature, volume, params):

def gibbs_free_energy(self, pressure, temperature, volume, params):
"""
Returns the Gibbs free energy :math:`\mathcal{G}` of the mineral. :math:`[J/mol]`
Returns the Gibbs free energy :math:`\\mathcal{G}` of the mineral. :math:`[J/mol]`
"""
# G = int VdP = [PV] - int PdV = E + PV
a, b, c = tait_constants(params)
Expand Down
6 changes: 3 additions & 3 deletions burnman/eos/morse_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ def shear_modulus(self, pressure, temperature, volume, params):

def entropy(self, pressure, temperature, volume, params):
"""
Returns the molar entropy :math:`\mathcal{S}` of the mineral. :math:`[J/K/mol]`
Returns the molar entropy :math:`\\mathcal{S}` of the mineral. :math:`[J/K/mol]`
"""
return 0.0

def molar_internal_energy(self, pressure, temperature, volume, params):
"""
Returns the internal energy :math:`\mathcal{E}` of the mineral. :math:`[J/mol]`
Returns the internal energy :math:`\\mathcal{E}` of the mineral. :math:`[J/mol]`
"""

x = (params["Kprime_0"] - 1) * (1 - np.power(volume / params["V_0"], 1.0 / 3.0))
Expand All @@ -134,7 +134,7 @@ def molar_internal_energy(self, pressure, temperature, volume, params):

def gibbs_free_energy(self, pressure, temperature, volume, params):
"""
Returns the Gibbs free energy :math:`\mathcal{G}` of the mineral. :math:`[J/mol]`
Returns the Gibbs free energy :math:`\\mathcal{G}` of the mineral. :math:`[J/mol]`
"""
return (
self.molar_internal_energy(pressure, temperature, volume, params)
Expand Down
6 changes: 3 additions & 3 deletions burnman/eos/murnaghan.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def shear_modulus(self, pressure, temperature, volume, params):

def entropy(self, pressure, temperature, volume, params):
"""
Returns the molar entropy :math:`\mathcal{S}` of the mineral.
Returns the molar entropy :math:`\\mathcal{S}` of the mineral.
:math:`[J/K/mol]`
"""
return 0.0

def molar_internal_energy(self, pressure, temperature, volume, params):
"""
Returns the internal energy :math:`\mathcal{E}` of the mineral.
Returns the internal energy :math:`\\mathcal{E}` of the mineral.
:math:`[J/mol]`
"""
return energy(
Expand All @@ -92,7 +92,7 @@ def molar_internal_energy(self, pressure, temperature, volume, params):

def gibbs_free_energy(self, pressure, temperature, volume, params):
"""
Returns the Gibbs free energy :math:`\mathcal{G}` of the mineral.
Returns the Gibbs free energy :math:`\\mathcal{G}` of the mineral.
:math:`[J/mol]`
"""
# G = E + PV
Expand Down
14 changes: 7 additions & 7 deletions burnman/eos/reciprocal_kprime.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ class RKprime(eos.EquationOfState):
unstable at negative pressures, so should not be trusted to provide
a good *HT-LP* equation of state using a thermal pressure
formulation. The negative root of :math:`dP/dK`
can be found at :math:`K/P = K'_{\infty} - K'_0`,
can be found at :math:`K/P = K'_{\\infty} - K'_0`,
which corresponds to a bulk modulus of
:math:`K = K_0 ( 1 - K'_{\infty}/K'_0 )^{K'_0/K'_{\infty}}`
:math:`K = K_0 ( 1 - K'_{\\infty}/K'_0 )^{K'_0/K'_{\\infty}}`
and a volume of
:math:`V = V_0 ( K'_0 / (K'_0 - K'_{\infty}) )^{K'_0/{K'}^2_{\infty}} \exp{(-1/K'_{\infty})}`.
:math:`V = V_0 ( K'_0 / (K'_0 - K'_{\\infty}) )^{K'_0/{K'}^2_{\\infty}} \\exp{(-1/K'_{\\infty})}`.
This equation of state has no temperature dependence.
"""
Expand Down Expand Up @@ -196,7 +196,7 @@ def shear_modulus(self, pressure, temperature, volume, params):

def entropy(self, pressure, temperature, volume, params):
"""
Returns the molar entropy :math:`\mathcal{S}` of the mineral. :math:`[J/K/mol]`
Returns the molar entropy :math:`\\mathcal{S}` of the mineral. :math:`[J/K/mol]`
"""
return 0.0

Expand Down Expand Up @@ -228,7 +228,7 @@ def _intVdP(self, xi, params):

def gibbs_free_energy(self, pressure, temperature, volume, params):
"""
Returns the Gibbs free energy :math:`\mathcal{G}` of the mineral. :math:`[J/mol]`
Returns the Gibbs free energy :math:`\\mathcal{G}` of the mineral. :math:`[J/mol]`
"""
# G = E0 + int VdP (when S = 0)
K = self.isothermal_bulk_modulus(pressure, temperature, volume, params)
Expand All @@ -241,7 +241,7 @@ def gibbs_free_energy(self, pressure, temperature, volume, params):

def molar_internal_energy(self, pressure, temperature, volume, params):
"""
Returns the internal energy :math:`\mathcal{E}` of the mineral. :math:`[J/mol]`
Returns the internal energy :math:`\\mathcal{E}` of the mineral. :math:`[J/mol]`
"""
# E = G - PV (+ TS)
return (
Expand Down Expand Up @@ -276,7 +276,7 @@ def grueneisen_parameter(self, pressure, temperature, volume, params):
def validate_parameters(self, params):
"""
Check for existence and validity of the parameters.
The value for :math:`K'_{\infty}` is thermodynamically bounded
The value for :math:`K'_{\\infty}` is thermodynamically bounded
between 5/3 and :math:`K'_0` :cite:`StaceyDavis2004`.
"""

Expand Down
6 changes: 3 additions & 3 deletions burnman/eos/vinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ def shear_modulus(self, pressure, temperature, volume, params):

def entropy(self, pressure, temperature, volume, params):
"""
Returns the molar entropy :math:`\mathcal{S}` of the mineral. :math:`[J/K/mol]`
Returns the molar entropy :math:`\\mathcal{S}` of the mineral. :math:`[J/K/mol]`
"""
return 0.0

def molar_internal_energy(self, pressure, temperature, volume, params):
"""
Returns the internal energy :math:`\mathcal{E}` of the mineral. :math:`[J/mol]`
Returns the internal energy :math:`\\mathcal{E}` of the mineral. :math:`[J/mol]`
"""
x = pow(volume / params["V_0"], 1.0 / 3.0)
eta = (3.0 / 2.0) * (params["Kprime_0"] - 1.0)
Expand All @@ -118,7 +118,7 @@ def molar_internal_energy(self, pressure, temperature, volume, params):

def gibbs_free_energy(self, pressure, temperature, volume, params):
"""
Returns the Gibbs free energy :math:`\mathcal{G}` of the mineral. :math:`[J/mol]`
Returns the Gibbs free energy :math:`\\mathcal{G}` of the mineral. :math:`[J/mol]`
"""
# G = int VdP = [PV] - int PdV = E + PV

Expand Down
2 changes: 1 addition & 1 deletion burnman/utils/chemistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def process_solution_chemistry(solution_model):
)

solution_model.empty_formula = re.sub(
"([\[]).*?([\]])", "\g<1>\g<2>", solution_model.formulas[0]
"([\\[]).*?([\\]])", "\\g<1>\\g<2>", solution_model.formulas[0]
)
split_empty = solution_model.empty_formula.split("[")
solution_model.general_formula = split_empty[0]
Expand Down
2 changes: 1 addition & 1 deletion burnman/utils/geotherm.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def adiabatic(pressures, T0, rock):
pressure. A good first guess is provided by integrating:
.. math::
\\frac{\partial T}{\partial P} = \\frac{ \\gamma T}{ K_s }
\\frac{\\partial T}{\\partial P} = \\frac{ \\gamma T}{ K_s }
where :math:`\\gamma` is the Grueneisen parameter and :math:`K_s` is
the adiabatic bulk modulus.
Expand Down
2 changes: 1 addition & 1 deletion burnman/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def pretty_print_table(table, use_tabs=False):
"""
if use_tabs:
for r in table:
print("\t".join(r).replace("_", "\_"))
print("\t".join(r).replace("_", "\\_"))
return

def col_width(table, colidx):
Expand Down
10 changes: 5 additions & 5 deletions contrib/CHRU2014/paper_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,24 @@ def check_slb_fig7_txt():
)
gr_comp[i] = (forsterite.grueneisen_parameter - gr[i]) / gr[i]

plt.plot(temperature, rho_comp, label=r"$\rho$")
plt.plot(temperature, rho_comp, label=r"$\\rho$")
plt.plot(temperature, Kt_comp, label=r"$K_S$")
plt.plot(temperature, Ks_comp, label=r"$K_T$")
plt.plot(temperature, G_comp, label=r"$G$")
plt.plot(temperature, VS_comp, label=r"$V_S$")
plt.plot(temperature, VP_comp, label=r"$V_P$")
plt.plot(temperature, VB_comp, label=r"$V_\phi$")
plt.plot(temperature, VB_comp, label=r"$V_\\phi$")
plt.plot(temperature, vol_comp, label=r"$V$")
plt.plot(temperature, alpha_comp, label=r"$\alpha$")
plt.plot(temperature, alpha_comp, label=r"$\\alpha$")
plt.plot(temperature, Cp_comp, label=r"$c_P$")
plt.plot(temperature, gr_comp, label=r"$\gamma$")
plt.plot(temperature, gr_comp, label=r"$\\gamma$")

plt.xlim([0, 2200])
plt.ylim([-0.002, 0.002])
plt.yticks([-0.002, -0.001, 0, 0.001, 0.002])
plt.xticks([0, 800, 1600, 2200])
plt.xlabel("Temperature (K)")
plt.ylabel("Difference (\%)")
plt.ylabel("Difference (\\%)")
plt.legend(loc="lower center", prop=prop, ncol=4)
if "RUNNING_TESTS" not in globals():
plt.savefig("benchmark1.pdf", bbox_inches="tight")
Expand Down
12 changes: 6 additions & 6 deletions contrib/CHRU2014/paper_onefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ def output_rock(rock, file_handle):
for ph in rock.staticphases:
if isinstance(ph.mineral, HelperSolidSolution):
for mineral in ph.mineral.endmembers:
file_handle.write("\t" + mineral.to_string() + "\n")
file_handle.write("\\t" + mineral.to_string() + "\\n")
for key in mineral.params:
file_handle.write(
"\t\t" + key + ": " + str(mineral.params[key]) + "\n"
"\\t\\t" + key + ": " + str(mineral.params[key]) + "\\n"
)
else:
file_handle.write("\t" + ph.mineral.to_string() + "\n")
file_handle.write("\\t" + ph.mineral.to_string() + "\\n")
for key in ph.mineral.params:
file_handle.write(
"\t\t" + key + ": " + str(ph.mineral.params[key]) + "\n"
"\\t\\t" + key + ": " + str(ph.mineral.params[key]) + "\\n"
)


Expand Down Expand Up @@ -351,7 +351,7 @@ def array_to_rock(arr, names):
figsize = (6, 5)
prop = {"size": 12}
plt.rc("text", usetex=True)
plt.rcParams["text.latex.preamble"] = r"\usepackage{relsize}"
plt.rcParams["text.latex.preamble"] = r"\\usepackage{relsize}"
plt.rc("font", family="sans-serif")
figure = plt.figure(dpi=100, figsize=figsize)

Expand Down Expand Up @@ -436,7 +436,7 @@ def array_to_rock(arr, names):
)

plt.xlabel("Pressure (GPa)")
plt.ylabel("Velocities (km/s) and Density ($\cdot 10^3$ kg/m$^3$)")
plt.ylabel("Velocities (km/s) and Density ($\\cdot 10^3$ kg/m$^3$)")
plt.legend(bbox_to_anchor=(1.0, 0.9), prop={"size": 12})
plt.xlim(25, 135)
# plt.ylim(6,11)
Expand Down
Loading

0 comments on commit d6773d0

Please sign in to comment.