Jpp  16.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | Friends | List of all members
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. More...
 
JSoundVelocityset (const double z0)
 Set depth. More...
 
JSoundVelocity operator[] (const double z0) const
 Get sound velocity at given depth. More...
 
virtual double operator() () const override
 Get velocity of sound at seabed. More...
 
virtual double operator() (const double z) const override
 Get velocity of sound at given depth relative to seabed. More...
 
virtual double getDistance (const double t_s, const double z1, const double z2) const override
 Get distance travelled by sound. More...
 
virtual double getTime (const double D_m, const double z1, const double z2) const override
 Get propagation time of sound. More...
 
virtual double getInverseVelocity (const double D_m, const double z1, const double z2) const override
 Get inverse velocity of sound. More...
 

Private Attributes

double a
 
double b
 
double z0
 

Friends

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

Detailed Description

Implementation for depth dependend velocity of sound.

Note that

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

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.

47  :
48  a (a),
49  b (b),
50  z0(z0)
51  {}

Member Function Documentation

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  }
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.
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  }
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  }
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] return 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  }
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] return 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  }
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] return 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 Function Documentation

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  }
is
Definition: JDAQCHSM.chsm:167
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
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

double JACOUSTICS::JSoundVelocity::a
private

Definition at line 236 of file JSoundVelocity.hh.

double JACOUSTICS::JSoundVelocity::b
private

Definition at line 237 of file JSoundVelocity.hh.

double JACOUSTICS::JSoundVelocity::z0
private

Definition at line 238 of file JSoundVelocity.hh.


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