Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temperature support (updated) #81

Merged
merged 25 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)