Jpp
 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

The depth is commonly referred to as the seabed.

Definition at line 31 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 43 of file JSoundVelocity.hh.

43  :
44  a (a),
45  b (b),
46  z0(z0)
47  {}

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

59  {
60  this->a += this->b * (z0 - this->z0);
61  this->z0 = z0;
62 
63  return *this;
64  }
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 75 of file JSoundVelocity.hh.

76  {
77  return JSoundVelocity(*this).set(z0);
78  }
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 86 of file JSoundVelocity.hh.

87  {
88  return a;
89  }
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 98 of file JSoundVelocity.hh.

99  {
100  return a + b * z;
101  }
virtual double JACOUSTICS::JSoundVelocity::getDistance ( const double  t_s,
const double  z1,
const double  z2 
) const
inlinevirtual

Get distance travelled by sound.

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

Implements JACOUSTICS::JAbstractSoundVelocity.

Definition at line 112 of file JSoundVelocity.hh.

115  {
116  const double eps = 1.0e-8;
117 
118  const double v1 = (*this)(z1);
119  const double v2 = (*this)(z2);
120  const double lv = log(v2/v1);
121 
122  if (fabs(lv) > eps)
123  return t_s * fabs((z2 - z1) * b / lv);
124  else
125  return 0.5 * t_s * (v1 + v2);
126  }
virtual double JACOUSTICS::JSoundVelocity::getTime ( const double  D_m,
const double  z1,
const double  z2 
) const
inlinevirtual

Get propagation time of sound.

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

Implements JACOUSTICS::JAbstractSoundVelocity.

Definition at line 137 of file JSoundVelocity.hh.

140  {
141  const double eps = 1.0e-8;
142 
143  const double ct = (z2 - z1) / D_m;
144  const double v1 = (*this)(z1);
145  const double v2 = (*this)(z2);
146 
147  if (fabs(ct) > eps)
148  return fabs(log(v2/v1) / (ct*b));
149  else
150  return 2.0 * D_m / (v1 + v2);
151  }
virtual double JACOUSTICS::JSoundVelocity::getInverseVelocity ( const double  D_m,
const double  z1,
const double  z2 
) const
inlinevirtual

Get inverse velocity of sound.

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

Implements JACOUSTICS::JAbstractSoundVelocity.

Definition at line 162 of file JSoundVelocity.hh.

165  {
166  const double eps = 1.0e-8;
167 
168  const double ct = (z2 - z1) / D_m;
169  const double v1 = (*this)(z1);
170  const double v2 = (*this)(z2);
171 
172  if (fabs(ct) > eps)
173  return fabs(log(v2/v1) / ((z2 - z1) * b));
174  else
175  return 2.0 / (v1 + v2);
176  }

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

187  {
188  if (in >> velocity.a) {
189 
190  in >> velocity.b
191  >> velocity.z0;
192 
193  in.clear();
194  }
195 
196  return in;
197  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
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 207 of file JSoundVelocity.hh.

208  {
209  out << velocity.a << ' ' << velocity.b << ' ' << velocity.z0;
210 
211  return out;
212  }

Member Data Documentation

double JACOUSTICS::JSoundVelocity::a
private

Definition at line 215 of file JSoundVelocity.hh.

double JACOUSTICS::JSoundVelocity::b
private

Definition at line 216 of file JSoundVelocity.hh.

double JACOUSTICS::JSoundVelocity::z0
private

Definition at line 217 of file JSoundVelocity.hh.


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