Skip to content

Commit

Permalink
Small fixes (#465)
Browse files Browse the repository at this point in the history
* Small fixes

* Fix for breaking update of mpi4py
  • Loading branch information
brownbaerchen authored Jul 29, 2024
1 parent 63c2b79 commit 2363944
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, num_procs, controller_params, description):
for _ in range(num_procs - 1):
self.MS.append(dill.copy(self.MS[0]))
# if this fails (e.g. due to un-picklable data in the steps), initialize separately
except (dill.PicklingError, TypeError) as error:
except (dill.PicklingError, TypeError, ValueError) as error:
self.logger.warning(f'Need to initialize steps separately due to pickling error: {error}')
for _ in range(num_procs - 1):
self.MS.append(stepclass.Step(description))
Expand Down
12 changes: 5 additions & 7 deletions pySDC/implementations/problem_classes/AllenCahn_2D_FFT.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class allencahn2d_imex(Problem):
or uniform distributed random numbers in :math:`[-1, 1]` for :math:`i, j=0,..,N-1`, where :math:`N` is the number of
spatial grid points. For time-stepping, the problem is treated *semi-implicitly*, i.e., the diffusion part is solved by
Fast-Fourier Tranform (FFT) and the nonlinear term is treated explicitly.
Fast-Fourier Transform (FFT) and the nonlinear term is treated explicitly.
An exact solution is not known, but instead the numerical solution can be compared via a generated reference solution computed
by a ``SciPy`` routine.
Expand Down Expand Up @@ -120,11 +120,10 @@ def eval_f(self, u, t):
"""

f = self.dtype_f(self.init)
v = u.flatten()
tmp = self.lap * np.fft.rfft2(u)
f.impl[:] = np.fft.irfft2(tmp)
if self.eps > 0:
f.expl[:] = (1.0 / self.eps**2 * v * (1.0 - v**self.nu)).reshape(self.nvars)
f.expl[:] = 1.0 / self.eps**2 * u * (1.0 - u**self.nu)
return f

def solve_system(self, rhs, factor, u0, t):
Expand Down Expand Up @@ -200,7 +199,7 @@ def eval_rhs(t, u):

class allencahn2d_imex_stab(allencahn2d_imex):
r"""
This implements the two-dimensional Allen-Cahn equation with periodic boundary conditions :math:`u \in [-1, 1]^2`
This implements the two-dimensional Allen-Cahn equation with periodic boundary conditions :math:`u \in [-0.5, 0.5]^2`
with stabilized splitting
.. math::
Expand All @@ -219,7 +218,7 @@ class allencahn2d_imex_stab(allencahn2d_imex):
or uniform distributed random numbers in :math:`[-1, 1]` for :math:`i, j=0,..,N-1`, where :math:`N` is the number of
spatial grid points. For time-stepping, the problem is treated *semi-implicitly*, i.e., the diffusion part is solved with
Fast-Fourier Tranform (FFT) and the nonlinear term is treated explicitly.
Fast-Fourier Transform (FFT) and the nonlinear term is treated explicitly.
An exact solution is not known, but instead the numerical solution can be compared via a generated reference solution computed
by a ``SciPy`` routine.
Expand Down Expand Up @@ -276,11 +275,10 @@ def eval_f(self, u, t):
"""

f = self.dtype_f(self.init)
v = u.flatten()
tmp = self.lap * np.fft.rfft2(u)
f.impl[:] = np.fft.irfft2(tmp)
if self.eps > 0:
f.expl[:] = (1.0 / self.eps**2 * v * (1.0 - v**self.nu) + 2.0 / self.eps**2 * v).reshape(self.nvars)
f.expl[:] = 1.0 / self.eps**2 * u * (1.0 - u**self.nu) + 2.0 / self.eps**2 * u
return f

def solve_system(self, rhs, factor, u0, t):
Expand Down
8 changes: 4 additions & 4 deletions pySDC/implementations/problem_classes/AllenCahn_MPIFFT.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class allencahn_imex(IMEX_Laplacian_MPIFFT):
u({\bf x}, 0) = \tanh\left(\frac{r - \sqrt{(x_i-0.5)^2 + (y_j-0.5)^2}}{\sqrt{2}\varepsilon}\right),
for :math:`i, j=0,..,N-1`, where :math:`N` is the number of spatial grid points. For time-stepping, the problem is treated
*semi-implicitly*, i.e., the linear part is solved with Fast-Fourier Tranform (FFT) and the nonlinear part in the right-hand
*semi-implicitly*, i.e., the linear part is solved with Fast-Fourier Transform (FFT) and the nonlinear part in the right-hand
side will be treated explicitly using ``mpi4py-fft`` [1]_ to solve them.
Parameters
Expand Down Expand Up @@ -183,7 +183,7 @@ class allencahn_imex_timeforcing(allencahn_imex):
u({\bf x}, 0) = \tanh\left(\frac{r - \sqrt{(x_i-0.5)^2 + (y_j-0.5)^2}}{\sqrt{2}\varepsilon}\right),
for :math:`i, j=0,..,N-1`, where :math:`N` is the number of spatial grid points. For time-stepping, the problem is treated
*semi-implicitly*, i.e., the linear part is solved with Fast-Fourier Tranform (FFT) and the nonlinear part in the right-hand
*semi-implicitly*, i.e., the linear part is solved with Fast-Fourier Transform (FFT) and the nonlinear part in the right-hand
side will be treated explicitly using ``mpi4py-fft`` [1]_ to solve them.
"""

Expand Down Expand Up @@ -230,7 +230,7 @@ def eval_f(self, u, t):
if self.comm is not None:
Ht_global = self.comm.allreduce(sendobj=Ht_local, op=MPI.SUM)
else:
Ht_global = Rt_local
Ht_global = Ht_local

# add/substract time-dependent driving force
if Ht_global != 0.0:
Expand Down Expand Up @@ -258,7 +258,7 @@ def eval_f(self, u, t):
if self.comm is not None:
Ht_global = self.comm.allreduce(sendobj=Ht_local, op=MPI.SUM)
else:
Ht_global = Rt_local
Ht_global = Ht_local

# add/substract time-dependent driving force
if Ht_global != 0.0:
Expand Down

0 comments on commit 2363944

Please sign in to comment.