/source/boundaryReflectionCoeff.c

https://github.com/EyNuel/cTraceo · C · 83 lines · 24 code · 10 blank · 49 comment · 0 complexity · bd3377ec9dd0658ca7d0498ae9332970 MD5 · raw file

  1. /****************************************************************************************
  2. * boundaryReflectionCoeff.c *
  3. * (formerly "bdryr.for") *
  4. * Calculates the reflection coefficient of a boudary between two media. *
  5. * *
  6. * Reference: "Recovery of the properties of an elastic bottom using reflection *
  7. * coefficient measurements", P.J.Papadakis et al, Proc. of the 2nd. ECUA, Vol II, *
  8. * page 943, 1994. *
  9. * *
  10. * ------------------------------------------------------------------------------------ *
  11. * Website: *
  12. * https://github.com/EyNuel/cTraceo/wiki *
  13. * *
  14. * License: This file is part of the cTraceo Raytracing Model and is released under the *
  15. * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License *
  16. * http://creativecommons.org/licenses/by-nc-sa/3.0/ *
  17. * *
  18. * NOTE: cTraceo is research code under active development. *
  19. * The code may contain bugs and updates are possible in the future. *
  20. * *
  21. * Written for project SENSOCEAN by: *
  22. * Emanuel Ey *
  23. * emanuel.ey@gmail.com *
  24. * Copyright (C) 2011 - 2013 *
  25. * Signal Processing Laboratory *
  26. * Universidade do Algarve *
  27. * *
  28. * cTraceo is the C port of the FORTRAN 77 TRACEO code written by: *
  29. * Orlando Camargo Rodriguez: *
  30. * Copyright (C) 2010 *
  31. * Orlando Camargo Rodriguez *
  32. * orodrig@ualg.pt *
  33. * Universidade do Algarve *
  34. * Physics Department *
  35. * Signal Processing Laboratory *
  36. * *
  37. * ------------------------------------------------------------------------------------ *
  38. * Inputs: *
  39. * TODO: correct this: *
  40. * aIn: Atenuation value to be converted. *
  41. * lambda: Wavelength. *
  42. * freq: Frequency. *
  43. * units: Determines the input units. *
  44. * (see globals.h for possible values) *
  45. * *
  46. * Outputs: *
  47. * aOut: Converted atenuation value. *
  48. * *
  49. ****************************************************************************************/
  50. #pragma once
  51. #include <complex.h>
  52. #include <math.h>
  53. void boundaryReflectionCoeff(double*, double*, double*, double*, double*, double*, double*, double*, complex double*);
  54. void boundaryReflectionCoeff(double* rho1, double* rho2, double* cp1, double* cp2, double* cs2, double* ap,
  55. double* as, double* theta, complex double* refl){
  56. double tilap, tilas;
  57. double a1;
  58. complex double a2, a3, a4, a5, a6, a7, d;
  59. complex double tilcp2, tilcs2;
  60. tilap = *ap/( 40.0 * M_PI * M_LOG10E );
  61. tilas = *as/( 40.0 * M_PI * M_LOG10E );
  62. tilcp2 = *cp2 * (1 - I * tilap) / (1 + tilap * tilap);
  63. tilcs2 = *cs2 * (1 - I * tilas) / (1 + tilas * tilas);
  64. a1 = *rho2 / *rho1;
  65. a2 = tilcp2 / *cp1;
  66. a3 = tilcs2 / *cp1;
  67. a4 = a3 * sin( *theta );
  68. a5 = 2*a4 * a4;
  69. a6 = a2 * sin( *theta );
  70. a7 = 2*a5 - a5*a5;
  71. d = a1 * ( a2 * (1 - a7 ) / csqrt( 1 - a6 * a6 ) + a3 * a7 / csqrt(1 - 0.5*a5) );
  72. *refl = ( d * ccos( *theta ) -1) / ( d * ccos( *theta ) + 1);
  73. }