def test_default(self): for rx in [ get_ionic_radii("Sr", charge=2, coordination=8), get_ionic_radii("Mn", charge=2, coordination=8), get_ionic_radii("Mg", charge=2, coordination=8), get_ionic_radii("Ba", charge=2, coordination=8), ]: D_j = self.D0 * strain_coefficient( self.ri, rx, r0=self.r0, E=self.E, T=self.Tk ) self.assertTrue(D_j > 0.0) self.assertTrue(D_j < self.D0)
def setUp(self): elements = [i for i in REE(dropPm=True) if i != "Eu"] # drop Pm, Eu self.xs = np.array(get_ionic_radii(elements, coordination=8, charge=3)) self.default_degree = 5 self.expect = [ (), (1.05477,), (1.00533, 1.12824), (0.99141, 1.06055, 1.14552), (0.98482, 1.03052, 1.10441, 1.15343), ]
def test_params(self): # the first three all have the same result - defaulting to ONeill 2016 # the two following use a full REE set for the OP basis function definition # the last illustrates that custom parameters could be used degree = self.default_degree for params in [ None, "ONeill2016", "O'Neill (2016)", "full", "Full", orthogonal_polynomial_constants( get_ionic_radii(REE(), charge=3, coordination=8), # xs degree=self.default_degree, ), ]: with self.subTest(params=params): ret = calc_lambdas(self.df, params=params, degree=degree) self.assertTrue(ret.columns.size == self.default_degree)
def setUp(self): self.xs = np.array(get_ionic_radii(REE(), coordination=8, charge=3)) self.default_degree = 4
""" Ionic Radii ============= :mod:`pyrolite` incldues a few sets of reference tables for ionic radii in aangstroms (Å) from [Shannon1976]_ and [WhittakerMuntus1970]_, each with tables indexed by element, ionic charge and coordination. The easiset way to access these is via the :func:`~pyrolite.geochem.ind.get_ionic_radii` function. The function can be used to get radii for individual elements: """ from pyrolite.geochem.ind import get_ionic_radii, REE Cu_radii = get_ionic_radii("Cu") print(Cu_radii) ######################################################################################## # Note that this function returned a series of the possible radii, given specific # charges and coordinations of the Cu ion. If we completely specify these, we'll get # a single number back: # Cu2plus6fold_radii = get_ionic_radii("Cu", coordination=6, charge=2) print(Cu2plus6fold_radii) ######################################################################################## # You can also pass lists to the function. For example, if you wanted to get the Shannon # ionic radii of Rare Earth Elements (REE) in eight-fold coordination with a valence of # +3, you should use the following: # shannon_ionic_radii = get_ionic_radii(REE(), coordination=8, charge=3) print(shannon_ionic_radii) ######################################################################################## # The function defaults to using the Shannon ionic radii consistent with [Pauling1960]_, # but you can adjust to use the set you like with the `pauling` boolean argument
def setUp(self): self.r0 = get_ionic_radii("Ca", charge=2, coordination=8) # angstroms self.ri = get_ionic_radii("Ca", charge=2, coordination=8) self.D0 = 4.1 self.E = 120 * 10 ** 9 # Pa self.Tk = 1200.0 # kelvin
def test_modulus_not_specified(self): rx = get_ionic_radii("Sr", charge=2, coordination=8) D_j = self.D0 * strain_coefficient(self.ri, rx, r0=self.r0, z=2, T=self.Tk) self.assertTrue(D_j > 0.0) self.assertTrue(D_j < self.D0)
Ionic Radii ============== :mod:`pyrolite` incldues a few sets of reference tables for ionic radii in aangstroms (Å) from [Shannon1976]_ and [WhittakerMuntus1970]_, each with tables indexed by element, ionic charge and coordination. The easiset way to access these is via the :func:`~pyrolite.geochem.ind.get_ionic_radii` function. The function can be used to get radii for individual elements, using a :code:`source` keyword argument to swap between the datasets: """ import pandas as pd import matplotlib.pyplot as plt from pyrolite.geochem.ind import get_ionic_radii, REE REE_radii = pd.Series(get_ionic_radii(REE(), coordination=8, charge=3, source="Whittaker"), index=REE()) REE_radii ######################################################################################## REE_radii.pyroplot.spider(color="k", logy=False) plt.show() ######################################################################################## # References # ---------- # .. [Shannon1976] Shannon RD (1976). Revised effective ionic radii and systematic # studies of interatomic distances in halides and chalcogenides. # Acta Crystallographica Section A 32:751–767. # `doi: 10.1107/S0567739476001551 <https://doi.org/10.1107/S0567739476001551>`__. # .. [WhittakerMuntus1970] Whittaker, E.J.W., Muntus, R., 1970. # Ionic radii for use in geochemistry.
from pyrolite.mineral.lattice import strain_coefficient # sphinx_gallery_thumbnail_number = 3 ######################################################################################## # First, we need to define some of the necessary parameters including temperature, the Young's # moduli for the :math:`X^{2+}` and :math:`X^{3+}` sites in plagioclase (:math:`E_2`, # :math:`E_3`), and some reference partition coefficients and radii for calcium and # sodium: D_Na = 1.35 # Partition coefficient Plag-Melt D_Ca = 4.1 # Partition coefficient Plag-Melt Tc = 900 # Temperature, °C Tk = Tc + 273.15 # Temperature, K E_2 = 120 * 10**9 # Youngs modulus for 2+ site, Pa E_3 = 135 * 10**9 # Youngs modulus for 3+ site, Pa r02, r03 = 1.196, 1.294 # fictive ideal cation radii for these sites rCa = get_ionic_radii("Ca", charge=2, coordination=8) rLa = get_ionic_radii("La", charge=3, coordination=8) ######################################################################################## # We can calculate and plot the partitioning of :math:`X^{2+}` cations relative to # :math:`Ca^{2+}` at a given temperature using their radii and the lattice strain function: # fontsize = 8 fig, ax = plt.subplots(1) site2labels = ["Na", "Ca", "Eu", "Sr"] # get the Shannon ionic radii for the elements in the 2+ site site2radii = [ get_ionic_radii("Na", charge=1, coordination=8), *[ get_ionic_radii(el, charge=2, coordination=8) for el in ["Ca", "Eu", "Sr"]
import numpy as np import matplotlib.pyplot as plt from pyrolite.plot import pyroplot from pyrolite.plot.spider import REE_v_radii from pyrolite.geochem.ind import REE, get_ionic_radii # sphinx_gallery_thumbnail_number = 4 ######################################################################################## # Where data is not specified, it will return a formatted axis which can be used for # subsequent plotting: ax = REE_v_radii( index='radii') # radii mode will put ionic radii on the x axis # create some example data ree = REE() xs = get_ionic_radii(ree, coordination=8, charge=3) ys = np.linspace(1, 20, len(xs)) ax.plot(xs, ys, marker='D', color='k') plt.show() ######################################################################################## # Here we generate some example data: # no_analyses = 10 data_ree = REE(dropPm=True) data_radii = np.array(get_ionic_radii(data_ree, coordination=8, charge=3)) data_radii = np.tile(data_radii, (1, no_analyses)).reshape(no_analyses, data_radii.shape[0]) dataframes = []
""" Shannon Radii ============= """ import matplotlib.pyplot as plt from pyrolite.geochem.ind import get_ionic_radii, REE REE_radii = get_ionic_radii(REE(), coordination=8, charge=3) fig, ax = plt.subplots(1) ax.plot(REE_radii, c='k', marker='D') ax.set_xticks(range(len(REE()))) ax.set_xticklabels(REE()) ax.set_ylabel('Ionic Radius ($\AA$)') ax.set_title('Rare Earth Element Shannon Ionic Radii') ######################################################################################## # .. seealso:: `Pandas Lambda Ln(REE) Function <../lambdas/pandaslambdas.html>`__, # `Lambdas for Dimensional Reduction <../lambdas/lambdadimreduction.html>`__, # `REE Radii Plot <../plotting/REE_radii_plot.html>`__
from pyrolite.geochem.ind import REE, get_ionic_radii from pyrolite.mineral.lattice import strain_coefficient # sphinx_gallery_thumbnail_number = 3 ######################################################################################## # First, we need to define some of the necessary parameters including temperature, the Young's # moduli for the :math:`X^{2+}` and :math:`X^{3+}` sites in plagioclase (:math:`E_2`, # :math:`E_3`), and some reference partition coefficients and radii for calcium and # sodium: D_Na = 1.35 # Partition coefficient Plag-Melt D_Ca = 4.1 # Partition coefficient Plag-Melt Tc = 900 # Temperature, °C Tk = Tc + 273.15 # Temperature, K E_2 = 120 * 10 ** 9 # Youngs modulus for 2+ site, Pa E_3 = 135 * 10 ** 9 # Youngs modulus for 3+ site, Pa r02, r03 = 1.196, 1.294 # fictive ideal cation radii for these sites rCa = get_ionic_radii("Ca", charge=2, coordination=8) rLa = get_ionic_radii("La", charge=3, coordination=8) ######################################################################################## # We can calculate and plot the partitioning of :math:`X^{2+}` cations relative to # :math:`Ca^{2+}` at a given temperature using their radii and the lattice strain function: # fontsize = 8 fig, ax = plt.subplots(1) site2labels = ["Na", "Ca", "Eu", "Sr"] # get the Shannon ionic radii for the elements in the 2+ site site2radii = [ get_ionic_radii("Na", charge=1, coordination=8), *[get_ionic_radii(el, charge=2, coordination=8) for el in ["Ca", "Eu", "Sr"]], ] # plot the relative paritioning curve for cations in the 2+ site
f = np.ones_like(xs) * w for c in p: f *= xs - np.float(c) if log: f = np.exp(f) label = ("$r^{}: \lambda_{}".format(len(p), len(p)) + ["\cdot f_{}".format(len(p)), ""][int(len(p) == 0)] + "$") ax.plot(xs, f, label=label, **kwargs) ######################################################################################## # First we generate some example data: # data_ree = REE(dropPm=True) data_radii = np.array(get_ionic_radii(data_ree, charge=3, coordination=8)) lnY = (np.random.randn(*data_radii.shape) * 0.1 + np.linspace(3.0, 0.0, data_radii.size) + (data_radii - 1.11)**2.0 - 0.1) for ix, el in enumerate(data_ree): if el in ["Ce", "Eu"]: lnY[ix] += np.random.randn(1) * 0.6 Y = np.exp(lnY) ######################################################################################## # Now we can calculate the lambdas: # exclude = ["Ce", "Eu"] if exclude: subset_ree = [i for i in data_ree if not i in exclude] subset_Y = Y[[i in subset_ree for i in data_ree]]