Skip to content

Commit

Permalink
Moved work_counters for rhs also to ProblemDAE
Browse files Browse the repository at this point in the history
  • Loading branch information
lisawim committed Oct 31, 2023
1 parent 6fd2a87 commit 076607f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 42 deletions.
5 changes: 4 additions & 1 deletion pySDC/projects/DAE/misc/ProblemDAE.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class ptype_dae(ptype):
Attributes
----------
work_counters : WorkCounter
Counts the work, here the number of function calls during the nonlinear solve is logged.
Counts the work, here the number of function calls during the nonlinear solve is logged and stored
in work_counters['newton']. The number of each function class of the right-hand side is then stored
in work_counters['rhs']
"""

dtype_u = mesh
Expand All @@ -32,6 +34,7 @@ def __init__(self, nvars, newton_tol):
self._makeAttributeAndRegister('nvars', 'newton_tol', localVars=locals(), readOnly=True)

self.work_counters['newton'] = WorkCounter()
self.work_counters['rhs'] = WorkCounter()

def solve_system(self, impl_sys, u0, t):
r"""
Expand Down
24 changes: 0 additions & 24 deletions pySDC/projects/DAE/problems/simple_DAE.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from scipy.interpolate import interp1d

from pySDC.projects.DAE.misc.ProblemDAE import ptype_dae
from pySDC.core.Problem import WorkCounter


class pendulum_2d(ptype_dae):
Expand Down Expand Up @@ -33,11 +32,6 @@ class pendulum_2d(ptype_dae):
----------
t_end: float
The end time at which the reference solution is determined.
Attributes
----------
work_counters : WorkCounter
Counts the work, i.e., number of function calls of right-hand side is called and stored in
``work_counters['rhs']``.
References
----------
Expand All @@ -55,7 +49,6 @@ def __init__(self, nvars, newton_tol):
# solution = data[:, 1:]
# self.u_ref = interp1d(t, solution, kind='cubic', axis=0, fill_value='extrapolate')
self.t_end = 0.0
self.work_counters['rhs'] = WorkCounter()

def eval_f(self, u, du, t):
r"""
Expand Down Expand Up @@ -140,24 +133,12 @@ class simple_dae_1(ptype_dae):
newton_tol : float
Tolerance for Newton solver.
Attributes
----------
work_counters : WorkCounter
Counts the work, i.e., number of function calls of right-hand side is called and stored in
``work_counters['rhs']``.
References
----------
.. [1] U. Ascher, L. R. Petzold. Computer method for ordinary differential equations and differential-algebraic
equations. Society for Industrial and Applied Mathematics (1998).
"""

def __init__(self, nvars, newton_tol):
"""Initialization routine"""
super().__init__(nvars, newton_tol)

self.work_counters['rhs'] = WorkCounter()

def eval_f(self, u, du, t):
r"""
Routine to evaluate the implicit representation of the problem, i.e., :math:`F(u, u', t)`.
Expand Down Expand Up @@ -230,9 +211,6 @@ class problematic_f(ptype_dae):
----------
eta : float
Specific parameter of the problem.
work_counters : WorkCounter
Counts the work, i.e., number of function calls of right-hand side is called and stored in
``work_counters['rhs']``
References
----------
Expand All @@ -245,8 +223,6 @@ def __init__(self, nvars, newton_tol, eta=1):
super().__init__(nvars, newton_tol)
self._makeAttributeAndRegister('eta', localVars=locals())

self.work_counters['rhs'] = WorkCounter()

def eval_f(self, u, du, t):
r"""
Routine to evaluate the implicit representation of the problem, i.e., :math:`F(u, u', t)`.
Expand Down
6 changes: 0 additions & 6 deletions pySDC/projects/DAE/problems/synchronous_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from scipy.interpolate import interp1d

from pySDC.projects.DAE.misc.ProblemDAE import ptype_dae
from pySDC.core.Problem import WorkCounter
from pySDC.implementations.datatype_classes.mesh import mesh


Expand Down Expand Up @@ -144,9 +143,6 @@ class synchronous_machine_infinite_bus(ptype_dae):
Voltage at the field winding.
T_m: float
Defines the mechanical torque applied to the rotor shaft.
work_counters : WorkCounter
Counts the work, i.e., number of function calls of right-hand side is called and stored in
``work_counters['rhs']``.
References
----------
Expand Down Expand Up @@ -188,8 +184,6 @@ def __init__(self, nvars, newton_tol):
self.v_F = 8.736809687330562e-4
self.T_m = 0.854

self.work_counters['rhs'] = WorkCounter()

def eval_f(self, u, du, t):
r"""
Routine to evaluate the implicit representation of the problem, i.e., :math:`F(u, u', t)`.
Expand Down
11 changes: 0 additions & 11 deletions pySDC/projects/DAE/problems/transistor_amplifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from scipy.interpolate import interp1d

from pySDC.projects.DAE.misc.ProblemDAE import ptype_dae
from pySDC.core.Problem import WorkCounter


# Helper function
Expand Down Expand Up @@ -55,9 +54,6 @@ class one_transistor_amplifier(ptype_dae):
----------
t_end: float
The end time at which the reference solution is determined.
work_counters : WorkCounter
Counts the work, i.e., number of function calls of right-hand side is called and stored in
``work_counters['rhs']``.
References
----------
Expand All @@ -76,8 +72,6 @@ def __init__(self, nvars, newton_tol):
# self.u_ref = interp1d(x, y, kind='cubic', axis=0, fill_value='extrapolate')
self.t_end = 0.0

self.work_counters['rhs'] = WorkCounter()

def eval_f(self, u, du, t):
r"""
Routine to evaluate the implicit representation of the problem, i.e., :math:`F(u, u', t)`.
Expand Down Expand Up @@ -194,9 +188,6 @@ class two_transistor_amplifier(ptype_dae):
----------
t_end: float
The end time at which the reference solution is determined.
work_counters : WorkCounter
Counts the work, i.e., number of function calls of right-hand side is called and stored in
``work_counters['rhs']``.
References
----------
Expand All @@ -215,8 +206,6 @@ def __init__(self, nvars, newton_tol):
# self.u_ref = interp1d(x, y, kind='cubic', axis=0, fill_value='extrapolate')
self.t_end = 0.0

self.work_counters['rhs'] = WorkCounter()

def eval_f(self, u, du, t):
r"""
Routine to evaluate the implicit representation of the problem, i.e., :math:`F(u, u', t)`.
Expand Down

0 comments on commit 076607f

Please sign in to comment.