Surface NMR forward modelling
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.

Coupling.cpp 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 11/11/2016 02:44:37 PM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email tirons@egi.utah.edu
  14. * @copyright Copyright (c) 2016, University of Utah
  15. * @copyright Copyright (c) 2016, Lemma Software, LLC
  16. */
  17. #include <Merlin>
  18. using namespace Lemma;
  19. static constexpr Real GAMMA = 2.67518e8; // MKS units
  20. std::shared_ptr<PolygonalWireAntenna> CircularLoop ( int nd, Real radius, Real Offsetx, Real Offsety, Real wL ) ;
  21. void MoveLoop( std::shared_ptr<PolygonalWireAntenna> Loop, int nd, Real Radius, Real Offsetx, Real Offsety, Real wL );
  22. int main(int argc, char** argv) {
  23. if ( argc < 2 ) {
  24. std::cout << "Calculates the coupling between two sNMR loops at the Larmor frequency. Usage\n"
  25. << "\t./Coupling EarthModel.yaml" << std::endl;
  26. exit(0);
  27. }
  28. //Real offset = atof(argv[1]);
  29. auto earth = LayeredEarthEM::DeSerialize( YAML::LoadFile(argv[1]) );
  30. Real Larmor = earth->GetMagneticFieldMagnitude()*GAMMA/(2*PI);
  31. // RedButtes model, also how you can generate your own files
  32. // auto earth = LayeredEarthEM::NewSP();
  33. // earth->SetNumberOfLayers(3);
  34. // earth->SetLayerConductivity( (VectorXcr(3) << Complex(0.,0), Complex(1./50.,0), Complex(1./100.)).finished() );
  35. // earth->SetLayerThickness( (VectorXr(1) << 10).finished() );
  36. // // Set mag field info
  37. // // From NOAA, Laramie WY, June 9 2016, aligned with mag. north
  38. // earth->SetMagneticFieldIncDecMag( 67, 0, 52750, NANOTESLA );
  39. // auto sig = std::ofstream("SigmaModel.yaml");
  40. // sig << *earth << std::endl;
  41. // sig.close();
  42. // Transmitter loops
  43. auto Tx1 = CircularLoop(21, 15, 100, 75, Larmor);
  44. auto Tx2 = CircularLoop(21, 15, 100, 75, Larmor); // initially coincident
  45. auto Kern = Coupling::NewSP();
  46. Kern->PushCoil( "Coil 1", Tx1 );
  47. Kern->PushCoil( "Coil 2", Tx2 );
  48. Kern->SetLayeredEarthEM( earth );
  49. Kern->SetIntegrationSize( (Vector3r() << 200,300,20).finished() );
  50. Kern->SetIntegrationOrigin( (Vector3r() << 0,0,0.01).finished() );
  51. Kern->SetTolerance( 1e-5 ); // 1e-12
  52. std::vector<std::string> tx = {std::string("Coil 1")};
  53. std::vector<std::string> rx = {std::string("Coil 2")};
  54. VectorXr Offsets = VectorXr::LinSpaced(6, 22.00, 23.0); // nbins, low, high
  55. auto outfile = std::ofstream("coupling.dat");
  56. for (int ii=0; ii< Offsets.size(); ++ii) {
  57. MoveLoop(Tx2, 21, 15, 100, 75 + Offsets(ii), Larmor);
  58. #ifdef LEMMAUSEVTK
  59. Complex coupling = Kern->Calculate( tx, rx, true );
  60. #else
  61. Complex coupling = Kern->Calculate( tx, rx, false );
  62. #endif
  63. std::cout << "coupling " << coupling << std::endl;
  64. outfile << Offsets(ii) << "\t" << std::real(coupling) << "\t" << std::imag(coupling) << std::endl;
  65. }
  66. outfile.close();
  67. }
  68. std::shared_ptr<Lemma::PolygonalWireAntenna> CircularLoop ( int nd, Real Radius, Real Offsetx, Real Offsety, Real wL ) {
  69. auto Tx1 = Lemma::PolygonalWireAntenna::NewSP();
  70. Tx1->SetNumberOfPoints(nd);
  71. VectorXr range = VectorXr::LinSpaced(nd, 0, 2*PI);
  72. int ii;
  73. for (ii=0; ii<nd; ++ii) {
  74. Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*std::cos(range(ii)), Offsety+Radius*std::sin(range(ii)), -1e-3));
  75. }
  76. Tx1->SetCurrent(1.);
  77. Tx1->SetNumberOfTurns(1);
  78. Tx1->SetNumberOfFrequencies(1);
  79. Tx1->SetFrequency(0,wL);
  80. return Tx1;
  81. }
  82. void MoveLoop( std::shared_ptr<Lemma::PolygonalWireAntenna> Tx1, int nd, Real Radius, Real Offsetx, Real Offsety, Real wL ) {
  83. Tx1->SetNumberOfPoints(nd);
  84. VectorXr range = VectorXr::LinSpaced(nd, 0, 2*PI);
  85. int ii;
  86. for (ii=0; ii<nd; ++ii) {
  87. Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*std::cos(range(ii)), Offsety+Radius*std::sin(range(ii)), -1e-3));
  88. }
  89. Tx1->SetCurrent(1.);
  90. Tx1->SetNumberOfTurns(1);
  91. Tx1->SetNumberOfFrequencies(1);
  92. Tx1->SetFrequency(0,wL);
  93. }