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

emdipearth1d.cpp 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // ===========================================================================
  2. //
  3. // Filename: utemdipearth1d.cpp
  4. //
  5. // Description:
  6. //
  7. // Version: 0.0
  8. // Created: 01/06/2010 04:27:56 PM
  9. // Revision: none
  10. // Compiler: g++ (c++)
  11. //
  12. // Author: Trevor Irons (ti)
  13. //
  14. // Organisation: Colorado School of Mines (CSM)
  15. // United States Geological Survey (USGS)
  16. //
  17. // Email: tirons@mines.edu, tirons@usgs.gov
  18. //
  19. // This program is free software: you can redistribute it and/or modify
  20. // it under the terms of the GNU General Public License as published by
  21. // the Free Software Foundation, either version 3 of the License, or
  22. // (at your option) any later version.
  23. //
  24. // This program is distributed in the hope that it will be useful,
  25. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. // GNU General Public License for more details.
  28. //
  29. // You should have received a copy of the GNU General Public License
  30. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  31. //
  32. // ===========================================================================
  33. #include "emearth1d.h"
  34. #include "dipolesource.h"
  35. #include "layeredearthem.h"
  36. #include "receiverpoints.h"
  37. using namespace Lemma;
  38. int main() {
  39. // Test with a single dipole
  40. DipoleSource *dipole = DipoleSource::New();
  41. dipole->SetType(GROUNDEDELECTRICDIPOLE);
  42. dipole->SetPolarisation(XPOLARISATION);
  43. dipole->SetNumberOfFrequencies(1);
  44. dipole->SetMoment(1);
  45. dipole->SetFrequency(0, 4400.1000);
  46. //dipole->SetPhase(0);
  47. //dipole->SetLocation( (VectorXr(3) << 49, 49, -1e-4).finished() );
  48. dipole->SetLocation( 49, 49, -1e-4 );
  49. // Define model
  50. VectorXcr sigma(2);
  51. sigma << 0., 1e-3;//, .1;//, .01, .001;
  52. VectorXr thick(1);
  53. thick << 10;//, 10, 10;
  54. LayeredEarthEM *earth = LayeredEarthEM::New();
  55. earth->SetNumberOfLayers(2);
  56. earth->SetLayerConductivity(sigma);
  57. //earth->SetLayerThickness(thick);
  58. // Receivers
  59. ReceiverPoints *receivers = ReceiverPoints::New();
  60. Vector3r loc;
  61. //Real ox = -5.1456;
  62. //Real oy = 2.2350;
  63. Real ox = 50.;
  64. Real oy = 20.;
  65. Real depth = 18.10;
  66. Real dz = 2.6;
  67. int nz = 1;
  68. receivers->SetNumberOfReceivers(nz);
  69. int ir = 0;
  70. for (int iz=0; iz<nz; ++iz) {
  71. loc << ox, oy, depth;
  72. receivers->SetLocation(ir, loc);
  73. depth += dz;
  74. ++ ir;
  75. }
  76. //receivers->SetLocation(1, ox, oy, depth);
  77. EMEarth1D *EmEarth = EMEarth1D::New();
  78. //EmEarth->SetHankelTransformMethod(DIGITALFILTERING);
  79. EmEarth->SetFieldsToCalculate(BOTH); // Fortran needs this
  80. EmEarth->AttachDipoleSource(dipole);
  81. EmEarth->AttachLayeredEarthEM(earth);
  82. EmEarth->AttachReceiverPoints(receivers);
  83. //dipole->SetType(ELECTRICDIPOLE);
  84. // receivers->SetNumberOfReceivers(1);
  85. // //for
  86. // receivers->SetLocation(0, ox, oy, depth);
  87. std::cout << "C++\n";
  88. EmEarth->MakeCalc3();
  89. std::cout << receivers->GetEfield(0,0) << std::endl;
  90. //std::cout << receivers->GetEfield(0) << std::endl;
  91. //std::cout << receivers->GetHfield(1) << std::endl;
  92. //std::cout << receivers->GetEfield(1) << std::endl;
  93. receivers->ClearFields();
  94. // swap tx rx posigion
  95. receivers->SetLocation(0, dipole->GetLocation());
  96. dipole->SetLocation(loc);
  97. EmEarth->MakeCalc3();
  98. std::cout << receivers->GetEfield(0,0) << std::endl;
  99. receivers->ClearFields();
  100. #ifdef KIHALEE_EM1D
  101. // //std::cout << "\nFORTRAN\n";
  102. EmEarth->MakeCalc();
  103. // std::cout << receivers->GetHfield(0,0) << std::endl;
  104. std::cout << receivers->GetEfield(0,0) << std::endl;
  105. #endif
  106. dipole->Delete();
  107. EmEarth->Delete();
  108. receivers->Delete();
  109. earth->Delete();
  110. // try {
  111. //
  112. // }
  113. //
  114. // // Catch exceptions
  115. // catch (NullEarth) {
  116. // std::cout << "Earth model not set dummy\n";
  117. // }
  118. //
  119. // catch (NullReceivers) {
  120. // std::cout << "Receivers not set dummy\n";
  121. // }
  122. //EmEarth->TestBess();
  123. }