Add native interlayer DMI (ext_InterlayerDMI)#406
Open
SanthoshSivasubramani wants to merge 2 commits into
Open
Add native interlayer DMI (ext_InterlayerDMI)#406SanthoshSivasubramani wants to merge 2 commits into
SanthoshSivasubramani wants to merge 2 commits into
Conversation
Adds interlayer Dzyaloshinskii-Moriya coupling E = D*zhat.(m1 x m2)*A as an effective-field term, with fields B1 = +(D/(Msat*dz))(zhat x m2), B2 = -(D/(Msat*dz))(zhat x m1). Uses the 1/Msat convention (no mu0), locates the partner cell by z-column scan so it spans a spacer gap, and self-guards in SetEffectiveField. Validated on an L4: adjacent and gap tests match the analytic field to 6 sig figs. cuda2go wrapper for the full CC set; gofmt-clean.
There was a problem hiding this comment.
Pull request overview
Adds a native interlayer Dzyaloshinskii–Moriya interaction effective-field term (ext_InterlayerDMI) to the engine, implemented with a CUDA kernel and exposed as a B_idmi output for validation and analysis.
Changes:
- Introduces the
ext_InterlayerDMI(region1, region2, D)API andB_idmivector output in the engine. - Adds a CUDA kernel + Go host wrapper to compute and accumulate the interlayer-DMI field, including z-column partner scanning across spacer gaps.
- Adds two regression tests covering adjacent layers and coupling across a nonmagnetic spacer.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/idmi.mx3 | Regression test for adjacent-layer interlayer DMI field magnitude/sign. |
| test/idmi_gap.mx3 | Regression test ensuring partner scan spans a spacer gap correctly. |
| engine/idmi.go | New engine-side API/storage and field adder wired into B_idmi. |
| engine/effectivefield.go | Integrates interlayer-DMI contribution into the effective field pipeline. |
| cuda/idmi.go | Go-side CUDA invocation wrapper for the addidmi kernel. |
| cuda/idmi.cu | CUDA kernel implementing z-column partner search and field accumulation. |
| cuda/idmi_wrapper.go | cuda2go-generated wrapper/PTX blobs for the new kernel. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+41
to
+43
| func InterlayerDMI(region1, region2 int, D float64) { | ||
| idmiPairs = append(idmiPairs, idmiPair{region1, region2, D}) | ||
| } |
Comment on lines
+65
to
+69
| for (int d = 1; d < Nz; d++) { | ||
| int lo = iz - d; | ||
| if (lo >= 0) { | ||
| int Q = idx(ix, iy, lo); | ||
| if (regions[Q] == partner) { |
…write, energy Addresses Copilot review: apply coupling only at the interface cell (thickness-independent), validate region ids, overwrite duplicate pairs, and register the interlayer-DMI energy (E_idmi, Edens_idmi). Added test/idmi_thick.mx3. VM-validated on L4: all tests OK.
Author
|
Thanks for the review — pushed
On the O(Nz) z-column scan: kept intentionally so the coupling can span a spacer gap; Nz is small for layered stacks. Validated on an NVIDIA L4 (CUDA 12.3): all tests pass. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add native interlayer DMI (
ext_InterlayerDMI)This adds a native interlayer Dzyaloshinskii–Moriya interaction (chiral
interlayer coupling) as an effective-field term, in the same style as the
ext_RKKYinterlayer-exchange term. It is the interlayer analogue of theintralayer interfacial DMI already in mumax3.
Physics
For two magnetic regions coupled across a (possibly nonmagnetic) spacer, the
interlayer-DMI energy is
whose exact variational-derivative effective fields are
i.e. an antisymmetric pair (the sign follows the stacking order). The kernel
follows the
ext_RKKYconvention1/Msat(no explicit µ0), and locates thepartner cell by scanning the z-column, so the coupling spans a spacer gap
between the layers rather than only coupling immediately-adjacent cells.
API
May be called multiple times to couple several region pairs. Exposes a
B_idmivector output. Integrated intoSetEffectiveField(self-guards to ano-op when no pair is defined).
Validation (NVIDIA L4, CUDA 12.3)
Both regression tests pass, matching the analytic field to 6 significant
figures:
test/idmi.mx3(adjacent)(2.22222, 0, 0)✓(0, 2.22222, 0)✓test/idmi_gap.mx3(across a spacer)(2.22222, 0, 0)✓(0, 2.22222, 0)✓with
D = −2e−3 J/m²,Msat = 1e6 A/m,dz = 0.9e−9 m→|D/(Msat·dz)| = 2.22222 T. The antisymmetry (region 100 → +x, region 101 → +y) confirms thechiral form, and the gap test confirms the z-column partner scan.
The CUDA wrapper is generated with
cuda2gofor the full compute-capabilityset (
50 52 53 60 61 62 70 72 75 80 86 87 89 90). Code isgofmt-clean.Files
cuda/idmi.cu— kernel (addidmi)cuda/idmi.go,cuda/idmi_wrapper.go— host wrapper (cuda2go-generated)engine/idmi.go—ext_InterlayerDMIAPI +B_idmifield termengine/effectivefield.go— one line:AddInterlayerDMIField(dst)test/idmi.mx3,test/idmi_gap.mx3— regression testsFollows the same structure as the
ext_RKKYPR. Happy to adapt to yourconventions.