Skip to main content

Magnetostatic solver

Project description

OpenMagnets

OpenMagnets is a magnetostatic solver with a Python API and a native Fortran core.

public API

  • SurfaceMesh
  • TetraMesh
  • Material
  • Problem
  • SolveResult
  • load_obj(...)
  • has_native()
  • backend_info()
  • reload_backend()
  • require_backend()

install

pip install openmagnets

source build

  • Python 3.11+
  • gfortran
  • ninja
  • build isolation support through pip

rebuild from source

python scripts/build_native.py

quick start

from openmagnets import Material, Problem, load_obj

surface = load_obj("part.obj")

mesh = surface.voxel_tetrahedralize(
    padding=0.01,
    resolution=(12, 12, 12),
    inside_region_id=10,
    outside_region_id=0,
    region_names={
        0: "air",
        10: "magnet",
    },
)

problem = Problem(
    mesh=mesh,
    materials={
        0: Material(name="air", mu_r=1.0),
        10: Material(name="magnet", mu_r=1.05, magnetization=[0.0, 0.0, 8.0e5]),
    },
)

result = problem.solve()
print(result.cell_B.shape)

gradients

SolveResult reconstructs the cell centered gradients

cell_grad_B = result.cell_grad_B
cell_grad_H = result.cell_grad_H

print(cell_grad_B.shape)  
print(result.sample_grad_B([[0.0, 0.0, 0.0]], outside="nearest")[0])

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

openmagnets-0.1.1.tar.gz (22.9 kB view details)

Uploaded Source

File details

Details for the file openmagnets-0.1.1.tar.gz.

File metadata

  • Download URL: openmagnets-0.1.1.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for openmagnets-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ced10a0583c7fe0d1c09c2b2d150ab0a19d4b5013291e4fac7969c1402b41f7d
MD5 b8598275b377dcf53caf538d42eb87c1
BLAKE2b-256 66933589cf915d63e1ec89960b57d29b08c74ce2909576b231425b0a4d568d1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for openmagnets-0.1.1.tar.gz:

Publisher: publish.yml on CoolPhys/openmagnets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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