<jupyter_start><jupyter_text>Inverse Birch-Murnaghan equation with spline interpolation How to cite: <NAME> (2022) Inverse Birch-Murnaghan equation with spline interpolation. Zenodo. http://doi.org/10.5281/zenodo.6349563[![DOI](https://zenodo.org/badge/469190447.svg)](https://zenodo.org/badge/latestdoi/469190447) In `pytheos` and also other apps, such as `dioptas` and `burnman`, to get volume for given pressure, root search is used.  However, for extremely incompressible or compressible materials, root search can fail.In the notebook below, we set up calibration function based on spline interpolation. the function takes the following form:$$V = f(P)$$Therefore, it becomes very easy to calculate volume from presssure.Ref: https://en.wikipedia.org/wiki/Spline_(mathematics)<jupyter_code>import pytheos as eos
import numpy as np
import matplotlib.pyplot as plt
from scipy import interpolate
%config InlineBackend.figure_format='retina'<jupyter_output><empty_output><jupyter_text>Physical parametersFind challenging ones which crashes root search options.<jupyter_code>v0 = 10.
k0 = 0.1
k0p = 20.
p_max = 1000.<jupyter_output><empty_output><jupyter_text>Construct spline calibration function<jupyter_code>n_pts = 110
p_calib = np.linspace(-100, p_max, n_pts)
v_calib = eos.bm3_v(p_calib, v0, k0, k0p)
bm3s_v = interpolate.InterpolatedUnivariateSpline(p_calib, v_calib)

plt.plot(p_calib, v_calib/v0)
plt.xlabel('Pressure (GPa)'); plt.ylabel('$V / V_0 $')<jupyter_output><empty_output><jupyter_text>Performance check<jupyter_code>n_test = 50
p_test = np.linspace(50, p_max, n_test)

v_test = eos.bm3_v(p_test, v0, k0, k0p)
plt.plot(p_test, (v_test-bm3s_v(p_test))/v_test)
plt.xlabel('Pressure (GPa)')
plt.ylabel('$\Delta$V / V')<jupyter_output><empty_output><jupyter_text>In general the perfomance is impressive.  However, the most problematic pressure range is near 0 GPa.  Do not attempt ambitious extrapolation<jupyter_code>bm3s_v(2000.) - eos.bm3_v(2000., v0, k0, k0p)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup