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

Merge branch 'developer' into patch/yosioka

parents 507091cc bc8627c1
Pipeline #91205 passed with stages
in 6 minutes and 25 seconds
......@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added - Jonas Fankhauser
- Streaming, Scattering, and ARF for Doinikov's Theory of viscoelastic fluids
of 2021
## [0.2.9] - 2021-04-15
### Changed - Christoph Goering
- unified position of units in doc string
## [0.2.8] - 2021-04-13
### Added - Cyrill Mast
- Acoustic Energy
- Acoustic Intensity
## [0.2.7] - 2021-03-29
### Changed - Cyrill Mast
- A_in was not dependent on the wavetype and was therefore not updated correctly
......@@ -15,11 +29,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- changed names of special functions
- updated tests for special funcitons
## [Unreleased]
### Added - Jonas Fankhauser
- Streaming, Scattering, and ARF for Doinikov's Theory of viscoelastic fluids
of 2021
## [0.2.5] - 2021-03-01
### Added - Cyrill Mast
- Spherical Neumann Functions
......
......@@ -23,9 +23,10 @@ class BackgroundField:
:param p_0: pressure amplitude in [Pa]
:type p_0: float
:param wave_type: wave type: either standing or traveling / travelling
:type wave_type: Optional[float]
:type wave_type: str = 'traveling'
:param position: position of the particle in the standing wave
field in [m], will be ignored for travelling wave
:type position: Optional[float] = None
:rtype: None
"""
......@@ -46,7 +47,10 @@ class BackgroundField:
"velocity potential amplitude A")
self._A_in = ActiveVariable(self._reset_A_in,
"velocity potential amplitude A_n")
self._E = ActiveVariable(self._compute_E,
"acoustic energy density E")
self._I = ActiveVariable(self._compute_I,
"acoustic intensity I")
# Dependencies
self._A.is_computed_by(self.fluid.frequency._omega,
self.fluid._rho_f,
......@@ -58,6 +62,17 @@ class BackgroundField:
self._A,
self._wave_type)
self._E.is_computed_by(
self._A,
self.fluid._rho_f,
self.fluid._k_f)
self._I.is_computed_by(
self._A,
self.fluid._rho_f,
self.fluid._k_f,
self.fluid._c_f)
# -------------------------------------------------------------------------
# Setters and Getters for Independent Variables
# -------------------------------------------------------------------------
......@@ -111,6 +126,7 @@ class BackgroundField:
@position.setter
def position(self, value: float) -> None:
self._position.value = value
# -------------------------------------------------------------------------
# Getters for Dependent Variables
# -------------------------------------------------------------------------
......@@ -123,6 +139,22 @@ class BackgroundField:
"""
return self._A.value
@property
def acoustic_energy_density(self) -> float:
"""Acoustic energy density [J/m^3]
:rtype: float
"""
return self._E.value
@property
def acoustic_intensity(self) -> float:
"""Acoustic Intensity [W/m^2]
:rtype: float
"""
return self._I.value
# -------------------------------------------------------------------------
# Method for Dependent Variables
# -------------------------------------------------------------------------
......@@ -191,11 +223,11 @@ class BackgroundField:
"'traveling'/'travelling' or 'standing'")
def A_in(self, n: int) -> complex:
"""Incident amplitude at order n
"""Incident amplitude at order n [Pa s]
:param n: order [-]
:param n: order
:type n: int
:rtype: complex [Pa s]
:rtype: complex
"""
if n < len(self._A_in.value):
return self._A_in.value[n]
......@@ -203,6 +235,15 @@ class BackgroundField:
self._compute_A_in(n)
return self._A_in.value[n]
def _compute_E(self) -> float:
return abs(self.A) * self.rho_f * self.k_f ** 2
def _compute_I(self) -> float:
out = abs(self.A)
out *= self.rho_f * self.fluid.c_f
out *= (self.fluid.k_f ** 2) / 2
return out
if __name__ == '__main__':
pass
......@@ -16,9 +16,9 @@ class InviscidFluid(BaseFrequencyComposite):
:param frequency: frequency in [Hz]
:type frequency: Union[int, float, Frequency]
:param rho: density in [km / m^3]
:param rho: density in [km/m^3]
:type rho: float
:param c: speed of sound [m / s]
:param c: speed of sound [m/s]
:type c: float
:rtype: None
"""
......@@ -84,25 +84,25 @@ class InviscidFluid(BaseFrequencyComposite):
@property
def kappa_f(self) -> float:
"""Returns the compressibility of the fluid
"""Returns the compressibility of the fluid [1/Pa]
:rtype: float [1/Pa]
:rtype: float
"""
return self._kappa_f.value
@property
def k_f(self) -> float:
"""Returns the wave number.
"""Returns the wave number [rad s^-1]
:rtype: float [rad s^-1]
:rtype: float
"""
return self._k_f.value
@property
def lambda_f(self) -> float:
"""Returns the wavelength
"""Returns the wavelength [m]
:rtype: float [m]
:rtype: float
"""
return self._lambda_f.value
......@@ -135,9 +135,9 @@ class ViscousFluid(InviscidFluid):
:param frequency: frequency in [Hz]
:type frequency: Union[int, float, Frequency]
:param rho: density in [km / m^3]
:param rho: density in [km/m^3]
:type rho: float
:param c: speed of sound [m / s]
:param c: speed of sound [m/s]
:type c: float
:param eta_f: shear viscosity [Pa s]
:type eta_f: float
......@@ -212,17 +212,17 @@ class ViscousFluid(InviscidFluid):
@property
def k_f(self) -> complex:
"""Returns the wave number in the fluid
"""Returns the wave number in the fluid [1/m]
:rtype: complex [1/m]
:rtype: complex
"""
return self._k_f.value
@property
def k_v(self) -> complex:
"""Returns the viscous wave number in the fluid
"""Returns the viscous wave number in the fluid [1/m]
:rtype: complex [1/m]
:rtype: complex
"""
return self._k_v.value
......@@ -230,15 +230,15 @@ class ViscousFluid(InviscidFluid):
def delta(self) -> float:
"""Returns the boundary layer thickness
:rtype: float [-]
:rtype: float
"""
return self._delta.value
@property
def lambda_v(self) -> float:
"""Returns the viscous wave length
"""Returns the viscous wave length [m]
:rtype: float [m]
:rtype: float
"""
return self._lambda_v.value
......@@ -274,9 +274,9 @@ class ViscoelasticFluid(ViscousFluid):
:param frequency: frequency in [Hz]
:type frequency: Union[int, float, Frequency]
:param rho: density in [km / m^3]
:param rho: density in [km/m^3]
:type rho: float
:param c: speed of sound [m / s]
:param c: speed of sound [m/s]
:type c: float
:param eta_f: shear viscosity of fluid component [Pa s]
:type eta_f: float
......@@ -393,57 +393,57 @@ class ViscoelasticFluid(ViscousFluid):
@property
def eta_c(self) -> complex:
"""Complex acoustic shear viscosity of the fluid.
"""Complex acoustic shear viscosity of the fluid [Pa s]
:rtype: complex [Pa s]
:rtype: complex
"""
return self._eta_c.value
@property
def zeta_c(self) -> complex:
"""Complex acoustic bulk viscosity of the fluid.
"""Complex acoustic bulk viscosity of the fluid [Pa s]
:rtype: complex [Pa s]
:rtype: complex
"""
return self._zeta_c.value
@property
def k_f(self) -> complex:
"""Returns the wave number in the fluid
"""Returns the wave number in the fluid [1/m]
:rtype: complex [1/m]
:rtype: complex
"""
return self._k_f.value
@property
def k_v(self) -> complex:
"""Returns the viscous wave number in the fluid
"""Returns the viscous wave number in the fluid [1/m]
:rtype: complex [1/m]
:rtype: complex
"""
return self._k_v.value
@property
def viscosity_term(self) -> complex:
"""Returns the viscosity term
"""Returns the viscosity term [Pa s]
:rtype: complex [Pa s]
:rtype: complex
"""
return self._viscosity_term.value
@property
def C_eta(self) -> complex:
"""Returns an often used shear viscosity term in viscoelastic fluids
"""Returns an often used shear viscosity term in viscoelastic fluids [Pa s]
:rtype: complex [Pa s]
:rtype: complex
"""
return self._C_eta.value
@property
def C_zeta(self) -> complex:
"""Returns an often used bulk viscosity term in viscoelastic fluids
"""Returns an often used bulk viscosity term in viscoelastic fluids [Pa s]
:rtype: complex [Pa s]
:rtype: complex
"""
return self._C_zeta.value
......
......@@ -61,9 +61,9 @@ class Frequency:
@property
def omega(self) -> float:
"""Returns the angular frequency.
"""Returns the angular frequency [rad/s].
:rtype: float [rad s^-1]
:rtype: float
"""
return self._omega.value
......
......@@ -60,17 +60,17 @@ class Sphere:
@property
def A(self) -> float:
"""Returns the surface area of the sphere.
"""Returns the surface area of the sphere [m^2]
:rtype: float [m^2]
:rtype: float
"""
return self._A.value
@property
def V(self) -> float:
"""Returns the volume of the sphere.
"""Returns the volume of the sphere [m^3]
:rtype: float [m^3]
:rtype: float
"""
return self._V.value
......
......@@ -156,49 +156,49 @@ class ElasticSolid(RigidSolid):
@property
def B_s(self) -> float:
"""Returns the Bulk modulus of the solid
"""Returns the Bulk modulus of the solid [Pa]
:rtype: float [Pa]
:rtype: float
"""
return self._B_s.value
@property
def kappa_s(self) -> float:
"""Returns the compressibility of the solid
"""Returns the compressibility of the solid [1/Pa]
:rtype: float [1/Pa]
:rtype: float
"""
return self._kappa_s.value
@property
def c_l(self) -> float:
"""Returns the longitudinal wave speed in the solid
"""Returns the longitudinal wave speed in the solid [m/s]
:rtype: float [m/s]
:rtype: float
"""
return self._c_l.value
@property
def c_t(self) -> float:
"""Return the transverse wave speed in the sold
"""Return the transverse wave speed in the solid [m/s]
:rtype: float [m/s]
:rtype: float
"""
return self._c_t.value
@property
def k_l(self) -> float:
"""Returns the longitudinal wave number in the solid
"""Returns the longitudinal wave number in the solid [1/m]
:rtype: float [1/m]
:rtype: float
"""
return self._k_l.value
@property
def k_t(self) -> float:
"""Returns the transverse wave number in the solid
"""Returns the transverse wave number in the solid [1/m]
:rtype: float [1/m]
:rtype: float
"""
return self._k_t.value
......
......@@ -84,7 +84,7 @@ class ARF(BaseARF, BaseSphereFrequencyComposite):
log.debug(repr(self))
def acoustic_radiation_force(self) -> float:
"""Computes the ARF and returns the force in Newton. Checks before
"""Computes the ARF and returns the force in Newton [N]. Checks before
computation of assumption of theory small particle radius to pressure
field wavelength is valid.
......@@ -155,7 +155,7 @@ class ARF(BaseARF, BaseSphereFrequencyComposite):
@property
def f1(self) -> float:
"""Monopole factor.
"""Monopole factor [-]
:rtype: float
"""
......@@ -163,7 +163,7 @@ class ARF(BaseARF, BaseSphereFrequencyComposite):
@property
def f2(self) -> float:
"""Dipole factor.
"""Dipole factor [-]
:rtype: float
"""
......@@ -171,7 +171,7 @@ class ARF(BaseARF, BaseSphereFrequencyComposite):
@property
def Phi(self) -> float:
"""Acoustic contrast factor
"""Acoustic contrast factor [-]
:rtype: float
"""
......
......@@ -128,7 +128,7 @@ class BaseKing(BaseSphereFrequencyComposite):
@property
def f2(self) -> float:
"""Dipole factor.
"""Dipole factor [-]
:rtype: float
"""
......@@ -136,7 +136,7 @@ class BaseKing(BaseSphereFrequencyComposite):
@property
def Phi(self) -> float:
"""Acoustic contrast factor
"""Acoustic contrast factor [-]
:rtype: float
"""
......
......@@ -8,7 +8,7 @@ class BaseARF(ABC):
@abstractmethod
def acoustic_radiation_force(self) -> float:
""" Returns the value for the ARF in Newton based on input parameters.
""" Returns the value for the ARF in Newton [N] based on input parameters.
This method must be implemented by every theory to have a common
interface for other modules.
......
......@@ -87,6 +87,15 @@ class TestViscousBackgroundField(BaseTestComposite):
* (exp(1j * position * k_f)
+ (-1) ** n * exp(-1j * position * k_f)))
def compute_E(self):
return abs(self.compute_A()) * self.rho_f * self.compute_k_f() ** 2
def compute_I(self):
out = abs(self.compute_A())
out *= self.rho_f * self.c_f
out *= (self.compute_k_f() ** 2) / 2
return out
def test_k_v(self):
self.assertEqual(self.fluid_cls.k_v, self.cls.k_v)
......@@ -111,6 +120,24 @@ class TestViscousBackgroundField(BaseTestComposite):
self.cls.wave_type = 'None'
self.assertRaises(ValueError, self.cls.A_in, 20)
def test_E(self) -> None:
for n in range(3):
self.assertEqual(
self.cls.acoustic_energy_density, self.compute_E())
for _ in self.range_runs:
self.change_and_assign()
self.assertEqual(
self.cls.acoustic_energy_density, self.compute_E())
def test_I(self) -> None:
for n in range(3):
self.assertEqual(
self.cls.acoustic_intensity, self.compute_I())
for _ in self.range_runs:
self.change_and_assign()
self.assertEqual(
self.cls.acoustic_intensity, self.compute_I())
if __name__ == '__main__':
unittest.main()
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