Coverage for pySDC/tutorial/step_4/PenningTrap_3D_coarse.py: 100%
10 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-11-02 12:30 +0000
« prev ^ index » next coverage.py v7.17.0, created at 2026-11-02 12:30 +0000
1import numpy as np
3from pySDC.implementations.problem_classes.PenningTrap_3D import penningtrap
6class penningtrap_coarse(penningtrap):
7 """
8 Coarse level problem description class, will only overwrite what is needed
9 """
11 def eval_f(self, part, t):
12 """
13 Routine to compute the E and B fields (named f for consistency with the original PEPC version)
15 Args:
16 t: current time (not used here)
17 part: the particles
18 Returns:
19 Fields for the particles (external only)
20 """
22 self.work_counters['rhs']() # count the evaluations, as the fine problem does
23 Emat = np.diag([1, 1, -2])
24 f = self.dtype_f(self.init, val=0.0)
26 # only compute external forces here: O(N) instead of O(N*N)
27 f.elec[:] = self.omega_E**2 / (part.q / part.m) * (Emat @ part.pos)
28 f.magn[:] = self.omega_B * np.array([0, 0, 1])[:, None]
30 return f