Skip to content

Transport

transport

This module contains functions for calculating transport properties such as resistance, resistivity, and Hall resistance. Functions act on pandas DataFrames and return Series that can be assigned to new columns in the DataFrame.

calculate_hall_resistance(df, hall_voltage, current, gain=None)

Calculate the Hall resistance using the Hall voltage and current.

Parameters:

Name Type Description Default
df DataFrame

The dataframe containing the data.

required
hall_voltage str

The name of the column in the dataframe that contains the Hall voltage values.

required
current str or float

The name of the column in the dataframe that contains the current values if it's a string, or a constant current value if it's a float.

required
gain str or float

The name of the column in the dataframe that contains the gain values if it's a string, or a constant gain value if it's a float. Defaults to None.

None

Returns:

Type Description
Series

pandas.Series: A series containing the calculated Hall resistance values.

Examples:

>>> import quantalize as qz
>>> df['hall_resistance'] = qz.calculate_hall_resistance(
>>>     df, 
>>>     hall_voltage='hall_voltage_col', 
>>>     current='current_col',
>>>     gain='gain_col'
>>> )
Source code in src/quantalyze/transport.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
139
140
141
142
143
144
145
def calculate_hall_resistance(df, hall_voltage, current, gain=None) -> pd.Series:
    """
    Calculate the Hall resistance using the Hall voltage and current.

    Args:
        df (pandas.DataFrame): The dataframe containing the data.
        hall_voltage (str): The name of the column in the dataframe that contains the Hall voltage values.
        current (str or float): The name of the column in the dataframe that contains the current values if it's a string,
            or a constant current value if it's a float.
        gain (str or float, optional): The name of the column in the dataframe that contains the gain values if it's a string,
            or a constant gain value if it's a float. Defaults to None.

    Returns:
        pandas.Series: A series containing the calculated Hall resistance values.

    Examples:
        >>> import quantalize as qz
        >>> df['hall_resistance'] = qz.calculate_hall_resistance(
        >>>     df, 
        >>>     hall_voltage='hall_voltage_col', 
        >>>     current='current_col',
        >>>     gain='gain_col'
        >>> )
    """
    if isinstance(current, str):
        hall_resistance = df[hall_voltage] / df[current]
    else:
        hall_resistance = df[hall_voltage] / current

    if gain is not None:
        if isinstance(gain, str):
            hall_resistance = hall_resistance / df[gain]
        else:
            hall_resistance = hall_resistance / gain

    return hall_resistance

calculate_hall_resistivity(df, hall_resistance=None, hall_voltage=None, current=None, thickness=None, gain=None)

Calculate the Hall resistivity using either Hall resistance or Hall voltage and current, along with thickness.

Parameters:

Name Type Description Default
df DataFrame

The dataframe containing the data.

required
hall_resistance str

The name of the column in the dataframe that contains the Hall resistance values.

None
hall_voltage str

The name of the column in the dataframe that contains the Hall voltage values.

None
current str or float

The name of the column in the dataframe that contains the current values if it's a string, or a constant current value if it's a float.

None
thickness float

The thickness of the material.

None
gain str or float

The name of the column in the dataframe that contains the gain values if it's a string, or a constant gain value if it's a float. Defaults to None.

None

Returns:

Type Description
Series

pandas.Series: A series containing the calculated Hall resistivity values.

Raises:

Type Description
ValueError

If neither hall_resistance nor both hall_voltage and current are provided.

ValueError

If both hall_resistance and hall_voltage are provided.

ValueError

If thickness is not provided.

ValueError

If hall_resistance is supplied along with a gain.

Examples:

>>> import quantalize as qz
>>> df['hall_resistivity'] = qz.calculate_hall_resistivity(
>>>     df, 
>>>     hall_resistance='hall_resistance_col', 
>>>     hall_voltage='hall_voltage_col', 
>>>     current='current_col', 
>>>     thickness=11e-6,
>>>     gain='gain_col'
>>> )
Source code in src/quantalyze/transport.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
def calculate_hall_resistivity(df, hall_resistance=None, hall_voltage=None, current=None, thickness=None, gain=None) -> pd.Series:
    """
    Calculate the Hall resistivity using either Hall resistance or Hall voltage and current, along with thickness.

    Args:
        df (pandas.DataFrame): The dataframe containing the data.
        hall_resistance (str, optional): The name of the column in the dataframe that contains the Hall resistance values.
        hall_voltage (str, optional): The name of the column in the dataframe that contains the Hall voltage values.
        current (str or float, optional): The name of the column in the dataframe that contains the current values if it's a string,
            or a constant current value if it's a float.
        thickness (float, optional): The thickness of the material.
        gain (str or float, optional): The name of the column in the dataframe that contains the gain values if it's a string,
            or a constant gain value if it's a float. Defaults to None.

    Returns:
        pandas.Series: A series containing the calculated Hall resistivity values.

    Raises:
        ValueError: If neither hall_resistance nor both hall_voltage and current are provided.
        ValueError: If both hall_resistance and hall_voltage are provided.
        ValueError: If thickness is not provided.
        ValueError: If hall_resistance is supplied along with a gain.

    Examples:
        >>> import quantalize as qz
        >>> df['hall_resistivity'] = qz.calculate_hall_resistivity(
        >>>     df, 
        >>>     hall_resistance='hall_resistance_col', 
        >>>     hall_voltage='hall_voltage_col', 
        >>>     current='current_col', 
        >>>     thickness=11e-6,
        >>>     gain='gain_col'
        >>> )
    """
    if hall_resistance is not None and hall_voltage is not None:
        raise ValueError("Only one of hall_resistance or hall_voltage can be provided, not both.")

    if hall_resistance is None:
        if hall_voltage is not None and current is not None:
            hall_resistance = calculate_hall_resistance(df, hall_voltage, current, gain=gain)
        else:
            raise ValueError("Either hall_resistance or both hall_voltage and current must be provided.")
    else:
        if gain is not None:
            raise ValueError("Gain cannot be applied when hall_resistance is directly supplied.")
        hall_resistance = df[hall_resistance]

    if thickness is None:
        raise ValueError("Thickness must be provided.")

    hall_resistivity = hall_resistance * thickness
    return hall_resistivity

calculate_resistance(df, voltage, current, gain=None)

Calculate the electrical resistance using voltage and current.

Parameters:

Name Type Description Default
df DataFrame

The dataframe containing the data.

required
voltage str

The name of the column in the dataframe that contains the voltage values.

required
current str or float

The name of the column in the dataframe that contains the current values if it's a string, or a constant current value if it's a float.

required
gain str or float

The name of the column in the dataframe that contains the gain values if it's a string, or a constant gain value if it's a float. Defaults to None.

None

Returns:

Type Description
Series

pandas.Series: A series containing the calculated resistance values.

Examples:

>>> import quantalize as qz
>>> df['resistance'] = qz.calculate_resistance(
>>>     df, 
>>>     voltage='voltage_col', 
>>>     current='current_col',
>>>     gain='gain_col'
>>> )
Source code in src/quantalyze/transport.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
def calculate_resistance(df, voltage, current, gain=None) -> pd.Series:
    """
    Calculate the electrical resistance using voltage and current.

    Args:
        df (pandas.DataFrame): The dataframe containing the data.
        voltage (str): The name of the column in the dataframe that contains the voltage values.
        current (str or float): The name of the column in the dataframe that contains the current values if it's a string,
            or a constant current value if it's a float.
        gain (str or float, optional): The name of the column in the dataframe that contains the gain values if it's a string,
            or a constant gain value if it's a float. Defaults to None.

    Returns:
        pandas.Series: A series containing the calculated resistance values.

    Examples:
        >>> import quantalize as qz
        >>> df['resistance'] = qz.calculate_resistance(
        >>>     df, 
        >>>     voltage='voltage_col', 
        >>>     current='current_col',
        >>>     gain='gain_col'
        >>> )
    """
    if isinstance(current, str):
        resistance = df[voltage] / df[current]
    else:
        resistance = df[voltage] / current

    if gain is not None:
        if isinstance(gain, str):
            resistance = resistance / df[gain]
        else:
            resistance = resistance / gain

    return resistance

calculate_resistivity(df, length=None, width=None, thickness=None, resistance=None, voltage=None, current=None, geometric_factor=None, gain=None)

Calculate the electrical resistivity using either resistance or voltage and current, along with length, width, and thickness, or a provided geometric factor.

Parameters:

Name Type Description Default
df DataFrame

The dataframe containing the data.

required
resistance str

The name of the column in the dataframe that contains the resistance values.

None
voltage str

The name of the column in the dataframe that contains the voltage values.

None
current str or float

The name of the column in the dataframe that contains the current values if it's a string, or a constant current value if it's a float.

None
length float

The length of the material.

None
width float

The width of the material.

None
thickness float

The thickness of the material.

None
geometric_factor float

The pre-calculated geometric factor (width * thickness / length).

None
gain str or float

The name of the column in the dataframe that contains the gain values if it's a string, or a constant gain value if it's a float. Defaults to None.

None

Returns:

Type Description
Series

pandas.Series: A series containing the calculated resistivity values.

Raises:

Type Description
ValueError

If neither resistance nor both voltage and current are provided.

ValueError

If both resistance and voltage are provided.

ValueError

If neither geometric_factor nor all of length, width, and thickness are provided.

ValueError

If resistance is supplied along with a gain.

Examples:

>>> import quantalize as qz
>>> df['resistivity'] = qz.calculate_resistivity(
>>>     df, 
>>>     resistance='resistance_col', 
>>>     voltage='voltage_col', 
>>>     current='current_col', 
>>>     length=100e-6, 
>>>     width=300e-6, 
>>>     thickness=11e-6
>>> )
Source code in src/quantalyze/transport.py
 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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
def calculate_resistivity(df, length=None, width=None, thickness=None, resistance=None, voltage=None, current=None, geometric_factor=None, gain=None) -> pd.Series:
    """
    Calculate the electrical resistivity using either resistance or voltage and current, along with length, width, and thickness,
    or a provided geometric factor.

    Args:
        df (pandas.DataFrame): The dataframe containing the data.
        resistance (str, optional): The name of the column in the dataframe that contains the resistance values.
        voltage (str, optional): The name of the column in the dataframe that contains the voltage values.
        current (str or float, optional): The name of the column in the dataframe that contains the current values if it's a string,
            or a constant current value if it's a float.
        length (float, optional): The length of the material.
        width (float, optional): The width of the material.
        thickness (float, optional): The thickness of the material.
        geometric_factor (float, optional): The pre-calculated geometric factor (width * thickness / length).
        gain (str or float, optional): The name of the column in the dataframe that contains the gain values if it's a string,
            or a constant gain value if it's a float. Defaults to None.

    Returns:
        pandas.Series: A series containing the calculated resistivity values.

    Raises:
        ValueError: If neither resistance nor both voltage and current are provided.
        ValueError: If both resistance and voltage are provided.
        ValueError: If neither geometric_factor nor all of length, width, and thickness are provided.
        ValueError: If resistance is supplied along with a gain.

    Examples:
        >>> import quantalize as qz
        >>> df['resistivity'] = qz.calculate_resistivity(
        >>>     df, 
        >>>     resistance='resistance_col', 
        >>>     voltage='voltage_col', 
        >>>     current='current_col', 
        >>>     length=100e-6, 
        >>>     width=300e-6, 
        >>>     thickness=11e-6
        >>> )
    """
    if resistance is not None and voltage is not None:
        raise ValueError("Only one of resistance or voltage can be provided, not both.")

    if resistance is None:
        if voltage is not None and current is not None:
            resistance = calculate_resistance(df, voltage, current, gain=gain)
        else:
            raise ValueError("Either resistance or both voltage and current must be provided.")
    else:
        if gain is not None:
            raise ValueError("Gain cannot be applied when resistance is directly supplied.")
        resistance = df[resistance]

    if geometric_factor is None:
        if length is not None and width is not None and thickness is not None:
            geometric_factor = (width * thickness) / length
        else:
            raise ValueError("Either geometric_factor or all of length, width, and thickness must be provided.")

    resistivity = resistance * geometric_factor
    return resistivity