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 a8b5306b authored by Cyrill Mast's avatar Cyrill Mast
Browse files

bugfix: velocities adressing issue #31

parent 831f8419
Pipeline #88544 failed with stages
in 2 minutes and 34 seconds
......@@ -3,8 +3,7 @@ from gorkov import (ActiveVariable,
Frequency, Sphere,
LegendreFunctions as leg,
SpecialFunctions as sp,
exp, log, cos, sqrt)
from scipy.special import lpmv
exp, log)
from gorkov.solutions.Yosioka1955 import BaseYosioka
from gorkov.solutions.base_scattering import BaseScattering
......@@ -18,7 +17,6 @@ class ScatteringField(BaseYosioka, BaseScattering):
particle_type: str,
position: Optional[float] = None,
n_max=None) -> None:
log.info('Create ScatteringField')
BaseYosioka.__init__(self, frequency, radius,
......@@ -216,8 +214,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
* sp.jn(n, self.k_f * self.r))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta,
coeff)
out *= leg.cos_poly(self.theta, coeff)
return out
def _compute_d_Phi_i_dr(self) -> complex:
......@@ -227,8 +224,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
sp.d_jn(n, self.k_f * self.r))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta,
coeff)
out *= leg.cos_poly(self.theta, coeff)
return out
def _compute_d_Phi_i_dtheta(self) -> complex:
......@@ -237,15 +233,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
* sp.jn(n, self.k_f * self.r))
out = exp(-1j * (self.omega * self.t))
p = [lpmv(1, n, cos(self.theta))
for n in range(len(coeff))]
p_der = []
for i, val in enumerate(p):
if i > 0:
p_der.append(i * val * coeff[i - 1])
out *= sum(p_der)
out *= -sqrt(1 - cos(self.theta) ** 2)
out *= leg.first_cos_poly(self.theta, coeff)
return out
def _compute_Phi_s(self) -> complex:
......@@ -261,7 +249,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
* sp.hn(n, self.k_f * self.r))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta, coeff)
out *= leg.cos_poly(self.theta, coeff)
return out
def _compute_d_Phi_s_dr(self) -> complex:
......@@ -271,7 +259,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
sp.d_hn(n, self.k_f * self.r))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta, coeff)
out *= leg.cos_poly(self.theta, coeff)
return out
def _compute_d_Phi_s_dtheta(self) -> complex:
......@@ -280,14 +268,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
* sp.hn(n, self.k_f * self.r))
out = exp(-1j * (self.omega * self.t))
p = [lpmv(1, n, cos(self.theta))
for n in range(len(coeff))]
p_der = []
for i, val in enumerate(p):
if i > 0:
p_der.append(i * val * coeff[i - 1])
out *= sum(p_der)
out *= -sqrt(1 - cos(self.theta) ** 2)
out *= leg.first_cos_poly(self.theta, coeff)
return out
def _compute_Phi_star(self) -> complex:
......@@ -303,35 +284,26 @@ class ScatteringField(BaseYosioka, BaseScattering):
* sp.jn(n, self.k_s * self.r))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta, coeff)
out *= leg.cos_poly(self.theta, coeff)
return out
def _compute_d_Phi_star_dr(self) -> complex:
coeff = self.legendre_coeffs(lambda n:
self.B_n(n)
* self.k_s *
sp.d_jn(n, self.k_s * self.r))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta, coeff)
out *= leg.cos_poly(self.theta, coeff)
return out
def _compute_d_Phi_star_dtheta(self) -> complex:
coeff = self.legendre_coeffs(lambda n:
self.B_n(n)
* sp.jn(n, self.k_s * self.r))
out = exp(-1j * (self.omega * self.t))
p = [lpmv(1, n, cos(self.theta))
for n in range(len(coeff))]
p_der = []
for i, val in enumerate(p):
if i > 0:
p_der.append(i * val * coeff[i - 1])
out *= sum(p_der)
out *= -sqrt(1 - cos(self.theta) ** 2)
out *= leg.first_cos_poly(self.theta, coeff)
return out
# -------------------------------------------------------------------------
......
......@@ -112,17 +112,17 @@ class TestScatteringField(unittest.TestCase):
def test_velocities(self) -> None:
self.cls.wave_type = 'traveling'
self.cls.n_max = 5
self.cls.n_max = 3
self.cls.t = 0
acc = 20
acc = 30
theta = np.linspace(0, 2 * pi, acc)
r = np.linspace(1e-6, 1e-5, acc)
r = np.linspace(1e-9, 1e-6, acc)
vel = np.zeros([acc, acc])
for i_t, val_t in enumerate(theta):
self.theta = val_t
for i_r, val_r in enumerate(r):
self.r = val_r
vel[i_r][i_t] = self.cls.tangential_acoustic_fluid_velocity(
vel[i_r][i_t] = self.cls.tangential_particle_velocity(
r=self.r, theta=self.theta, t=self.cls.t)
print(vel)
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
......
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