From 223424b3c6023e66a1b1fcf86ec36c3202b7d349 Mon Sep 17 00:00:00 2001 From: Gertjan van Zwieten Date: Tue, 25 May 2021 22:48:00 +0200 Subject: [PATCH] identify linear conditions in solver.thetamethod --- nutils/solver.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nutils/solver.py b/nutils/solver.py index 3a31a3aa5..777a4754a 100644 --- a/nutils/solver.py +++ b/nutils/solver.py @@ -723,8 +723,19 @@ def __init__(self, target, residual:integraltuple, inertia:optionalintegraltuple self.old_new.append((timetarget+historysuffix, timetarget)) subs0 = {new: evaluable.Argument(old, self.lhs0[new].shape) for old, new in self.old_new} dt = evaluable.Argument(timetarget, ()) - subs0[timetarget] - self.residuals = tuple(res * theta + evaluable.replace_arguments(res, subs0) * (1-theta) + ((inert - evaluable.replace_arguments(inert, subs0)) / dt if inert else 0) for res, inert in zip(residual, inertia)) - self.jacobians = _derivative(self.residuals, target) + residuals = [] + for n, (res, inert) in enumerate(zip(residual, inertia), start=1): + if inert is None and timetarget not in res.arguments \ + and not any(evaluable.derivative(res, arg).simplified.arguments for arg in res.arguments if arg._name in target): + log.info('identified residual #{} as a linear condition'.format(n)) + else: + if theta < 1: + res = res * theta + evaluable.replace_arguments(res, subs0) * (1-theta) + if inert: + res += (inert - evaluable.replace_arguments(inert, subs0)) / dt + residuals.append(res) + self.residuals = tuple(residuals) + self.jacobians = _derivative(residuals, target) def _step(self, lhs0, dt): arguments = lhs0.copy()