From dbbf0dc33fd1982b53b498b77eabd4c57dabb9aa Mon Sep 17 00:00:00 2001 From: Carl-Martin Pfeiler <carl-martin.pfeiler@asc.tuwien.ac.at> Date: Wed, 8 Jan 2020 10:58:32 +0100 Subject: [PATCH] Catch wrong applied field given by user. --- integrators/_details/physicalToMathematical.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/integrators/_details/physicalToMathematical.py b/integrators/_details/physicalToMathematical.py index 5f1b9e0..8c7f6ab 100644 --- a/integrators/_details/physicalToMathematical.py +++ b/integrators/_details/physicalToMathematical.py @@ -107,6 +107,7 @@ def Compute_Cst(self): def ConvertAppliedField(self): import types + from inspect import signature from ngsolve import CoefficientFunction, x, y, z if(self.parameters.H_ext == None): @@ -122,6 +123,11 @@ def ConvertAppliedField(self): hext_mp = [0.0, 0.0, 0.0] for d in range(3): if isinstance(self.parameters.H_ext[d], types.FunctionType): + if(len(signature(self.parameters.H_ext[d]).parameters) != 4): + raise ValueError(("H_ext[" + str(d) + "] is a function with " \ + + str(len(signature(self.parameters.H_ext[d]).parameters)) \ + + " parameter(s)! --> Error: Needs to depend on exactly 4 parameters" \ + + " (t, x, y, z) !")) hext[d] = self.parameters.H_ext[d](self._time_cf / tScale, x, y, z) hext_impl[d] = self.parameters.H_ext[d]( \ (self._time_cf + self._theta*self._k) / tScale, x, y, z) -- GitLab