Skip to content

Commit

Permalink
added first calibrant benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
bobmyhill committed Nov 12, 2024
1 parent 18672a9 commit ad671a9
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 16 deletions.
23 changes: 8 additions & 15 deletions burnman/calibrants/Fei_2007.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,14 @@ def _pressure_Fei_Pt(volume, temperature, params):
Pth0 = thermal_model._thermal_pressure(params["T_0"], volume, params)
Pth = thermal_model._thermal_pressure(temperature, volume, params)

# Electronic pressure
Pel = (
1.1916e-15 * temperature**4.0
- 1.4551e-11 * temperature**3.0
+ 1.6209e-07 * temperature**2.0
+ 1.8269e-4 * temperature
- 0.069
) * 1.0e09

# Total pressure
P = P0 + Pth - Pth0 + Pel
P = P0 + Pth - Pth0

return P

Z = 4.0
_params_Fei_Pt = {
"V_0": 9.0904e-06,
"V_0": molar_volume_from_unit_cell_volume(60.38, Z),
"K_0": 277.0e9,
"Kprime_0": 5.08,
"Debye_0": 230.0,
Expand All @@ -57,7 +49,7 @@ def _pressure_Fei_Pt(volume, temperature, params):
"n": 1.0,
"T_0": 300.0,
"P_0": 0.0,
"Z": 4.0,
"Z": Z,
}

Calibrant.__init__(self, _pressure_Fei_Pt, "pressure", _params_Fei_Pt)
Expand Down Expand Up @@ -86,17 +78,18 @@ def _pressure_Fei_Au(volume, temperature, params):

return P

Z = 4.0
_params_Fei_Au = {
"V_0": molar_volume_from_unit_cell_volume(67.850, 4.0),
"V_0": molar_volume_from_unit_cell_volume(67.850, Z),
"K_0": 167.0e9,
"Kprime_0": 6.00,
"Kprime_0": 6.0,
"Debye_0": 170.0,
"grueneisen_0": 2.97,
"q_0": 0.6,
"n": 1.0,
"T_0": 300.0,
"P_0": 0.0,
"Z": 4.0,
"Z": Z,
}

Calibrant.__init__(self, _pressure_Fei_Au, "pressure", _params_Fei_Au)
4 changes: 3 additions & 1 deletion burnman/calibrants/Holmes_1989.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ def _pressure(volume, temperature, params):

return P_300 + params["alpha_T"] * params["beta_T"] * (temperature - 300.0)

Z = 4.0
_params = {
"V_0": molar_volume_from_unit_cell_volume(60.38, 4.0),
"V_0": molar_volume_from_unit_cell_volume(60.38, Z),
"beta_T": 798.31e9 / 3.0,
"eta": 7.2119,
"beta_prime_T": (7.2119 / 1.5) + 1.0,
"alpha_T": 2.61e-5,
"Z": Z,
}

Calibrant.__init__(self, _pressure, "pressure", _params)
67 changes: 67 additions & 0 deletions misc/benchmarks/calibrant_benchmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from __future__ import absolute_import

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from burnman import calibrants
from burnman.tools.unitcell import molar_volume_from_unit_cell_volume


def make_VPT_figure(calibrant, temperatures, figure, figure_extent, plot_extent):
name = str(calibrant).split(" ")[0][1:]
print(f"Checking {name}...")

fig = plt.figure(figsize=(6, 4))
fig.suptitle(f"{name}")

ax = [fig.add_subplot(1, 1, 1)]

fig1 = mpimg.imread(figure)
ax[0].imshow(fig1, extent=figure_extent, aspect="auto")

pressures = np.linspace(plot_extent[0] * 1.0e9, plot_extent[1] * 1.0e9, 101)
volumes = np.empty_like(pressures)
for T in temperatures:
for i, P in enumerate(pressures):
volumes[i] = calibrant.volume(P, T) / molar_volume_from_unit_cell_volume(
1.0, calibrant.params["Z"]
)

plt.plot(pressures / 1.0e9, volumes)

ax[0].set_xlim(plot_extent[0], plot_extent[1])
ax[0].set_ylim(plot_extent[2], plot_extent[3])
plt.show()


def check_figures():
make_VPT_figure(
calibrants.Fei_2007.Au(),
[300.0, 1473.0, 2173.0],
"figures/Fei_2007_Au.png",
[0, 139.5, 50, 68],
[0, 139.5, 50, 68],
)

make_VPT_figure(
calibrants.Fei_2007.Pt(),
[300.0, 1473.0, 1873.0],
"figures/Fei_2007_Pt.png",
[-2, 125, 46.98, 61.02],
[0, 125, 47, 61],
)

V_0 = calibrants.Holmes_1989.Pt().params[
"V_0"
] / molar_volume_from_unit_cell_volume(1.0, 4)
make_VPT_figure(
calibrants.Holmes_1989.Pt(),
[300.0],
"figures/Holmes_1989_Pt.png",
[0, 600, 0.6 * V_0, 1.1 * V_0],
[0, 600, 0.6 * V_0, 1.1 * V_0],
)


if __name__ == "__main__":
check_figures()
Binary file added misc/benchmarks/figures/Fei_2007_Au.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added misc/benchmarks/figures/Fei_2007_Pt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added misc/benchmarks/figures/Holmes_1989_Pt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ad671a9

Please sign in to comment.