Python API
oersted
Python bindings for oersted
BHCurve
dataclass
B-H curve for a nonlinear magnetic material
Source code in src/oersted/materials.py
11 12 13 14 15 16 17 18 19 20 21 | |
lookup
lookup(h: float) -> float
Linearly interpolate from the B-H curve
Source code in src/oersted/materials.py
18 19 20 21 | |
FreeSpace
dataclass
Bases: Material
Source code in src/oersted/materials.py
38 39 40 41 42 | |
mu_r
mu_r(h: float) -> float
Free space (vacuum) has a relative permeability of exactly 1.0
Source code in src/oersted/materials.py
40 41 42 | |
LinearMaterial
dataclass
Bases: Material
A linear magnetic material that has a constant mu_r for all values of applied H-field.
Source code in src/oersted/materials.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
mu_r
mu_r(h: float)
Return the relative magnetic permeability
Source code in src/oersted/materials.py
56 57 58 | |
to_mh_curve
to_mh_curve() -> tuple[NDArray[float64], NDArray[float64]]
Convert the B-H curve to an M-H curve, which is more convenient for magnetization calculations
Source code in src/oersted/materials.py
60 61 62 63 64 65 | |
Mesh
A continuous finite element mesh made of tet4 elements
Source code in src/oersted/mesh.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 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 146 147 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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
centroids
property
centroids: NDArray[float64]
Returns an (N,3) array of all element centroids in the mesh
connectivity
property
connectivity: NDArray[uint32]
Returns an (N,4) array of the node numbers associated with each element
Node numbers are indices into the self._nodes array
edges
property
edges
Returns an (N,2) array of edges in the model
Each value in the array is a node number associated with that edge. The first node is the start node, the second is the end node. This provides directionality for the edge.
faces
property
faces
Returns an (N,3) array of nodes associated with each element face in the model
Nodes are ordered such that the right hand rule forms the face normal.
nodes
property
writable
nodes: NDArray[float64]
Returns an (N,3) array of nodal coordinates in the mesh
num_elems
property
num_elems: int
Returns the number of elements in the model
num_nodes
property
num_nodes: int
Returns the number of nodes in the model
surface
property
surface: SurfaceMesh
Return the surface mesh associated with the volumetric mesh
volumes
property
volumes: NDArray[float64]
Return an (N,) array of the volume of each element in the mesh
append
append(mesh: Mesh) -> Mesh
Convenience function for appending two meshes together.
Source code in src/oersted/mesh.py
245 246 247 248 249 250 251 252 | |
from_step
classmethod
from_step(
filename: str | Path,
mesh_size: float,
mesh_size_scale: float = 1000.0,
part_size_scale: float = 0.001,
) -> Mesh
Create a Mesh from a step file
Note
oersted needs mesh dimensions in meters, but gmsh typically works in mm.
This function scales the input mesh size up to be in mm, and scales the
gmsh resultant down to be in m. Adjust these parameters if the mesh isn't
working properly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str | Path
|
STEP file to mesh |
required |
mesh_size
|
float
|
(m) nominal element size to use for the mesh |
required |
mesh_size_scale
|
float
|
(mm/m) adjust if the model units are in mm and not m |
1000.0
|
part_size_scale
|
float
|
(m/mm) adjust if the mesh units are in mm and not m |
0.001
|
Returns:
| Type | Description |
|---|---|
Mesh
|
volumetric tet4 mesh of the STEP file |
Source code in src/oersted/mesh.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
plot
plot(filename: str | None = None)
Convenience function for plotting just the mesh itself
Source code in src/oersted/mesh.py
209 210 211 | |
NonlinearMaterial
dataclass
Bases: Material
A nonlinear magnetic material that has a B-H curve
Source code in src/oersted/materials.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
mu_r
mu_r(h: float) -> float
Return the relative magnetic permeability at a given H-field strength
Source code in src/oersted/materials.py
77 78 79 80 81 82 83 84 | |
to_mh_curve
to_mh_curve() -> tuple[NDArray[float64], NDArray[float64]]
Convert the B-H curve to an M-H curve, which is more convenient for magnetization calculations
Source code in src/oersted/materials.py
86 87 88 89 | |
SolverSettings
dataclass
Define settings to use during a solve
Attributes:
| Name | Type | Description |
|---|---|---|
method |
Method
|
use either "direct" O(N^2) or "octree" O(N log(N)) integration for Biot-Savart law integration |
integration |
Integration
|
use either "element" for full integration (high accuracy, slow) or "point" for a point-source approximation (low accuracy near the source, but ~40x faster) |
n_threads |
int
|
number of cpu threads to use for solution; default is 0 for all available |
theta |
float
|
the Barnes-Hut angle-opening criteria (theta >= 0.0) |
near_field_ratio |
float
|
(deprecated) ratio of target distance to source element size; defines the 'mid-field' during a barnes-hut solve (alpha >= 0.0) |
max_leaf_size |
int
|
defines the maximum leaf size before splitting in the octree (>=1) |
batch_size |
int
|
defines the number of target points to process at a time (for Barnes-Hut solves)) |
multipole_order |
MultipoleOrder
|
defines the multipole expansion order for Barnes-Hut solves; currently supported are "monopole" and "dipole" |
max_iterations |
int
|
maximum number of iterations before solution returns early |
atol |
float
|
absolute tolerance for convergence criteria |
under_relaxation_factor |
float
|
provides solution stability for fixed-point iteration |
Source code in src/oersted/solver.py
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 | |
a_field
a_field(
src_mesh: Mesh,
targets: NDArray[float64],
*,
jdensity: NDArray[float64] | None = None,
magnetization: NDArray[float64] | None = None,
settings: SolverSettings = DEFAULT_SETTINGS,
) -> NDArray[float64]
Compute the magnetic vector potential (A field) at a collection of target points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_mesh
|
Mesh
|
mesh to use as the field source |
required |
targets
|
NDArray[float64]
|
(m) (N,3) array of target point positions in 3D space |
required |
jdensity
|
NDArray[float64] | None
|
(A/m^2) (N,3) array of current density vectors at each of the source element centroids |
None
|
magnetization
|
NDArray[float64] | None
|
(A/m) (N,3) array of magnetization vectors at each of the source element centroids |
None
|
settings
|
SolverSettings
|
selects the solution settings |
DEFAULT_SETTINGS
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(T-m) (N,3) array of magnetic vector potential (A) vectors at each target position |
Source code in src/oersted/biotsavart.py
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 146 147 148 149 | |
b_field
b_field(
src_mesh: Mesh,
targets: NDArray[float64],
*,
jdensity: NDArray[float64] | None = None,
magnetization: NDArray[float64] | None = None,
settings: SolverSettings = DEFAULT_SETTINGS,
) -> NDArray[float64]
Compute the magnetic flux density (B field) at a collection of target points, assuming the target points are in free space
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_mesh
|
Mesh
|
mesh to use as the field source |
required |
targets
|
NDArray[float64]
|
(m) (N,3) array of target point positions in 3D space |
required |
jdensity
|
NDArray[float64] | None
|
(A/m^2) (N,3) array of current density vectors at each of the source element centroids |
None
|
magnetization
|
NDArray[float64] | None
|
(A/m) (N,3) array of magnetization vectors at each of the source element centroids |
None
|
settings
|
SolverSettings
|
selects the solution settings |
DEFAULT_SETTINGS
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(T) (N,3) array of magnetic flux density (B) vectors at each target position |
Source code in src/oersted/biotsavart.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
bz_finite_length_solenoid
bz_finite_length_solenoid(
jmag: float,
length: float,
r: float,
dr: float,
z: float,
) -> float
Compute the magnetic field on the axis of a finite-length solenoid
This function assumes that the solenoid dr dimension is small relative to the
radius and thickness, and does not correct for finite radial thickness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jmag
|
float
|
(A/m2) magnitude of current density in the solenoid |
required |
length
|
float
|
(m) length of the solenoid |
required |
r
|
float
|
(m) representative radius of the solenoid |
required |
dr
|
float
|
(m) thickness of the solenoid cross section |
required |
z
|
float
|
(m) position along the axis of the solenoid at which the field should be calculated |
required |
Returns:
| Type | Description |
|---|---|
float
|
(T) axial magnetic field |
Reference
https://en.wikipedia.org/wiki/Solenoid#Finite_continuous_solenoid (with modifications for current density and finite thickness)
Source code in src/oersted/testing.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
bz_loop_axis
bz_loop_axis(
current: float, radius: float, z: float
) -> float
Compute the vertical field Bz at the center of a current-carrying loop
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
float
|
(A) total electrical current in the loop |
required |
radius
|
float
|
(m) centerline radius of the loop |
required |
z
|
float
|
(m) height of the target point along the loop axis |
required |
Returns:
| Type | Description |
|---|---|
float
|
(T) magnetic flux density, oriented along the loop axis |
Source code in src/oersted/testing.py
225 226 227 228 229 230 231 232 233 234 235 236 | |
curl
curl(
fx: NDArray[float64],
fy: NDArray[float64],
fz: NDArray[float64],
spacing: tuple[float, float, float],
) -> tuple[
NDArray[float64], NDArray[float64], NDArray[float64]
]
Compute the curl of a vector-value function in 3D space on a uniform grid
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fx
|
NDArray[float64]
|
shape (nx, ny, nz) value of function in x-direction at all points in 3d grid |
required |
fy
|
NDArray[float64]
|
shape (nx, ny, nz) value of function in y-direction at all points in 3d grid |
required |
fz
|
NDArray[float64]
|
shape (nx, ny, nz) value of function in z-direction at all points in 3d grid |
required |
spacing
|
tuple[float, float, float]
|
(dx, dy, dz) step size in each direction |
required |
Returns:
| Type | Description |
|---|---|
tuple[NDArray[float64], NDArray[float64], NDArray[float64]]
|
curl_x, curl_y, curl_z: each shape (nx, ny, nz) |
Source code in src/oersted/testing.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
dbzdz_loop_axis
dbzdz_loop_axis(
current: float, radius: float, z: float
) -> float
Compute the vertical field gradient dBz/dz at the center of a current-carrying loop
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
float
|
(A) total electrical current in the loop |
required |
radius
|
float
|
(m) centerline radius of the loop |
required |
z
|
float
|
(m) height of the target point along the loop axis |
required |
Returns:
| Type | Description |
|---|---|
float
|
(T/m) magnetic flux density gradient, oriented along the loop axis |
Source code in src/oersted/testing.py
239 240 241 242 243 244 245 246 247 248 249 250 251 | |
demag_solve
demag_solve(
mesh: Mesh,
material: Material,
h_external: NDArray[float64],
settings: SolverSettings,
) -> tuple[NDArray[float64], NDArray[float64]]
Compute magnetization field M and the total H field at element centroids, given a background field
Uses simple fixed-point iteration and therefore only converges for low-permeable materials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
finite element mesh on which to evaluate the demagnetizing field |
required |
material
|
Material
|
linear or nonlinear magnetic maaterial properties |
required |
h_external
|
NDArray[float64]
|
(A/m) an (Ne,3) array of external field at each element centroid |
required |
solver
|
solution parameters for the problem, including iteration method |
required |
Returns:
| Type | Description |
|---|---|
(M, Htotal)
|
each (Ne, 3), magnetization field M(Htotal) and total H field |
NDArray[float64]
|
at element centroids. These can be summed to give B = mu0 * (Htotal + M). |
Source code in src/oersted/magnetization.py
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 | |
h_field
h_field(
src_mesh: Mesh,
targets: NDArray[float64],
*,
jdensity: NDArray[float64] | None = None,
magnetization: NDArray[float64] | None = None,
settings: SolverSettings = DEFAULT_SETTINGS,
) -> NDArray[float64]
Compute the magnetic field strength (H field) at a collection of target points
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_mesh
|
Mesh
|
mesh to use as the field source |
required |
targets
|
NDArray[float64]
|
(m) (N,3) array of target point positions in 3D space |
required |
jdensity
|
NDArray[float64] | None
|
(A/m^2) (N,3) array of current density vectors at each of the source element centroids |
None
|
magnetization
|
NDArray[float64] | None
|
(A/m) (N,3) array of magnetization vectors at each of the source element centroids |
None
|
settings
|
SolverSettings
|
selects the solution settings |
DEFAULT_SETTINGS
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(A/m) (N,3) array of magnetic field strength (H) vectors at each target position |
Source code in src/oersted/biotsavart.py
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 | |
kelvin_force_density
kelvin_force_density(
mesh: Mesh,
m_field_centroids: NDArray[float64],
b_field_nodes: NDArray[float64],
) -> NDArray[float64]
Compute the Kelvin force density acting on a magnetized mesh.
Note
The h_field must be calculated at the element nodes, while the magnetization field must be known at the centroids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
the mesh on which to evaluate the forces |
required |
m_field_centroids
|
NDArray[float64]
|
(A/m) the magnetization field (M field), evaluated at the centroids of the elements in the mesh |
required |
b_field_nodes
|
NDArray[float64]
|
(T) the magnetic flux density, evaluated at the nodes within the mesh |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(N/m^3) an (N,3) array of the force density vector acting on each element centroid |
Source code in src/oersted/results.py
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 | |
kelvin_forces
kelvin_forces(
mesh: Mesh,
m_field_centroids: NDArray[float64],
b_field_nodes: NDArray[float64],
) -> NDArray[float64]
Compute the Kelvin forces acting on a magnetized mesh.
Note
The h_field must be calculated at the element nodes, while the magnetization field must be known at the centroids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
the mesh on which to evaluate the forces |
required |
m_field_centroids
|
NDArray[float64]
|
(A/m) the magnetization field (M field), evaluated at the centroids of the elements in the mesh |
required |
b_field_nodes
|
NDArray[float64]
|
(T) the magnetic flux density, evaluated at the nodes within the mesh |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(N) an (N,3) array of the force vector acting on each element centroid |
Source code in src/oersted/results.py
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 | |
lorentz_force_density
lorentz_force_density(
j_density: NDArray[float64], b_field: NDArray[float64]
) -> NDArray[float64]
Compute the Lorentz forces acting on a mesh
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
j_density
|
NDArray[float64]
|
(A/m^2) an (N,3) array containing the current density vector at every element |
required |
b_field
|
NDArray[float64]
|
(T) an (N,3) array containing the magnetic flux density vector at every element |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(N/m^3) an (N,3) array of the force density vectors acting on the mesh at every element |
Source code in src/oersted/results.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
lorentz_forces
lorentz_forces(
mesh: Mesh,
j_density: NDArray[float64],
b_field: NDArray[float64],
total: bool = False,
) -> NDArray[float64]
Compute the Lorentz forces acting on a mesh
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
the finite element mesh on which the fields and forces are calculated |
required |
j_density
|
NDArray[float64]
|
(A/m^2) an (N,3) array containing the current density vector at every element |
required |
b_field
|
NDArray[float64]
|
(T) an (N,3) array containing the magnetic flux density vector at every element |
required |
total
|
bool
|
if true, return only the total force (default: false) |
False
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(N) an (N,3) array of the force vectors acting on the mesh at every element |
Source code in src/oersted/results.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
make_helmholtz
make_helmholtz(
filename: str | Path,
size: float,
jmag: None | float = None,
scale: float = 0.001,
) -> tuple[Mesh, NDArray[float64]]
Make the helmholtz coil test problem
The geometry of the problem is defined as:
- Two circular coils of radius R=0.2m
- Distance between the coils is d=0.2m
- Coils are aligned with the z-axis and symmetric about the xy plane
- Currents in the currents are flowing in the same direction
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str | Path
|
STEP file containing the geometry of a single loop in the Helmholtz pair |
required |
size
|
float
|
(m) mesh size |
required |
jmag
|
None | float
|
(A/m^2) magnitude of current density in each loop |
None
|
scale
|
float
|
(mm/m) scale factor for meshing |
0.001
|
Returns:
| Type | Description |
|---|---|
tuple[Mesh, NDArray[float64]]
|
(mesh, current density) the volumetric mesh and current density vectors of the Helmholtz coil pair |
Source code in src/oersted/testing.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 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 | |
make_ring
make_ring(
mesh_size: float = 0.015, jmag: float = 100000000.0
) -> tuple[Mesh, NDArray[float64]]
Make a mesh of a current-carrying ring for testing
Source code in src/oersted/testing.py
180 181 182 183 184 185 186 187 188 189 190 191 | |
max_verr
max_verr(
measurement: NDArray[float64],
baseline: NDArray[float64],
eps: float = 1e-06,
) -> float
Compute max relative vector error, with the denominator bounded by eps to
prevent divide by zero issues
Source code in src/oersted/testing.py
38 39 40 41 42 43 44 45 | |
maxwell_forces
maxwell_forces(
mesh: SurfaceMesh, b_field: NDArray[float64]
) -> NDArray[float64]
Compute the maxwell stress tensor and determine the force vector acting on each surface face centroid. Returns an (N,3) array of the force vector
Warning
This form of the Maxwell stress tensor is numerically unstable, especially in the presence of large background fields. Perform a mesh convergence study to identify an appropriate mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
SurfaceMesh
|
a surface mesh on which to integrate the Maxwell stress tensor |
required |
b_field
|
NDArray[float64]
|
(T) magnetic flux density evaluated at each of the centroids of the surface mesh elements |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(N) an (N,3) array of the force acting on each of the surface mesh centroids |
Source code in src/oersted/results.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
mean_verr
mean_verr(
measurement: NDArray[float64],
baseline: NDArray[float64],
eps: float = 1e-06,
) -> float
Compute mean relative vector error, with the denominator bounded by eps to
prevent divide by zero issues
Source code in src/oersted/testing.py
28 29 30 31 32 33 34 35 | |
mesh_step
mesh_step(
infile: str,
max_size: float,
min_size: float = 0.0,
scale: float = 0.001,
) -> Mesh
Mesh a step file using gmsh
Note
This requires gmsh to be installed: pip install gmsh
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
infile
|
str
|
path to the STEP file to mesh |
required |
max_size
|
float
|
(m) maximum allowable element size |
required |
min_size
|
float
|
(m) minimum allowable element size |
0.0
|
scale
|
float
|
(mm/m) adjust if the part or mesh is scaled incorrectly |
0.001
|
Returns:
| Type | Description |
|---|---|
Mesh
|
a tet4 (volumetric) mesh of the component |
Source code in src/oersted/mesh.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
plot_mesh
plot_mesh(
mesh: Mesh,
filename: str | None = None,
scalars: NDArray[float64] | None = None,
centroids: NDArray[float64] | None = None,
vectors: NDArray[float64] | None = None,
vector_scale: float | None = None,
transparency: bool = False,
)
Make a 3D plot of the mesh
Note
This function requires pyvista: pip install pyvista.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
the tet4 mesh to plot |
required |
filename
|
str | None
|
if this argument is passed, save to file only |
None
|
scalars
|
NDArray[float64] | None
|
(Ne,) array of scalar values to color the mesh, defined at element centroids |
None
|
centroids
|
NDArray[float64] | None
|
(N,3) array of vector positions for plotting vector values on the mesh |
None
|
vectors
|
NDArray[float64] | None
|
(N,3) array of vector magnitudes for plotting vector values on the
mesh; must be same length as |
None
|
vector_scale
|
float | None
|
adjust for setting vector length |
None
|
transparency
|
bool
|
set to |
False
|
Source code in src/oersted/mesh.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
smape
smape(
baseline: NDArray[float64],
measurement: NDArray[float64],
) -> float
Compute the symmetric mean absolute percentage error of measurement
against baseline
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
baseline
|
NDArray[float64]
|
an (N,) array of data values to compute error against |
required |
measurement
|
NDArray[float64]
|
an (N,) array of data values of which to compute error |
required |
Returns:
| Type | Description |
|---|---|
float
|
error associated with this comparison |
Source code in src/oersted/testing.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
uniform_3d_grid
uniform_3d_grid(
xrange: tuple[float, float],
yrange: tuple[float, float],
zrange: tuple[float, float],
n: tuple[int, int, int],
) -> tuple[NDArray[float64], tuple[float, float, float]]
Create a uniform 3D grid
Args xrange: (xmin, xmax) yrange: (ymin, ymax) zrange: (zmin, zmax) n: (nx, ny, nz)
Returns:
| Name | Type | Description |
|---|---|---|
pts |
NDArray[float64]
|
shape (nxnynz,3), locations of points in 3d space |
(dx, dy, dz)
|
length increment along each axis |
Source code in src/oersted/testing.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
verr
verr(
measurement: NDArray[float64],
baseline: NDArray[float64],
eps: float = 1e-06,
) -> NDArray[float64]
Compute simple relative vector error, with the denominator bounded by eps to
prevent divide by zero issues
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
element-wise error at each output point |
Source code in src/oersted/testing.py
13 14 15 16 17 18 19 20 21 22 23 24 25 | |