Miscellaneous Utilities
Contains definition of a base vector object used in the models such as Domain Wall Dynamics or Smit-Beljers model.
VectorObj
dataclass
Vector object for standard manipulation. Alternative to CVectors (which are used in the C++ code). Easier to modify and manipulate, but slower.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
float
|
positive z-axis angle (in xz plane) in radians. |
required |
phi |
float
|
positive x-axis (in xy plane) angle in radians |
required |
mag |
float
|
magnitude of the vector, if not set defaults to 1 unit vector |
1
|
Source code in cmtj/utils/general.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
__add__(other)
Adds two vectors
Source code in cmtj/utils/general.py
24 25 26 |
|
__mul__(other)
Multiplies a vector by a scalar
Source code in cmtj/utils/general.py
28 29 30 31 32 |
|
__rmul__(other)
Multiplies a vector by a scalar
Source code in cmtj/utils/general.py
34 35 36 |
|
from_cartesian(x, y, z)
staticmethod
Creates a spherical vector from Cartesian components
Source code in cmtj/utils/general.py
70 71 72 73 74 75 76 77 78 |
|
from_cvector(cvector)
staticmethod
Creates a spherical vector from Cartesian components
Source code in cmtj/utils/general.py
80 81 82 83 84 85 86 87 88 |
|
from_spherical(theta, phi, mag=1)
staticmethod
Creates a Cartesian vector from spherical components
Source code in cmtj/utils/general.py
61 62 63 64 65 66 67 68 |
|
get_cartesian()
Returns the vector in Cartesian coordinates with (x, y, z) compnents
Source code in cmtj/utils/general.py
57 58 59 |
|
to_cvector()
Creates a Cartesian vector from spherical components
Source code in cmtj/utils/general.py
90 91 92 |
|
box_muller_random(mean, std)
Generates Gaussian noise with mean and standard deviation using the Box-Muller transform. https://en.wikipedia.org/wiki/Box–Muller_transform
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mean |
mean of the Gaussian. |
required | |
std |
standard deviation of the Gaussian. |
required |
Source code in cmtj/utils/general.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
perturb_position(eq_point, pmax=0.001)
Perturbs an equilibrium point by a random amount.
Source code in cmtj/utils/general.py
111 112 113 114 115 |
|