Architecture and Source Map

This page is the shortest path from the public API to the underlying analytical kernels.

Layered structure

The repository is organized in layers.

Public API layer

This layer handles:

  • object construction,

  • compatibility-oriented getB/getH/getJ/getM behavior,

  • source/sensor formatting,

  • path and orientation semantics,

  • pixel aggregation,

  • squeeze and broadcasting behavior.

Object base layer

This layer handles:

  • shared object state,

  • path mutation semantics,

  • orientation storage and caching,

  • validation of constructor and motion inputs,

  • lightweight style compatibility.

Geometry and kernel layer

This is where the actual field formulas live.

Source wrappers

Current-driven sources:

Magnet sources:

Miscellaneous sources:

How getB flows through the code

A typical high-level getB call follows this path:

  1. Validate inputs and normalize source/sensor descriptors.

  2. Prepare source tensors and sensor tensors, reusing caches where possible.

  3. Group homogeneous source families for efficient batched evaluation.

  4. Call the matching analytical kernel.

  5. Rotate the resulting field back to the global frame.

  6. Apply sensor aggregation and Magpylib-compatible squeeze behavior.

The orchestration lives in functional.py.

Where to profile

If the issue is: