Lemma is an Electromagnetics API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

min.dox 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. namespace Lemma{
  2. /**
  3. \page Minimal
  4. <div class="lemmamainmenu">
  5. \ref Intro "Intro"
  6. | \ref Compiling "Compiling"
  7. | \ref Memory "Memory management"
  8. | \b Minimal \b programme
  9. | \ref EmSources "EM Sources"
  10. </div>
  11. \section Download Download
  12. Lemma source code may be obtained via svn server
  13. \code
  14. svn co http://cgem.ath.cx/repos/MR/Lemma Lemma
  15. \endcode
  16. Binary versions of the library for Microsoft Windows will be available for download shortly.
  17. To compile you will also need the Eigen3 linear algebra header library, freely available at
  18. <http://eigen.tuxfamily.org>.
  19. We use the scons, a make replacement for builds which is available at <http://scons.org>.
  20. Finally a good C++ compiler is needed. We actively support gcc, intel, and
  21. Microsoft Visual C++ 2010. Your mileage may vary with other compilers. Lemma has been sucessfully compiled on
  22. Microsoft Windows, Mac OSX, many flavours of Linux 64 and 32 bit, and BSD's.
  23. \section Exposing Exposing the API
  24. You may choose to either include individual pieces of Lemma, or instead to simply
  25. include all of Lemma using '#include Lemma'. Examples will be shown both ways but
  26. generally speaking including all of Lemma is a fine thing to do. All of the objects
  27. are defined within the Lemma namespace, so you may want to use that, too.
  28. \code
  29. #include "Lemma"
  30. using namespace Lemma;
  31. int main() {
  32. // Any Lemma Code is OK
  33. }
  34. \endcode
  35. \section Compiling_old
  36. Compiling Lemma code is fairly straightforward. For example using g++
  37. \code
  38. g++ min.cpp -I/path/to/Lemma/include -L/path/to/Lemma/lib -llemma -lmatio -lticppd -lem1d
  39. \endcode
  40. \subsection Libs Whoa, what are all those libs
  41. Compiling Lemma builds several libraries. The largest one is liblemma.so(dll). This contains all the Lemma classes.
  42. The libmatio is responsible for reading in MATLAB files and libticcppd is an XML reader/writer/parser. The libem1d library is a FORTRAN implimentation of a dipole em solver that is used for quality control and assurance.
  43. We use scons to build Lemma. It is easy to extend scons to compile your applications as well, taking care of all
  44. the compiler linker details.
  45. \section VTK
  46. Lemma can be integrated with VTK to produce data visualizations. Using the VTK interfaces is a slightly more advanced
  47. topic and will be handled in a later tutorial.
  48. \section Small Small example application.
  49. We will now spend the next few pages building a Lemma application that computes fields from a wire loop in a time domain survey.
  50. When forward modelling geophysical data, it is natural to break up what is needed into several catagories: the transmitter, the receiver, the earth model, and the specific instrument. In fact, these are exactly the classes needed by Lemma to execute a forward model. Therefore, the first step will be to define these classes. Continuing the code from above, we add class constructors:
  51. \code
  52. #include "Lemma"
  53. using namespace Lemma;
  54. int main() {
  55. PolygonalWireAntenna* Trans = PolygonalWireAntenna::New();
  56. ReceiverPoints* Receivers = ReceiverPoints::New();
  57. LayeredEarthEM *Earth = LayeredEarthEM::New();
  58. // More Lemma code to go here
  59. return EXIT_SUCCESS;
  60. }
  61. \endcode
  62. Now that we have created objects for a transmitter, a receiver, and a layered earth model, we need to populate them with their appropriate parameters.
  63. For the transmitter, we will define a 100 metre by 100 metre loop just above the surface of the Earth with 1 A current and one turn. We input the following after our new objects:
  64. \code
  65. Trans->SetNumberOfPoints(5);
  66. Trans->SetPoint(0, Vector3r( 0, 0, -1e-3));
  67. Trans->SetPoint(1, Vector3r( 100, 0, -1e-3));
  68. Trans->SetPoint(2, Vector3r( 100, 100, -1e-3));
  69. Trans->SetPoint(3, Vector3r( 0, 100, -1e-3));
  70. Trans->SetPoint(4, Vector3r( 0, 0, -1e-3));
  71. Trans->SetCurrent(1);
  72. Trans->SetNumberOfTurns(1);
  73. \endcode
  74. For the receiver location, we'll put one receiver in the centre of the transmitter loop.
  75. \code
  76. Vector3r loc;
  77. Real ox = 50.;
  78. Real oy = 50.;
  79. Real depth = -1.e-3;
  80. Receivers->SetNumberOfReceivers(1);
  81. loc << ox,oy,depth;
  82. Receivers->SetLocation(0,loc);
  83. \endcode
  84. We now set our 5 layer earth model up, with conductivities in S/m. The 5 layers include the air and basement halfspace.
  85. \code
  86. Earth->SetNumberOfLayers(5);
  87. Earth->SetLayerConductivity( (VectorXcr(5) << 0.,1.e-4,1.e-2,
  88. 1.e-4,1.e-6).finished() );
  89. Earth->SetLayerThickness( (VectorXr(3) << 10,5,50).finished() );
  90. \endcode
  91. Finally, we set up an instrument object and attach these objects to it. Since this is a time domain survey, we also define and attach the centre-gate times for a particular instrument.
  92. \code
  93. VectorXr maintimes;
  94. maintimes.resize(25);
  95. maintimes << 191.,216.,246.,286.,336.,400.,480.,584.,
  96. 714.,883.,1097.,1366.,1714.,2157.,2724.,3445.,4361.,
  97. 5535.,7032.,8858.,10724.,13151.,16196.,20047.,25012.;
  98. maintimes = maintimes.array() /1000000;
  99. InstrumentTem *instrument = InstrumentTem::New();
  100. instrument->EMEarthModel(Earth);
  101. instrument->SetTransmitLoop(Trans);
  102. instrument->SetReceiver(Receivers);
  103. instrument->SetTimes(maintimes);
  104. \endcode
  105. We are now ready to make the calculation and get our results.
  106. \code
  107. instrument->MakeCalculation();
  108. // Output results to file
  109. std::ofstream outfile1;
  110. outfile1.open("solution.out");
  111. for (int ii=0;ii<ntimes;ii++) {
  112. outfile1 << instrument->GetMeasurements()(ii,0)<<" "<<
  113. instrument->GetMeasurements()(ii,1)<<std::endl;
  114. }
  115. outfile1.close();
  116. //A little cleanup
  117. instrument->Delete();
  118. Trans->Delete();
  119. Earth->Delete();
  120. Receivers->Delete();
  121. \endcode
  122. Congrats! You have used Lemma to create a forward modelling program. Hopefully now you can see how easy it is to use Lemma to create powerful programs.
  123. */
  124. }
  125. //\include utdipolesource.cpp