Skip to content

Add native interlayer DMI (ext_InterlayerDMI)#406

Open
SanthoshSivasubramani wants to merge 2 commits into
mumax:masterfrom
SanthoshSivasubramani:feature/native-idmi
Open

Add native interlayer DMI (ext_InterlayerDMI)#406
SanthoshSivasubramani wants to merge 2 commits into
mumax:masterfrom
SanthoshSivasubramani:feature/native-idmi

Conversation

@SanthoshSivasubramani

Copy link
Copy Markdown

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_RKKY interlayer-exchange term. It is the interlayer analogue of the
intralayer interfacial DMI already in mumax3.

Physics

For two magnetic regions coupled across a (possibly nonmagnetic) spacer, the
interlayer-DMI energy is

E = D * ẑ · (m1 × m2) * A          (areal, D in J/m^2)

whose exact variational-derivative effective fields are

B1 = +(D / (Msat·dz)) · (ẑ × m2)
B2 = −(D / (Msat·dz)) · (ẑ × m1)

i.e. an antisymmetric pair (the sign follows the stacking order). The kernel
follows the ext_RKKY convention 1/Msat (no explicit µ0), and locates the
partner cell by scanning the z-column, so the coupling spans a spacer gap
between the layers rather than only coupling immediately-adjacent cells.

API

ext_InterlayerDMI(region1, region2, D)   // D in J/m^2

May be called multiple times to couple several region pairs. Exposes a
B_idmi vector output. Integrated into SetEffectiveField (self-guards to a
no-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 region 100 region 101
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 the
chiral form, and the gap test confirms the z-column partner scan.

The CUDA wrapper is generated with cuda2go for the full compute-capability
set (50 52 53 60 61 62 70 72 75 80 86 87 89 90). Code is gofmt-clean.

Files

  • cuda/idmi.cu — kernel (addidmi)
  • cuda/idmi.go, cuda/idmi_wrapper.go — host wrapper (cuda2go-generated)
  • engine/idmi.goext_InterlayerDMI API + B_idmi field term
  • engine/effectivefield.go — one line: AddInterlayerDMIField(dst)
  • test/idmi.mx3, test/idmi_gap.mx3 — regression tests

Follows the same structure as the ext_RKKY PR. Happy to adapt to your
conventions.

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.
Copilot AI review requested due to automatic review settings July 3, 2026 17:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 and B_idmi vector 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 thread engine/idmi.go
Comment on lines +41 to +43
func InterlayerDMI(region1, region2 int, D float64) {
idmiPairs = append(idmiPairs, idmiPair{region1, region2, D})
}
Comment thread cuda/idmi.cu
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.
@SanthoshSivasubramani

Copy link
Copy Markdown
Author

Thanks for the review — pushed 96c184e addressing the comments:

  • Interface-only coupling. The areal interlayer-DMI field is now applied only at the interface cell, so it is independent of layer thickness. Added test/idmi_thick.mx3 (2-cell layers) asserting the layer-averaged field halves and E_idmi is thickness-independent.
  • Region-id validation. ext_InterlayerDMI now validates both ids via defRegionId.
  • Duplicate pairs. Re-calling for the same region pair now overwrites instead of appending.
  • Energy. Registered E_idmi / Edens_idmi. The field is the exact variational derivative of the bilinear energy E = D·A·ẑ·(m1×m2), so the standard -1/2 M·B density is exact.

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.

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.

2 participants