From a546490a0f3e8a171cbedcb31feb95c4cd851962 Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Tue, 23 Jan 2024 21:46:51 +0100 Subject: [PATCH 01/10] checking the system for dynamics and energy presence --- mumax3c/drivers/mindriver.py | 6 +++++- mumax3c/drivers/relaxdriver.py | 8 +++++++- mumax3c/drivers/timedriver.py | 9 ++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/mumax3c/drivers/mindriver.py b/mumax3c/drivers/mindriver.py index e2c1ea7..fcee853 100644 --- a/mumax3c/drivers/mindriver.py +++ b/mumax3c/drivers/mindriver.py @@ -48,7 +48,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") + @property def _x(self): return "t" # TODO correct iteration diff --git a/mumax3c/drivers/relaxdriver.py b/mumax3c/drivers/relaxdriver.py index 1b1b0ed..2b15a39 100644 --- a/mumax3c/drivers/relaxdriver.py +++ b/mumax3c/drivers/relaxdriver.py @@ -48,7 +48,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") + if len(system.energy)==0: + raise AttributeError("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..16fc7eb 100644 --- a/mumax3c/drivers/timedriver.py +++ b/mumax3c/drivers/timedriver.py @@ -61,7 +61,14 @@ def _checkargs(self, **kwargs): if n <= 0: 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") + if len(system.energy)==0: + raise AttributeError("System's energy is not defined") + @property def _x(self): return "t" From dec75ecd947fa6c4b63a6113a9d28fc804b17ee2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 20:52:02 +0000 Subject: [PATCH 02/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mumax3c/drivers/mindriver.py | 5 +++-- mumax3c/drivers/relaxdriver.py | 7 ++++--- mumax3c/drivers/timedriver.py | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mumax3c/drivers/mindriver.py b/mumax3c/drivers/mindriver.py index fcee853..8dc9dbf 100644 --- a/mumax3c/drivers/mindriver.py +++ b/mumax3c/drivers/mindriver.py @@ -48,11 +48,12 @@ 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: + if len(system.energy) == 0: raise AttributeError("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 2b15a39..cef7d43 100644 --- a/mumax3c/drivers/relaxdriver.py +++ b/mumax3c/drivers/relaxdriver.py @@ -48,13 +48,14 @@ 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: + if len(system.dynamics) == 0: raise AttributeError("System's dynamics is not defined") - if len(system.energy)==0: + if len(system.energy) == 0: raise AttributeError("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 16fc7eb..cccf9d3 100644 --- a/mumax3c/drivers/timedriver.py +++ b/mumax3c/drivers/timedriver.py @@ -61,14 +61,14 @@ def _checkargs(self, **kwargs): if n <= 0: 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: + if len(system.dynamics) == 0: raise AttributeError("System's dynamics is not defined") - if len(system.energy)==0: + if len(system.energy) == 0: raise AttributeError("System's energy is not defined") - + @property def _x(self): return "t" From 63d5872f1d8d73fb0bc256aaa3248158a853b76f Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Wed, 24 Jan 2024 12:34:22 +0100 Subject: [PATCH 03/10] updated the name of the check system funtion to _check_syatem --- mumax3c/drivers/mindriver.py | 2 +- mumax3c/drivers/relaxdriver.py | 2 +- mumax3c/drivers/timedriver.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mumax3c/drivers/mindriver.py b/mumax3c/drivers/mindriver.py index 8dc9dbf..987eb10 100644 --- a/mumax3c/drivers/mindriver.py +++ b/mumax3c/drivers/mindriver.py @@ -49,7 +49,7 @@ class MinDriver(Driver): def _checkargs(self, **kwargs): pass # no kwargs should be checked - def check_system(self, system): + 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") diff --git a/mumax3c/drivers/relaxdriver.py b/mumax3c/drivers/relaxdriver.py index cef7d43..fb5faf5 100644 --- a/mumax3c/drivers/relaxdriver.py +++ b/mumax3c/drivers/relaxdriver.py @@ -49,7 +49,7 @@ class RelaxDriver(Driver): def _checkargs(self, **kwargs): pass # no kwargs should be checked - def check_system(self, system): + 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") diff --git a/mumax3c/drivers/timedriver.py b/mumax3c/drivers/timedriver.py index cccf9d3..d7d426c 100644 --- a/mumax3c/drivers/timedriver.py +++ b/mumax3c/drivers/timedriver.py @@ -62,7 +62,7 @@ def _checkargs(self, **kwargs): msg = f"Cannot drive with {n=}." raise ValueError(msg) - def check_system(self, system): + 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") From d8749a6b86f1e9091760c00ac7a698296960468d Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Tue, 27 Feb 2024 17:45:57 +0100 Subject: [PATCH 04/10] Damping term not required for RelaxDriver Mumax documentation is not clear about setting alpha, it is not needed or harmful : "Relax() tries to evolve the magnetization as closely as possible to the minimum energy state. This function assumes all excitations have been turned off (temperature, electrical current, time-dependent magnetic fields). During relax precession is disabled and the time t does not increase. There is no need to set high damping." --- mumax3c/scripts/driver.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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": From 2d62ada7cc6f71da9afcaacc99c1d7afb04bd348 Mon Sep 17 00:00:00 2001 From: Sam Holt <48217392+samjrholt@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:43:40 +0100 Subject: [PATCH 05/10] Change Error type --- mumax3c/drivers/mindriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mumax3c/drivers/mindriver.py b/mumax3c/drivers/mindriver.py index 987eb10..522db30 100644 --- a/mumax3c/drivers/mindriver.py +++ b/mumax3c/drivers/mindriver.py @@ -52,7 +52,7 @@ def _checkargs(self, **kwargs): 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") + raise RuntimeError("System's energy is not defined") @property def _x(self): From 114097653eb72927c1aac1be5bcf6231b132d4b6 Mon Sep 17 00:00:00 2001 From: Sam Holt <48217392+samjrholt@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:43:45 +0100 Subject: [PATCH 06/10] Change Error type --- mumax3c/drivers/relaxdriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mumax3c/drivers/relaxdriver.py b/mumax3c/drivers/relaxdriver.py index fb5faf5..574a3e0 100644 --- a/mumax3c/drivers/relaxdriver.py +++ b/mumax3c/drivers/relaxdriver.py @@ -52,7 +52,7 @@ def _checkargs(self, **kwargs): 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") + raise RuntimeError("System's dynamics is not defined") if len(system.energy) == 0: raise AttributeError("System's energy is not defined") From f62683b978dcc7244370fcbdbad3a2275eb4b3d4 Mon Sep 17 00:00:00 2001 From: Sam Holt <48217392+samjrholt@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:43:50 +0100 Subject: [PATCH 07/10] Change Error type --- mumax3c/drivers/relaxdriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mumax3c/drivers/relaxdriver.py b/mumax3c/drivers/relaxdriver.py index 574a3e0..cb893b3 100644 --- a/mumax3c/drivers/relaxdriver.py +++ b/mumax3c/drivers/relaxdriver.py @@ -54,7 +54,7 @@ def _check_system(self, system): if len(system.dynamics) == 0: raise RuntimeError("System's dynamics is not defined") if len(system.energy) == 0: - raise AttributeError("System's energy is not defined") + raise RuntimeError("System's energy is not defined") @property def _x(self): From 7f6b75f36c7afeeed2e1c748acfe5a2dce56064c Mon Sep 17 00:00:00 2001 From: Sam Holt <48217392+samjrholt@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:43:55 +0100 Subject: [PATCH 08/10] Change Error type --- mumax3c/drivers/timedriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mumax3c/drivers/timedriver.py b/mumax3c/drivers/timedriver.py index d7d426c..aa530ab 100644 --- a/mumax3c/drivers/timedriver.py +++ b/mumax3c/drivers/timedriver.py @@ -65,7 +65,7 @@ def _checkargs(self, **kwargs): 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") + raise RuntimeError("System's dynamics is not defined") if len(system.energy) == 0: raise AttributeError("System's energy is not defined") From 1e7f773f557dda18ad8e21d9b7e4c6a67332b05e Mon Sep 17 00:00:00 2001 From: Sam Holt <48217392+samjrholt@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:44:00 +0100 Subject: [PATCH 09/10] Change Error type --- mumax3c/drivers/timedriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mumax3c/drivers/timedriver.py b/mumax3c/drivers/timedriver.py index aa530ab..489d2cc 100644 --- a/mumax3c/drivers/timedriver.py +++ b/mumax3c/drivers/timedriver.py @@ -67,7 +67,7 @@ def _check_system(self, system): if len(system.dynamics) == 0: raise RuntimeError("System's dynamics is not defined") if len(system.energy) == 0: - raise AttributeError("System's energy is not defined") + raise RuntimeError("System's energy is not defined") @property def _x(self): From 05b56b65a770b179644a7aaa5e8637b6b9eaf094 Mon Sep 17 00:00:00 2001 From: Martin Lang <67915889+lang-m@users.noreply.github.com> Date: Fri, 1 Mar 2024 14:53:54 +0100 Subject: [PATCH 10/10] Update mumax3c/drivers/relaxdriver.py --- mumax3c/drivers/relaxdriver.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mumax3c/drivers/relaxdriver.py b/mumax3c/drivers/relaxdriver.py index cb893b3..bebc562 100644 --- a/mumax3c/drivers/relaxdriver.py +++ b/mumax3c/drivers/relaxdriver.py @@ -51,8 +51,6 @@ def _checkargs(self, **kwargs): 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")