tdmrsdm 2025.7.1.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tdmrsdm/__init__.py ADDED
File without changes
@@ -0,0 +1,154 @@
1
+ {
2
+ "TD-MRSDM-constants": {
3
+ "water-phase": {
4
+ "bound-water": {
5
+ "relaxation-time": {
6
+ "low-frequency": {
7
+ "t_lte_-1C": {
8
+ "e0p": 86,
9
+ "bv0p": -1.22E-4,
10
+ "tse0p": -25,
11
+ "dHp/R": 362,
12
+ "dSp/R": -9.93
13
+ },
14
+ "t_gte_0C": {
15
+ "e0p": 110,
16
+ "bv0p": -1.1E-4,
17
+ "tse0p": 25,
18
+ "dHp/R": 662,
19
+ "dSp/R": -8.82
20
+ }
21
+ },
22
+ "mid-frequency": {
23
+ "t_lte_-1C": {
24
+ "e0p": 13,
25
+ "bv0p": -3.95E-3,
26
+ "tse0p": -25,
27
+ "dHp/R": 617,
28
+ "dSp/R": -4.81
29
+ },
30
+ "t_gte_0C": {
31
+ "e0p": 30,
32
+ "bv0p": -1.82E-3,
33
+ "tse0p": 25,
34
+ "dHp/R": 493,
35
+ "dSp/R": -5.65
36
+ }
37
+ },
38
+ "high-frequency": {
39
+ "t_lte_-1C": {
40
+ "e0p": 8,
41
+ "bv0p": -1.14E-3,
42
+ "tse0p": -25,
43
+ "dHp/R": 671,
44
+ "dSp/R": -2.5
45
+ },
46
+ "t_gte_0C": {
47
+ "e0p": 13,
48
+ "bv0p": -3.83E-3,
49
+ "tse0p": 25,
50
+ "dHp/R": 366,
51
+ "dSp/R": -3.79
52
+ }
53
+ }
54
+ },
55
+ "electrical-conductivity": {
56
+ "temperature-range": {
57
+ "t_lte_-1C": {
58
+ "sigma(tsp)": 5E-3,
59
+ "betap": 0,
60
+ "tsp": -25
61
+ },
62
+ "t_gte_0C": {
63
+ "sigma(tsp)": 5E-3,
64
+ "betap": 0,
65
+ "tsp": 25
66
+ }
67
+ }}
68
+ },
69
+ "transient-water": {
70
+ "relaxation-time": {
71
+ "low-frequency": {
72
+ "t_lte_-1C": {
73
+ "e0p": 75,
74
+ "bv0p": -5.02E-4,
75
+ "tse0p": -25,
76
+ "dHp/R": 2837,
77
+ "dSp/R": 3.45
78
+ },
79
+ "t_gte_0C": {
80
+ "e0p": 97,
81
+ "bv0p": 7.48E-5,
82
+ "tse0p": 25,
83
+ "dHp/R": 2133,
84
+ "dSp/R": 0.74
85
+ }
86
+ },
87
+ "high-frequency": {
88
+ "t_lte_-1C": {
89
+ "e0p": 22,
90
+ "bv0p": -2.89E-3,
91
+ "tse0p": -25,
92
+ "dHp/R": 2870,
93
+ "dSp/R": 5.88
94
+ },
95
+ "t_gte_0C": {
96
+ "e0p": 58,
97
+ "bv0p": -1.93E-4,
98
+ "tse0p": 25,
99
+ "dHp/R": 1849,
100
+ "dSp/R": 1.81
101
+ }
102
+ }
103
+ },
104
+ "electrical-conductivity": {
105
+ "temperature-range": {
106
+ "t_lte_-1C": {
107
+ "sigma(tsp)": 0.01,
108
+ "betap": 0,
109
+ "tsp": -25
110
+ },
111
+ "t_gte_0C": {
112
+ "sigma(tsp)": 0.01,
113
+ "betap": 0,
114
+ "tsp": 25
115
+ }
116
+ }}
117
+ },
118
+ "ice-unbound-water": {
119
+ "relaxation-time": {
120
+ "low-frequency": {
121
+ "t_lte_-1C": {
122
+ "e0p": 6,
123
+ "bv0p": -11.3E-3,
124
+ "tse0p": -25,
125
+ "dHp/R": 3484,
126
+ "dSp/R": 7.78
127
+ }
128
+ },
129
+ "high-frequency": {
130
+ "t_gte_0C": {
131
+ "e0p": 85,
132
+ "bv0p": 1.53E-4,
133
+ "tse0p": 25,
134
+ "dHp/R": 2319,
135
+ "dSp/R": 3.72
136
+ }
137
+ }
138
+ },
139
+ "electrical-conductivity": {
140
+ "temperature-range": {
141
+ "t_lte_-1C": {
142
+ "sigma(tsp)": 0.008,
143
+ "betap": 1.15E-3,
144
+ "tsp": -25
145
+ },
146
+ "t_gte_0C": {
147
+ "sigma(tsp)": 0.26,
148
+ "betap": 3.3E-3,
149
+ "tsp": 25
150
+ }
151
+ }}
152
+ }
153
+ }}
154
+ }
@@ -0,0 +1,154 @@
1
+ {
2
+ "TD-MRSDM-constants": {
3
+ "water-phase": {
4
+ "bound-water": {
5
+ "relaxation-time": {
6
+ "low-frequency": {
7
+ "t_lte_-1C": {
8
+ "e0p": 86,
9
+ "bv0p": -0.000119,
10
+ "tse0p": -25,
11
+ "dHp/R": 362,
12
+ "dSp/R": -9.93
13
+ },
14
+ "t_gte_0C": {
15
+ "e0p": 110,
16
+ "bv0p": -0.000112,
17
+ "tse0p": 25,
18
+ "dHp/R": 662,
19
+ "dSp/R": -8.82
20
+ }
21
+ },
22
+ "mid-frequency": {
23
+ "t_lte_-1C": {
24
+ "e0p": 13,
25
+ "bv0p": -0.003945,
26
+ "tse0p": -25,
27
+ "dHp/R": 617,
28
+ "dSp/R": -4.81
29
+ },
30
+ "t_gte_0C": {
31
+ "e0p": 30,
32
+ "bv0p": -0.001823,
33
+ "tse0p": 25,
34
+ "dHp/R": 493,
35
+ "dSp/R": -5.65
36
+ }
37
+ },
38
+ "high-frequency": {
39
+ "t_lte_-1C": {
40
+ "e0p": 8,
41
+ "bv0p": -0.001143,
42
+ "tse0p": -25,
43
+ "dHp/R": 671,
44
+ "dSp/R": -2.5
45
+ },
46
+ "t_gte_0C": {
47
+ "e0p": 13,
48
+ "bv0p": -0.00383,
49
+ "tse0p": 25,
50
+ "dHp/R": 366,
51
+ "dSp/R": -3.79
52
+ }
53
+ }
54
+ },
55
+ "electrical-conductivity": {
56
+ "temperature-range": {
57
+ "t_lte_-1C": {
58
+ "sigma(tsp)": 5E-3,
59
+ "betap": 0,
60
+ "tsp": -25
61
+ },
62
+ "t_gte_0C": {
63
+ "sigma(tsp)": 5E-3,
64
+ "betap": 0,
65
+ "tsp": 25
66
+ }
67
+ }}
68
+ },
69
+ "transient-water": {
70
+ "relaxation-time": {
71
+ "low-frequency": {
72
+ "t_lte_-1C": {
73
+ "e0p": 75,
74
+ "bv0p": -0.0005587,
75
+ "tse0p": -25,
76
+ "dHp/R": 2837,
77
+ "dSp/R": 3.45
78
+ },
79
+ "t_gte_0C": {
80
+ "e0p": 97,
81
+ "bv0p": 3.039E-5,
82
+ "tse0p": 25,
83
+ "dHp/R": 2133,
84
+ "dSp/R": 0.74
85
+ }
86
+ },
87
+ "high-frequency": {
88
+ "t_lte_-1C": {
89
+ "e0p": 22,
90
+ "bv0p": -0.002944,
91
+ "tse0p": -25,
92
+ "dHp/R": 2870,
93
+ "dSp/R": 5.88
94
+ },
95
+ "t_gte_0C": {
96
+ "e0p": 58,
97
+ "bv0p": -0.0001349,
98
+ "tse0p": 25,
99
+ "dHp/R": 1849,
100
+ "dSp/R": 1.81
101
+ }
102
+ }
103
+ },
104
+ "electrical-conductivity": {
105
+ "temperature-range": {
106
+ "t_lte_-1C": {
107
+ "sigma(tsp)": 0.01,
108
+ "betap": 0,
109
+ "tsp": -25
110
+ },
111
+ "t_gte_0C": {
112
+ "sigma(tsp)": 0.01,
113
+ "betap": 0,
114
+ "tsp": 25
115
+ }
116
+ }}
117
+ },
118
+ "ice-unbound-water": {
119
+ "relaxation-time": {
120
+ "low-frequency": {
121
+ "t_lte_-1C": {
122
+ "e0p": 6,
123
+ "bv0p": -0.0113,
124
+ "tse0p": -25,
125
+ "dHp/R": 3484,
126
+ "dSp/R": 7.78
127
+ }
128
+ },
129
+ "high-frequency": {
130
+ "t_gte_0C": {
131
+ "e0p": 85,
132
+ "bv0p": 0.00015,
133
+ "tse0p": 25,
134
+ "dHp/R": 2319,
135
+ "dSp/R": 3.72
136
+ }
137
+ }
138
+ },
139
+ "electrical-conductivity": {
140
+ "temperature-range": {
141
+ "t_lte_-1C": {
142
+ "sigma(tsp)": 0.008,
143
+ "betap": 1.15E-3,
144
+ "tsp": -25
145
+ },
146
+ "t_gte_0C": {
147
+ "sigma(tsp)": 0.26,
148
+ "betap": 3.3E-3,
149
+ "tsp": 25
150
+ }
151
+ }}
152
+ }
153
+ }}
154
+ }
@@ -0,0 +1,154 @@
1
+ {
2
+ "TD-MRSDM-constants": {
3
+ "water-phase": {
4
+ "bound-water": {
5
+ "relaxation-time": {
6
+ "low-frequency": {
7
+ "t_lte_-1C": {
8
+ "e0p": 86,
9
+ "bv0p": -0.00008978,
10
+ "tse0p": -25,
11
+ "dHp/R": 362,
12
+ "dSp/R": -9.93
13
+ },
14
+ "t_gte_0C": {
15
+ "e0p": 110,
16
+ "bv0p": -0.00005081,
17
+ "tse0p": 25,
18
+ "dHp/R": 662,
19
+ "dSp/R": -8.82
20
+ }
21
+ },
22
+ "mid-frequency": {
23
+ "t_lte_-1C": {
24
+ "e0p": 13,
25
+ "bv0p": -0.00395,
26
+ "tse0p": -25,
27
+ "dHp/R": 617,
28
+ "dSp/R": -4.81
29
+ },
30
+ "t_gte_0C": {
31
+ "e0p": 30,
32
+ "bv0p": -0.00178,
33
+ "tse0p": 25,
34
+ "dHp/R": 493,
35
+ "dSp/R": -5.65
36
+ }
37
+ },
38
+ "high-frequency": {
39
+ "t_lte_-1C": {
40
+ "e0p": 8,
41
+ "bv0p": -0.00116,
42
+ "tse0p": -25,
43
+ "dHp/R": 671,
44
+ "dSp/R": -2.5
45
+ },
46
+ "t_gte_0C": {
47
+ "e0p": 13,
48
+ "bv0p": -0.00380,
49
+ "tse0p": 25,
50
+ "dHp/R": 366,
51
+ "dSp/R": -3.79
52
+ }
53
+ }
54
+ },
55
+ "electrical-conductivity": {
56
+ "temperature-range": {
57
+ "t_lte_-1C": {
58
+ "sigma(tsp)": 0.00499,
59
+ "betap": -0.00005705,
60
+ "tsp": -25
61
+ },
62
+ "t_gte_0C": {
63
+ "sigma(tsp)": 0.005,
64
+ "betap": 0.00000654,
65
+ "tsp": 25
66
+ }
67
+ }}
68
+ },
69
+ "transient-water": {
70
+ "relaxation-time": {
71
+ "low-frequency": {
72
+ "t_lte_-1C": {
73
+ "e0p": 75,
74
+ "bv0p": -0.00038,
75
+ "tse0p": -25,
76
+ "dHp/R": 2837,
77
+ "dSp/R": 3.45
78
+ },
79
+ "t_gte_0C": {
80
+ "e0p": 97,
81
+ "bv0p": 0.00023,
82
+ "tse0p": 25,
83
+ "dHp/R": 2133,
84
+ "dSp/R": 0.74
85
+ }
86
+ },
87
+ "high-frequency": {
88
+ "t_lte_-1C": {
89
+ "e0p": 22,
90
+ "bv0p": -0.00305,
91
+ "tse0p": -25,
92
+ "dHp/R": 2870,
93
+ "dSp/R": 5.88
94
+ },
95
+ "t_gte_0C": {
96
+ "e0p": 58,
97
+ "bv0p": 0.00069,
98
+ "tse0p": 25,
99
+ "dHp/R": 1849,
100
+ "dSp/R": 1.81
101
+ }
102
+ }
103
+ },
104
+ "electrical-conductivity": {
105
+ "temperature-range": {
106
+ "t_lte_-1C": {
107
+ "sigma(tsp)": 0.00999,
108
+ "betap": -0.00004105,
109
+ "tsp": -25
110
+ },
111
+ "t_gte_0C": {
112
+ "sigma(tsp)": 0.01,
113
+ "betap": -0.00004395,
114
+ "tsp": 25
115
+ }
116
+ }}
117
+ },
118
+ "ice-unbound-water": {
119
+ "relaxation-time": {
120
+ "low-frequency": {
121
+ "t_lte_-1C": {
122
+ "e0p": 6,
123
+ "bv0p": -0.01127,
124
+ "tse0p": -25,
125
+ "dHp/R": 3484,
126
+ "dSp/R": 7.78
127
+ }
128
+ },
129
+ "high-frequency": {
130
+ "t_gte_0C": {
131
+ "e0p": 85,
132
+ "bv0p": 0.00011,
133
+ "tse0p": 25,
134
+ "dHp/R": 2319,
135
+ "dSp/R": 3.72
136
+ }
137
+ }
138
+ },
139
+ "electrical-conductivity": {
140
+ "temperature-range": {
141
+ "t_lte_-1C": {
142
+ "sigma(tsp)": 0.00799,
143
+ "betap": 0.00111,
144
+ "tsp": -25
145
+ },
146
+ "t_gte_0C": {
147
+ "sigma(tsp)": 0.26,
148
+ "betap": 0.00330,
149
+ "tsp": 25
150
+ }
151
+ }}
152
+ }
153
+ }}
154
+ }
tdmrsdm/core.py ADDED
@@ -0,0 +1,356 @@
1
+ import json
2
+ import numpy as np
3
+ from os import path as p
4
+
5
+
6
+
7
+ class TDMRSDM:
8
+
9
+ """
10
+ Temperature-Dependent Multi-Relaxation Spectroscopic Dielectric Model (TD-MRSDM)
11
+ """
12
+
13
+ current_dir = p.dirname(p.realpath(__file__))
14
+
15
+ def __init__(self, freq_GHz, sst, som, sbd, ssm, optimize=None) -> None:
16
+
17
+ self.constants_dir = p.realpath(p.join(self.current_dir, 'constants'))
18
+ if not p.isdir(self.constants_dir):
19
+ raise OSError(f'Cannot find constants folder: {self.constants_dir}')
20
+
21
+ if optimize == 'v1':
22
+ cname = 'td_mrsdm_constants_v2019_optimized_v1.json'
23
+ elif optimize == 'v2':
24
+ cname = 'td_mrsdm_constants_v2019_optimized_v2.json'
25
+ else:
26
+ cname = 'td_mrsdm_constants_v2019.json'
27
+
28
+ self.constant_file_path = p.join(self.constants_dir, cname)
29
+
30
+ self.f = freq_GHz * 1.0e+9 # Convert frequency to Hz
31
+
32
+ # check st if not a numpy array
33
+ if not isinstance(sst, np.ndarray):
34
+ self.T = np.array([sst, ])
35
+ else:
36
+ self.T = sst # degrees Celsius
37
+
38
+ self.som = som # percentage (%)
39
+ self.mg = ssm / sbd # g/g
40
+ self.rd = sbd # g/cm^3
41
+
42
+ sb, st, siu = self._simga_p()
43
+
44
+ e0_bl, e0_bm, e0_bh, e0_tl, e0_th, e0_iuh = self._e0pq()
45
+
46
+ tau_bl, tau_tl, tau_bm, tau_bh, tau_th, tau_iuh = self._relax_time()
47
+
48
+ er_b, ei_b = self._eps_p(e0_bl, e0_bm, e0_bh, tau_bl, tau_bm, tau_bh)
49
+ er_t, ei_t = self._eps_p(e0_tl, e0_tl, e0_th, tau_tl, tau_tl, tau_th)
50
+ er_iu, ei_iu = self._eps_p(e0_iuh, e0_iuh, e0_iuh, tau_iuh, tau_iuh, tau_iuh)
51
+
52
+ nb, kb = self._RI_NAC(er_b, ei_b)
53
+ nt, kt = self._RI_NAC(er_t, ei_t)
54
+ niu, kiu = self._RI_NAC(er_iu, ei_iu)
55
+
56
+ self.es = self._CRI(nb, kb, nt, kt, niu, kiu, sb, st, siu)
57
+
58
+ return None
59
+
60
+
61
+ def run(self):
62
+ return self.es
63
+
64
+ def _extract_model_constant(self, water_phase, data, dtype, temp, param):
65
+ # Load the JSON data (replace 'your_file.json' with the actual filename)
66
+ with open(self.constant_file_path, 'r') as file:
67
+ table2_constants = json.load(file)
68
+
69
+ return table2_constants["TD-MRSDM-constants"]["water-phase"][water_phase][data][dtype][temp][param]
70
+
71
+ def _simga_p(self):
72
+ data = 'electrical-conductivity'
73
+ dtype = 'temperature-range'
74
+
75
+ # Extract all positive temperatures
76
+ s0_bp = self._extract_model_constant('bound-water', data, dtype, 't_gte_0C', 'sigma(tsp)')
77
+ bv0_bp = self._extract_model_constant('bound-water', data, dtype, 't_gte_0C', 'betap')
78
+ tsp_bp = self._extract_model_constant('bound-water', data, dtype, 't_gte_0C', 'tsp')
79
+
80
+ s0_tp = self._extract_model_constant('transient-water', data, dtype, 't_gte_0C', 'sigma(tsp)')
81
+ bv0_tp = self._extract_model_constant('transient-water', data, dtype, 't_gte_0C', 'betap')
82
+ tsp_tp = self._extract_model_constant('transient-water', data, dtype, 't_gte_0C', 'tsp')
83
+
84
+ s0_u = self._extract_model_constant('ice-unbound-water', data, dtype, 't_gte_0C', 'sigma(tsp)')
85
+ bv0_u = self._extract_model_constant('ice-unbound-water', data, dtype, 't_gte_0C', 'betap')
86
+ tsp_u = self._extract_model_constant('ice-unbound-water', data, dtype, 't_gte_0C', 'tsp')
87
+
88
+ # Extract all negative temperatures
89
+ s0_bn = self._extract_model_constant('bound-water', data, dtype, 't_lte_-1C', 'sigma(tsp)')
90
+ bv0_bn = self._extract_model_constant('bound-water', data, dtype, 't_lte_-1C', 'betap')
91
+ tsp_bn = self._extract_model_constant('bound-water', data, dtype, 't_lte_-1C', 'tsp')
92
+
93
+ s0_tn = self._extract_model_constant('transient-water', data, dtype, 't_lte_-1C', 'sigma(tsp)')
94
+ bv0_tn = self._extract_model_constant('transient-water', data, dtype, 't_lte_-1C', 'betap')
95
+ tsp_tn = self._extract_model_constant('transient-water', data, dtype, 't_lte_-1C', 'tsp')
96
+
97
+ s0_i = self._extract_model_constant('ice-unbound-water', data, dtype, 't_lte_-1C', 'sigma(tsp)')
98
+ bv0_i = self._extract_model_constant('ice-unbound-water', data, dtype, 't_lte_-1C', 'betap')
99
+ tsp_i = self._extract_model_constant('ice-unbound-water', data, dtype, 't_lte_-1C', 'tsp')
100
+
101
+
102
+ sb = np.where(self.T >= 0,
103
+ s0_bp + bv0_bp * (self.T - tsp_bp),
104
+ s0_bn + bv0_bn * (self.T - tsp_bn))
105
+ st = np.where(self.T >= 0,
106
+ s0_tp + bv0_tp * (self.T - tsp_tp),
107
+ s0_tn + bv0_tn * (self.T - tsp_tn))
108
+ siu = np.where(self.T >= 0,
109
+ s0_u + bv0_u * (self.T - tsp_u),
110
+ s0_i + bv0_i * (self.T - tsp_i))
111
+
112
+ return sb, st, siu
113
+
114
+
115
+ def _CM_law(self, T, e0pQ, bvpQ, TsepQ):
116
+ FpQ = np.log((e0pQ - 1) / (e0pQ + 2))
117
+ return (1 + 2 * np.exp(FpQ - bvpQ * (T - TsepQ))) / (1 - np.exp(FpQ - bvpQ * (T - TsepQ)))
118
+
119
+
120
+ def _e0pq(self):
121
+
122
+ data = 'relaxation-time'
123
+
124
+ # Bound water (p=b)
125
+ e0_bl_neg = self._extract_model_constant('bound-water', data, 'low-frequency', 't_lte_-1C', 'e0p')
126
+ b0_bl_neg = self._extract_model_constant('bound-water', data, 'low-frequency', 't_lte_-1C', 'bv0p')
127
+ tse0p_bl_neg = self._extract_model_constant('bound-water', data, 'low-frequency', 't_lte_-1C', 'tse0p')
128
+
129
+ e0_bm_neg = self._extract_model_constant('bound-water', data, 'mid-frequency', 't_lte_-1C', 'e0p')
130
+ b0_bm_neg = self._extract_model_constant('bound-water', data, 'mid-frequency', 't_lte_-1C', 'bv0p')
131
+ tse0p_bm_neg = self._extract_model_constant('bound-water', data, 'mid-frequency', 't_lte_-1C', 'tse0p')
132
+
133
+ e0_bh_neg = self._extract_model_constant('bound-water', data, 'high-frequency', 't_lte_-1C', 'e0p')
134
+ b0_bh_neg = self._extract_model_constant('bound-water', data, 'high-frequency', 't_lte_-1C', 'bv0p')
135
+ tse0p_bh_neg = self._extract_model_constant('bound-water', data, 'high-frequency', 't_lte_-1C', 'tse0p')
136
+
137
+ e0_bl_pos = self._extract_model_constant('bound-water', data, 'low-frequency', 't_gte_0C', 'e0p')
138
+ b0_bl_pos = self._extract_model_constant('bound-water', data, 'low-frequency', 't_gte_0C', 'bv0p')
139
+ tse0p_bl_pos = self._extract_model_constant('bound-water', data, 'low-frequency', 't_gte_0C', 'tse0p')
140
+
141
+ e0_bm_pos = self._extract_model_constant('bound-water', data, 'mid-frequency', 't_gte_0C', 'e0p')
142
+ b0_bm_pos = self._extract_model_constant('bound-water', data, 'mid-frequency', 't_gte_0C', 'bv0p')
143
+ tse0p_bm_pos = self._extract_model_constant('bound-water', data, 'mid-frequency', 't_gte_0C', 'tse0p')
144
+
145
+ e0_bh_pos = self._extract_model_constant('bound-water', data, 'high-frequency', 't_gte_0C', 'e0p')
146
+ b0_bh_pos = self._extract_model_constant('bound-water', data, 'high-frequency', 't_gte_0C', 'bv0p')
147
+ tse0p_bh_pos = self._extract_model_constant('bound-water', data, 'high-frequency', 't_gte_0C', 'tse0p')
148
+
149
+ # Transient bound water (p=t)
150
+ e0_tl_neg = self._extract_model_constant('transient-water', data, 'low-frequency', 't_lte_-1C', 'e0p')
151
+ b0_tl_neg = self._extract_model_constant('transient-water', data, 'low-frequency', 't_lte_-1C', 'bv0p')
152
+ tse0p_tl_neg = self._extract_model_constant('transient-water', data, 'low-frequency', 't_lte_-1C', 'tse0p')
153
+
154
+ e0_th_neg = self._extract_model_constant('transient-water', data, 'high-frequency', 't_lte_-1C', 'e0p')
155
+ b0_th_neg = self._extract_model_constant('transient-water', data, 'high-frequency', 't_lte_-1C', 'bv0p')
156
+ tse0p_th_neg = self._extract_model_constant('transient-water', data, 'high-frequency', 't_lte_-1C', 'tse0p')
157
+
158
+ e0_tl_pos = self._extract_model_constant('transient-water', data, 'low-frequency', 't_gte_0C', 'e0p')
159
+ b0_tl_pos = self._extract_model_constant('transient-water', data, 'low-frequency', 't_gte_0C', 'bv0p')
160
+ tse0p_tl_pos = self._extract_model_constant('transient-water', data, 'low-frequency', 't_gte_0C', 'tse0p')
161
+
162
+ e0_th_pos = self._extract_model_constant('transient-water', data, 'high-frequency', 't_gte_0C', 'e0p')
163
+ b0_th_pos = self._extract_model_constant('transient-water', data, 'high-frequency', 't_gte_0C', 'bv0p')
164
+ tse0p_th_pos = self._extract_model_constant('transient-water', data, 'high-frequency', 't_gte_0C', 'tse0p')
165
+
166
+ # Moistured ie (p=i)
167
+ e0_il_neg = self._extract_model_constant('ice-unbound-water', data, 'low-frequency', 't_lte_-1C', 'e0p')
168
+ b0_il_neg = self._extract_model_constant('ice-unbound-water', data, 'low-frequency', 't_lte_-1C', 'bv0p')
169
+ tse0p_il_neg = self._extract_model_constant('ice-unbound-water', data, 'low-frequency', 't_lte_-1C', 'tse0p')
170
+
171
+ # Unbound water (p=u)
172
+ e0_uh_pos = self._extract_model_constant('ice-unbound-water', data, 'high-frequency', 't_gte_0C', 'e0p')
173
+ b0_uh_pos = self._extract_model_constant('ice-unbound-water', data, 'high-frequency', 't_gte_0C', 'bv0p')
174
+ tse0p_uh_pos = self._extract_model_constant('ice-unbound-water', data, 'high-frequency', 't_gte_0C', 'tse0p')
175
+
176
+ eps_bl = np.where(self.T >= 0,
177
+ self._CM_law(self.T, e0_bl_pos, b0_bl_pos, tse0p_bl_pos),
178
+ self._CM_law(self.T, e0_bl_neg, b0_bl_neg, tse0p_bl_neg))
179
+ eps_bm = np.where(self.T >= 0,
180
+ self._CM_law(self.T, e0_bm_pos, b0_bm_pos, tse0p_bm_pos),
181
+ self._CM_law(self.T, e0_bm_neg, b0_bm_neg, tse0p_bm_neg))
182
+ eps_bh = np.where(self.T >= 0,
183
+ self._CM_law(self.T, e0_bh_pos, b0_bh_pos, tse0p_bh_pos),
184
+ self._CM_law(self.T, e0_bh_neg, b0_bh_neg, tse0p_bh_neg))
185
+ eps_tl = np.where(self.T >= 0,
186
+ self._CM_law(self.T, e0_tl_pos, b0_tl_pos, tse0p_tl_pos),
187
+ self._CM_law(self.T, e0_tl_neg, b0_tl_neg, tse0p_tl_neg))
188
+ eps_th = np.where(self.T >= 0,
189
+ self._CM_law(self.T, e0_th_pos, b0_th_pos, tse0p_th_pos),
190
+ self._CM_law(self.T, e0_th_neg, b0_th_neg, tse0p_th_neg))
191
+ eps_iuh = np.where(self.T >= 0,
192
+ self._CM_law(self.T, e0_uh_pos, b0_uh_pos, tse0p_uh_pos),
193
+ self._CM_law(self.T, e0_il_neg, b0_il_neg, tse0p_il_neg))
194
+
195
+ return eps_bl, eps_bm, eps_bh, eps_tl, eps_th, eps_iuh
196
+
197
+
198
+ def _relax_time(self):
199
+
200
+ data = 'relaxation-time'
201
+
202
+ # Bound water (p=b)
203
+ dHR_bl_neg = self._extract_model_constant('bound-water', data, 'low-frequency', 't_lte_-1C', 'dHp/R')
204
+ dSR_bl_neg = self._extract_model_constant('bound-water', data, 'low-frequency', 't_lte_-1C', 'dSp/R')
205
+ dHR_bm_neg = self._extract_model_constant('bound-water', data, 'mid-frequency', 't_lte_-1C', 'dHp/R')
206
+ dSR_bm_neg = self._extract_model_constant('bound-water', data, 'mid-frequency', 't_lte_-1C', 'dSp/R')
207
+ dHR_bh_neg = self._extract_model_constant('bound-water', data, 'high-frequency', 't_lte_-1C', 'dHp/R')
208
+ dSR_bh_neg = self._extract_model_constant('bound-water', data, 'high-frequency', 't_lte_-1C', 'dSp/R')
209
+
210
+ dHR_bl_pos = self._extract_model_constant('bound-water', data, 'low-frequency', 't_gte_0C', 'dHp/R')
211
+ dSR_bl_pos = self._extract_model_constant('bound-water', data, 'low-frequency', 't_gte_0C', 'dSp/R')
212
+ dHR_bm_pos = self._extract_model_constant('bound-water', data, 'mid-frequency', 't_gte_0C', 'dHp/R')
213
+ dSR_bm_pos = self._extract_model_constant('bound-water', data, 'mid-frequency', 't_gte_0C', 'dSp/R')
214
+ dHR_bh_pos = self._extract_model_constant('bound-water', data, 'high-frequency', 't_gte_0C', 'dHp/R')
215
+ dSR_bh_pos = self._extract_model_constant('bound-water', data, 'high-frequency', 't_gte_0C', 'dSp/R')
216
+
217
+ # Transient bound water (p=t)
218
+ dHR_tl_neg = self._extract_model_constant('transient-water', data, 'low-frequency', 't_lte_-1C', 'dHp/R')
219
+ dSR_tl_neg = self._extract_model_constant('transient-water', data, 'low-frequency', 't_lte_-1C', 'dSp/R')
220
+ dHR_th_neg = self._extract_model_constant('transient-water', data, 'high-frequency', 't_lte_-1C', 'dHp/R')
221
+ dSR_th_neg = self._extract_model_constant('transient-water', data, 'high-frequency', 't_lte_-1C', 'dSp/R')
222
+
223
+ dHR_tl_pos = self._extract_model_constant('transient-water', data, 'low-frequency', 't_gte_0C', 'dHp/R')
224
+ dSR_tl_pos = self._extract_model_constant('transient-water', data, 'low-frequency', 't_gte_0C', 'dSp/R')
225
+ dHR_th_pos = self._extract_model_constant('transient-water', data, 'high-frequency', 't_gte_0C', 'dHp/R')
226
+ dSR_th_pos = self._extract_model_constant('transient-water', data, 'high-frequency', 't_gte_0C', 'dSp/R')
227
+
228
+ # Moistured ie (p=i)
229
+ dHR_il_neg = self._extract_model_constant('ice-unbound-water', data, 'low-frequency', 't_lte_-1C', 'dHp/R')
230
+ dSR_il_neg = self._extract_model_constant('ice-unbound-water', data, 'low-frequency', 't_lte_-1C', 'dSp/R')
231
+
232
+ # Unbound water (p=u)
233
+ dHR_uh_pos = self._extract_model_constant('ice-unbound-water', data, 'high-frequency', 't_gte_0C', 'dHp/R')
234
+ dSR_uh_pos = self._extract_model_constant('ice-unbound-water', data, 'high-frequency', 't_gte_0C', 'dSp/R')
235
+
236
+ # Temp in kelvin
237
+ t_kelvin = self.T + 273.15
238
+
239
+ # https://en.wikipedia.org/wiki/List_of_physical_constants
240
+ h_plank = 6.624E-34 # Planck constant
241
+ k_boltz = 1.38E-23 # Boltzmann constant
242
+
243
+ # this specific ratio doesn’t have a unique name on its own and is usually referred to as simply
244
+ # the "Planck-to-Boltzmann ratio" or the "dimensionless ratio h/kT" in thermal analyses.
245
+ hkt = h_plank / k_boltz / t_kelvin
246
+
247
+ tau_bl = np.where(self.T >= 0,
248
+ hkt * np.exp((dHR_bl_pos / t_kelvin) - dSR_bl_pos),
249
+ hkt * np.exp((dHR_bl_neg / t_kelvin) - dSR_bl_neg))
250
+ tau_bm = np.where(self.T >= 0,
251
+ hkt * np.exp((dHR_bm_pos / t_kelvin) - dSR_bm_pos),
252
+ hkt * np.exp((dHR_bm_neg / t_kelvin) - dSR_bm_neg))
253
+ tau_bh = np.where(self.T >= 0,
254
+ hkt * np.exp((dHR_bh_pos / t_kelvin) - dSR_bh_pos),
255
+ hkt * np.exp((dHR_bh_neg / t_kelvin) - dSR_bh_neg))
256
+ tau_tl = np.where(self.T >= 0,
257
+ hkt * np.exp((dHR_tl_pos / t_kelvin) - dSR_tl_pos),
258
+ hkt * np.exp((dHR_tl_neg / t_kelvin) - dSR_tl_neg))
259
+ tau_th = np.where(self.T >= 0,
260
+ hkt * np.exp((dHR_th_pos / t_kelvin) - dSR_th_pos),
261
+ hkt * np.exp((dHR_th_neg / t_kelvin) - dSR_th_neg))
262
+ tau_iuh = np.where(self.T >= 0,
263
+ hkt * np.exp((dHR_uh_pos / t_kelvin) - dSR_uh_pos),
264
+ hkt * np.exp((dHR_il_neg / t_kelvin) - dSR_il_neg))
265
+
266
+ return tau_bl, tau_tl, tau_bm, tau_bh, tau_th, tau_iuh
267
+
268
+
269
+ def _eps_p(self, eps_pL, eps_pM, eps_pH, tau_pL, tau_pM, tau_pH):
270
+ eps_inf = 4.9
271
+ omega = 2 * np.pi * self.f
272
+ real = ((eps_pL - eps_pM) / (1 + (omega * tau_pL)**2)) + \
273
+ ((eps_pM - eps_pH) / (1 + (omega * tau_pM)**2)) + \
274
+ ((eps_pH - eps_inf) / (1 + (omega * tau_pH)**2)) + eps_inf
275
+
276
+ imag = (((eps_pL - eps_pM) / (1 + (omega * tau_pL)**2)) * omega * tau_pL) + \
277
+ (((eps_pM - eps_pH) / (1 + (omega * tau_pM)**2)) * omega * tau_pM) + \
278
+ (((eps_pH - eps_inf) / (1 + (omega * tau_pH)**2)) * omega * tau_pH)
279
+
280
+ return real, imag
281
+
282
+
283
+ def _RI_NAC(self, er_p, ei_p):
284
+ npp = np.sqrt(np.sqrt(er_p**2 + ei_p**2) + er_p) / np.sqrt(2)
285
+ kp = np.sqrt(np.sqrt(er_p**2 + ei_p**2) - er_p) / np.sqrt(2)
286
+
287
+ return npp, kp
288
+
289
+
290
+ def _CRI(self, nb0, kb0, nt0, kt0, niu0, kiu0, sb, st, siu):
291
+
292
+ # Density of soil in thawed and frozen states (g/cm3)
293
+ rb, rt, ru, ri = 1, 1, 1, 0.917
294
+
295
+ # Permittivity of free space; epsilon_0: 8.85418782e-12 F/m, [Permittivity of vacuum]; https://en.wikipedia.org/wiki/List_of_physical_constants
296
+ eps0 = 8.85418782e-12
297
+
298
+ omega = 2 * np.pi * self.f * eps0
299
+
300
+ nm = 0.441 + 1.68e-3 * self.som # -30C <= T <= 25C
301
+ km = -0.002 + 1.48e-4 * self.som # -30C <= T <= 25C
302
+
303
+ nb = (nb0 - 1) / rb
304
+ kb = kb0 / rb
305
+
306
+ nt = (nt0 - 1) / rt
307
+ kt = kt0 / rt
308
+
309
+ nu = (niu0 - 1) / ru
310
+ ku = kiu0 / ru
311
+
312
+ ni = (niu0 - 1) / ri
313
+ ki = kiu0 / ri
314
+
315
+ # With error
316
+ # mg1 = np.where(self.T >= 0, 0.118 + 8.7e-4 * self.som - 9.6e-4 * self.T, 0.114 + 9.5e-4 * self.som + 12.3e-4 * self.T)
317
+ # mg2 = np.where(self.T >= 0, 0.38 + 9.2e-4 * self.som - 119.1e-4 * self.T, 0.2 + 14.9e-4 * self.som + 0.186 * np.exp(self.T / 6.59))
318
+
319
+ # # Without error
320
+ # mg1 = np.where(self.T >= 0, 0.118 + 8.7e-4 * self.som - 9.6e-4 * self.T, 0.114 + 9.5e-4 * self.som + 12.3e-4 * self.T)
321
+ # mg2 = np.where(self.T >= 0, 0.38 + 9.2e-4 * self.som - 1.91e-4 * self.T, 0.2 + 14.9e-4 * self.som + 0.186 * np.exp(self.T / 6.59))
322
+
323
+ # Paper 2019 for 1.41GHz
324
+ mg1 = np.where(self.T >= 0, 0.118 + 8.695e-4 * self.som - 9.6e-4 * self.T, 0.114 + 9.516e-4 * self.som + 1.23e-3 * self.T)
325
+ mg2 = np.where(self.T >= 0, 0.382 + 9.208e-4 * self.som - 1.91e-3 * self.T, 0.205 + 1.43e-3 * self.som + 0.187 * np.exp(self.T / 6.6))
326
+
327
+ niu = np.where(self.T >= 0, nu, ni)
328
+ kiu = np.where(self.T >= 0, ku, ki)
329
+ riu = np.where(self.T >= 0, ru, ri)
330
+
331
+ nss = np.where(self.mg <= mg1, (nm + nb * self.mg),
332
+ np.where((mg1 <= self.mg) & (self.mg <= mg2), (nm + nb * mg1 + nt * (self.mg - mg1)),
333
+ np.where(self.mg >= mg2, (nm + nb * mg1 + nt * (mg2 - mg1) + niu * (self.mg - mg2)), 0.)))
334
+
335
+ kss = np.where(self.mg <= mg1, (km + kb * self.mg),
336
+ np.where((mg1 <= self.mg) & (self.mg <= mg2), (km + kb * mg1 + kt * (self.mg - mg1)),
337
+ np.where(self.mg >= mg2, (km + kb * mg1 + kt * (mg2 - mg1) + kiu * (self.mg - mg2)), 0.)))
338
+
339
+ ns = nss * self.rd + 1
340
+ ks = kss * self.rd
341
+
342
+ esr = ns**2 - ks**2
343
+ esi = 2 * ns * ks
344
+
345
+ esi = np.where((0 <= self.mg) & (self.mg <= mg1),
346
+ esi + self.rd * ((self.mg / rb) * sb) / omega,
347
+ np.where((mg1 <= self.mg) & (self.mg <= mg2),
348
+ esi + self.rd * (((mg1 / rb) * sb) + (((self.mg - mg1) / rt) * st)) / omega,
349
+ np.where(self.mg >= mg2,
350
+ esi + self.rd * (((mg1 / rb) * sb) + (((mg2 - mg1) / rt) * st) + (((self.mg - mg2) / riu) * siu)) / omega, 0.)
351
+ )
352
+ )
353
+
354
+ eps = esr + esi * 1j
355
+
356
+ return eps
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.4
2
+ Name: tdmrsdm
3
+ Version: 2025.7.1.dev1
4
+ Summary: A Temperature-Dependent Multi-Relaxation Spectroscopic Dielectric Model (TD-MRSDM).
5
+ Author-email: Morteza Khazaei <morteza.khazaei@usherbrooke.ca>
6
+ License: MIT License
7
+ Project-URL: Homepage, https://github.com/Morteza-Khazaei/TD-MRSDM
8
+ Project-URL: Repository, https://github.com/Morteza-Khazaei/TD-MRSDM
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.7
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.7
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: matplotlib
19
+ Requires-Dist: seaborn
20
+ Requires-Dist: numpy
21
+ Dynamic: license-file
22
+
23
+ # TD-MRSDM
24
+
25
+ [![Python Version](https://img.shields.io/badge/python-3.7%20|%203.8%20|%203.9-blue.svg)](https://www.python.org/downloads/)
26
+
27
+
28
+ This Python package, based on the paper titled [Spectroscopic Multirelaxation Dielectric Model of Thawed and Frozen Arctic Soils Considering the Dependence on Temperature and Organic Matter Content](https://doi.org/10.1134/S0001433819090305), provides an implementation of the temperature-dependent multi-relaxation spectroscopic dielectric model described in the paper. The model is designed for characterizing the dielectric properties of organic soil at frequencies ranging from 0.05 to 15 GHz under various temperature conditions.
29
+
30
+ <p float="center">
31
+ <img src="figures/TD-MRSDM.png" width="800">
32
+ </p>
33
+
34
+ ## Installation
35
+
36
+ To use **TD-MRSDM**, you need to install it first. You can install it using `pip`:
37
+
38
+ ```bash
39
+ pip install tdmrsdm
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ Here's a simple example of how to use the smwlst package to compute LST:
45
+
46
+ ```python
47
+ import numpy as np
48
+ import matplotlib.pyplot as plt
49
+ import seaborn as sns
50
+ from tdmrsdm import TDMRSDM
51
+
52
+
53
+ # Define temperature and MgCl2 concentration ranges
54
+ ssts = np.arange(-30, 26, 1) # From -30 to 25 degrees Celsius
55
+ mvs = np.arange(0, 0.86, 0.01) # From 0 to 0.85
56
+
57
+ # Create empty lists to store results
58
+ epsr_values = []
59
+ epsi_values = []
60
+ moisture_values = []
61
+
62
+
63
+ # Loop through soil moisture content
64
+ for mv in mvs:
65
+ for sst in ssts:
66
+ mrsdm = TDMRSDM(freq_GHz=1.41, sst=sst, som=25, sbd=0.95, ssm=mv)
67
+ eps = mrsdm.run()
68
+ epsr, epsi = eps.real, eps.imag
69
+ epsr_values.append(epsr[0]) # Access the first element because epsr is an array
70
+ epsi_values.append(epsi[0]) # Access the first element because epsi is an array
71
+ moisture_values.append(mv)
72
+
73
+
74
+ # Create the plot using seaborn
75
+ plt.figure(figsize=(10, 6))
76
+ sns.lineplot(x=moisture_values, y=epsr_values, label='Real Soil DC')
77
+ sns.lineplot(x=moisture_values, y=epsi_values, label='Imaginary Soil DC')
78
+
79
+ plt.xlabel('Soil Moisture (g/g)')
80
+ plt.ylabel('Soil DC')
81
+ plt.title('Real and Imaginary Soil DC as a Function of Soil Moisture')
82
+ plt.legend()
83
+ plt.grid(True)
84
+ plt.show()
85
+
86
+ ```
87
+ <p float="center">
88
+ <img src="figures/soil_dc_vs_ssm.png" width="800">
89
+ </p>
90
+
91
+ >[!WARNING]
92
+ >**Copyright Notice:** This code is part of a PhD research program and is not licensed for public use or distribution yet! All rights are reserved by the author [**Morteza Khazaei**]. Unauthorized use, reproduction, or distribution of this code is prohibited without prior written permission from the author. For inquiries or collaboration, please contact [morteza.khazaei@usherbrooke.ca](morteza.khazaei@usherbrooke.ca).
93
+
94
+ ## Authors
95
+
96
+ - [Morteza Khazaei - [morteza.khazaei@usherbrooke.ca]](https://github.com/Morteza-Khazaei)
97
+
98
+ ## References
99
+
100
+ - [Mironov, V., & Savin, I. (2015). A temperature-dependent multi-relaxation spectroscopic dielectric model for thawed and frozen organic soil at 0.05–15 GHz. Physics and Chemistry of the Earth, Parts A/B/C, 83, 57-64.](https://doi.org/10.1016/j.pce.2015.02.011)
@@ -0,0 +1,10 @@
1
+ tdmrsdm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ tdmrsdm/core.py,sha256=wNrfbzMeGy_tUwN0AbVL1HW6bd7FS5Oyzq5iQ2FskLc,18977
3
+ tdmrsdm/constants/td_mrsdm_constants_v2019.json,sha256=YrvNZy5wc61i4f39Rc9C3P3oZZijdpkgsL0Q1YRD4e8,5617
4
+ tdmrsdm/constants/td_mrsdm_constants_v2019_optimized_v1.json,sha256=JXGJ2UndQPWDh6m78CAXlI8VM5RQAisbIhOFSvGBQp8,5628
5
+ tdmrsdm/constants/td_mrsdm_constants_v2019_optimized_v2.json,sha256=-g_B-kgo88t0WNQ_hmC3Rz1UY91rtWEFnzeArOtO6BQ,5672
6
+ tdmrsdm-2025.7.1.dev1.dist-info/licenses/LICENSE,sha256=ONDcqcAEcN1zWyfH0WqkgOjLXAz0h2vVDLlSkCS1VN4,1072
7
+ tdmrsdm-2025.7.1.dev1.dist-info/METADATA,sha256=B02WUCU6AlHx9ifXdW0EZbUsdwHi4gFlSLB4xnT3glk,3877
8
+ tdmrsdm-2025.7.1.dev1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ tdmrsdm-2025.7.1.dev1.dist-info/top_level.txt,sha256=_Z7_igXSeiydZMWm0FutMzwtCIKSolPtgdWETL1PYSs,8
10
+ tdmrsdm-2025.7.1.dev1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Morteza Khazaei
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ tdmrsdm