Commit cb3e6183 by Cyrill Mast

### Improving analytical derivative

parent 98b64a49
Pipeline #88019 canceled with stages
in 1 minute and 55 seconds
 ... ... @@ -278,11 +278,15 @@ class ScatteringField(BaseYosioka, BaseScattering): coeff = 0 raise NotImplementedError out = exp(1j * (self.omega * self.t)) degrees = len(coeff) out *= sum([coeff[n] * (lpmv(2, n, cos(self.theta))) for n in range(degrees)]) out *= -sin(self.theta) out /= self.r 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 *= -sin(self.theta) / self.r return out def _compute_Phi_s(self) -> complex: ... ... @@ -356,11 +360,14 @@ class ScatteringField(BaseYosioka, BaseScattering): coeff = 0 raise NotImplementedError out = exp(1j * (self.omega * self.t)) degrees = len(coeff) out *= sum([coeff[n] * (lpmv(2, n, cos(self.theta))) for n in range(degrees)]) out *= -sin(self.theta) out /= self.r 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 *= -sin(self.theta) / self.r return out def _compute_Phi_star(self) -> complex: ... ... @@ -419,6 +426,7 @@ class ScatteringField(BaseYosioka, BaseScattering): according to (19) for travelling waves and (30) for standing waves """ # (19) if self.wave_type == "traveling": coeff = self.legendre_coeffs(lambda n: ... ... @@ -433,13 +441,15 @@ class ScatteringField(BaseYosioka, BaseScattering): # No incident potential field coeff = 0 raise NotImplementedError out = exp(1j * (self.omega * self.t)) degrees = len(coeff) out *= sum([coeff[n] * (lpmv(2, n, cos(self.theta))) for n in range(degrees)]) out *= -sin(self.theta) out /= self.r 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 *= -sin(self.theta) / self.r return out # ------------------------------------------------------------------------- ... ...
 ... ... @@ -37,7 +37,7 @@ class TestYosiokaARF(BaseTest): self.wave_type = 'traveling' self.inf_type = 'radius' self.pos = 1e-4 n_max = 3 n_max = 1e10 self.cls = Yosioka1955.ARF(frequency=self.f, radius=self.R_0, rho_s=self.rho_s, ... ... @@ -85,13 +85,14 @@ class TestYosiokaARF(BaseTest): 'traveling', self.p0, self.pos) self.cls_list = [ self.cls, self.cls_num, self.cls_special, self.cls_bubble, self.cls_sphere, self.clsKing, self.clsGorkov self.cls # , # self.cls_num, # self.cls_special, # self.cls_bubble, # self.cls_sphere, # self.clsKing, # self.clsGorkov ] def randomly_change_parameters(self) -> None: ... ... @@ -148,8 +149,8 @@ class TestYosiokaARF(BaseTest): def test_arf(self) -> None: n = 0 while (n < 5): self.change_and_assign() while n < 1: # self.change_and_assign() for cls in self.cls_list: print(cls.acoustic_radiation_force()) print("") ... ...
 ... ... @@ -96,7 +96,7 @@ class TestScatteringField(unittest.TestCase): self.cls.wave_type = 'traveling' self.cls.n_max = 3 self.cls.r = 1e-6 acc = 20 acc = 3 theta = np.linspace(0, 2 * pi, acc) t = np.linspace(0, 5e-6, acc) phi = np.zeros((len(theta), len(t))) ... ... @@ -112,21 +112,22 @@ class TestScatteringField(unittest.TestCase): def test_velocities(self) -> None: self.cls.wave_type = 'traveling' self.cls.n_max = 10 self.cls.t = 1e-6 acc = 10 self.cls.n_max = 5 self.cls.t = 0 acc = 6 theta = np.linspace(0, 2 * pi, acc) r = np.linspace(1e-9, 1e-6, acc) vel = np.zeros((len(theta), len(r))) for ix, dx in enumerate(theta): self.cls.theta = dx for ir, dr in enumerate(r): self.cls.r = dr vel[ix][ir] = self.cls.tangential_particle_velocity( self.cls.r, self.cls.theta, self.cls.t) theta, r = np.meshgrid(theta, r) 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( r=self.r, theta=self.theta, t=self.cls.t) print(vel) fig, ax = plt.subplots(subplot_kw={"projection": "3d"}) ax.plot_surface(theta, r, vel, antialiased=True) theta, r = np.meshgrid(theta, r) ax.plot_surface(theta, r, vel) plt.show() ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!