Surface NMR forward modelling
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Interference.cpp 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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, Real pol=1. ) ;
  21. void MoveLoop( std::shared_ptr<PolygonalWireAntenna> Loop, int nd, Real Radius, Real Offsetx, Real Offsety, Real wL, Real pol=1. );
  22. int main(int argc, char** argv) {
  23. /*
  24. if ( argc < 2 ) {
  25. std::cout << "Calculates the coupling between two sNMR loops at the Larmor frequency. Usage\n"
  26. << "\t./Coupling EarthModel.yaml" << std::endl;
  27. exit(0);
  28. }
  29. //Real offset = atof(argv[1]);
  30. auto earth = LayeredEarthEM::DeSerialize( YAML::LoadFile(argv[1]) );
  31. */
  32. // RedButtes model, also how you can generate your own files
  33. auto earth = LayeredEarthEM::NewSP();
  34. earth->SetNumberOfLayers(3);
  35. earth->SetLayerConductivity( (VectorXcr(3) << Complex(0.,0), Complex(1./50.,0), Complex(1./100.)).finished() );
  36. earth->SetLayerThickness( (VectorXr(1) << 10).finished() );
  37. // Set mag field info
  38. // From NOAA, Laramie WY, June 9 2016, aligned with mag. north
  39. earth->SetMagneticFieldIncDecMag( 67, 0, 52750, NANOTESLA );
  40. // auto sig = std::ofstream("SigmaModel.yaml");
  41. // sig << *earth << std::endl;
  42. // sig.close();
  43. Real Larmor = earth->GetMagneticFieldMagnitude()*GAMMA/(2*PI);
  44. // Transmitter loops
  45. auto Tx1 = CircularLoop(21, 15, 50, 50, Larmor, 1);
  46. auto Tx2 = CircularLoop(21, 15, 50, 50, Larmor, -1); // initially coincident
  47. auto Kern = LoopInteractions<INTERFERENCE>::NewSP();
  48. Kern->PushCoil( "Coil 1", Tx1 );
  49. Kern->PushCoil( "Coil 2", Tx2 );
  50. Kern->SetLayeredEarthEM( earth );
  51. Kern->SetIntegrationSize( (Vector3r() << 50,200,50).finished() );
  52. Kern->SetIntegrationOrigin( (Vector3r() << 0, 0, 0.1).finished() );
  53. Kern->SetTolerance( 1e-5 ); // 1e-12
  54. std::vector<std::string> tx = {std::string("Coil 1")};//,std::string("Coil 2")};
  55. std::vector<std::string> rx = {std::string("Coil 2")};
  56. VectorXr Offsets = VectorXr::LinSpaced(61, 0.00, 60.0); // nbins, low, high
  57. auto outfile = std::ofstream("interference-opposed.dat");
  58. for (int ii=0; ii< Offsets.size(); ++ii) {
  59. MoveLoop(Tx2, 21, 15, 50, 50 + Offsets(ii), Larmor, -1.);
  60. #ifdef LEMMAUSEVTK
  61. Complex coupling = Kern->Calculate( tx, rx, true );
  62. #else
  63. Complex coupling = Kern->Calculate( tx, rx, false );
  64. #endif
  65. std::cout << "coupling " << coupling << std::endl;
  66. outfile << Offsets(ii) << "\t" << std::real(coupling) << "\t" << std::imag(coupling) << std::endl;
  67. }
  68. outfile.close();
  69. }
  70. std::shared_ptr<Lemma::PolygonalWireAntenna> CircularLoop ( int nd, Real Radius, Real Offsetx, Real Offsety, Real wL, Real pol ) {
  71. auto Tx1 = Lemma::PolygonalWireAntenna::NewSP();
  72. Tx1->SetNumberOfPoints(nd);
  73. VectorXr range = VectorXr::LinSpaced(nd, 0, 2*PI);
  74. int ii;
  75. for (ii=0; ii<nd; ++ii) {
  76. Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*std::cos(range(ii)), Offsety+pol*Radius*std::sin(range(ii)), -1e-3));
  77. }
  78. Tx1->SetCurrent(1.);
  79. Tx1->SetNumberOfTurns(1);
  80. Tx1->SetNumberOfFrequencies(1);
  81. Tx1->SetFrequency(0,wL);
  82. return Tx1;
  83. }
  84. void MoveLoop( std::shared_ptr<Lemma::PolygonalWireAntenna> Tx1, int nd, Real Radius, Real Offsetx, Real Offsety, Real wL, Real pol ) {
  85. Tx1->SetNumberOfPoints(nd);
  86. VectorXr range = VectorXr::LinSpaced(nd, 0, 2*PI);
  87. int ii;
  88. for (ii=0; ii<nd; ++ii) {
  89. Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*std::cos(range(ii)), Offsety+pol*Radius*std::sin(range(ii)), -1e-3));
  90. }
  91. Tx1->SetCurrent(1.);
  92. Tx1->SetNumberOfTurns(1);
  93. Tx1->SetNumberOfFrequencies(1);
  94. Tx1->SetFrequency(0,wL);
  95. }