Skip to content

Commit

Permalink
Merge pull request #81 from SeregaKR/master
Browse files Browse the repository at this point in the history
Temperature support (updated)
  • Loading branch information
samjrholt authored Jun 10, 2024
2 parents b777399 + dd8293f commit b722c48
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ Licensed under the BSD 3-Clause "New" or "Revised" License. For details, please
- [OpenDreamKit](http://opendreamkit.org/) – Horizon 2020 European Research Infrastructure project (676541)

- EPSRC Programme Grant on [Skyrmionics](http://www.skyrmions.ac.uk) (EP/N032128/1)
-
4 changes: 4 additions & 0 deletions mumax3c/scripts/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def driver_script(driver, system, compute=None, ovf_format="bin4", **kwargs):
mx3 = "tableadd(E_total)\n"
mx3 += "tableadd(dt)\n"
mx3 += "tableadd(maxtorque)\n"

if isinstance(driver, mc.MinDriver):
for attr, value in driver:
if attr != "evolver":
Expand All @@ -32,6 +33,9 @@ def driver_script(driver, system, compute=None, ovf_format="bin4", **kwargs):
mx3 += "tablesave()\n\n"

if isinstance(driver, mc.TimeDriver):
# Need temperature only here
if system.T > 0:
mx3 += f"Temp = {system.T}\n"
# Extract dynamics equation parameters.
gamma0 = (
precession[0].gamma0
Expand Down
31 changes: 31 additions & 0 deletions mumax3c/tests/test_micromagnetictests.py
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
import discretisedfield as df
import micromagneticmodel as mm
import numpy as np
from micromagnetictests.calculatortests import * # noqa: F401,F403

import mumax3c as mc


def test_temperature():
p1 = (0, 0, 0)
p2 = (5e-9, 5e-9, 5e-9)
n = (2, 2, 2)
Ms = 1e6
A = 1e-13
region = df.Region(p1=p1, p2=p2)
mesh = df.Mesh(region=region, n=n)

system = mm.System(name="mumax3_temperature")
system.energy = mm.Exchange(A=A)
system.dynamics = mm.Precession(gamma0=mm.consts.gamma0) + mm.Damping(alpha=1)
system.m = df.Field(mesh, nvdim=3, value=(0, 0.1, 1), norm=Ms)
system.T = 1000 # Set a high temperature so it is almost random
assert f"Temp = {system.T}" in mc.scripts.driver_script(
mc.TimeDriver(), system, compute=None, t=1, n=1
)

td = mc.TimeDriver()
td.drive(system, t=0.2e-9, n=1)

# If random then there should be no overall direction
assert np.linalg.norm(system.m.orientation.mean()) < 0.5
mc.delete(system)

0 comments on commit b722c48

Please sign in to comment.