PyMPDATA_examples.Molenkamp_test_as_in_Jaruga_et_al_2015_Fig_12.settings

 1import numba
 2import numpy as np
 3from pystrict import strict
 4
 5grid = (100, 100)
 6
 7dt = 0.1
 8dx = 1
 9dy = 1
10omega = 0.1
11h = 4.0
12h0 = 1
13
14r = 15.0 * dx
15x0 = 50 * dx
16y0 = 75 * dy
17xc = 0.5 * grid[0] * dx
18yc = 0.5 * grid[1] * dy
19
20
21@strict
22class Settings:
23    def __init__(self, n_rotations: int = 6):
24        self.n_rotations = n_rotations
25
26    @property
27    def dt(self):
28        return dt
29
30    @property
31    def nt(self):
32        return int(628 * self.n_rotations)
33
34    @property
35    def size(self):
36        return self.xrange[1], self.yrange[1]
37
38    @property
39    def xrange(self):
40        return 0, grid[0] * dx
41
42    @property
43    def yrange(self):
44        return 0, grid[1] * dy
45
46    @property
47    def grid(self):
48        return grid
49
50    @staticmethod
51    @numba.njit()
52    def pdf(x, y):
53        tmp = (x - x0) ** 2 + (y - y0) ** 2
54        return h0 + np.where(
55            # if
56            tmp - r**2 <= 0,
57            # then
58            h - np.sqrt(tmp / (r / h) ** 2),
59            # else
60            0.0,
61        )
62
63    @staticmethod
64    def stream_function(xX, yY):
65        x = xX * grid[0] * dx
66        y = yY * grid[1] * dy
67        return 1 / 2 * omega * ((x - xc) ** 2 + (y - yc) ** 2)
grid = (100, 100)
dt = 0.1
dx = 1
dy = 1
omega = 0.1
h = 4.0
h0 = 1
r = 15.0
x0 = 50
y0 = 75
xc = 50.0
yc = 50.0
@strict
class Settings:
22@strict
23class Settings:
24    def __init__(self, n_rotations: int = 6):
25        self.n_rotations = n_rotations
26
27    @property
28    def dt(self):
29        return dt
30
31    @property
32    def nt(self):
33        return int(628 * self.n_rotations)
34
35    @property
36    def size(self):
37        return self.xrange[1], self.yrange[1]
38
39    @property
40    def xrange(self):
41        return 0, grid[0] * dx
42
43    @property
44    def yrange(self):
45        return 0, grid[1] * dy
46
47    @property
48    def grid(self):
49        return grid
50
51    @staticmethod
52    @numba.njit()
53    def pdf(x, y):
54        tmp = (x - x0) ** 2 + (y - y0) ** 2
55        return h0 + np.where(
56            # if
57            tmp - r**2 <= 0,
58            # then
59            h - np.sqrt(tmp / (r / h) ** 2),
60            # else
61            0.0,
62        )
63
64    @staticmethod
65    def stream_function(xX, yY):
66        x = xX * grid[0] * dx
67        y = yY * grid[1] * dy
68        return 1 / 2 * omega * ((x - xc) ** 2 + (y - yc) ** 2)
Settings(n_rotations: int = 6)
24    def __init__(self, n_rotations: int = 6):
25        self.n_rotations = n_rotations
n_rotations
dt
27    @property
28    def dt(self):
29        return dt
nt
31    @property
32    def nt(self):
33        return int(628 * self.n_rotations)
size
35    @property
36    def size(self):
37        return self.xrange[1], self.yrange[1]
xrange
39    @property
40    def xrange(self):
41        return 0, grid[0] * dx
yrange
43    @property
44    def yrange(self):
45        return 0, grid[1] * dy
grid
47    @property
48    def grid(self):
49        return grid
@staticmethod
@numba.njit()
def pdf(x, y):
51    @staticmethod
52    @numba.njit()
53    def pdf(x, y):
54        tmp = (x - x0) ** 2 + (y - y0) ** 2
55        return h0 + np.where(
56            # if
57            tmp - r**2 <= 0,
58            # then
59            h - np.sqrt(tmp / (r / h) ** 2),
60            # else
61            0.0,
62        )
@staticmethod
def stream_function(xX, yY):
64    @staticmethod
65    def stream_function(xX, yY):
66        x = xX * grid[0] * dx
67        y = yY * grid[1] * dy
68        return 1 / 2 * omega * ((x - xc) ** 2 + (y - yc) ** 2)