Lemma is an Electromagnetics API
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

FHTKey51.cpp 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 02/11/2014 03:42:53 PM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email Trevor.Irons@xri-geo.com
  14. * @copyright Copyright (c) 2014, XRI Geophysics, LLC
  15. * @copyright Copyright (c) 2014, Trevor Irons
  16. */
  17. #include "FHTKey51.h"
  18. namespace Lemma {
  19. // ==================== FRIEND METHODS =====================
  20. std::ostream &operator<<(std::ostream &stream, const FHTKey51 &ob) {
  21. stream << ob.Serialize() << "\n"; // End of doc ---
  22. return stream;
  23. }
  24. // ==================== STATIC CONST MEMBERS ============
  25. const Eigen::Matrix<Real, 51, 3> FHTKey51::WT51 =
  26. ( Eigen::Matrix<Real, 51, 3>() <<
  27. // Base J0 J1
  28. 4.9915939069102170e-03, 6.5314496156480717e-02, 3.8409924166118657e-05,
  29. 6.1703482511978082e-03, -2.2265895125268051e-01, -9.4382633059055269e-05,
  30. 7.6274629409160176e-03, 4.2794928430042073e-01, 1.6377612356675232e-04,
  31. 9.4286721829279947e-03, -5.8890658905204007e-01, -1.7853487610334151e-04,
  32. 1.1655233178024955e-02, 6.7897324897038758e-01, 1.9759569268356316e-04,
  33. 1.4407591843112350e-02, -6.8296549495756353e-01, -1.2796247718553291e-04,
  34. 1.7809914185937643e-02, 6.4702210424566342e-01, 1.3163370416771999e-04,
  35. 2.2015687754376449e-02, -5.6843090153083187e-01, 1.7066927559149181e-05,
  36. 2.7214645856121149e-02, 4.9960500362966542e-01, 4.1368007808198310e-05,
  37. 3.3641326918204623e-02, -4.0923517268678855e-01, 2.3582259002758631e-04,
  38. 4.1585655121173182e-02, 3.5487831784012780e-01, -1.9929745662753875e-05,
  39. 5.1406019627642255e-02, -2.7408257835871558e-01, 5.8196110748926486e-04,
  40. 6.3545442443014022e-02, 2.4668368971888163e-01, 1.1164151202379049e-05,
  41. 7.8551564282309541e-02, -1.7348161774657314e-01, 1.2053942009238238e-03,
  42. 9.7101350057185065e-02, 1.7509173908347012e-01, 2.8328713800714110e-04,
  43. 1.2003162851145673e-01, -1.0007796678766585e-01, 2.4375075610646724e-03,
  44. 1.4837684372696586e-01, 1.3297302593795621e-01, 1.1709289200267103e-03,
  45. 1.8341572156771246e-01, -4.3822390117083297e-02, 5.0080095645252103e-03,
  46. 2.2672895630607542e-01, 1.1415804492335258e-01, 3.5856849047131551e-03,
  47. 2.8027051982381157e-01, 4.2584271963990363e-03, 1.0536604059335859e-02,
  48. 3.4645581033005746e-01, 1.1496183925974515e-01, 9.6674718436839564e-03,
  49. 4.2827061721265969e-01, 5.1313336759457658e-02, 2.2583365267100426e-02,
  50. 5.2940581770869455e-01, 1.3312389010285514e-01, 2.4201911801947001e-02,
  51. 6.5442388190885858e-01, 1.0111673764393908e-01, 4.8602551164692191e-02,
  52. 8.0896469756649991e-01, 1.6331446488042209e-01, 5.6856974938076565e-02,
  53. 1.0000000000000000e+00, 1.4704406144951229e-01, 1.0202078096072606e-01,
  54. 1.2361478850785035e+00, 1.8341391219815678e-01, 1.2202639829343022e-01,
  55. 1.5280615937840571e+00, 1.5073655145087875e-01, 1.9561985197118459e-01,
  56. 1.8889101074258496e+00, 1.2356364992866918e-01, 2.1570853920674185e-01,
  57. 2.3349722343978727e+00, 1.1529465836107913e-02, 2.8552388758852060e-01,
  58. 2.8863709892679585e+00, -1.2852626053530605e-01, 2.0559964796530625e-01,
  59. 3.5679813939355345e+00, -2.9874216118407571e-01, 1.1666011451374350e-01,
  60. 4.4105526541128617e+00, -3.1330553036684633e-01, -2.3636714743601936e-01,
  61. 5.4520953354089947e+00, -3.2332453606385231e-02, -3.4036030266164258e-01,
  62. 6.7395961181122024e+00, 4.2056051544727674e-01, -1.9475364255836261e-01,
  63. 8.3311374876876929e+00, 1.3883637369942961e-01, 5.7608115965662166e-01,
  64. 1.0298517985703377e+01, -5.0223684329542873e-01, -2.1471464584834585e-01,
  65. 1.2730491227470161e+01, 3.7996073748731690e-01, -1.2611070492338947e-01,
  66. 1.5736769806847677e+01, -1.7984404170109178e-01, 2.0019703515125831e-01,
  67. 1.9452974714702009e+01, 7.0557286965350657e-02, -1.6147664664730754e-01,
  68. 2.4046753552064487e+01, -2.7522277139686569e-02, 1.1398023016900673e-01,
  69. 2.9725343546388515e+01, 1.1909130661901874e-02, -7.9924455203352035e-02,
  70. 3.6744920558100112e+01, -5.8977428045126450e-03, 5.7024556382799692e-02,
  71. 4.5422155835273074e+01, 3.2648420034561555e-03, -4.1006636508593382e-02,
  72. 5.6148501871478999e+01, -1.9304039780209286e-03, 2.9192063091319696e-02,
  73. 6.9407851838755207e+01, 1.1594138315987755e-03, -2.0089573135329029e-02,
  74. 8.5798369258319340e+01, -6.7050941490060716e-04, 1.2965400526524978e-02,
  75. 1.0605947270185592e+02, 3.5089803807606258e-04, -7.5154910983038946e-03,
  76. 1.3110519287294045e+02, -1.5287051174029577e-04, 3.6269079130258285e-03,
  77. 1.6206540689269471e+02, 4.8238483411813232e-05, -1.2668720233377250e-03,
  78. 2.0033680997479166e+02, -8.0433917146487977e-06, 2.3403502580547994e-04).finished();
  79. // ==================== LIFECYCLE =======================
  80. //--------------------------------------------------------------------------------------
  81. // Class: FHTKey51
  82. // Method: FHTKey51
  83. // Description: constructor (locked)
  84. //--------------------------------------------------------------------------------------
  85. FHTKey51::FHTKey51 (const ctor_key& key ) : HankelTransform( key ) {
  86. } // ----- end of method FHTKey51::FHTKey51 (constructor) -----
  87. //--------------------------------------------------------------------------------------
  88. // Class: FHTKey51
  89. // Method: FHTKey51
  90. // Description: constructor (protected)
  91. //--------------------------------------------------------------------------------------
  92. FHTKey51::FHTKey51( const YAML::Node& node, const ctor_key& key ) : HankelTransform(node, key) {
  93. }
  94. //--------------------------------------------------------------------------------------
  95. // Class: FHTKey51
  96. // Method: New()
  97. // Description: public constructor
  98. //--------------------------------------------------------------------------------------
  99. std::shared_ptr<FHTKey51> FHTKey51::NewSP() {
  100. return std::make_shared< FHTKey51 >( ctor_key() );
  101. }
  102. //--------------------------------------------------------------------------------------
  103. // Class: FHTKey51
  104. // Method: ~FHTKey51
  105. // Description: destructor
  106. //--------------------------------------------------------------------------------------
  107. FHTKey51::~FHTKey51 () {
  108. } // ----- end of method FHTKey51::~FHTKey51 (destructor) -----
  109. //--------------------------------------------------------------------------------------
  110. // Class: FHTKey51
  111. // Method: DeSerialize
  112. // Description: Factory method, converts YAML node into object
  113. //--------------------------------------------------------------------------------------
  114. std::shared_ptr<FHTKey51> FHTKey51::DeSerialize( const YAML::Node& node ) {
  115. if (node.Tag() != "FHTKey51") {
  116. throw DeSerializeTypeMismatch( "FHTKey51", node.Tag());
  117. }
  118. return std::make_shared<FHTKey51> ( node, ctor_key() );
  119. }
  120. //--------------------------------------------------------------------------------------
  121. // Class: FHTKey51
  122. // Method: Serialize
  123. // Description: Converts object into Serialized version
  124. //--------------------------------------------------------------------------------------
  125. YAML::Node FHTKey51::Serialize() const {
  126. YAML::Node node = HankelTransform::Serialize();
  127. node.SetTag( GetName() );
  128. //node["LayerConductivity"] = LayerConductivity;
  129. return node;
  130. }
  131. //--------------------------------------------------------------------------------------
  132. // Class: FHTKey51
  133. // Method: GetName
  134. // Description: Class identifier
  135. //--------------------------------------------------------------------------------------
  136. inline std::string FHTKey51::GetName ( ) const {
  137. return CName;
  138. } // ----- end of method FHTKey51::GetName -----
  139. //--------------------------------------------------------------------------------------
  140. // Class: FHTKey51
  141. // Method: Zgauss
  142. //--------------------------------------------------------------------------------------
  143. Complex FHTKey51::Zgauss ( const int &ikk, const EMMODE &imode,
  144. const int &itype, const Real &rho,
  145. const Real &wavef, KernelEM1DBase* Kernel ) {
  146. return Zans(0, Kernel->GetManagerIndex());
  147. } // ----- end of method FHTKey51::ComputeRelated -----
  148. //--------------------------------------------------------------------------------------
  149. // Class: FHTKey51
  150. // Method: ComputeRelated
  151. //--------------------------------------------------------------------------------------
  152. void FHTKey51::ComputeRelated ( const Real& rho, std::shared_ptr<KernelEM1DBase> Kernel ) {
  153. return ;
  154. } // ----- end of method FHTKey51::ComputeRelated -----
  155. //--------------------------------------------------------------------------------------
  156. // Class: FHTKey51
  157. // Method: ComputeRelated
  158. //--------------------------------------------------------------------------------------
  159. void FHTKey51::ComputeRelated ( const Real& rho, std::vector< std::shared_ptr<KernelEM1DBase> > KernelVec ) {
  160. return ;
  161. } // ----- end of method FHTKey51::ComputeRelated -----
  162. //--------------------------------------------------------------------------------------
  163. // Class: FHTKey51
  164. // Method: ComputeRelated
  165. //--------------------------------------------------------------------------------------
  166. void FHTKey51::ComputeRelated ( const Real& rho, std::shared_ptr<KernelEM1DManager> KernelManager ) {
  167. //kernelVec = KernelManager->GetSTLVector();
  168. int nrel = (int)(KernelManager->GetSTLVector().size());
  169. Eigen::Matrix<Complex, 51, Eigen::Dynamic > Zwork;
  170. // TODO, if we want to allow lagged, then 1 below should be nlag
  171. Zans= Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic>::Zero(1, nrel);
  172. Zwork.resize(51, nrel);
  173. VectorXr lambda = WT51.col(0).array()/rho;
  174. int NumFun = 0;
  175. int idx = 0;
  176. // Get Kernel values
  177. for (int ir=0; ir<lambda.size(); ++ir) {
  178. // irelated loop
  179. ++NumFun;
  180. KernelManager->ComputeReflectionCoeffs(lambda(ir), idx, rho);
  181. for (int ir2=0; ir2<nrel; ++ir2) {
  182. // Zwork* needed due to sign convention of filter weights
  183. Zwork(ir, ir2) = std::conj(KernelManager->GetSTLVector()[ir2]->RelBesselArg(lambda(ir)));
  184. }
  185. }
  186. // We diverge slightly from Key here, each kernel is evaluated seperately, whereby instead
  187. // they prefer to sum them. The reason is that all those terms have been removed from the kernels
  188. // in the interests of making them as generic and reusable as possible. This approach requires slightly
  189. // more multiplies, but the same number of kernel evaluations, which is the expensive part.
  190. // Inner product and scale
  191. for (int ir2=0; ir2<nrel; ++ir2) {
  192. Zans(0, ir2) = Zwork.col(ir2).dot(WT51.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder() + 1))/rho;
  193. }
  194. return ;
  195. } // ----- end of method FHTKey51::ComputeRelated -----
  196. } // ----- end of Lemma name -----