LiFePO4¶
In this example we will go through the relevant lines of the script run_example.py in the LiFePO4 directory of the examples. This example shows how to calculate the local fields at the muon sites in LiFePO4 and loosely follows the description of Ref. [Sugiyama2011].
Interactive magnetic order definition¶
In this section we will prepare a script that asks the user to specify the magnetic order at runtime and prints the output on screen.
Let’s first import the necessary python objects and functions of muesr
.
11 12 13 14 15 16 17 | import numpy as np # to calculate the norm
import os # join path on windows.
from muesr.core import Sample # this object contains all the info on our sample
from muesr.i_o import load_cif # loads lattice and symmetry from CIF file
from muesr.utilities import mago_add # this function provides a CLI for inserting the MAGnetic Order
from muesr.engines.clfc import locfield # this is the function which actually performs the sum and returns
|
To create a new sample definition and initialize it, just do:
28 | smpl = Sample()
|
- The sample object holds the following information:
- Lattice structure
- Magnetic Orders
- Muon positions
- Symmetry (optional)
The lattice structure is orthorhombic, with Pnma symmetry and
lattice parameters \(a=10.3244(2), b=6.0064(3), c=4.6901(5)\).
We can import these data from a CIF file using the function
load_cif()
:
31 | load_cif(smpl, os.path.join('.','cifs','4001848.cif'))
|
(make sure you give the correct path, the cif file is in the muer example directory tree). The next step is the definition of the magnetic order. This can be done interactively during the script execution or programmatically.
Let’s discuss the former case first. The function mago_add()
will let you specify the Fourier components and the propagation vector.
We want to describe LiFePo anti-ferromagnetic order in which the iron moments, 4.19 \(\mu_{\mathrm{B}}\) in magnitude, lie along the \(y\) axis. We do this by defining a ferromagnetic order (propagation vector k = 0), with a basis of four moments. If you run the code the full output below allows you to recognize the input that you have to provide from the function prompts.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | mago_add(smpl)
# the interactive session of the above command should be like this:
# Propagation vector (w.r.t. conv. rec. cell): 0 0 0
# Magnetic moments in bohr magnetons and cartesian coordinates.
# Which atom? (enter for all)Fe
# Lattice vectors:
# a 10.324400000000001 0.000000000000000 0.000000000000000
# b 0.000000000000000 6.006400000000000 0.000000000000000
# c 0.000000000000000 0.000000000000000 4.690100000000000
# Atomic positions (fractional):
# 1 Fe 0.28220100000000 0.25000000000000 0.97474000000000 55.845
# 2 Fe 0.21779900000000 0.75000000000000 0.47474000000000 55.845
# 3 Fe 0.71779900000000 0.75000000000000 0.02526000000000 55.845
# 4 Fe 0.78220100000000 0.25000000000000 0.52526000000000 55.845
# FC for atom 1 Fe (3 real, [3 imag]): 0 4.19 0
# FC for atom 2 Fe (3 real, [3 imag]): 0 -4.19 0
# FC for atom 3 Fe (3 real, [3 imag]): 0 -4.19 0
# FC for atom 4 Fe (3 real, [3 imag]): 0 4.19 0
|
In order to complete the setup we specify the muon positions.
The method add_muon
inputs lattice
(fractional) coordinates by default. Four muon sites are discussed by
Jun Sugiyama et al. [Sugiyama2011].
67 68 69 70 | smpl.add_muon([0.1225,0.3772,0.8679])
smpl.add_muon([0.0416,0.2500,0.9172])
smpl.add_muon([0.3901,0.2500,0.3599])
smpl.add_muon([0.8146,0.0404,0.8914])
|
Note
The muon sites will be automatically placed in the central unit cell of the supercell that will be used for the subsequent calculations.
The local fields are finally calculated with the locfield()
command.
80 81 | # sample type of calculation supercell Lorentz radius
r = locfield( smpl, 's', [100,100,100], 40)
|
Warning
- Always check convergence against the supercell size.
- Always use a Lorentz sphere that can be inscribed in the selected supercell.
Please see the documentation of the function locfield()
to see a description of the input parameters. As it is immediately evident,
the supercell size and the Lorentz radius are not the ideal choices.
Improving this parameters is left as an exercise to the reader.
The results are stored in a list of
LocalField
objects which, for each muon
site, contain the total, dipolar, Lorentz and Contact contributions in
Tesla (in the present case, an antiferromagnet in zero external field, with no Fermi contact term, only the dipolar field is obtained).
The next four lines of code print the results of the simulation in T/\(\mu_{\mathrm{B}}\)
84 85 86 87 | print(r[0].T/4.19, "Norm {: 0.4f}".format(np.linalg.norm(r[0].T/4.19)))
print(r[1].T/4.19, "Norm {: 0.4f}".format(np.linalg.norm(r[1].T/4.19)))
print(r[2].T/4.19, "Norm {: 0.4f}".format(np.linalg.norm(r[2].T/4.19)))
print(r[3].T/4.19, "Norm {: 0.4f}".format(np.linalg.norm(r[3].T/4.19)))
|
You should now see the following self explaining result
(array([-0.15540174, -0.12234256, -0.02399385]), 'Norm 0.1992')
(array([ -1.32075572e-17, -1.24059244e-01, -1.10237957e-19]), 'Norm 0.1241')
(array([ -5.22880379e-18, -1.80946551e-01, 3.16831013e-18]), 'Norm 0.1809')
(array([-0.1333684 , -0.11733706, -0.03497624]), 'Norm 0.1810')"
These are the Cartesian components and modulus of the local field at the four Sugiyama sites, in Tesla.
Note
The results are always reported in the Cartesian coordinate system defined by the lattice vectors of the crystal.
Programmatic magnetic order definition¶
As already mentioned above, it’s also possible to specify a magnetic
order programmatically. This can be done with the help of the methods
new_mm
,
k
and fc
.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | # create a new magnetic model for the sample
smpl.new_mm()
# The new magnetic order is automatically selected.
# One can obtain the current magnetic model with the
# property "mm". E.g. smpl.mm.k prints the k-vector, etc.
# Set a description for the magnetic order
smpl.mm.desc = "Ferromagnetic"
# Remember: anti-ferro = ferro with a bassis
# The smpl.mm.k property can also set the propagation vector,
# in reciprocal lattice units (r.l.u.).
smpl.mm.k=np.array([0.,0.,0.])
# Now define Fourier components (in CARTESIAN coordinates and Bohr magnetons);
# the components must be set for all the atoms in a cell (28 in the present case).
FCs = np.array([[ 0.00+0.j, 4.19+0.j, 0.00+0.j],
[ 0.00+0.j, -4.19+0.j, 0.00+0.j],
[ 0.00+0.j, -4.19+0.j, 0.00+0.j],
[ 0.00+0.j, 4.19+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j],
[ 0.00+0.j, 0.00+0.j, 0.00+0.j]])
# Set the Fourier components, by default in Cartesian coordinates.
|
Please remember to specify the FC in a 2D array with 3 columns and \(N_{\mathrm{Atoms}}\) rows of complex values.
Note
The propagation vector is always specified in reciprocal lattice units. On the other hand, the Fourier components can be specified with three different coordinate system and units:
- Bohr magnetons in Cartesian coordinates (Cartesian vector notation)
- Bohr magnetons/Angstrom along the lattice vectors (Lattice vector notation)
- Modulus (in Bohr magnetons) along the lattice vectors.
The results can be retrieved as described above.
[Sugiyama2011] | (1, 2) Jun Sugiyama et al., Phys. Rev. B 84, 054430 (2011) |