Main Lemma Repository
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.

uttemforward.cpp 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. // ===========================================================================
  2. //
  3. // Filename: uttemforward.cpp
  4. //
  5. // Description: TEM Forward Modeller
  6. //
  7. // Version: 0.0
  8. // Created: 02/10/2011 03:32:18 PM
  9. // Revision: none
  10. // Compiler: Tested with g++, icpc, and MSVC 2000
  11. //
  12. // Author: M. Andy Kass (MAK)
  13. //
  14. // Copyright: 2011 Trevor Irons and M. Andy Kass
  15. //
  16. // Organisation: Colorado School of Mines (CSM)
  17. // Broken Spoke Development, LLC
  18. //
  19. // Email: mkass@numericalgeo.com
  20. //
  21. // This program is free software: you can redistribute it and/or modify
  22. // it under the terms of the GNU General Public License as published by
  23. // the Free Software Foundation, either version 3 of the License, or
  24. // (at your option) any later version.
  25. //
  26. // This program is distributed in the hope that it will be useful,
  27. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. // GNU General Public License for more details.
  30. //
  31. // You should have received a copy of the GNU General Public License
  32. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  33. //
  34. // ===========================================================================
  35. #include <time.h>
  36. #include "Lemma"
  37. #include "banner.h"
  38. using namespace Lemma;
  39. #ifdef LEMMAUSEVTK
  40. #include "matplot.h"
  41. using namespace matplot;
  42. #endif
  43. int main(int argv, char** argc) {
  44. // Just for timing
  45. clock_t launch =clock();
  46. // Banner display
  47. std::string name;
  48. std::string version;
  49. std::string usage;
  50. name = "TEM Forward Modeller - 1D";
  51. version = "1.0beta";
  52. usage = "temforward1d [inputfile]";
  53. banner(name,version,usage);
  54. if ( argv < 2 ) {
  55. std::cout << "No input file specified, should be of format\n";
  56. std::cout <<
  57. "origparabk.obsy ! Observations-style file.\n\
  58. origpara.con ! Starting model.\n\
  59. 100 ! Number of Hankel kernel evaluations.\n\
  60. 100 1. 1.0E+10 ! Number of Fourier kernel evaluations, & min & max freq.\n\
  61. N ! Is noise to be added?\n\
  62. 5. 1.0E-08 30 ! Noise to be added: percentage, threshold, seed.\n\
  63. " << std::endl;
  64. exit(0);
  65. }
  66. time_t curr=time(0);
  67. std::cout << std::endl;
  68. std::cout << " Start time: " << ctime(&curr) << std::endl;
  69. // Define objects
  70. PolygonalWireAntenna* Trans = PolygonalWireAntenna::New();
  71. // PolygonalWireAntenna* pa = PolygonalWireAntenna::New();
  72. // pa->SetNumberOfPoints(5);
  73. // pa->SetPoint(0, Vector3r( 0, 0, -30.001));
  74. // pa->SetPoint(1, Vector3r( 0, 20, -35.001));
  75. // pa->SetPoint(2, Vector3r( 20 , 20, -35.001));
  76. // pa->SetPoint(3, Vector3r( 20, 0, -30.001));
  77. // pa->SetPoint(4, Vector3r( 0, 0, -30.001));
  78. // pa->SetCurrent(100.);
  79. // pa->SetNumberOfTurns(1);
  80. //DipoleSource* Trans = DipoleSource::New();
  81. ReceiverPoints *Receivers = ReceiverPoints::New();
  82. LayeredEarthEM *Earth = LayeredEarthEM::New();
  83. VectorXr maintimes;
  84. /////////////////////////////////////
  85. // Using model reader
  86. ModelReaderTem1DUBC* Reader = ModelReaderTem1DUBC::New();
  87. Reader->SetEMEarth1D(Earth);
  88. Reader->SetTransmitter(Trans);
  89. Reader->SetReceiver(Receivers);
  90. Reader->ReadParameters( argc[1] );
  91. maintimes = Reader->GetTimes();
  92. // Attach it to instrumentTEM
  93. InstrumentTem *instrument = InstrumentTem::New();
  94. instrument->EMEarthModel(Earth);
  95. instrument->SetTransmitLoop(Trans);
  96. //instrument->SetTransmitLoop(pa);
  97. //instrument->SetDipoleSource(Trans);
  98. instrument->SetReceiver(Receivers);
  99. // TODO need to input these
  100. VectorXr widths = VectorXr::Ones(maintimes.size()); // * 1e-5;
  101. /*
  102. widths.segment(0,5).array() *= 5e-6;
  103. widths.segment(5,5).array() *= 1e-5;
  104. widths.segment(10,5).array() *= 5e-5;
  105. widths.segment(15,5).array() *= 2e-4;
  106. widths.segment(20,5).array() *= 4e-4;
  107. //widths.segment(25,5).array() *= 4e-4;
  108. */
  109. /*
  110. widths << .48,4.,8.,8.,8.,8.,8.,12.,12.,12.,16.,16.,16.,20.,24.,24.,28.,32.,32.,36.,40.,44.,52.,
  111. 56.,64.,68.,76.,88.,96.,104.,120.,132.,144.,160.,180.,200.,220.,248.,272.,304.,336.,376.,
  112. 416.,464.,516.,572.,636.,708.,784.,872.,968.,1076.,1196.,1328.,1476.,1640.,1824.,2024.,
  113. 2248.,2500. ;
  114. */
  115. widths *= 1e-6;
  116. std::cout << widths.transpose() << std::endl;
  117. instrument->SetReferenceTime(.025);
  118. //instrument->SetReferenceTime(.025);
  119. instrument->SetTimeGates(maintimes, widths);
  120. //instrument->SetReceiverType(MAGNETOMETER);
  121. instrument->SetReceiverType(INDUCTIVE);
  122. // Set the pulse
  123. VectorXr Amp(4); Amp << 0,1,1,0;
  124. VectorXr Times(4); Times << 0., .0005, .02497, .025;
  125. //VectorXr Amp(4); Amp << 0,1,1,0;
  126. //VectorXr Times(4); Times << -0.025, -0.0245, -0.00003, 0.0;
  127. //instrument->SetPulse(Amp, Times);
  128. //VectorXr Amp(3); Amp << 0,1,0;
  129. //VectorXr Times(3); Times << 0, .015, .030;
  130. //instrument->SetPulse(Amp, Times);
  131. //VectorXr Amp(3); Amp << 0,1,0;
  132. //VectorXr Times(3); Times << 0, .01, .020;
  133. instrument->SetPulse(Amp, Times);
  134. std::cout << *Earth << "\n" << *Trans << "\n" << *Receivers << std::endl;
  135. // Perform the forward model
  136. //instrument->MakeDirectCalculation( FHTKEY201 );
  137. //instrument->MakeLaggedCalculation( ANDERSON801 );
  138. //instrument->MakeLaggedCalculation( QWEKEY );
  139. //instrument->MakeLaggedCalculation( CHAVE );
  140. instrument->MakeLaggedCalculation( FHTKEY201 );
  141. //instrument->MakeLaggedCalculation( FHTKEY101 );
  142. int nlag = instrument->GetMeasurements().rows();
  143. // Output results to screen
  144. for (int ii=0; ii<nlag; ii++) {
  145. std::cout<<" "<<instrument->GetMeasurements()(ii,0)<<" "<<instrument->GetMeasurements()(ii,1)<<std::endl;
  146. }
  147. // Output results to file
  148. std::ofstream outfile1;
  149. outfile1.open("solution.out");
  150. //outfile1 << "//timegate [ms]\t dB/dt [nT/s]" << std::endl;
  151. outfile1 << "//timegate [s]\t dB/dt [T/s]" << std::endl;
  152. for (int ii=0; ii<nlag; ii++) {
  153. //outfile1 << 1e3*instrument->GetMeasurements()(ii,0)<< "\t" << (MU0*1e9)*instrument->GetMeasurements()(ii,1)<<std::endl;
  154. outfile1 << instrument->GetMeasurements()(ii,0)<< "\t" << MU0*instrument->GetMeasurements()(ii,1) << std::endl;
  155. //outfile1 << instrument->GetMeasurements()(ii,0)<< "\t" << instrument->GetMeasurements()(ii,1)<<std::endl;
  156. }
  157. outfile1.close();
  158. // Timing stuff
  159. std::cout << " Time for execution: " << (clock()-launch)/CLOCKS_PER_SEC << " [CPU] seconds."
  160. << std::endl;
  161. instrument->Delete();
  162. Trans->Delete();
  163. Earth->Delete();
  164. Receivers->Delete();
  165. Reader->Delete();
  166. return EXIT_SUCCESS;
  167. }