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

Coupling.cpp 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. std::shared_ptr<PolygonalWireAntenna> CircularLoop ( int nd, Real radius, Real Offsetx, Real Offsety ) ;
  20. void MoveLoop( std::shared_ptr<PolygonalWireAntenna> Loop, int nd, Real Radius, Real Offsetx, Real Offsety );
  21. int main(int argc, char** argv) {
  22. Real offset = atof(argv[1]);
  23. auto earth = LayeredEarthEM::NewSP();
  24. earth->SetNumberOfLayers(3);
  25. earth->SetLayerConductivity( (VectorXcr(3) << Complex(0.,0), Complex(1./50.,0), Complex(1./100.)).finished() );
  26. earth->SetLayerThickness( (VectorXr(1) << 10).finished() );
  27. // Set mag field info
  28. // From NOAA, Laramie WY, June 9 2016, aligned with mag. north
  29. earth->SetMagneticFieldIncDecMag( 67, 0, 52750, NANOTESLA );
  30. // Transmitter loops
  31. auto Tx1 = CircularLoop(21, 15, 100, 100);
  32. auto Tx2 = CircularLoop(21, 15, 100, 100 + offset);
  33. auto Kern = Coupling::NewSP();
  34. Kern->PushCoil( "Coil 1", Tx1 );
  35. Kern->PushCoil( "Coil 2", Tx2 );
  36. Kern->SetLayeredEarthEM( earth );
  37. Kern->SetIntegrationSize( (Vector3r() << 200,200,200).finished() );
  38. Kern->SetIntegrationOrigin( (Vector3r() << 0,0,2).finished() );
  39. Kern->SetTolerance( 1e-7 ); // 1e-12
  40. std::vector<std::string> tx = {std::string("Coil 1")};
  41. std::vector<std::string> rx = {std::string("Coil 2")};
  42. VectorXr Offsets = VectorXr::LinSpaced(60,0.25,60); // nbins, low, high
  43. auto outfile = std::ofstream("coupling.dat");
  44. for (int ii=0; ii< Offsets.size(); ++ii) {
  45. MoveLoop(Tx2, 21, 15, 100, 100 + Offsets(ii));
  46. Complex coupling = Kern->Calculate( tx, rx, false );
  47. std::cout << "coupling " << coupling << std::endl;
  48. outfile << Offsets(ii) << "\t" << std::real(coupling) << "\t" << std::imag(coupling) << std::endl;
  49. }
  50. outfile.close();
  51. }
  52. std::shared_ptr<Lemma::PolygonalWireAntenna> CircularLoop ( int nd, Real Radius, Real Offsetx, Real Offsety ) {
  53. auto Tx1 = Lemma::PolygonalWireAntenna::NewSP();
  54. Tx1->SetNumberOfPoints(nd);
  55. VectorXr range = VectorXr::LinSpaced(nd, 0, 2*PI);
  56. int ii;
  57. for (ii=0; ii<nd; ++ii) {
  58. Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*std::cos(range(ii)), Offsety+Radius*std::sin(range(ii)), -1e-3));
  59. }
  60. //Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*1, Offsety, -1e-3));
  61. Tx1->SetCurrent(1.);
  62. Tx1->SetNumberOfTurns(1);
  63. Tx1->SetNumberOfFrequencies(1);
  64. Tx1->SetFrequency(0,2246);
  65. return Tx1;
  66. }
  67. void MoveLoop( std::shared_ptr<Lemma::PolygonalWireAntenna> Tx1, int nd, Real Radius, Real Offsetx, Real Offsety ) {
  68. Tx1->SetNumberOfPoints(nd);
  69. VectorXr range = VectorXr::LinSpaced(nd, 0, 2*PI);
  70. int ii;
  71. for (ii=0; ii<nd; ++ii) {
  72. Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*std::cos(range(ii)), Offsety+Radius*std::sin(range(ii)), -1e-3));
  73. }
  74. //Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*1, Offsety, -1e-3));
  75. Tx1->SetCurrent(1.);
  76. Tx1->SetNumberOfTurns(1);
  77. Tx1->SetNumberOfFrequencies(1);
  78. Tx1->SetFrequency(0,2246);
  79. }