Skip to content

feat: implement magnetic dipole field calculation#3

Draft
majockbim wants to merge 3 commits into
mainfrom
feat/dipole-field
Draft

feat: implement magnetic dipole field calculation#3
majockbim wants to merge 3 commits into
mainfrom
feat/dipole-field

Conversation

@majockbim

Copy link
Copy Markdown
Owner

Summary

This PR implements the foundational physics layer for magnetic field simulation by adding the dipole field calculation function. This is a prerequisite for grid iteration and field line tracing.

Changes

See (#2)

Physics Implementation

The field $\mathbf{B}$ is calculated as:
$$\mathbf{B}(\mathbf{r}) = \frac{\mu_0}{4\pi} \cdot \frac{1}{r^3} [3(\mathbf{m} \cdot \hat{\mathbf{r}})\hat{\mathbf{r}} - \mathbf{m}]$$
where $r = r_{obs} - r_{dipole}$.

Verification Results

Automated Tests (GTest)

  • Point Singularity: Returns zero vector when $r_{obs} = r_{dipole}$.
  • On-Axis Accuracy: Field direction aligns with the dipole axis for points along the axis of $\mathbf{m}$.
  • Inverse-Cube Law: Verified that $|\mathbf{B}|$ scales with $\frac 1{r^3}$ across varying distances.
  • Superposition: Confirmed that the total field from two dipoles equals the vector sum of their individual fields.

Constraints

  • Observation points within 1e-9 units of a dipole are treated as being at the dipole center to avoid numerical instability.

@majockbim majockbim linked an issue Jun 8, 2026 that may be closed by this pull request
8 tasks
@majockbim majockbim self-assigned this Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Implement Magnetic Dipole Field Function

1 participant