diff --git a/mumax3c/drivers/mindriver.py b/mumax3c/drivers/mindriver.py index e2c1ea7..522db30 100644 --- a/mumax3c/drivers/mindriver.py +++ b/mumax3c/drivers/mindriver.py @@ -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 diff --git a/mumax3c/drivers/relaxdriver.py b/mumax3c/drivers/relaxdriver.py index 1b1b0ed..bebc562 100644 --- a/mumax3c/drivers/relaxdriver.py +++ b/mumax3c/drivers/relaxdriver.py @@ -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 diff --git a/mumax3c/drivers/timedriver.py b/mumax3c/drivers/timedriver.py index c9d38f0..489d2cc 100644 --- a/mumax3c/drivers/timedriver.py +++ b/mumax3c/drivers/timedriver.py @@ -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" diff --git a/mumax3c/scripts/driver.py b/mumax3c/scripts/driver.py index ada3e4e..105b189 100644 --- a/mumax3c/scripts/driver.py +++ b/mumax3c/scripts/driver.py @@ -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":