magnopy.Convention.get_modified#
method
- Convention.get_modified(multiple_counting: bool = None, spin_normalized: bool = None, c1: float = None, c21: float = None, c22: float = None, c31: float = None, c32: float = None, c33: float = None, c41: float = None, c42: float = None, c43: float = None, c44: float = None, c45: float = None, name: str = None, keep_undefined: bool = False)[source]#
Returns a new instance of the
Conventionclass.Properties of the new instance are the same as in the original convention, except for those explicitly given as arguments of this method.
- Parameters:
- multiple_countingbool, optional
Whether the pairs of spins are counted multiple times in the Hamiltonian's sums.
- spin_normalizedbool, optional
Whether spin vectors/operators are normalized to 1. If
True, then spin vectors/operators are normalized.- c1float, optional
Numerical factor before the sum over sites in the spin Hamiltonian (( 1 ) terms).
- c21float, optional
Numerical factor before the sum over sites in the spin Hamiltonian ((2, 1) terms).
- c22float, optional
Numerical factor before the sum over sites in the spin Hamiltonian ((2, 2) terms).
- c31float, optional
Numerical factor before the sum over sites in the spin Hamiltonian ((3, 1) terms).
- c32float, optional
Numerical factor before the sum over sites in the spin Hamiltonian ((3, 2) terms).
- c33float, optional
Numerical factor before the sum over sites in the spin Hamiltonian ((3, 3) terms).
- c41float, optional
Numerical factor before the sum over sites in the spin Hamiltonian ((4, 1) terms).
- c42float, optional
Numerical factor before the sum over sites in the spin Hamiltonian ((4, 2) terms).
- c43float, optional
Numerical factor before the sum over sites in the spin Hamiltonian ((4, 3) terms).
- c44float, optional
Numerical factor before the sum over sites in the spin Hamiltonian ((4, 4) terms).
- c45float, optional
Numerical factor before the sum over sites in the spin Hamiltonian ((4, 5) terms).
- namestr, optional
A label for the convention. Any string, case-insensitive.
- keep_undefinedbool, default False
Added in version 0.6.1.
If
True, then the properties of the new convention are modified only if the corresponding properties of the original convention are defined. IfFalse, then the properties of the new convention are modified regardless of whether the corresponding properties of the original convention are defined. See Examples for more details.
Notes
Giving
Noneas the value to the keyword arguments of this method does not change the corresponding properties of the convention>>> import magnopy >>> conv = magnopy.Convention(name="original", c21=1) >>> mod_conv = conv.get_modified(name="modified", c21=None) >>> # Still 1, not None >>> mod_conv.c21 1.0
Examples
>>> import magnopy >>> conv = magnopy.Convention( ... name="original", ... multiple_counting=True, ... spin_normalized=False, ... c1=1, ... c21=1, ... c22=-1, ... ) >>> print(conv) "original" convention where * Bonds are counted multiple times in the sum; * Spin vectors are not normalized; * c1 = 1.0; * c21 = 1.0; * c22 = -1.0; * Undefined c31 factor; * Undefined c32 factor; * Undefined c33 factor; * Undefined c41 factor; * Undefined c42 factor; * Undefined c43 factor; * Undefined c44 factor; * Undefined c45 factor.
>>> mod_conv = conv.get_modified(name="modified", c22=1, c33=-3) >>> print(mod_conv) "modified" convention where * Bonds are counted multiple times in the sum; * Spin vectors are not normalized; * c1 = 1.0; * c21 = 1.0; * c22 = 1.0; * Undefined c31 factor; * Undefined c32 factor; * c33 = -3.0; * Undefined c41 factor; * Undefined c42 factor; * Undefined c43 factor; * Undefined c44 factor; * Undefined c45 factor.
>>> import magnopy >>> conv = magnopy.Convention( ... name="original", ... multiple_counting=True, ... spin_normalized=False, ... c1=1, ... c21=1, ... ) >>> # Try to modify c22, which is undefined: >>> mod_conv = conv.get_modified( ... name="modified", c22=1, keep_undefined=True ... ) >>> print(mod_conv) "modified" convention where * Bonds are counted multiple times in the sum; * Spin vectors are not normalized; * c1 = 1.0; * c21 = 1.0; * Undefined c22 factor; * Undefined c31 factor; * Undefined c32 factor; * Undefined c33 factor; * Undefined c41 factor; * Undefined c42 factor; * Undefined c43 factor; * Undefined c44 factor; * Undefined c45 factor. >>> # Now modify c22, regardless of whether it is defined or not: >>> mod_conv = conv.get_modified(name="modified", c22=1) >>> print(mod_conv) "modified" convention where * Bonds are counted multiple times in the sum; * Spin vectors are not normalized; * c1 = 1.0; * c21 = 1.0; * c22 = 1.0; * Undefined c31 factor; * Undefined c32 factor; * Undefined c33 factor; * Undefined c41 factor; * Undefined c42 factor; * Undefined c43 factor; * Undefined c44 factor; * Undefined c45 factor.