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

bugfix: velocities adressing issue #31

parent b5b48e62
Pipeline #88518 failed with stages
in 2 minutes and 38 seconds
......@@ -2,7 +2,7 @@ from __future__ import annotations
from typing import Union
from gorkov import (
log, pi, full_range,
log, pi, full_range, exp,
BaseSphereFrequencyComposite,
Sphere, Frequency,
BackgroundField,
......@@ -74,15 +74,15 @@ class BaseYosioka(BaseSphereFrequencyComposite):
"ratio of speed of sounds")
self._F = ActiveVariable(self._compute_F,
"density-compressibility factor")
self._A_n = ActiveVariable(self._reset_A_n,
self._A_n = ActiveVariable(self._reset_coeff,
"Coefficient A_n"
" for scattered potential")
self._B_n = ActiveVariable(self._reset_B_n,
self._B_n = ActiveVariable(self._reset_coeff,
"Coefficient B_n"
" for potential inside particle")
self._M_n = ActiveVariable(self._reset_M_n,
self._M_n = ActiveVariable(self._reset_coeff,
"Coefficient M_n")
self._K_n = ActiveVariable(self._reset_K_n,
self._K_n = ActiveVariable(self._reset_coeff,
"Coefficient K_n")
# Dependencies
self._xlambda.is_computed_by(
......@@ -106,10 +106,12 @@ class BaseYosioka(BaseSphereFrequencyComposite):
self.solid._k_f, self._R_0
)
self._M_n.is_computed_by(self._omega,
self._t, self.solid._k_f, self._R_0
self._t, self.solid._k_f,
self._R_0, self._B_n
)
self._K_n.is_computed_by(self._omega,
self._t, self.solid._k_f, self._R_0
self._t, self.solid._k_f,
self._R_0, self._B_n
)
log.info(str(self))
......@@ -337,11 +339,7 @@ class BaseYosioka(BaseSphereFrequencyComposite):
# -------------------------------------------------------------------------
@staticmethod
def _reset_A_n() -> list:
return []
@staticmethod
def _reset_B_n() -> list:
def _reset_coeff() -> list:
return []
def A_n(self, n: int) -> complex:
......@@ -428,14 +426,6 @@ class BaseYosioka(BaseSphereFrequencyComposite):
"""
return self.rho_s / self.rho_f
@staticmethod
def _reset_K_n() -> list:
return []
@staticmethod
def _reset_M_n() -> list:
return []
def M_n(self, n: int) -> complex:
if n < len(self._M_n.value):
return self._M_n.value[n]
......@@ -459,6 +449,7 @@ class BaseYosioka(BaseSphereFrequencyComposite):
for n in full_range(n_old, N):
out = (-1j) ** n * self.B_n(n)
out *= sp.jn(n, self.k_s * self.R_0)
out *= exp(1j * self.omega * self.t)
self._M_n.value.append(out)
def _compute_K_n(self, N: int) -> None:
......@@ -470,6 +461,7 @@ class BaseYosioka(BaseSphereFrequencyComposite):
for n in full_range(n_old, N):
out = (-1j) ** n * self.B_n(n) * self.k_s
out *= sp.d_jn(n, self.k_s * self.R_0)
out *= exp(1j * self.omega * self.t)
self._K_n.value.append(out)
def _D(self, num: int, n: int) -> float:
......
......@@ -3,7 +3,7 @@ from gorkov import (ActiveVariable,
Frequency, Sphere,
LegendreFunctions as leg,
SpecialFunctions as sp,
exp, log, cos, sin)
exp, log, cos, sqrt)
from scipy.special import lpmv
from gorkov.solutions.Yosioka1955 import BaseYosioka
from gorkov.solutions.base_scattering import BaseScattering
......@@ -215,7 +215,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
self.field.A_in(n)
* sp.jn(n, self.k_f * self.r))
out = exp(1j * (self.omega * self.t))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta,
coeff)
return out
......@@ -226,7 +226,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
* self.k_f *
sp.d_jn(n, self.k_f * self.r))
out = exp(1j * (self.omega * self.t))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta,
coeff)
return out
......@@ -236,7 +236,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
self.field.A_in(n)
* sp.jn(n, self.k_f * self.r))
out = exp(1j * (self.omega * self.t))
out = exp(-1j * (self.omega * self.t))
p = [lpmv(1, n, cos(self.theta))
for n in range(len(coeff))]
......@@ -245,7 +245,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
if i > 0:
p_der.append(i * val * coeff[i - 1])
out *= sum(p_der)
out *= -sin(self.theta) / self.r
out *= -sqrt(1 - cos(self.theta) ** 2)
return out
def _compute_Phi_s(self) -> complex:
......@@ -260,7 +260,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
self.A_n(n)
* sp.hn(n, self.k_f * self.r))
out = exp(1j * (self.omega * self.t))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta, coeff)
return out
......@@ -270,7 +270,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
* self.k_f *
sp.d_hn(n, self.k_f * self.r))
out = exp(1j * (self.omega * self.t))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta, coeff)
return out
......@@ -279,7 +279,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
self.A_n(n)
* sp.hn(n, self.k_f * self.r))
out = exp(1j * (self.omega * self.t))
out = exp(-1j * (self.omega * self.t))
p = [lpmv(1, n, cos(self.theta))
for n in range(len(coeff))]
p_der = []
......@@ -287,7 +287,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
if i > 0:
p_der.append(i * val * coeff[i - 1])
out *= sum(p_der)
out *= -sin(self.theta) / self.r
out *= -sqrt(1 - cos(self.theta) ** 2)
return out
def _compute_Phi_star(self) -> complex:
......@@ -302,7 +302,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
self.B_n(n)
* sp.jn(n, self.k_s * self.r))
out = exp(1j * (self.omega * self.t))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta, coeff)
return out
......@@ -313,7 +313,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
* self.k_s *
sp.d_jn(n, self.k_s * self.r))
out = exp(1j * (self.omega * self.t))
out = exp(-1j * (self.omega * self.t))
out *= leg.first_cos_poly(self.theta, coeff)
return out
......@@ -323,7 +323,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
self.B_n(n)
* sp.jn(n, self.k_s * self.r))
out = exp(1j * (self.omega * self.t))
out = exp(-1j * (self.omega * self.t))
p = [lpmv(1, n, cos(self.theta))
for n in range(len(coeff))]
p_der = []
......@@ -331,7 +331,7 @@ class ScatteringField(BaseYosioka, BaseScattering):
if i > 0:
p_der.append(i * val * coeff[i - 1])
out *= sum(p_der)
out *= -sin(self.theta) / self.r
out *= -sqrt(1 - cos(self.theta) ** 2)
return out
# -------------------------------------------------------------------------
......
......@@ -116,13 +116,13 @@ class TestScatteringField(unittest.TestCase):
self.cls.t = 0
acc = 20
theta = np.linspace(0, 2 * pi, acc)
r = np.linspace(1e-9, 1e-6, acc)
r = np.linspace(1e-6, 1e-5, 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_particle_velocity(
vel[i_r][i_t] = self.cls.tangential_acoustic_fluid_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