To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit b08617e7 authored by Jonas Fankhauser's avatar Jonas Fankhauser
Browse files

bugfix in _compute_general_arf where self.n_max is not set by user, 'Special' solution removed

parent 3851c7b8
......@@ -104,12 +104,14 @@ class ARF(ScatteringField, BaseARF):
:rtype: float
"""
if self.n_max is None:
self.n_max = 10
out = 4 * [0]
out = [0 for _ in range(5)]
if self.n_max is None:
N_max = 10
else:
N_max = self.N_max
for n in range(self.n_max):
for n in range(N_max):
# (45)
s1 = (self.K_n(n) * conj(self.K_n(n + 1))).real
s1 *= n + 1
......@@ -156,41 +158,6 @@ class ARF(ScatteringField, BaseARF):
return out
def _traveling_wave_solution_special(self) -> float:
"""
based on eq. (56)
:rtype: float
"""
out = 0
n = 0
while True:
num = ((n + 1) *
((self._D(1, n) * self._D(2, n + 1)
- self._D(2, n) * self._D(1, n + 1)))
** 2)
denom = ((self._D(1, n) ** 2 + self._D(2, n) ** 2) *
(self._D(1, n + 1) ** 2 + self._D(2, n + 1) ** 2))
out_prev = out
try:
out += num / denom
except ZeroDivisionError:
print("Early Termination due to zero division")
break
# condition when to terminate
# (change is less than 0.1% and at least 1000 iterations)
try:
error = abs((out - out_prev) / out_prev)
# at the beginning
except ZeroDivisionError:
error = 1
if n >= 100 or error < 0.001:
# print("Termination after {} iterations".format(n))
break
n += 1
out *= 2 * pi * self.rho_f
return out
def _compute_sphere_arf(self):
order_sphere = 1.0
mag = 10
......@@ -198,7 +165,7 @@ class ARF(ScatteringField, BaseARF):
self.xlambda > (1.0 * mag) * order_sphere,
(self.k_s * self.R_0) ** 2 > 1.0,
(self.k_f * self.R_0) ** 2 > 1.0]
for i, c in enumerate(conditions):
for c in conditions:
if c:
text = 'Criteria for small spheres might not be fulfilled.'
text += 'Consider using another model approach'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment