diff --git a/engine/demag.go b/engine/demag.go index 7f3f083bb..23da396c9 100644 --- a/engine/demag.go +++ b/engine/demag.go @@ -10,14 +10,14 @@ import ( // Demag variables var ( - Msat ScalarParam - Bsat derivedParam - M_full vSetter - B_demag vSetter - E_demag *GetScalar - Edens_demag sAdder - EnableDemag = true // enable/disable global demag field - NoDemagSpins ScalarParam // disable demag field per-cell + Msat ScalarParam + Bsat derivedParam + M_full vSetter + B_demag vSetter + E_demag *GetScalar + Edens_demag sAdder + EnableDemag = true // enable/disable global demag field + //NoDemagSpins ScalarParam // disable demag field per-cell conv_ *cuda.DemagConvolution // does the heavy lifting and provides FFTM DemagAccuracy = 6.0 // Demag accuracy (divide cubes in at most N^3 points) CacheDir = "" // directory for kernel cache @@ -25,7 +25,7 @@ var ( func init() { Msat.init("Msat", "A/m", "Saturation magnetization", []derived{&Bsat, &lex2, &din2, &dbulk2, &ku1_red, &ku2_red, &kc1_red, &kc2_red, &kc3_red, &temp_red}) - NoDemagSpins.init("NoDemagSpins", "", "Disable magnetostatic interaction per-spin (set to 1 to disable)", nil) + //NoDemagSpins.init("NoDemagSpins", "", "Disable magnetostatic interaction per-spin (set to 1 to disable)", nil) M_full.init("m_full", "A/m", "Unnormalized magnetization", SetMFull) DeclVar("EnableDemag", &EnableDemag, "Enables/disables demag (default=true)") DeclVar("DemagAccuracy", &DemagAccuracy, "Controls accuracy of demag kernel") @@ -46,42 +46,42 @@ func init() { // Sets dst to the current demag field func SetDemagField(dst *data.Slice) { if EnableDemag { - if NoDemagSpins.isZero() { - // Normal demag, everywhere - demagConv().Exec(dst, M.Buffer(), geometry.Gpu(), Bsat.gpuLUT1(), regions.Gpu()) - } else { - setMaskedDemagField(dst) - } + //if NoDemagSpins.isZero() { + // Normal demag, everywhere + demagConv().Exec(dst, M.Buffer(), geometry.Gpu(), Bsat.gpuLUT1(), regions.Gpu()) + //} else { + //setMaskedDemagField(dst) + //} } else { cuda.Zero(dst) // will ADD other terms to it } } // Sets dst to the demag field, but cells where NoDemagSpins != 0 do not generate nor recieve field. -func setMaskedDemagField(dst *data.Slice) { - // No-demag spins: mask-out geometry with zeros where NoDemagSpins is set, - // so these spins do not generate a field - - buf := cuda.Buffer(SCALAR, geometry.Gpu().Size()) // masked-out geometry - defer cuda.Recycle(buf) - - // obtain a copy of the geometry mask, which we can overwrite - geom, r := geometry.Slice() - if r { - defer cuda.Recycle(geom) - } - data.Copy(buf, geom) - - // mask-out - cuda.ZeroMask(buf, NoDemagSpins.gpuLUT1(), regions.Gpu()) - - // convolution with masked-out cells. - demagConv().Exec(dst, M.Buffer(), buf, Bsat.gpuLUT1(), regions.Gpu()) - - // After convolution, mask-out the field in the NoDemagSpins cells - // so they don't feel the field generated by others. - cuda.ZeroMask(dst, NoDemagSpins.gpuLUT1(), regions.Gpu()) -} +//func setMaskedDemagField(dst *data.Slice) { +// // No-demag spins: mask-out geometry with zeros where NoDemagSpins is set, +// // so these spins do not generate a field +// +// buf := cuda.Buffer(SCALAR, geometry.Gpu().Size()) // masked-out geometry +// defer cuda.Recycle(buf) +// +// // obtain a copy of the geometry mask, which we can overwrite +// geom, r := geometry.Slice() +// if r { +// defer cuda.Recycle(geom) +// } +// data.Copy(buf, geom) +// +// // mask-out +// cuda.ZeroMask(buf, NoDemagSpins.gpuLUT1(), regions.Gpu()) +// +// // convolution with masked-out cells. +// demagConv().Exec(dst, M.Buffer(), buf, Bsat.gpuLUT1(), regions.Gpu()) +// +// // After convolution, mask-out the field in the NoDemagSpins cells +// // so they don't feel the field generated by others. +// cuda.ZeroMask(dst, NoDemagSpins.gpuLUT1(), regions.Gpu()) +//} // Sets dst to the full (unnormalized) magnetization in A/m func SetMFull(dst *data.Slice) {