318{
321
324 double precision;
326
327 try {
328
329 JParser<> zap(
"Example program for sound ray tracing.");
330
335
336 zap(argc, argv);
337 }
338 catch(const exception &error) {
339 FATAL(error.what() << endl);
340 }
341
342
344
345 const JBellhop bellhop(V, precision);
346
348
349 double x0, z0;
350 double x1, z1;
351
352
353
354
355
356
357
358 for ( ; ; ) {
359
360 cout << "> " << flush;
361 cin >> x0 >> z0 >> x1 >> z1;
362
363
364 try {
365
366 const double D = hypot(x1 - x0, z1 - z0);
367 const sin_t s0 = bellhop(x0, z0, x1, z1);
368 const JBellhop_t
result = bellhop(s0, x0, z0, x1, z1);
369
370 cout <<
"s " <<
SCIENTIFIC(12,5) << (x1 - x0) / D << endl;
371 cout <<
"s0 " <<
SCIENTIFIC(12,5) << s0.value <<
' ' << s0.option << endl;
373 cout <<
"x' " <<
FIXED (12,5) <<
result.x <<
" [m]" << endl;
374 cout <<
"z' " <<
FIXED (12,5) <<
result.z <<
" [m]" << endl;
375 cout <<
"D " <<
FIXED (12,5) << D <<
" [m]" << endl;
376 cout <<
"D' " <<
FIXED (12,5) <<
result.d <<
" [m]" << endl;
377 cout <<
"t " <<
FIXED (12,5) << V.
getTime(D, z0, z1) <<
" [s]" << endl;
378 cout <<
"t' " <<
FIXED (12,5) <<
result.t <<
" [s]" << endl;
379
380
381 const double v0 = V(z0);
382 const double v1 = V(z1);
383 const double b = (v1 - v0) / (z1 - z0);
384 const double c = v1 / v0;
385 const double u = (v0 + v1) / v1;
386 const double v = (v0 - v1) / v1;
387 const double st = s0.value;
388
389 cout <<
"v0 " <<
FIXED (12,5) << v0 <<
" [m/s]" << endl;
390 cout <<
"v1 " <<
FIXED (12,5) << v1 <<
" [m/s]" << endl;
391
392 double dx = 0.0;
393
394 if (s0.option) {
395
396 dx = (sqrt(2.0 + st) * sqrt(0.0 - st) - sqrt(1.0 + c + c * st) * sqrt(1.0 - c - c * st)) * v0 / (1.0 + st) / b;
397
398 } else {
399
400 dx = (sqrt(1.0 + st) * sqrt(1.0 - st) - sqrt(1.0 + c * st) * sqrt(1.0 - c * st)) * v0 / ( st ) / b;
401 }
402
403 cout <<
"x' " <<
FIXED (12,5) << dx <<
" [m]" << endl;
404
405 const double x = s0.getc();
406 const double y = (s0.option ? c * sqrt(u + st) * sqrt(v - st) : sqrt(1.0 + c * st) * sqrt(1.0 - c * st));
407
408 cout <<
"t' " <<
FIXED (12,5) << (atanh(x) - atanh(y)) / b << endl;
409 }
410 catch(const exception& error) {
411 cerr << error.what() << endl;
412 }
413 }
414
415 } else {
416
417 const double x0 = 0.0;
418 const double z0 = 0.0;
419
422
424
425 TH2D h2("h2", NULL, 50, 1.0, 3.5, 50, -1.0, 3.0);
426
427 for (int ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
428 for (int iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
429
430 const double x1 =
pow(10.0, h2.GetXaxis()->GetBinCenter(ix));
431 const double z1 =
pow(10.0, h2.GetYaxis()->GetBinCenter(iy));
432
435
436 try {
437
438 const double D = hypot(x1 - x0, z1 - z0);
439 const sin_t s0 = bellhop(x0, z0, x1, z1);
440 const JBellhop_t
result = bellhop(s0, x0, z0, x1, z1);
441
444
445 h2.SetBinContent(ix, iy, (
result.t - V.
getTime(D, z0, z1)) * 1.0e6);
446 }
447 catch(const exception& error) {
448 ERROR(error.what() << endl);
449 }
450 }
451 }
452
453 Qx.print(cout);
454 Qz.print(cout);
455
456 out.Write();
457 out.Close();
458 }
459}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
T pow(const T &x, const double y)
Power .
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Implementation for depth dependend velocity of sound.
virtual double getTime(const double D_m, const double z1, const double z2) const override
Get propagation time of sound.
JSoundVelocity & set(const double z0)
Set depth.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure for floating point format specification.