PyMPDATA_examples.Smolarkiewicz_2006_Figs_3_4_10_11_12.settings

 1import numpy as np
 2from pystrict import strict
 3
 4
 5@strict
 6class Settings:
 7    nt = 1600
 8    dt = 1
 9    nx = 500
10    C = 0.5
11    x_min = -250
12    x_max = 250
13
14    def __init__(self, shape: str):
15        if shape == "cosine":
16            self.cdf = Settings.cdf_cosine
17        elif shape == "rect":
18            self.cdf = Settings.cdf_rect
19        else:
20            raise ValueError()
21
22    @staticmethod
23    def cdf_cosine(x):
24        x_mid = -150
25        f = 2 / 12
26        amplitude = 2
27
28        pdf = np.where(np.abs(x - x_mid) < 10, amplitude * np.cos(f * (x - x_mid)), 0)
29        return np.cumsum(pdf)
30
31    @staticmethod
32    def cdf_rect(x):
33        x_mid = -150
34        amplitude = 2
35        offset = 2
36
37        pdf = offset + np.where(np.abs(x - x_mid) <= 12, amplitude, 0)
38        return np.cumsum(pdf)
@strict
class Settings:
 6@strict
 7class Settings:
 8    nt = 1600
 9    dt = 1
10    nx = 500
11    C = 0.5
12    x_min = -250
13    x_max = 250
14
15    def __init__(self, shape: str):
16        if shape == "cosine":
17            self.cdf = Settings.cdf_cosine
18        elif shape == "rect":
19            self.cdf = Settings.cdf_rect
20        else:
21            raise ValueError()
22
23    @staticmethod
24    def cdf_cosine(x):
25        x_mid = -150
26        f = 2 / 12
27        amplitude = 2
28
29        pdf = np.where(np.abs(x - x_mid) < 10, amplitude * np.cos(f * (x - x_mid)), 0)
30        return np.cumsum(pdf)
31
32    @staticmethod
33    def cdf_rect(x):
34        x_mid = -150
35        amplitude = 2
36        offset = 2
37
38        pdf = offset + np.where(np.abs(x - x_mid) <= 12, amplitude, 0)
39        return np.cumsum(pdf)
Settings(shape: str)
15    def __init__(self, shape: str):
16        if shape == "cosine":
17            self.cdf = Settings.cdf_cosine
18        elif shape == "rect":
19            self.cdf = Settings.cdf_rect
20        else:
21            raise ValueError()
nt = 1600
dt = 1
nx = 500
C = 0.5
x_min = -250
x_max = 250
@staticmethod
def cdf_cosine(x):
23    @staticmethod
24    def cdf_cosine(x):
25        x_mid = -150
26        f = 2 / 12
27        amplitude = 2
28
29        pdf = np.where(np.abs(x - x_mid) < 10, amplitude * np.cos(f * (x - x_mid)), 0)
30        return np.cumsum(pdf)
@staticmethod
def cdf_rect(x):
32    @staticmethod
33    def cdf_rect(x):
34        x_mid = -150
35        amplitude = 2
36        offset = 2
37
38        pdf = offset + np.where(np.abs(x - x_mid) <= 12, amplitude, 0)
39        return np.cumsum(pdf)