Jpp 19.3.0-rc.2
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.
 
JSoundVelocityset (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 35 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 47 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 62 of file JSoundVelocity.hh.

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

◆ 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 79 of file JSoundVelocity.hh.

80 {
81 return JSoundVelocity(*this).set(z0);
82 }
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 90 of file JSoundVelocity.hh.

91 {
92 return a;
93 }

◆ 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 102 of file JSoundVelocity.hh.

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

◆ 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 119 of file JSoundVelocity.hh.

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

◆ 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 147 of file JSoundVelocity.hh.

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

◆ 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 175 of file JSoundVelocity.hh.

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

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 199 of file JSoundVelocity.hh.

200 {
201 using namespace JPP;
202
203 JStringStream is(in);
204
205 if (getFileStatus(is.str().c_str())) {
206 is.load();
207 }
208
209 if (is >> velocity.a) {
210
211 is >> velocity.b
212 >> velocity.z0;
213
214 is.clear();
215 }
216
217 return in;
218 }
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 228 of file JSoundVelocity.hh.

229 {
230 out << velocity.a << ' ' << velocity.b << ' ' << velocity.z0;
231
232 return out;
233 }

Member Data Documentation

◆ a

double JACOUSTICS::JSoundVelocity::a
private

Definition at line 236 of file JSoundVelocity.hh.

◆ b

double JACOUSTICS::JSoundVelocity::b
private

Definition at line 237 of file JSoundVelocity.hh.

◆ z0

double JACOUSTICS::JSoundVelocity::z0
private

Definition at line 238 of file JSoundVelocity.hh.


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