Lemma is an Electromagnetics API
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

KernelEM1DReflBase.h 7.4KB

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