Skip to content

Commit

Permalink
Merge pull request #79 from ubermag/check_system
Browse files Browse the repository at this point in the history
checking the system for dynamics and energy presence
  • Loading branch information
samjrholt authored Mar 4, 2024
2 parents 97e27a0 + 05b56b6 commit 3fdd65c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions mumax3c/drivers/mindriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class MinDriver(Driver):
def _checkargs(self, **kwargs):
pass # no kwargs should be checked

def _check_system(self, system):
"""Checks the system has energy in it"""
if len(system.energy) == 0:
raise RuntimeError("System's energy is not defined")

@property
def _x(self):
return "t" # TODO correct iteration
5 changes: 5 additions & 0 deletions mumax3c/drivers/relaxdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class RelaxDriver(Driver):
def _checkargs(self, **kwargs):
pass # no kwargs should be checked

def _check_system(self, system):
"""Checks the system has dynamics in it"""
if len(system.energy) == 0:
raise RuntimeError("System's energy is not defined")

@property
def _x(self):
return "t" # TODO correct iteration
7 changes: 7 additions & 0 deletions mumax3c/drivers/timedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ def _checkargs(self, **kwargs):
msg = f"Cannot drive with {n=}."
raise ValueError(msg)

def _check_system(self, system):
"""Checks the system has dynamics in it"""
if len(system.dynamics) == 0:
raise RuntimeError("System's dynamics is not defined")
if len(system.energy) == 0:
raise RuntimeError("System's energy is not defined")

@property
def _x(self):
return "t"
7 changes: 3 additions & 4 deletions mumax3c/scripts/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ def driver_script(driver, system, compute=None, ovf_format="bin4", **kwargs):
mx3 += "tablesave()\n\n"

if isinstance(driver, mc.RelaxDriver):
if not system.dynamics.get(type=mm.Damping):
raise ValueError("A damping term is needed.")
alpha = system.dynamics.get(type=mm.Damping)[0].alpha
mx3 += f"alpha = {alpha}\n"
if system.dynamics.get(type=mm.Damping):
alpha = system.dynamics.get(type=mm.Damping)[0].alpha
mx3 += f"alpha = {alpha}\n"

for attr, value in driver:
if attr != "evolver":
Expand Down

0 comments on commit 3fdd65c

Please sign in to comment.