Note
Go to the end to download the full example code.
Crystal structure¶
Exercises
Create a crystal structure for the material of your choosing. Create a cell and a set of atoms. Specify all mentioned properties for each atom.
(extra) Visualize your structure using
magnopy.PlotlyEngine(extra) Compute conventional and primitive cell for your structure (see
wulfric.crystal.get_primitive()andwulfric.crystal.get_conventional()). Visualize them. Are they they the same for your crystal? Shall they always be the same or not?
Every spin Hamiltonian in magnopy is defined on a lattice and a set of magnetic centers in its unit cell. In other words, one needs to define a crystal structure in order to define the spin Hamiltonian. This tutorial explains how to do that.
Crystal structure in magnopy is defined in the same way as in wulfric: a unit cell with the set of atoms (or "magnetic centers").
import magnopy
Cell¶
Unit cell is simply a set of three vectors (rows are vectors, i. e. a_1 = cell[0]).
Read magnopy's dedicated documentation page for more information.
cell = [
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
]
Atoms¶
Magnopy calls magnetic centers "atoms" due to historical reasons, but they are not necessary atoms. We will use the term "atoms" in this tutorial. In all cases "atom" simply mean an object with the set of properties. Read magnopy's dedicated documentation page for the full account of the expected properties and their meaning.
Magnopy operates with a set of atoms (even if there is only one atom in the set). Atoms are stored as a python dictionary. For example, set of three atoms
"Cr1" atom located at \((0, 0, 0)\) with spin value \(1.5\) and g-factor \(2\).
"I1" atom located at \((0.5, 0, 0)\) with undefined spin value and g-factor.
"I2" atom located at \((0, 0.5, 0)\) with undefined spin value and g-factor.
is defined as
atoms = {
"names": ["Cr1", "I1", "I2"],
"positions": [[0.0, 0.0, 0.0], [0.5, 0.0, 0.0], [0.0, 0.5, 0.0]],
"spins": [1.5, None, None],
"g_factors": [2, None, None],
}
Visualization¶
Magnopy relies on wulfric for all manipulations with the crystal. In fact,
visualization engine of magnopy (magnopy.PlotlyEngine) is an
extension of wulfric's visualization engine (wulfric.PlotlyEngine).
There are three steps in using this visualization technique. First, one shall create an instance of the visualization backend
pe = magnopy.PlotlyEngine(_sphinx_gallery_fix=True)
Note
Please ignore _sphinx_gallery_fix=True and do not include this argument in you
scripts.
Second, plot what you want to plot. See API reference (magnopy.PlotlyEngine)
for the list of available plotting methods. For example, display cell with
magnopy.PlotlyEngine.plot_cell() and atoms with
magnopy.PlotlyEngine.plot_atoms()
pe.plot_cell(cell, legend_label="Unit cell", color="Black")
pe.plot_atoms(cell, atoms, legend_label="Atoms of the unit cell")
Finally, display the figure with magnopy.PlotlyEngine.show() or save it with
magnopy.PlotlyEngine.save()
pe.show(axes_visible=False)
Hint
Figures are interactive. Try to rotate it. Try to zoom in/out. Try to click on the elements of the legend.
Total running time of the script: (0 minutes 0.089 seconds)