PyMPDATA_examples.Olesik_et_al_2022.coordinates

 1import numpy as np
 2
 3
 4class x_id:
 5    @staticmethod
 6    def x(r):
 7        return r
 8
 9    @staticmethod
10    def r(x):
11        return x
12
13    @staticmethod
14    def dx_dr(r):
15        return r**0
16
17    @staticmethod
18    def moment_of_r_integral(x, k):
19        return 1 / (k + 1) * x ** (k + 1)
20
21
22class x_p2:
23    @staticmethod
24    def x(r):
25        return r**2
26
27    @staticmethod
28    def r(x):
29        return np.sqrt(np.where(x < 0, 1e10, x))
30
31    @staticmethod
32    def dx_dr(r):
33        return 2 * r
34
35    @staticmethod
36    def moment_of_r_integral(x, k):
37        return 2 / (k + 2) * x ** ((k + 2) / 2)
38
39
40class x_p3:
41    @staticmethod
42    def x(r):
43        return r**3
44
45    @staticmethod
46    def r(x):
47        return np.power(x, 1 / 3)
48
49    @staticmethod
50    def dx_dr(r):
51        return 3 * r**2
52
53    @staticmethod
54    def moment_of_r_integral(x, k):
55        return 3 / (k + 3) * x ** ((k + 3) / 3)
56
57
58class x_log_of_pn:
59    def __init__(self, r0=1, base=np.e, n=3):
60        self.r0 = r0
61        self.base = base
62        self.n = n
63
64    def x(self, r):
65        return np.log(r**self.n / self.r0**self.n) / np.log(self.base)
66
67    def r(self, x):
68        return self.r0 * self.base ** (x / self.n)
69
70    def dx_dr(self, r):
71        return self.n / r / np.log(self.base)
72
73    def moment_of_r_integral(self, x, k):
74        return (
75            self.r0**k
76            * self.n
77            / (k * np.log(self.base))
78            * self.base ** (k / self.n * x)
79        )
class x_id:
 5class x_id:
 6    @staticmethod
 7    def x(r):
 8        return r
 9
10    @staticmethod
11    def r(x):
12        return x
13
14    @staticmethod
15    def dx_dr(r):
16        return r**0
17
18    @staticmethod
19    def moment_of_r_integral(x, k):
20        return 1 / (k + 1) * x ** (k + 1)
@staticmethod
def x(r):
6    @staticmethod
7    def x(r):
8        return r
@staticmethod
def r(x):
10    @staticmethod
11    def r(x):
12        return x
@staticmethod
def dx_dr(r):
14    @staticmethod
15    def dx_dr(r):
16        return r**0
@staticmethod
def moment_of_r_integral(x, k):
18    @staticmethod
19    def moment_of_r_integral(x, k):
20        return 1 / (k + 1) * x ** (k + 1)
class x_p2:
23class x_p2:
24    @staticmethod
25    def x(r):
26        return r**2
27
28    @staticmethod
29    def r(x):
30        return np.sqrt(np.where(x < 0, 1e10, x))
31
32    @staticmethod
33    def dx_dr(r):
34        return 2 * r
35
36    @staticmethod
37    def moment_of_r_integral(x, k):
38        return 2 / (k + 2) * x ** ((k + 2) / 2)
@staticmethod
def x(r):
24    @staticmethod
25    def x(r):
26        return r**2
@staticmethod
def r(x):
28    @staticmethod
29    def r(x):
30        return np.sqrt(np.where(x < 0, 1e10, x))
@staticmethod
def dx_dr(r):
32    @staticmethod
33    def dx_dr(r):
34        return 2 * r
@staticmethod
def moment_of_r_integral(x, k):
36    @staticmethod
37    def moment_of_r_integral(x, k):
38        return 2 / (k + 2) * x ** ((k + 2) / 2)
class x_p3:
41class x_p3:
42    @staticmethod
43    def x(r):
44        return r**3
45
46    @staticmethod
47    def r(x):
48        return np.power(x, 1 / 3)
49
50    @staticmethod
51    def dx_dr(r):
52        return 3 * r**2
53
54    @staticmethod
55    def moment_of_r_integral(x, k):
56        return 3 / (k + 3) * x ** ((k + 3) / 3)
@staticmethod
def x(r):
42    @staticmethod
43    def x(r):
44        return r**3
@staticmethod
def r(x):
46    @staticmethod
47    def r(x):
48        return np.power(x, 1 / 3)
@staticmethod
def dx_dr(r):
50    @staticmethod
51    def dx_dr(r):
52        return 3 * r**2
@staticmethod
def moment_of_r_integral(x, k):
54    @staticmethod
55    def moment_of_r_integral(x, k):
56        return 3 / (k + 3) * x ** ((k + 3) / 3)
class x_log_of_pn:
59class x_log_of_pn:
60    def __init__(self, r0=1, base=np.e, n=3):
61        self.r0 = r0
62        self.base = base
63        self.n = n
64
65    def x(self, r):
66        return np.log(r**self.n / self.r0**self.n) / np.log(self.base)
67
68    def r(self, x):
69        return self.r0 * self.base ** (x / self.n)
70
71    def dx_dr(self, r):
72        return self.n / r / np.log(self.base)
73
74    def moment_of_r_integral(self, x, k):
75        return (
76            self.r0**k
77            * self.n
78            / (k * np.log(self.base))
79            * self.base ** (k / self.n * x)
80        )
x_log_of_pn(r0=1, base=2.718281828459045, n=3)
60    def __init__(self, r0=1, base=np.e, n=3):
61        self.r0 = r0
62        self.base = base
63        self.n = n
r0
base
n
def x(self, r):
65    def x(self, r):
66        return np.log(r**self.n / self.r0**self.n) / np.log(self.base)
def r(self, x):
68    def r(self, x):
69        return self.r0 * self.base ** (x / self.n)
def dx_dr(self, r):
71    def dx_dr(self, r):
72        return self.n / r / np.log(self.base)
def moment_of_r_integral(self, x, k):
74    def moment_of_r_integral(self, x, k):
75        return (
76            self.r0**k
77            * self.n
78            / (k * np.log(self.base))
79            * self.base ** (k / self.n * x)
80        )