Skip to main content

Overview

This script performs passive magnetic shimming to improve the homogeneity of a magnetic field. Below is a breakdown of the code:

1. Reading Magnetic Field Data

  • The script loads magnetic field data from a .npy file.
  • Converts the field and position data into meters and filters the data within a defined spherical region (DSV - Diameter Spherical Volume).
  • The magnetic field data is visualized in 3D scatter plots.

2. Defining Shim Geometry

  • Specifies the geometry of the shim array, including magnet dimensions, diameter, and magnetization.
  • Creates shim ring templates using the make_shim_ring_template function.
  • Saves the initial shim tray arrangement as an STL file for visualization.

3. Field Computation

  • Computes the magnetic field generated by the shim tray template.
  • Visualizes the computed field and its combination with the measured field.

4. Optimization for Homogeneity

  • Defines an optimization problem using the shimming_problem function to minimize field inhomogeneity.
  • Uses the MixedVariableGA algorithm from the pymoo library to solve the optimization problem.
  • Outputs the optimized shim tray configuration.

5. Generating Optimized Shim Tray

  • Creates an optimized shim tray based on the optimization results.
  • Saves the optimized shim tray as an STL file and visualizes the shimmed magnetic field.

6. Saving and Loading Shim Tray

  • Saves the optimized shim tray configuration to a .pkl file.
  • Demonstrates how to reload and visualize the saved shim tray.

Key Functions and Libraries

  • magpylib: Used for magnetic field computations and visualization.
  • pymoo: Provides optimization algorithms for solving the shimming problem.
  • Custom Functions:
    • get_field_pos, filter_dsv: Process and filter magnetic field data.
    • make_shim_ring_template: Creates shim tray templates.
    • cost_fn: Evaluates the field homogeneity.
    • write2stl: Exports shim tray configurations to STL files.

Outputs

  • Visualizations of the magnetic field before and after shimming.
  • STL files for initial and optimized shim tray configurations.
  • A .pkl file containing the optimized shim tray for future use.

This script automates the process of designing and optimizing passive shim trays for magnetic field correction.

Download files

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

Source Distribution

passive_shimming-0.0.1.tar.gz (59.1 kB view details)

Uploaded Source

Built Distribution

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

passive_shimming-0.0.1-py3-none-any.whl (61.3 kB view details)

Uploaded Python 3

File details

Details for the file passive_shimming-0.0.1.tar.gz.

File metadata

  • Download URL: passive_shimming-0.0.1.tar.gz
  • Upload date:
  • Size: 59.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.9

File hashes

Hashes for passive_shimming-0.0.1.tar.gz
Algorithm Hash digest
SHA256 adf8bc9d740c27b516e7791baab3b1c511a3f169a0d946531d0f042cb1e56574
MD5 fba291072782d4e830c53f463d3696f0
BLAKE2b-256 18ed548c442e71ed2936b98a20c7313b871599dd1f13d90c801703da5528f68b

See more details on using hashes here.

File details

Details for the file passive_shimming-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for passive_shimming-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4af77e4e4eea331ec1e8abe2550508163b5af66745dcd4023b2534a02d5b9c49
MD5 41b927215b1128a2eb8265a154db69e5
BLAKE2b-256 b232644dea0aacefa563cb6b61fdc17e9202635c1c023ada903166e72a5d8c45

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page