Skip to content

Fix #357: Msat=0 affects exchange#372

Merged
JonathanMaes merged 6 commits into3.11.1from
bugfix/MsatZeroExchange
Jun 17, 2025
Merged

Fix #357: Msat=0 affects exchange#372
JonathanMaes merged 6 commits into3.11.1from
bugfix/MsatZeroExchange

Conversation

@JonathanMaes
Copy link
Copy Markdown
Contributor

@JonathanMaes JonathanMaes commented Jun 17, 2025

This PR fixes issue #357, where cells with Msat=0 were reported to affect other cells through the exchange interaction.

Background

As correctly identified by @jplauzie, this bug appeared in mumax3.10 as part of PR #115 (6303d01), which addressed an "increasing-energy" problem related to Eq. (9) of the mumax³ paper. Note that, since 3.10, Eq. (9) in the paper is no longer the actually implemented equation. Originally, it was

$$\vec{\boldsymbol{\mathrm{B}}}_\mathrm{exch} = 2 S \frac{2\frac{A_\mathrm{ex1}}{M_\mathrm{sat1}}\frac{A_\mathrm{ex2}}{M_\mathrm{sat2}}}{\frac{A_\mathrm{ex1}}{M_\mathrm{sat1}}+\frac{A_\mathrm{ex2}}{M_\mathrm{sat2}}} \sum_i \frac{(\vec{\boldsymbol{\mathrm{m}}}_i - \vec{\boldsymbol{\mathrm{m}}})}{\Delta_i^2} \mathrm{,}$$

but this was changed in PR #115 to

$$\vec{\boldsymbol{\mathrm{B}}}_\mathrm{exch} = \frac{2S}{M_\mathrm{sat1}} \frac{2 A_\mathrm{ex1} A_\mathrm{ex2}}{A_\mathrm{ex1}+A_\mathrm{ex2}} \sum_i \frac{(\vec{\boldsymbol{\mathrm{m}}}_i - \vec{\boldsymbol{\mathrm{m}}})}{\Delta_i^2} \mathrm{.}$$

In other words, since then, the exchange interaction of a spin with its neighbours has no longer been scaled by the Msat of each neighbour separately, but only by Msat of the spin itself.

Edge case for Msat=0

While PR #115 solved the "increasing-energy" problem, it also caused magnets with nonzero Msat to be affected by neighbouring Msat=0 cells. This edge case was the underlying reason for issue #358 and has now been fixed.

On a related note, but unrelated to PR #115: magnets with Msat=0 were affected by the demag field generated by other cells. Since this is a rather weak interaction compared to exchange, functions like relax() were very slow if regions with Msat=0 were present. Hence, from now on, magnets with Msat=0 are no longer affected by demag fields.

@JonathanMaes JonathanMaes requested a review from JLeliaert June 17, 2025 12:01
@JonathanMaes JonathanMaes merged commit 9ae4126 into 3.11.1 Jun 17, 2025
@JonathanMaes JonathanMaes deleted the bugfix/MsatZeroExchange branch June 17, 2025 13:49
@JonathanMaes JonathanMaes mentioned this pull request Jun 17, 2025
@ac2290
Copy link
Copy Markdown

ac2290 commented Mar 2, 2026

Hi in mumax3.11. I cannot get the output of the stray field from a nanomagnet at a certain distance away from the nanomagnet. it is showing always zero

JonathanMaes added a commit that referenced this pull request Mar 18, 2026
Fix bug from #372 that made B_demag==0 where Msat==0
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.

3 participants