Coverage for pySDC/projects/FastWaveSlowWave/AcousticAdvection_1D_FD_imex_multiscale.py: 100%
13 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
1import numpy as np
3from pySDC.implementations.problem_classes.AcousticAdvection_1D_FD_imex import acoustic_1d_imex
6# noinspection PyUnusedLocal
7class acoustic_1d_imex_multiscale(acoustic_1d_imex):
8 """
9 Example implementing the one-dimensional IMEX acoustic-advection with multiscale initial values
10 """
12 def u_exact(self, t):
13 """
14 Routine to compute the exact solution at time t
16 Args:
17 t (float): current time
19 Returns:
20 dtype_u: exact solution
21 """
23 sigma_0 = 0.1
24 k = 7.0 * 2.0 * np.pi
25 x_0 = 0.75
26 x_1 = 0.25
28 ms = 1.0
30 me = self.dtype_u(self.init)
31 me[0, :] = np.exp(-np.square(self.mesh - x_0 - self.cs * t) / (sigma_0 * sigma_0)) + ms * np.exp(
32 -np.square(self.mesh - x_1 - self.cs * t) / (sigma_0 * sigma_0)
33 ) * np.cos(k * (self.mesh - self.cs * t) / sigma_0)
34 me[1, :] = me[0, :]
36 return me