Skip to content

Commit abfbe74

Browse files
Update lattice strain fitting example
1 parent 302c8e9 commit abfbe74

File tree

3 files changed

+44
-32
lines changed

3 files changed

+44
-32
lines changed

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ def reset_mpl(gallery_conf, fname):
343343
)
344344
+ "</dl>"
345345
)
346-
print(refcomps)
347346
rst_prolog = """
348347
.. |br| raw:: html
349348

docs/source/gallery/examples/geochem/mineral_lattice.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
# get the Shannon ionic radii for the elements in the 2+ site
5959
site2radii = [
6060
get_ionic_radii("Na", charge=1, coordination=8),
61-
*[get_ionic_radii(el, charge=2, coordination=8) for el in ["Ca", "Eu", "Sr"]],
61+
*get_ionic_radii(["Ca", "Eu", "Sr"], charge=2, coordination=8),
6262
]
6363
# plot the relative paritioning curve for cations in the 2+ site
6464
site2Ds = D_Ca * np.array(
@@ -89,7 +89,7 @@
8989
#
9090
site3labels = REE(dropPm=True)
9191
# get the Shannon ionic radii for the elements in the 3+ site
92-
site3radii = [get_ionic_radii(x, charge=3, coordination=8) for x in REE(dropPm=True)]
92+
site3radii = get_ionic_radii([x for x in REE(dropPm=True)], charge=3, coordination=8)
9393
site3Ds = D_La * np.array(
9494
[strain_coefficient(rLa, rx, r0=r03, E=E_3, T=Tk) for rx in site3radii]
9595
)
@@ -103,9 +103,7 @@
103103
ax.annotate(
104104
l, xy=(r, d), xycoords="data", ha="right", va="bottom", fontsize=fontsize
105105
)
106-
ax.set_yscale("log")
107-
ax.set_ylabel("$D_X$")
108-
ax.set_xlabel("Radii ($\AA$)")
106+
ax.set(ylabel="$D_X$", xlabel="Radii ($\AA$)", yscale="log")
109107
fig
110108
########################################################################################
111109
# As europium is commonly present as a mixture of both :math:`Eu^{2+}`
@@ -134,6 +132,8 @@
134132
ax.legend(bbox_to_anchor=(1.05, 1))
135133
fig
136134
########################################################################################
135+
# Fitting Lattice Strain Models
136+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137137
# Given the lattice strain model and a partitioning profile (for e.g. REE data),
138138
# we can also fit a model to a given curve; here we fit to our REE data above,
139139
# for which we have some known parameters to compare to:
@@ -158,8 +158,8 @@
158158
#
159159
from pyrolite.plot.spider import REE_v_radii
160160

161-
ax = REE_v_radii()
162-
161+
ax = REE_v_radii(index="radii")
162+
ax.set(ylabel="$D_X$", xlabel="Radii ($\AA$)")
163163
ax.plot(site3radii, site3Ds, label="True", color="k")
164164
ax.plot(
165165
site3radii,
@@ -169,18 +169,15 @@
169169
color="0.5",
170170
)
171171

172-
ax.plot(site3radii, fit_lattice_strain._opt(site3radii, _ri, _tk, _D, z=3), label="Fit")
173-
172+
ax.plot(
173+
site3radii,
174+
_lattice_opt_function(site3radii, _ri, _tk, _D, z=3),
175+
label="Fit",
176+
color="r",
177+
)
178+
ax.legend()
174179
ax.figure
175180
########################################################################################
176-
# .. [#ref_1] Blundy, J., Wood, B., 1994. Prediction of crystal–melt partition coefficients
177-
# from elastic moduli. Nature 372, 452.
178-
# doi: `10.1038/372452A0 <https://doi.org/10.1038/372452A0>`__
179-
#
180-
# .. [#ref_2] Dohmen, R., Blundy, J., 2014. A predictive thermodynamic model for element partitioning
181-
# between plagioclase and melt as a function of pressure, temperature and composition.
182-
# American Journal of Science 314, 1319–1372.
183-
# doi: `10.2475/09.2014.04 <https://doi.org/10.2475/09.2014.04>`__
184181
#
185182
# .. seealso::
186183
#
@@ -191,4 +188,18 @@
191188
# Functions:
192189
# :func:`~pyrolite.mineral.lattice.strain_coefficient`,
193190
# :func:`~pyrolite.mineral.lattice.youngs_modulus_approximation`,
191+
# :func:`~pyrolite.mineral.lattice.fit_lattice_strain`
194192
# :func:`~pyrolite.geochem.get_ionic_radii`
193+
#
194+
# References
195+
# ~~~~~~~~~~~
196+
# .. [#ref_1] Blundy, J., Wood, B., 1994. Prediction of crystal–melt partition coefficients
197+
# from elastic moduli. Nature 372, 452.
198+
# doi: `10.1038/372452A0 <https://doi.org/10.1038/372452A0>`__
199+
#
200+
# .. [#ref_2] Dohmen, R., Blundy, J., 2014. A predictive thermodynamic model for element partitioning
201+
# between plagioclase and melt as a function of pressure, temperature and composition.
202+
# American Journal of Science 314, 1319–1372.
203+
# doi: `10.2475/09.2014.04 <https://doi.org/10.2475/09.2014.04>`__
204+
#
205+

pyrolite/geochem/ind.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -459,18 +459,20 @@ def get_ionic_radii(
459459
* Implement interpolation for coordination +/- charge.
460460
"""
461461
if isinstance(element, list):
462-
return [
463-
get_ionic_radii(
464-
e,
465-
charge=charge,
466-
coordination=coordination,
467-
variant=variant,
468-
source=source,
469-
pauling=pauling,
470-
**kwargs,
471-
)
472-
for e in element
473-
]
462+
return np.array(
463+
[
464+
get_ionic_radii(
465+
e,
466+
charge=charge,
467+
coordination=coordination,
468+
variant=variant,
469+
source=source,
470+
pauling=pauling,
471+
**kwargs,
472+
)
473+
for e in element
474+
]
475+
)
474476

475477
if "shannon" in source.lower():
476478
df = __radii__["shannon"]
@@ -491,7 +493,7 @@ def get_ionic_radii(
491493
if charge in df.loc[elfltr, "charge"].unique():
492494
fltrs *= df.charge == charge
493495
else:
494-
logger.warn("Charge {:d} not in table.".format(int(charge)))
496+
logger.warning("Charge {:d} not in table.".format(int(charge)))
495497
# try to interpolate over charge?..
496498
# interpolate_charge=True
497499
else:
@@ -502,7 +504,7 @@ def get_ionic_radii(
502504
if coordination in df.loc[elfltr, "coordination"].unique():
503505
fltrs *= df.coordination == coordination
504506
else:
505-
logger.warn("Coordination {:d} not in table.".format(int(coordination)))
507+
logger.warning("Coordination {:d} not in table.".format(int(coordination)))
506508
# try to interpolate over coordination
507509
# interpolate_coordination=True
508510

0 commit comments

Comments
 (0)