From 9aaeb9b833733e2cf297a00fa4bd92124472c700 Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Tue, 23 Jan 2024 21:57:15 +0100 Subject: [PATCH] checks for system dynamic and system energy is added --- oommfc/drivers/mindriver.py | 6 +++++- oommfc/drivers/timedriver.py | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/oommfc/drivers/mindriver.py b/oommfc/drivers/mindriver.py index c0aa3c8..8745f2c 100644 --- a/oommfc/drivers/mindriver.py +++ b/oommfc/drivers/mindriver.py @@ -58,7 +58,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 "iteration" diff --git a/oommfc/drivers/timedriver.py b/oommfc/drivers/timedriver.py index 6b4ec1d..d55f680 100644 --- a/oommfc/drivers/timedriver.py +++ b/oommfc/drivers/timedriver.py @@ -66,7 +66,13 @@ 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"