DESERT 3.5.1
Loading...
Searching...
No Matches
uwphysicalrogersmodel.cpp
Go to the documentation of this file.
1//
2// Copyright (c) 2017 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29
40
41static class UwPhysicalRogersModelClass : public TclClass
42{
43public:
45 : TclClass("Module/UW/PROPAGATIONROGERS")
46 {
47 }
48 TclObject *
49 create(int, const char *const *)
50 {
52 }
54
56 : bottom_depth(100)
57 , sound_speed_water_bottom(1500)
58 , sound_speed_water_surface(1520)
59 , sound_speed_sediment(1585)
60 , density_sediment(1.740)
61 , density_water(1)
62 , attenuation_coeff_sediment(0.51)
63 , debug_(0)
64{
65 bind("bottom_depth_", &bottom_depth);
66 bind("sound_speed_water_bottom_", &sound_speed_water_bottom);
67 bind("sound_speed_water_surface_", &sound_speed_water_surface);
68 bind("sound_speed_sediment_", &sound_speed_sediment);
69 bind("density_sediment_", &density_sediment);
70 bind("density_water_", &density_water);
71 bind("attenuation_coeff_sediment_", &attenuation_coeff_sediment);
72 bind("debug_", &debug_);
73}
74
75int
76UnderwaterPhysicalRogersModel::command(int argc, const char *const *argv)
77{
78 Tcl &tcl = Tcl::instance();
79
80 if (argc == 2) {
81 if (strcasecmp(argv[1], "getBottomDepth") == 0) {
82 tcl.resultf("%f", bottom_depth);
83 return TCL_OK;
84 } else if (strcasecmp(argv[1], "getSoundSpeedWaterBottom") == 0) {
85 tcl.resultf("%f", sound_speed_water_bottom);
86 return TCL_OK;
87 } else if (strcasecmp(argv[1], "getSoundSpeedWaterSurface") == 0) {
88 tcl.resultf("%f", sound_speed_water_surface);
89 return TCL_OK;
90 } else if (strcasecmp(argv[1], "getSoundSpeedSediment") == 0) {
91 tcl.resultf("%f", sound_speed_sediment);
92 return TCL_OK;
93 } else if (strcasecmp(argv[1], "getDensitySediment") == 0) {
94 tcl.resultf("%f", density_sediment);
95 return TCL_OK;
96 } else if (strcasecmp(argv[1], "getDensityWater") == 0) {
97 tcl.resultf("%f", density_water);
98 return TCL_OK;
99 } else if (strcasecmp(argv[1], "getAttenuationCoeffSediment") == 0) {
100 tcl.resultf("%f", attenuation_coeff_sediment);
101 return TCL_OK;
102 }
103 } else if (argc == 3) {
104 if (strcasecmp(argv[1], "setBottomDepth") == 0) {
105 bottom_depth = static_cast<double>(atof(argv[2]));
106 return TCL_OK;
107 } else if (strcasecmp(argv[1], "setSoundSpeedWaterBottom") == 0) {
108 sound_speed_water_bottom = static_cast<double>(atof(argv[2]));
109 return TCL_OK;
110 } else if (strcasecmp(argv[1], "setSoundSpeedWaterSurface") == 0) {
111 sound_speed_water_surface = static_cast<double>(atof(argv[2]));
112 return TCL_OK;
113 } else if (strcasecmp(argv[1], "setSoundSpeedSediment") == 0) {
114 sound_speed_sediment = static_cast<double>(atof(argv[2]));
115 return TCL_OK;
116 } else if (strcasecmp(argv[1], "setDensitySediment") == 0) {
117 density_sediment = static_cast<double>(atof(argv[2]));
118 return TCL_OK;
119 } else if (strcasecmp(argv[1], "setDensityWater") == 0) {
120 density_water = static_cast<double>(atof(argv[2]));
121 return TCL_OK;
122 } else if (strcasecmp(argv[1], "setAttenuationCoeffSediment") == 0) {
123 attenuation_coeff_sediment = static_cast<double>(atof(argv[2]));
124 return TCL_OK;
125 }
126 }
127 return UnderwaterMPropagation::command(argc, argv);
128} /* UnderwaterPhysicalRogersModel::command */
129
130double
132{
133 hdr_MPhy *ph = HDR_MPHY(p);
134
135 Position *sp = ph->srcPosition;
136 Position *rp = ph->dstPosition;
137
138 MSpectralMask *sm = ph->srcSpectralMask;
139
140 assert(sp);
141 assert(rp);
142 assert(sm);
143
144 const double frequency_ =
145 ph->srcSpectralMask->getFreq(); // Frequency of the carrier in Hz
146 const double distance_ = sp->getDist(rp); // Distance in meters
147
148 // getAttenuation is in dB. The attanuation is converted in linear and it is
149 // converted in gain.
150 const double gain = pow(10,
152 distance_,
153 frequency_,
154 bottom_depth));
155 // const double gainUrick = uwlib_AInv(distance_/1000.0,
156 // uw.practical_spreading, frequency_/1000.0);
157
158 // std::cout << (10*log10(gain) - 10*log10(gainUrick)) << std::endl;
159 if (debug_)
160 std::cout << NOW << " UnderwaterPhysicalRogersMode::getGain()"
161 << " distance=" << distance_ << " frequency=" << frequency_
162 << " gain=" << gain << std::endl;
163 return (gain);
164} /* UnderwaterPhysicalRogersModel::getGain */
165
166double
168 const double &_sound_speed_water_bottom, const double &_distance,
169 const double &_frequency, const double &_bottom_depth)
170{
171 const double theta_g_ = getTheta_g(_bottom_depth, _distance);
172 const double theta_l_ = std::max(getTheta_g_max(_sound_speed_water_bottom),
173 getTheta_c(_sound_speed_water_bottom, _frequency, _bottom_depth));
174
175 if (_distance > 0) { // If the distane is known
176 if (theta_g_ >= theta_l_) {
177 return (15 * log10(_distance) +
178 5 * log10(_bottom_depth * getBeta()) +
179 (getBeta() * _distance * pow(theta_l_, 2)) /
180 (4 * _bottom_depth) -
181 7.18 + getThorp(_frequency / 1000.0) * _distance);
182 } else {
183 return (10 * log10(_distance) +
184 10 * log10(_bottom_depth / (2 * theta_l_)) +
185 (getBeta() * _distance * pow(theta_l_, 2)) /
186 (4 * _bottom_depth) +
187 getThorp(_frequency / 1000.0) * _distance);
188 }
189 } else {
190 return 1;
191 }
192} /* UnderwaterPhysicalRogersModel::getAttenutation */
const double getTheta_g_max(const double &_sound_speed_water_bottom) const
Maximum grazion angle for an RBR mode.
double density_water
Water density (g/cm^3).
const double getTheta_c(const double &_sound_speed_water_bottom, const double &_frequency, const double &_bottom_depth) const
Cutoff angle of the lowest mode.
double density_sediment
Sediment density (g/cm^3).
double sound_speed_water_bottom
Speed of sound in water at the sea bottom level (m/s).
const double getBeta() const
Bottom loss (dB/rad) derived from the expression for the Rayleigh reflection coefficient for a two-fl...
double sound_speed_water_surface
Speed of sound in water at the sea surface level (m/s).
double getThorp(double _frequency)
Absorption coefficient calculated by using Thorp's equation.
double attenuation_coeff_sediment
Attenuation coefficient of the sediment (dB/(m*kHz)).
virtual double getAttenuation(const double &_sound_speed_water_bottom, const double &_distance, const double &_frequency, const double &_bottom_depth)
Attenuation of acoustic signal in underwater channel.
UnderwaterPhysicalRogersModel()
Constructor of UnderwaterMPhyBpskDb class.
double sound_speed_sediment
Speed of sound in the sediment (m/s).
virtual int command(int, const char *const *)
TCL command interpreter.
const double getTheta_g(const double &_bottom_depth, const double &_distance) const
Effective angle of the last mode striped.
TclObject * create(int, const char *const *)
UwPhysicalRogersModelClass class_module_UnderwaterPhysicalRogersModel
Definition of UwPhysicalRogersModel class.