Jpp - 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 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
 Get velocity of sound. More...
 
virtual double operator() (const double z) const
 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
 Get distance travelled by sound. More...
 
virtual double getTime (const double D_m, const double z1, const double z2) const
 Get propagation time of sound. More...
 
virtual double getInverseVelocity (const double D_m, const double z1, const double z2) const
 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 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 depth is 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 depth is 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 depth is 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
inlinevirtual

Get velocity of sound.

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
inlinevirtual

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
inlinevirtual

Get distance travelled by sound.

The distance travelled is obtained by consistency with method JSoundVelocity::getTime.

Parameters
t_stime [s]
z1depth [m]
z2depth [m] return 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  }
virtual double JACOUSTICS::JSoundVelocity::getTime ( const double  D_m,
const double  z1,
const double  z2 
) const
inlinevirtual

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$.

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

Implements JACOUSTICS::JAbstractSoundVelocity.

Definition at line 145 of file JSoundVelocity.hh.

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

Get inverse velocity of sound.

The inverse velocity is obtained from the propagation time given by method JSoundVelocity::getTime.

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

Implements JACOUSTICS::JAbstractSoundVelocity.

Definition at line 172 of file JSoundVelocity.hh.

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

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

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

226  {
227  out << velocity.a << ' ' << velocity.b << ' ' << velocity.z0;
228 
229  return out;
230  }

Member Data Documentation

double JACOUSTICS::JSoundVelocity::a
private

Definition at line 233 of file JSoundVelocity.hh.

double JACOUSTICS::JSoundVelocity::b
private

Definition at line 234 of file JSoundVelocity.hh.

double JACOUSTICS::JSoundVelocity::z0
private

Definition at line 235 of file JSoundVelocity.hh.


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