Skip to content

henry2004y/Magnetostatics.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magnetostatics.jl

Dev Coverage Aqua License: MIT

A Julia package for computing magnetostatic fields from current sources or potentials.

Overview

Magnetostatics.jl provides solvers and analytical models for computing magnetic fields produced by steady-state current distributions or potentials. The package includes:

  • Biot-Savart solver — numerical integration of the Biot-Savart law for arbitrary wire geometries.
  • FFT solver — spectral method for computing B from a volumetric current density J on a uniform grid with periodic boundaries.
  • Vector Potential solver — computes the magnetic vector potential A for wires, current loops, and dipoles.
  • Magnetosphere models — planetary dipoles, magnetopause shielding, magnetotail, and interplanetary magnetic field (IMF) components.
  • Tokamaks — analytical magnetic field models for toroidal/poloidal coils, central solenoids, and q-profile based configurations.
  • Analytical fields — closed-form models for Harris current sheets (asymmetric, force-free), magnetic dipoles, mirrors, pinches, and circular current loops.

Installation

To install Magnetostatics.jl, run the following command in the Julia REPL:

using Pkg
Pkg.add("Magnetostatics")

Quick Start

using Magnetostatics

# Create a circular current loop and discretize it into wire segments
loop = CurrentLoop(1.0, 1.0, [0.0, 0.0, 0.0], [0.0, 0.0, 1.0])
wire = discretize_loop(loop, 100)

# Compute B at a point using the Biot-Savart solver
B = solve(BiotSavart(), wire, [0.0, 0.0, 0.5])

# Compare with the analytical solution
B_exact = getB_loop([0.0, 0.0, 0.5], loop)

Documentation

For more detailed information on the API and usage, please refer to the documentation.

About

Computing magnetostatic fields from current sources in Julia

Resources

License

Stars

6 stars

Watchers

0 watching

Forks

Contributors

Languages