Skip to content

Resistance functions

Those functions are used to compute the resistance of a given system. They are all defined in the resistance module for version upside of 1.2.0.

calculate_magnetoresistance(Rp, Rap, m)

Computes the magnetoresistance using parallel and antiparallel resistance.

Parameters:

Name Type Description Default
Rp float

parallel resistance

required
Rap float

antiparallel resistance

required
m np.ndarray

magnetisation, 2 layers of shape [2, 3, T] where T is the time component

required
Source code in cmtj/utils/resistance.py
64
65
66
67
68
69
70
71
72
73
74
75
76
def calculate_magnetoresistance(Rp: float, Rap: float, m: np.ndarray):
    """Computes the magnetoresistance using parallel and antiparallel resistance.
    :param Rp: parallel resistance
    :param Rap: antiparallel resistance
    :param m: magnetisation, 2 layers of shape [2, 3, T] where T is the time component
    """
    if not isinstance(m, np.ndarray):
        m = np.asarray(m)
    if m.shape[0] != 2:
        raise ValueError(
            "The magnetoresistance can only be computed for 2 layers"
            f". Current shape {m.shape}")
    return Rp + 0.5 * (Rap - Rp) * np.sum(m[0] * m[1], axis=0)

calculate_resistance_parallel(Rx0, Ry0, AMR, AHE, SMR, m, l, w)

Calculates the resistance of the system in parallel. If you want to compute the resistance for an entire time series, pass m as a 3D array. [number_of_layers, 3, T] where T is the time component. Uses Kim's formula from the paper: https://link.aps.org/doi/10.1103/PhysRevLett.116.097201

Parameters:

Name Type Description Default
Rx0 List[float]

resistance offset in longitudinal direction

required
Ry0 List[float]

resistance offset in transverse direction

required
AMR List[float]

anisotropic magnetoresistance

required
AHE List[float]

anomalous Hall effect

required
SMR List[float]

spin Hall magnetoresistance

required
m List[float]

magnetisation of the layers. Shape [number_of_layers, 3, T]

required
l List[float]

length of the layers

required
w List[float]

width of the layers

required
Source code in cmtj/utils/resistance.py
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
def calculate_resistance_parallel(
    Rx0: List[float],
    Ry0: List[float],
    AMR: List[float],
    AHE: List[float],
    SMR: List[float],
    m: List[float],
    l: List[float],
    w: List[float],
):
    """Calculates the resistance of the system in parallel.
    If you want to compute the resistance for an entire time series, pass m as a 3D array.
    [number_of_layers, 3, T] where T is the time component.
    Uses Kim's formula from the paper:
    https://link.aps.org/doi/10.1103/PhysRevLett.116.097201

    :param Rx0: resistance offset in longitudinal direction
    :param Ry0: resistance offset in transverse direction
    :param AMR: anisotropic magnetoresistance
    :param AHE: anomalous Hall effect
    :param SMR: spin Hall magnetoresistance
    :param m: magnetisation of the layers. Shape [number_of_layers, 3, T]
    :param l: length of the layers
    :param w: width of the layers
    """
    SxAll, SyAll = compute_resistance(Rx0, Ry0, AMR, AHE, SMR, m, l, w)
    Rx = 1 / np.sum(1.0 / SxAll, axis=0)
    Ry = 1 / np.sum(1.0 / SyAll, axis=0)
    return Rx, Ry

calculate_resistance_series(Rx0, Ry0, AMR, AHE, SMR, m, l, w)

Calculates the resistance of the system in series. If you want to compute the resistance for an entire time series, pass m as a 3D array. [number_of_layers, 3, T] where T is the time component. Uses Kim's formula from the paper: https://link.aps.org/doi/10.1103/PhysRevLett.116.097201

Parameters:

Name Type Description Default
Rx0 List[float]

resistance offset in longitudinal direction

required
Ry0 List[float]

resistance offset in transverse direction

required
AMR List[float]

anisotropic magnetoresistance

required
AHE List[float]

anomalous Hall effect

required
SMR List[float]

spin Hall magnetoresistance

required
m List[float]

magnetisation of the layers. Shape [number_of_layers, 3, T]

required
l List[float]

length of the layers

required
w List[float]

width of the layers

required
Source code in cmtj/utils/resistance.py
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
def calculate_resistance_series(
    Rx0: List[float],
    Ry0: List[float],
    AMR: List[float],
    AHE: List[float],
    SMR: List[float],
    m: List[float],
    l: List[float],
    w: List[float],
):
    """Calculates the resistance of the system in series.
    If you want to compute the resistance for an entire time series, pass m as a 3D array.
    [number_of_layers, 3, T] where T is the time component.
    Uses Kim's formula from the paper:
    https://link.aps.org/doi/10.1103/PhysRevLett.116.097201

    :param Rx0: resistance offset in longitudinal direction
    :param Ry0: resistance offset in transverse direction
    :param AMR: anisotropic magnetoresistance
    :param AHE: anomalous Hall effect
    :param SMR: spin Hall magnetoresistance
    :param m: magnetisation of the layers. Shape [number_of_layers, 3, T]
    :param l: length of the layers
    :param w: width of the layers
    """
    SxAll, SyAll = compute_resistance(Rx0, Ry0, AMR, AHE, SMR, m, l, w)
    Rx = np.sum(SxAll, axis=0)
    Ry = np.sum(SyAll, axis=0)
    return Rx, Ry

compute_gmr(Rp, Rap, m1, m2)

Computes the GMR using parallel and antiparallel resistance.

Parameters:

Name Type Description Default
Rp float

parallel resistance

required
Rap float

antiparallel resistance

required
m1 np.ndarray

magnetisation of layer 1

required
m2 np.ndarray

magnetisation of layer 2

required
Source code in cmtj/utils/resistance.py
55
56
57
58
59
60
61
def compute_gmr(Rp: float, Rap: float, m1: np.ndarray, m2: np.ndarray):
    """Computes the GMR using parallel and antiparallel resistance.
    :param Rp: parallel resistance
    :param Rap: antiparallel resistance
    :param m1: magnetisation of layer 1
    :param m2: magnetisation of layer 2"""
    return Rp + 0.5 * (Rap - Rp) * np.sum(m1 * m2, axis=0)

compute_resistance(Rx0, Ry0, AMR, AHE, SMR, m, l, w)

Computes the resistance of the system. If you want to compute the resistance for an entire time series, pass m as a 3D array with shape [number_of_layers, 3, T], where T is the time component. [number_of_layers, 3, T] where T is the time component.

Source code in cmtj/utils/resistance.py
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
def compute_resistance(
    Rx0: List[float],
    Ry0: List[float],
    AMR: List[float],
    AHE: List[float],
    SMR: List[float],
    m: Union[List[float], np.ndarray],
    l: List[float],
    w: List[float],
):
    """Computes the resistance of the system.
    If you want to compute the resistance for an entire time series, pass m as a 3D array
    with shape [number_of_layers, 3, T], where T is the time component.
    [number_of_layers, 3, T] where T is the time component.
    """
    number_of_layers = len(Rx0)
    if not isinstance(m, np.ndarray):
        m = np.asarray(m)
    if m.ndim == 2:
        SxAll = np.zeros((number_of_layers, ))
        SyAll = np.zeros((number_of_layers, ))

    elif m.ndim == 3:
        SxAll = np.zeros((number_of_layers, m.shape[2]))
        SyAll = np.zeros((number_of_layers, m.shape[2]))

    for i in range(number_of_layers):
        w_l = w[i] / l[i]
        SxAll[i] = Rx0[i] + (AMR[i] * m[i, 0]**2 + SMR[i] * m[i, 1]**2)
        SyAll[i] = (Ry0[i] + 0.5 * AHE[i] * m[i, 2] + (w_l) *
                    (SMR[i] - AMR[i]) * m[i, 0] * m[i, 1])
    return SxAll, SyAll

compute_sd(dynamic_r, dynamic_i, integration_step)

Computes the SD voltage.

Parameters:

Name Type Description Default
dynamic_r np.ndarray

magnetoresistance from log

required
dynamic_i np.ndarray

excitation current

required
integration_step float

integration paramemter from run_simulation

required
Source code in cmtj/utils/resistance.py
 8
 9
10
11
12
13
14
15
16
17
18
def compute_sd(dynamic_r: np.ndarray, dynamic_i: np.ndarray,
               integration_step: float) -> np.ndarray:
    """Computes the SD voltage.
    :param dynamic_r: magnetoresistance from log
    :param dynamic_i: excitation current
    :param integration_step: integration paramemter from run_simulation
    """
    SD = -dynamic_i * dynamic_r
    fs = 1.0 / integration_step
    SD_dc = Filters.butter_lowpass_filter(SD, cutoff=10e6, fs=fs, order=3)
    return np.mean(SD_dc)