Main Lemma Repository
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

kernelem1dreflbase.h 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author Trevor Irons
  8. @date 05/18/2012
  9. @version $Id: kernelem1dreflbase.h 193 2014-11-10 23:51:41Z tirons $
  10. **/
  11. #ifndef KERNELEM1DREFLBASE_INC
  12. #define KERNELEM1DREFLBASE_INC
  13. #include "KernelEM1DSpec.h"
  14. //#include "kernelem1dbase.h"
  15. #include "DipoleSource.h"
  16. #include "LayeredEarthEM.h"
  17. namespace Lemma {
  18. enum DIPOLE_LOCATION { INAIR, INGROUND };
  19. // forward declaration for friend
  20. //template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
  21. //class KernelEM1DSpec;
  22. // ===================================================================
  23. // Class: KernelEM1DReflBase
  24. /**
  25. @class
  26. \brief Abstract class defining EM1DRefl class.
  27. \details Derived classes are template specialized for optimal performance.
  28. */
  29. // ===================================================================
  30. class KernelEM1DReflBase : public LemmaObject {
  31. //template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
  32. friend class KernelEM1DSpec;
  33. //friend class KernelEM1DManager;
  34. //friend class DipoleSource;
  35. public:
  36. // ==================== LIFECYCLE =======================
  37. // ==================== OPERATORS =======================
  38. // ==================== OPERATIONS =======================
  39. void Initialise( std::shared_ptr<LayeredEarthEM> EarthIn) {
  40. nlay = EarthIn->GetNumberOfLayers();
  41. zh = VectorXcr::Zero(nlay);
  42. yh = VectorXcr::Zero(nlay);
  43. u = VectorXcr::Zero(nlay);
  44. cf = VectorXcr::Zero(nlay); // nlay -1 (lay 0 empty)
  45. rtu = VectorXcr::Zero(nlay); // nlay -1 Interfaces only
  46. rtd = VectorXcr::Zero(nlay); // nlay -1 Interfaces only
  47. kk = VectorXcr::Zero(nlay);
  48. Zyu = VectorXcr::Zero(nlay);
  49. Zyd = VectorXcr::Zero(nlay);
  50. Zyi = VectorXcr::Zero(nlay);
  51. th = VectorXcr::Zero(nlay);
  52. // Don't attach Earth, because this is performance critical.
  53. // Everying is internal, it's OK relax Frankie
  54. //if (Earth != NULL) {
  55. // Earth->DetachFrom(this);
  56. // Earth = NULL;
  57. //}
  58. //EarthIn->AttachTo(this);
  59. Earth = EarthIn;
  60. LayerThickness.resize(nlay);
  61. for (int ilay=0; ilay<nlay; ++ilay) {
  62. LayerThickness(ilay) = Earth->GetLayerThickness(ilay);
  63. }
  64. LayerDepth.resize(nlay);
  65. for (int ilay=0; ilay<nlay; ++ilay) {
  66. LayerDepth(ilay) = Earth->GetLayerDepth(ilay);
  67. }
  68. }
  69. void SetUpSource( std::shared_ptr<DipoleSource> Dipole, const int &ifreq ) {
  70. zh(0) = Complex(0, Dipole->GetAngularFrequency(ifreq)*MU0);
  71. yh(0) = Complex(0, Dipole->GetAngularFrequency(ifreq)*EPSILON0);
  72. kk(0) = -zh(0) * yh(0);
  73. Earth->EvaluateColeColeModel(Dipole->GetAngularFrequency(ifreq));
  74. for (int ilay=1; ilay<Earth->GetNumberOfLayers(); ++ilay) {
  75. zh(ilay) = zh(0) * Earth->GetLayerSusceptibility(ilay);
  76. yh(ilay) = Earth->GetLayerConductivity(ilay) +
  77. yh(0)*Earth->GetLayerPermitivity(ilay);
  78. kk(ilay) = -zh(ilay)*yh(ilay);
  79. }
  80. tx_z = Dipole->GetLocation(2);
  81. lays = 0;
  82. Real Depth(0);
  83. for (int ilay=1; ilay<nlay; ++ilay) {
  84. if (tx_z > Depth) {
  85. lays = ilay;
  86. }
  87. Depth += LayerThickness(ilay);
  88. }
  89. }
  90. void SetUpReceiver(const Real &rz) {
  91. rx_z = rz;
  92. Real Depth(0.);
  93. layr = 0;
  94. for (int ilay=1; ilay<Earth->GetNumberOfLayers(); ++ilay) {
  95. if (rx_z > Depth) {
  96. layr = ilay;
  97. }
  98. Depth += LayerThickness(ilay);
  99. }
  100. }
  101. // ==================== ACCESS =======================
  102. Complex GetYm() {
  103. return yh(layr);
  104. }
  105. Complex GetZm() {
  106. return zh(layr);
  107. }
  108. Complex GetZs() {
  109. return zh(lays);
  110. }
  111. Complex GetKs() {
  112. return kk(lays);
  113. }
  114. // ==================== INQUIRY =======================
  115. protected:
  116. // ==================== LIFECYCLE =======================
  117. /// Default protected constructor.
  118. KernelEM1DReflBase ( ) : LemmaObject( )
  119. {
  120. }
  121. /// Default protected constructor.
  122. ~KernelEM1DReflBase () {
  123. }
  124. // ==================== OPERATIONS =======================
  125. /** Computes reflection coefficients. Depending on the
  126. * specialisation, this will either be TM or TE mode.
  127. */
  128. virtual void ComputeReflectionCoeffs(const Real& lambda)=0;
  129. /** Precomputes expensive calculations that are reused by insances
  130. * of KernelEM1DSpec in the calculation of Related potentials.
  131. */
  132. virtual void PreComputePotentialTerms()=0;
  133. // ==================== DATA MEMBERS =========================
  134. /// Bessel order, only 0 or 1 supported
  135. int id; // Needs to be dim nRel, or separate
  136. /// Layer the source is in
  137. int lays;
  138. /// Layer the receiver is in
  139. int layr;
  140. /// Number of Layers
  141. int nlay;
  142. /// Number of Related kernels to be computed
  143. int nRelated;
  144. /// Used in related kernel precompute calls
  145. int relIud;
  146. /// Receiver z position
  147. Real rx_z;
  148. /// Transmitter z position
  149. Real tx_z;
  150. /// bessel arg squared
  151. Real rams;
  152. /** Related part of con term */
  153. Complex relCon;
  154. Complex relenukadz;
  155. Complex relexp_pbs1;
  156. Complex relexp_pbs2;
  157. Complex rel_a;
  158. /// TM or TE mode
  159. EMMODE mode;
  160. /// Pointer to layered earth
  161. std::shared_ptr<LayeredEarthEM> Earth;
  162. Complex uk;
  163. Complex um;
  164. VectorXcr cf; // nlay
  165. VectorXcr u; // nlay
  166. VectorXcr yh; // nlay
  167. VectorXcr zh; // nlay
  168. VectorXcr kk; // nlay
  169. VectorXcr Zyu; //(nlay); //Zyu.setZero();
  170. VectorXcr Zyd; //(nlay); //Zyd.setZero();
  171. VectorXcr Zyi; //(nlay); //Zyi.setZero();
  172. VectorXcr th; //(nlay);
  173. VectorXr LayerThickness;
  174. VectorXr LayerDepth;
  175. /// Reflection/Transmission coeffients for upgoing waves in a
  176. /// layered earth model
  177. VectorXcr rtu;
  178. /// Reflection/Transmission coeffients for downgoing waves in
  179. /// a layered earth model
  180. VectorXcr rtd;
  181. private:
  182. }; // ----- end of class KernelEM1DReflBase -----
  183. } // ----- end of Lemma name -----
  184. #endif // ----- #ifndef KERNELEM1DREFLBASE_INC -----