Skip to content

Commit 2f4a4f1

Browse files
author
Thomas Baumann
committed
Added exponential growth to quench problem
1 parent 7697003 commit 2f4a4f1

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

pySDC/implementations/problem_classes/LeakySuperconductor.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(self, problem_params, dtype_u=mesh, dtype_f=mesh):
4040
'u_max': 2e-2,
4141
'Q_max': 1.0,
4242
'leak_range': (0.45, 0.55),
43+
'leak_type': 'linear',
4344
'order': 2,
4445
'stencil_type': 'center',
4546
'bc': 'neumann-zero',
@@ -116,7 +117,13 @@ def eval_f_non_linear(self, u, t):
116117
Q_max = self.params.Q_max
117118
me = self.dtype_u(self.init)
118119

119-
me[:] = (u - u_thresh) / (u_max - u_thresh) * Q_max
120+
if self.params.leak_type == 'linear':
121+
me[:] = (u - u_thresh) / (u_max - u_thresh) * Q_max
122+
elif self.params.leak_type == 'exponential':
123+
me[:] = Q_max * (np.exp(u) - np.exp(u_thresh)) / (np.exp(u_max) - np.exp(u_thresh))
124+
else:
125+
raise NotImplementedError(f'Leak type {self.params.leak_type} not implemented!')
126+
120127
me[u < u_thresh] = 0
121128
me[self.leak] = Q_max
122129
me[u >= u_max] = Q_max
@@ -160,7 +167,13 @@ def get_non_linear_Jacobian(self, u):
160167
Q_max = self.params.Q_max
161168
me = self.dtype_u(self.init)
162169

163-
me[:] = Q_max / (u_max - u_thresh)
170+
if self.params.leak_type == 'linear':
171+
me[:] = Q_max / (u_max - u_thresh)
172+
elif self.params.leak_type == 'exponential':
173+
me[:] = Q_max * np.exp(u) / (np.exp(u_max) - np.exp(u_thresh))
174+
else:
175+
raise NotImplementedError(f'Leak type {self.params.leak_type} not implemented!')
176+
164177
me[u < u_thresh] = 0
165178
me[u > u_max] = 0
166179
me[self.leak] = 0

pySDC/projects/Resilience/leaky_superconductor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def plot_solution(stats, controller): # pragma: no cover
194194
dt_ax.set_ylabel(r'$\Delta t$')
195195

196196

197-
def compare_imex_full(plotting=False):
197+
def compare_imex_full(plotting=False, leak_type='linear'):
198198
"""
199199
Compare the results of IMEX and fully implicit runs. For IMEX we need to limit the step size in order to achieve convergence, but for fully implicit, adaptivity can handle itself better.
200200
@@ -218,6 +218,7 @@ def compare_imex_full(plotting=False):
218218
'newton_tol': 1e-10,
219219
'newton_iter': newton_iter_max,
220220
'nvars': 2**9,
221+
'leak_type': leak_type,
221222
}
222223
custom_description['step_params'] = {'maxiter': maxiter}
223224
custom_description['sweeper_params'] = {'num_nodes': num_nodes}
@@ -229,7 +230,7 @@ def compare_imex_full(plotting=False):
229230
custom_description=custom_description,
230231
custom_controller_params=custom_controller_params,
231232
imex=imex,
232-
Tend=5e2,
233+
Tend=4.3e2,
233234
hook_class=[LogWork, LogGlobalErrorPostRun],
234235
)
235236

pySDC/tests/test_projects/test_resilience/test_leaky_superconductor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33

44
@pytest.mark.base
5-
def test_imex_vs_fully_implicit_leaky_superconductor():
5+
@pytest.mark.parametrize('leak_type', ['linear', 'exponential'])
6+
def test_imex_vs_fully_implicit_leaky_superconductor(leak_type):
67
"""
78
Test if the IMEX and fully implicit schemes get the same solution and that the runaway process has started.
89
"""
910
from pySDC.projects.Resilience.leaky_superconductor import compare_imex_full
1011

11-
compare_imex_full()
12+
compare_imex_full(plotting=False, leak_type=leak_type)

0 commit comments

Comments
 (0)