DESERT 3.5.1
Loading...
Searching...
No Matches
soundlevels.cpp
Go to the documentation of this file.
1//
2// Copyright (c) 2024 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
39#include "soundlevels.h"
40#include <iostream>
41#include <cmath>
42
43namespace ship_noise
44{
45
46double
48 const ShipCategory &cat, double freq, double speed, double length)
49{
50
51 if (speed < 1)
52 speed = 1;
53
54 if (freq < 1)
55 freq = 1;
56
57 switch (cat) {
59 return cargo_ship(freq, speed, length);
60 break;
62 return cargoL_ship(freq, speed, length);
63 break;
65 return cruise_ship(freq, speed, length);
66 break;
68 break;
70 return fishing_vessel(freq, speed, length);
71 break;
73 return auv(freq);
74 break;
75 }
76
77 return -1;
78}
79
80double
81cargo_ship(double freq, double speed, double length)
82{
83
84 double SL_mach = 0.0;
85 double SL_prop = 0.0;
86 double SL_cav = 0.0;
87
88 if (freq > 200)
89 SL_mach = 186 - 22 * std::log10(freq) + 15 * std::log10(speed);
90 else
91 std::cout << "WARNING: Too low frequency for MACH." << std::endl;
92
93 if (freq > 80)
94 SL_prop = 156 - 30 * std::log10(freq) + 50 * std::log10(speed);
95 else
96 std::cout << "WARNING: Too low frequency for PROP." << std::endl;
97
98 if ((freq > 200) && (speed > 10))
99 SL_cav = 129 - 20 * std::log10(freq) + 60 * std::log10(speed);
100
101 double SL_tot = 10 * std::log10(std::pow(10, (SL_mach / 10))
102 + std::pow(10, (SL_prop / 10))
103 + std::pow(10, (SL_cav / 10)))
104 + 25 * std::log10(length / 180);
105
106 return (std::pow(10, (SL_tot / 10)));
107}
108
109double
110cargoL_ship(double freq, double speed, double length)
111{
112
113 double SL_mach = 0;
114 double SL_prop = 0;
115 double SL_cav = 0;
116
117 if (freq > 250)
118 SL_mach = 182 - 22 * std::log10(freq) + 15 * std::log10(speed);
119 else
120 std::cout << "WARNING: Too low frequency for MACH." << std::endl;
121
122 if (freq > 80)
123 SL_prop = 150 - 30 * std::log10(freq) + 50 * std::log10(speed);
124 else
125 std::cout << "WARNING: Too low frequency for PROP." << std::endl;
126
127 if ((freq > 50) && (speed > 13))
128 SL_cav = 120 - 20 * std::log10(freq) + 60 * std::log10(speed);
129
130 double SL_tot = 10 * std::log10(std::pow(10, (SL_mach / 10))
131 + std::pow(10, (SL_prop / 10))
132 + std::pow(10, (SL_cav / 10)))
133 + 25 * std::log10(length / 280);
134
135 return (std::pow(10, (SL_tot / 10)));
136}
137
138double
139cruise_ship(double freq, double speed, double length)
140{
141
142 double SL_mach = 0;
143 double SL_prop = 0;
144 double SL_cav = 0;
145
146 if (freq > 100)
147 SL_mach = 179 - 22 * std::log10(freq) + 15 * std::log10(speed);
148 else
149 std::cout << "WARNING: Too low frequency for MACH." << std::endl;
150
151 if (freq > 80)
152 SL_prop = 142 - 25 * std::log10(freq) + 50 * std::log10(speed);
153 else
154 std::cout << "WARNING: Too low frequency for PROP." << std::endl;
155
156 if ((freq > 60) && (speed > 12))
157 SL_cav = 125 - 20 * std::log10(freq) + 60 * std::log10(speed);
158
159 double SL_tot = 10 * std::log10(std::pow(10, (SL_mach / 10))
160 + std::pow(10, (SL_prop / 10))
161 + std::pow(10, (SL_cav / 10)))
162 + 25 * std::log10(length / 250);
163
164 return (std::pow(10, (SL_tot / 10)));
165}
166
167double
168ferry(double freq, double speed, double length)
169{
170
171 double SL_mach = 0;
172 double SL_prop = 0;
173 double SL_cav = 0;
174
175 if (freq > 200)
176 SL_mach = 177 - 20 * std::log10(freq) + 15 * std::log10(speed);
177 else
178 std::cout << "WARNING: Too low frequency for MACH." << std::endl;
179
180 if (freq > 80)
181 SL_prop = 140 - 25 * std::log10(freq) + 50 * std::log10(speed);
182 else
183 std::cout << "WARNING: Too low frequency for PROP." << std::endl;
184
185 if ((freq > 200) && (speed > 10))
186 SL_cav = 127 - 20 * std::log10(freq) + 60 * std::log10(speed);
187
188 double SL_tot = 10 * std::log10(std::pow(10, (SL_mach / 10))
189 + std::pow(10, (SL_prop / 10))
190 + std::pow(10, (SL_cav / 10)))
191 + 25 * std::log10(length / 180);
192
193 return (std::pow(10, (SL_tot / 10)));
194}
195
196double
197fishing_vessel(double freq, double speed, double length)
198{
199
200 double SL_mach = 0;
201 double SL_prop = 0;
202 double SL_cav = 0;
203
204 if (freq > 150)
205 SL_mach = 185 - 20 * std::log10(freq) + 25 * std::log10(speed);
206 else
207 std::cout << "WARNING: Too low frequency for MACH." << std::endl;
208
209 if (freq > 80)
210 SL_prop = 132 - 25 * std::log10(freq) + 50 * std::log10(speed);
211 else
212 std::cout << "WARNING: Too low frequency for PROP." << std::endl;
213
214 if ((freq > 80) && (speed > 8) && (speed < 12))
215 SL_cav = 180 - 20 * std::log10(freq);
216
217 double SL_tot = 10 * std::log10(std::pow(10, (SL_mach / 10))
218 + std::pow(10, (SL_prop / 10))
219 + std::pow(10, (SL_cav / 10)))
220 + 25 * std::log10(length / 50);
221
222 return (std::pow(10, (SL_tot / 10)));
223}
224
225double
226auv(double freq)
227{
228 double SL_tot = 0;
229
230 if (freq <= 7982.5)
231 SL_tot = 10 *
232 std::log10(113.392 - 0.0139886 * freq +
233 1.68571e-6 * std::pow(freq, 2) -
234 7.11945e-11 * std::pow(freq, 3));
235 else
236 SL_tot = 10 * std::log10(72.99);
237
238 return std::pow(10, SL_tot / 10);
239}
240
241}
double cargoL_ship(double freq, double speed, double length)
Compute the sound level of a long cargo ship.
double ferry(double freq, double speed, double length)
Compute the sound level of a ferry.
double cargo_ship(double freq, double speed, double length)
Compute the sound level of a cargo ship.
double getNoisefromCategory(const ShipCategory &cat, double freq, double speed, double length)
Compute the sound level of a ship given the type.
double fishing_vessel(double freq, double speed, double length)
Compute the sound level of a fishing vessel.
double auv(double freq)
Compute the sound level of an Autonomous Underwater Vehicle (AUV)
double cruise_ship(double freq, double speed, double length)
Compute the sound level of a cruise ship.
ShipCategory
Enum type representing the ship categories.
Definition soundlevels.h:57
Functions to compute the noise power spectral density for different type of ships and auv.