Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added solve_system to all DAE problem classes #371

Merged
merged 6 commits into from
Nov 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moved work_counters for rhs also to ProblemDAE
lisawim committed Oct 31, 2023
commit 076607f0ab1066e7ab92d15f0e578a2890e7ee66
5 changes: 4 additions & 1 deletion pySDC/projects/DAE/misc/ProblemDAE.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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"""
24 changes: 0 additions & 24 deletions pySDC/projects/DAE/problems/simple_DAE.py
Original file line number Diff line number Diff line change
@@ -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):
@@ -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
----------
@@ -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"""
@@ -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)`.
@@ -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
----------
@@ -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)`.
6 changes: 0 additions & 6 deletions pySDC/projects/DAE/problems/synchronous_machine.py
Original file line number Diff line number Diff line change
@@ -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


@@ -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
----------
@@ -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)`.
11 changes: 0 additions & 11 deletions pySDC/projects/DAE/problems/transistor_amplifier.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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
----------
@@ -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)`.
@@ -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
----------
@@ -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)`.