Skip to main content

Lightning-fast magnetic fields calculations

Project description

oersted

Lightning-fast magnetic fields calculations

Documentation | Rust API

Timing Results

Installation

oersted can be installed via pypi:

pip install oersted

or from crates.io:

cargo add oersted

Example

import oersted 

# Mesh the part 
mesh_size = 10e-3 # (m)
mesh = oersted.Mesh.from_step("my_part.stp", mesh_size)

# Compute the current density on the part 
j_density: NDArray[float64] = ... 

# Compute self-fields using the 'fast' solver
solver = oersted.OctreeSolver()
B = oersted.b_field(mesh, j_density, mesh.centroids, solver=solver)

# Compute forces from self-fields 
F = oersted.lorentz_forces(mesh, j_density, B)

Features

This library provides Barnes-Hut-accelerated volume integral methods for computing magnetic fields generated by current-carrying solid conductors and magnetic materials:

  • Methods for meshing STEP files (via gmsh)
  • Analytic Biot-Savart integrals for current-carrying and magnetized tetrahedrons
  • A 'point' finite element source, which is orders of magnitude faster and highly accurate for far-field and force calculations
  • Barnes-Hut/octree methods for reducing the time complexity of Biot-Savart law integration from O(N^2) to near-linear, allowing the solution of multi-million element models in seconds on a laptop
  • A basic iterative solver for isotropic linear materials (mu_r < 20.0)
  • Force calculations using the Maxwell stress tensor (surface-based), Kelvin, or Lorentz (volumetric) formulations

Roadmap

This project is under active development and will be changing quite a bit on its way to a stable 1.0.0 release:

  • v0.1.0
    • Octree acceleration for both analytic and point approximations of finite element sources
  • v0.2.0
    • Dramatic simplification of the library and internal/external API's
    • Finite element meshing and force calculations
  • v0.3.0
    • Solid angle calculations to replace the edge-integral formulations for fields from 3D elements (2-4x speed improvement)
    • Convert octree methods from recursive to interaction lists (2-5x speed improvement)
  • v0.4.0
    • BH curves for nonlinear magnetic materials
    • GMRES iterative solver for high-permeability materials
  • v0.5.0
    • Multi-mesh/body/component/material models
  • v0.6.0
    • Steady-state conduction solver
  • v0.7.0
    • Eddy current solver for time-domain problems
  • v0.8.0
    • Eddy current solver for frequency-domain problems
  • v0.9.0
    • 3D GUI (e.g. integrated with ONELAB)

Background

The Biot-Savart Law is widely used to calculate the magnetic fields of electromagnets by summing the contributions of many small magnetic field sources at a large number of target points. This calculation, in its simplest form, has time complexity of O(M x N), where M is the number of source points and N is the number of target points.

Barnes-Hut Algorithm

This code applies the Barnes Hut algorithm for large-N interaction problems to achieve linear time complexity of the same calculation while maintaining reasonable (<1%) error relative to the full ("direct") calculation.

This library uses an octree, which is a tree structure that divides the problem space recursively into 8 octants. Each octant hosts a collection of source points, which are summed together at each node. If the distance between the node and a target point is far enough away such that treating the many source points within the node as one large "super source", the node is 'accepted' and an approximate calculation is performed. If the node is too close, then it is recursively subdivided and the same acceptance criteria is applied again. In practice, an acceptance criteria of phi = node_size/distance = 0.5 has been found to be effective for self-fields problems.

See https://jheer.github.io/barnes-hut/ for an excellent demo of the algorithm applied to gravitational problems.

Intended Problems

The intended problem for this code is a finite element mesh of a solenoidal collection of current-carrying 3D bodies. The magnetic field generated by these currents can either be computed on the bodies themselves (self-field) or at a collection of points not on the bodies. Each element is treated as a component of a finite sum approximation to the Biot Savart integral.

Problem sizes typically solved on a workstation computer (i.e. finite element meshes of <10M elements) are considered for testing of this code.

Contributing

Please contact the author prior to making a pull request.

License

MIT or Apache 2.0, at your option.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oersted-0.3.0.tar.gz (1.6 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

oersted-0.3.0-cp310-abi3-win_amd64.whl (332.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

oersted-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

oersted-0.3.0-cp310-abi3-macosx_11_0_arm64.whl (403.3 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

oersted-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl (426.6 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file oersted-0.3.0.tar.gz.

File metadata

  • Download URL: oersted-0.3.0.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oersted-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3a1def0f0fcc1aefcc0fb080bdde6a7435b23f724c1f30c78b8c9feb2a961d5f
MD5 8ac4caf6a63742fc67d41cef99f74290
BLAKE2b-256 af2fd5b1a51184d1722b81558991b10ab577c0a9437e86e55367c2520fca5c60

See more details on using hashes here.

File details

Details for the file oersted-0.3.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: oersted-0.3.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 332.6 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oersted-0.3.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b9043832e06cec8cb9ad5b8d9d7193b09dc3eb0694a7cf67e3a3cd631460520c
MD5 f9d52fb5743e6d94c0910de7455f2b3a
BLAKE2b-256 e09097078e226678885208b0f176cd4ad16f9931f332f1d3102d9830446450d9

See more details on using hashes here.

File details

Details for the file oersted-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: oersted-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oersted-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea61147b84a6c754c334f2f6aee00070f5964b68bd6b5e92898ddecf3c40e239
MD5 3d14b67f4f4a62b57a2ec5fff5ce83ce
BLAKE2b-256 d732d98ab12cc3c716aa6ceaf9151df0dfd2e7df4b7033234a64712348ee57c4

See more details on using hashes here.

File details

Details for the file oersted-0.3.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: oersted-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 403.3 kB
  • Tags: CPython 3.10+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oersted-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a1836e50d5e9851fd032343cda906298ea991a38a52569d548aa7efb9d57d36
MD5 6bea4688a910b20f42a91e8cdb29d513
BLAKE2b-256 017037c3d3652b3b3a9829ddb3f43ade9ebe107097c89b6378fd8e382a2c8a30

See more details on using hashes here.

File details

Details for the file oersted-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: oersted-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 426.6 kB
  • Tags: CPython 3.10+, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for oersted-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 06a910a0c088344989aafe7ebc40ad2177576600548e78bc39eb999263ecfb78
MD5 5c539d91d2c6a842e51ea48cb7b7dc34
BLAKE2b-256 56af1fedf2ccdb5cf54a13a19288bba3bbbe613a55e7847c50ea2bd2c8e993f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page