Magnetism¶
- class py4vasp.data.Magnetism(raw_data)¶
Bases:
py4vasp.data._trajectory.DataTrajectory
The magnetic moments and localized charges for selected ionic steps.
This class gives access to the magnetic moments and charges projected on the different orbitals on every atom.
- Parameters
raw_magnetism (RawMagnetism) – Dataclass containing the charges and magnetic moments read from Vasp.
Examples
If you access a method of this class, the result will depend on the steps that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calc.magnetism.read()
To select the results for all steps, you don’t specify the array boundaries.
>>> calc.magnetism[:].read()
You can also select specific steps or a subset of steps as follows
>>> calc.magnetism[5].read() >>> calc.magnetism[1:6].read()
Attributes Summary
Length in Å how a magnetic moment is displayed relative to the largest moment.
Methods Summary
charges
()Read the charges of the selected steps.
from_dict
(dict_)Initialize refinement class from data dictionary
from_file
([file])Read the data dictionary from the given file.
moments
()Read the magnetic moments of the selected steps.
plot
()Visualize the magnetic moments as arrows inside the structure.
print
()Print a string representation of this class to standard output.
read
()Read the charges and magnetization data into a dictionary.
to_dict
()Read the charges and magnetization data into a dictionary.
Visualize the magnetic moments as arrows inside the structure.
Read the total charges of the selected steps.
Read the total magnetic moments of the selected steps.
Attributes Documentation
- length_moments = 1.5¶
Length in Å how a magnetic moment is displayed relative to the largest moment.
Methods Documentation
- charges()¶
Read the charges of the selected steps.
- Returns
Contains the charges for the selected steps projected on atoms and orbitals.
- Return type
np.ndarray
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calc.magnetism.charges()
To select the results for all steps, you don’t specify the array boundaries.
>>> calc.magnetism[:].charges()
You can also select specific steps or a subset of steps as follows
>>> calc.magnetism[5].charges() >>> calc.magnetism[1:6].charges()
- classmethod from_dict(dict_)¶
Initialize refinement class from data dictionary
- Parameters
data_dict (dict) – Data dictionary that contains one or more different raw data sources.
- classmethod from_file(file=None)¶
Read the data dictionary from the given file.
You want to use this method if you want to avoid using the Calculation wrapper, for example because you renamed the output of the VASP calculation.
- Parameters
file (str or Path or raw.File) – Filename from which the data is extracted. If not present the default filename is used. Alternatively, you can open the file yourself and pass the File object. In that case, you need to take care the file is properly closed again and be aware the generated instance of this class becomes unusable after the file is closed.
- Returns
The returned instance handles opening and closing the file for every function called on it, unless a File object in which case this is left to the user.
- Return type
DataBase
- moments()¶
Read the magnetic moments of the selected steps.
- Returns
Contains the magnetic moments for the selected steps projected on atoms and orbitals.
- Return type
np.ndarray
Notes
The index order is different compared to the raw data when noncollinear calculations are used. This routine returns the magnetic moments as (steps, atoms, orbitals, directions).
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calc.magnetism.moments()
To select the results for all steps, you don’t specify the array boundaries.
>>> calc.magnetism[:].moments()
You can also select specific steps or a subset of steps as follows
>>> calc.magnetism[5].moments() >>> calc.magnetism[1:6].moments()
- plot()¶
Visualize the magnetic moments as arrows inside the structure.
- Returns
Contains the atoms and the unit cell as well as an arrow indicating the strength of the magnetic moment. If noncollinear magnetism is used the moment points in the actual direction; for collinear magnetism the moments are aligned along the z axis by convention.
- Return type
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calc.magnetism.plot()
To select the results for all steps, you don’t specify the array boundaries.
>>> calc.magnetism[:].plot()
You can also select specific steps or a subset of steps as follows
>>> calc.magnetism[5].plot() >>> calc.magnetism[1:6].plot()
- print()¶
Print a string representation of this class to standard output.
- read()¶
Read the charges and magnetization data into a dictionary.
- Returns
Contains the charges and magnetic moments generated by Vasp projected on atoms and orbitals.
- Return type
dict
Notes
The index order is different compared to the raw data when noncollinear calculations are used. This routine returns the magnetic moments as (steps, atoms, orbitals, directions).
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calc.magnetism.read()
To select the results for all steps, you don’t specify the array boundaries.
>>> calc.magnetism[:].read()
You can also select specific steps or a subset of steps as follows
>>> calc.magnetism[5].read() >>> calc.magnetism[1:6].read()
- to_dict()¶
Read the charges and magnetization data into a dictionary.
- Returns
Contains the charges and magnetic moments generated by Vasp projected on atoms and orbitals.
- Return type
dict
Notes
The index order is different compared to the raw data when noncollinear calculations are used. This routine returns the magnetic moments as (steps, atoms, orbitals, directions).
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calc.magnetism.read()
To select the results for all steps, you don’t specify the array boundaries.
>>> calc.magnetism[:].read()
You can also select specific steps or a subset of steps as follows
>>> calc.magnetism[5].read() >>> calc.magnetism[1:6].read()
- to_viewer3d()¶
Visualize the magnetic moments as arrows inside the structure.
- Returns
Contains the atoms and the unit cell as well as an arrow indicating the strength of the magnetic moment. If noncollinear magnetism is used the moment points in the actual direction; for collinear magnetism the moments are aligned along the z axis by convention.
- Return type
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calc.magnetism.plot()
To select the results for all steps, you don’t specify the array boundaries.
>>> calc.magnetism[:].plot()
You can also select specific steps or a subset of steps as follows
>>> calc.magnetism[5].plot() >>> calc.magnetism[1:6].plot()
- total_charges()¶
Read the total charges of the selected steps.
- Returns
Contains the total charges for the selected steps projected on atoms. This corresponds to the charges summed over the orbitals.
- Return type
np.ndarray
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calc.magnetism.total_charges()
To select the results for all steps, you don’t specify the array boundaries.
>>> calc.magnetism[:].total_charges()
You can also select specific steps or a subset of steps as follows
>>> calc.magnetism[5].total_charges() >>> calc.magnetism[1:6].total_charges()
- total_moments()¶
Read the total magnetic moments of the selected steps.
- Returns
Contains the total magnetic moments for the selected steps projected on atoms. This corresponds to the magnetic moments summed over the orbitals.
- Return type
np.ndarray
Notes
The index order is different compared to the raw data when noncollinear calculations are used. This routine returns the magnetic moments as (steps, atoms, orbitals, directions).
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calc.magnetism.total_moments()
To select the results for all steps, you don’t specify the array boundaries.
>>> calc.magnetism[:].total_moments()
You can also select specific steps or a subset of steps as follows
>>> calc.magnetism[5].total_moments() >>> calc.magnetism[1:6].total_moments()