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

checking the system for dynamics and energy presence #79

Merged
merged 11 commits into from
Mar 4, 2024
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 AttributeError("System's energy is not defined")
samjrholt marked this conversation as resolved.
Show resolved Hide resolved

@property
def _x(self):
return "t" # TODO correct iteration
7 changes: 7 additions & 0 deletions mumax3c/drivers/relaxdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ 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.dynamics) == 0:
raise AttributeError("System's dynamics is not defined")
samjrholt marked this conversation as resolved.
Show resolved Hide resolved
if len(system.energy) == 0:
raise AttributeError("System's energy is not defined")
samjrholt marked this conversation as resolved.
Show resolved Hide resolved

@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 AttributeError("System's dynamics is not defined")
samjrholt marked this conversation as resolved.
Show resolved Hide resolved
if len(system.energy) == 0:
raise AttributeError("System's energy is not defined")
samjrholt marked this conversation as resolved.
Show resolved Hide resolved

@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
Loading