Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JACOUSTICS::JSoundVelocity Struct Reference

Implementation for depth dependend velocity of sound. More...

#include <JSoundVelocity.hh>

Inheritance diagram for JACOUSTICS::JSoundVelocity:
JACOUSTICS::JAbstractSoundVelocity

Public Member Functions

 JSoundVelocity (const double a, const double b, const double z0)
 Constructor.
 
JSoundVelocity & set (const double z0)
 Set depth.
 
JSoundVelocity operator[] (const double z0) const
 Get sound velocity at given depth.
 
virtual double operator() () const override
 Get velocity of sound at seabed.
 
virtual double operator() (const double z) const override
 Get velocity of sound at given depth relative to seabed.
 
virtual double getDistance (const double t_s, const double z1, const double z2) const override
 Get distance travelled by sound.
 
virtual double getTime (const double D_m, const double z1, const double z2) const override
 Get propagation time of sound.
 
virtual double getInverseVelocity (const double D_m, const double z1, const double z2) const override
 Get inverse velocity of sound.
 

Private Attributes

double a
 
double b
 
double z0
 

Friends

std::istream & operator>> (std::istream &in, JSoundVelocity &velocity)
 Read sound velocity from input.
 
std::ostream & operator<< (std::ostream &out, const JSoundVelocity &velocity)
 Write sound velocity to output.
 

Detailed Description

Implementation for depth dependend velocity of sound.

Note that

  • z-axis is pointing upwards; and
  • velocity is defined at a given depth.

It is assumed that the dependence of the sound velocity on the depth is non-zero.
The depth is commonly referred to as the seabed.

Definition at line 34 of file JSoundVelocity.hh.

Constructor & Destructor Documentation

◆ JSoundVelocity()

JACOUSTICS::JSoundVelocity::JSoundVelocity ( const double a,
const double b,
const double z0 )
inline

Constructor.

Note that the depth is relative to the sea surface and therefore should be negative.

Parameters
avelocity [m/s]
bd(v)/d(z) [m/s/m]
z0depth [m]

Definition at line 46 of file JSoundVelocity.hh.

Member Function Documentation

◆ set()

JSoundVelocity & JACOUSTICS::JSoundVelocity::set ( const double z0)
inline

Set depth.

Note that the depth is relative to the sea surface and therefore should be negative.

Parameters
z0depth [m]
Returns
this sound velocity

Definition at line 61 of file JSoundVelocity.hh.

62 {
63 this->a += this->b * (z0 - this->z0);
64 this->z0 = z0;
65
66 return *this;
67 }

◆ operator[]()

JSoundVelocity JACOUSTICS::JSoundVelocity::operator[] ( const double z0) const
inline

Get sound velocity at given depth.

Note that the depth is relative to the sea surface and therefore should be negative.

Parameters
z0depth [m]
Returns
sound velocity

Definition at line 78 of file JSoundVelocity.hh.

79 {
80 return JSoundVelocity(*this).set(z0);
81 }
JSoundVelocity(const double a, const double b, const double z0)
Constructor.

◆ operator()() [1/2]

virtual double JACOUSTICS::JSoundVelocity::operator() ( ) const
inlineoverridevirtual

Get velocity of sound at seabed.

Returns
velocity [m/s]

Implements JACOUSTICS::JAbstractSoundVelocity.

Definition at line 89 of file JSoundVelocity.hh.

90 {
91 return a;
92 }

◆ operator()() [2/2]

virtual double JACOUSTICS::JSoundVelocity::operator() ( const double z) const
inlineoverridevirtual

Get velocity of sound at given depth relative to seabed.

Parameters
zdepth [m]
Returns
velocity [m/s]

Reimplemented from JACOUSTICS::JAbstractSoundVelocity.

Definition at line 101 of file JSoundVelocity.hh.

102 {
103 return a + b * z;
104 }

◆ getDistance()

virtual double JACOUSTICS::JSoundVelocity::getDistance ( const double t_s,
const double z1,
const double z2 ) const
inlineoverridevirtual

Get distance travelled by sound.

The distance travelled is obtained by consistency with method JSoundVelocity::getTime.
Note that the depth is relative to the seabed.

Parameters
t_stime [s]
z1depth [m]
z2depth [m]
Returns
distance [m]

Implements JACOUSTICS::JAbstractSoundVelocity.

Definition at line 118 of file JSoundVelocity.hh.

121 {
122 const double eps = 1.0e-8;
123
124 const double v1 = (*this)(z1);
125 const double v2 = (*this)(z2);
126 const double lv = log(v2/v1);
127
128 if (fabs(lv) > eps)
129 return t_s * fabs((z2 - z1) * b / lv);
130 else
131 return 0.5 * t_s * (v1 + v2);
132 }

◆ getTime()

virtual double JACOUSTICS::JSoundVelocity::getTime ( const double D_m,
const double z1,
const double z2 ) const
inlineoverridevirtual

Get propagation time of sound.

The propagation time is obtained from the integral $\Delta T = \frac{D}{\Delta z} \int\frac{1}{V(z)}dz$.
Note that the depth is relative to the seabed.

Parameters
D_mdistance [m]
z1depth [m]
z2depth [m]
Returns
time [s]

Implements JACOUSTICS::JAbstractSoundVelocity.

Definition at line 146 of file JSoundVelocity.hh.

149 {
150 const double eps = 1.0e-8;
151
152 const double ct = (z2 - z1) / D_m;
153 const double v1 = (*this)(z1);
154 const double v2 = (*this)(z2);
155
156 if (fabs(ct) > eps)
157 return fabs(log(v2/v1) / (ct*b));
158 else
159 return 2.0 * D_m / (v1 + v2);
160 }

◆ getInverseVelocity()

virtual double JACOUSTICS::JSoundVelocity::getInverseVelocity ( const double D_m,
const double z1,
const double z2 ) const
inlineoverridevirtual

Get inverse velocity of sound.

The inverse velocity is obtained from the propagation time given by method JSoundVelocity::getTime.
Note that the depth is relative to the seabed.

Parameters
D_mdistance [m]
z1depth [m]
z2depth [m]
Returns
inverse velocity [s/m]

Implements JACOUSTICS::JAbstractSoundVelocity.

Definition at line 174 of file JSoundVelocity.hh.

177 {
178 const double eps = 1.0e-8;
179
180 const double ct = (z2 - z1) / D_m;
181 const double v1 = (*this)(z1);
182 const double v2 = (*this)(z2);
183
184 if (fabs(ct) > eps)
185 return fabs(log(v2/v1) / ((z2 - z1) * b));
186 else
187 return 2.0 / (v1 + v2);
188 }

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JSoundVelocity & velocity )
friend

Read sound velocity from input.

Parameters
ininput stream
velocitysound velocity
Returns
input stream

Definition at line 198 of file JSoundVelocity.hh.

199 {
200 using namespace JPP;
201
202 JStringStream is(in);
203
204 if (is >> velocity.a) {
205
206 is >> velocity.b
207 >> velocity.z0;
208
209 is.clear();
210 }
211
212 return in;
213 }
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JSoundVelocity & velocity )
friend

Write sound velocity to output.

Parameters
outoutput stream
velocitysound velocity
Returns
output stream

Definition at line 223 of file JSoundVelocity.hh.

224 {
225 out << velocity.a << ' ' << velocity.b << ' ' << velocity.z0;
226
227 return out;
228 }

Member Data Documentation

◆ a

double JACOUSTICS::JSoundVelocity::a
private

Definition at line 231 of file JSoundVelocity.hh.

◆ b

double JACOUSTICS::JSoundVelocity::b
private

Definition at line 232 of file JSoundVelocity.hh.

◆ z0

double JACOUSTICS::JSoundVelocity::z0
private

Definition at line 233 of file JSoundVelocity.hh.


The documentation for this struct was generated from the following file: