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

KV0-3loops.cpp 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. int main(int argc, char** argv) {
  21. if (argc < 3) {
  22. std::cout << "./KVo-3loops <offset> <tolerance> <rx>" << std::endl;
  23. exit(0);
  24. }
  25. Real offset = atof(argv[1]);
  26. std::cout << offset << std::endl;
  27. Real tol = atof(argv[2]);
  28. auto earth = LayeredEarthEM::NewSP();
  29. earth->SetNumberOfLayers(3);
  30. earth->SetLayerConductivity( (VectorXcr(3) << Complex(0.,0), Complex(1./50.,0), Complex(1./100.)).finished() );
  31. earth->SetLayerThickness( (VectorXr(1) << 10).finished() );
  32. // Set mag field info
  33. // From NOAA, Laramie WY, June 9 2016, aligned with mag. north
  34. earth->SetMagneticFieldIncDecMag( 67, 0, 52750, NANOTESLA );
  35. // Transmitter loops
  36. auto Tx1 = CircularLoop(21, 15, 100+offset/2., 100-offset/2.);
  37. auto Tx2 = CircularLoop(21, 15, 100+offset/2., 100+offset/2.);
  38. auto Tx3 = CircularLoop(21, 15, 100-offset/2., 100 );
  39. auto Kern = KernelV0::NewSP();
  40. Kern->PushCoil( "Coil 1", Tx1 );
  41. Kern->PushCoil( "Coil 2", Tx2 );
  42. Kern->PushCoil( "Coil 3", Tx3 );
  43. Kern->SetLayeredEarthEM( earth );
  44. Kern->SetIntegrationSize( (Vector3r() << 200,200,200).finished() );
  45. Kern->SetIntegrationOrigin( (Vector3r() << 0,0,0).finished() );
  46. Kern->SetTolerance( tol ); // 1e-12
  47. Kern->SetPulseDuration(0.020);
  48. VectorXr I(36);
  49. // off from VC by 1.075926340216996
  50. // Pulses from Wyoming Red Buttes exp 0
  51. I << 397.4208916184016, 352.364477036168, 313.0112765842783, 278.37896394065376, 247.81424224324982,
  52. 220.77925043190442, 196.76493264105017, 175.31662279234038, 156.0044839325404, 138.73983004230124,
  53. 123.42064612625474, 109.82713394836259, 97.76534468972267, 87.06061858367781, 77.56000002944572, 69.1280780096311,
  54. 61.64250263640252, 54.99473044877554, 49.091182970515476, 43.84634004556388, 39.184136917167976, 35.03619319797924,
  55. 31.347205894128976, 28.06346770557137, 25.139117042424758, 22.53420773366429, 20.214205433283347,
  56. 18.144318026099942, 16.299965972298878, 14.652633628829891, 13.184271405688083, 11.870540177313893,
  57. 10.697057141915716, 9.64778948429609, 8.709338689612677, 7.871268012862094;
  58. //Kern->SetPulseCurrent( VectorXr::LinSpaced( 1, 10, 200 ) ); // nbins, low, high
  59. Kern->SetPulseCurrent( I ); // nbins, low, high
  60. //Kern->SetDepthLayerInterfaces( VectorXr::LinSpaced( 30, 3, 45.5 ) ); // nlay, low, high
  61. VectorXr interfaces = VectorXr::LinSpaced( 41, .5, 45.5 ); // nlay, low, high
  62. Real thick = .5;
  63. for (int ilay=1; ilay<interfaces.size(); ++ilay) {
  64. interfaces(ilay) = interfaces(ilay-1) + thick;
  65. thick *= 1.05;
  66. }
  67. Kern->SetDepthLayerInterfaces( interfaces ); // nlay, low, high
  68. // We could, I suppose, take the earth model in here? For non-linear that
  69. // may be more natural to work with?
  70. std::vector<std::string> tx = {std::string("Coil 1"), std::string("Coil 2"), std::string("Coil 3") };
  71. //std::vector<std::string> rx = {std::string("Coil 1"), std::string("Coil 2")};//, std::string("Coil 3") };
  72. std::vector<std::string> rx = {std::string(argv[3])};
  73. Kern->CalculateK0( tx, rx, false );
  74. std::ofstream dout = std::ofstream(std::string("k0-3Tx-RxCh-") + std::string(argv[3]) + std::string("-tol") + std::string(argv[1])+ std::string(".dat"));
  75. dout << "# Transmitters: ";
  76. for (auto lp : tx) {
  77. dout << lp << "\t";
  78. }
  79. dout << "\n# Receivers: ";
  80. for (auto lp : rx) {
  81. dout << lp << "\t";
  82. }
  83. dout << "\n# Tolerance: " << tol << std::endl;
  84. dout << "# Offset: " << offset << std::endl;
  85. dout << "# Radius: " << 15 << std::endl;
  86. dout << interfaces.transpose() << std::endl;
  87. dout << Kern->GetPulseDuration()*I.transpose() << std::endl;
  88. dout << "#real\n";
  89. dout << Kern->GetKernel().real() << std::endl;
  90. dout << "#imag\n";
  91. dout << Kern->GetKernel().imag() << std::endl;
  92. dout.close();
  93. //std::ofstream out = std::ofstream(std::string("k0-3Tx-RxCh1-")+std::string(argv[1])+std::string(".yaml"));
  94. std::ofstream out = std::ofstream(std::string("k0-3Tx-RxCh-") + std::string(argv[3]) + std::string("-tol") + std::string(argv[1])+ std::string(".yaml"));
  95. out << *Kern;
  96. out.close();
  97. }
  98. std::shared_ptr<Lemma::PolygonalWireAntenna> CircularLoop ( int nd, Real Radius, Real Offsetx, Real Offsety ) {
  99. auto Tx1 = Lemma::PolygonalWireAntenna::NewSP();
  100. Tx1->SetNumberOfPoints(nd);
  101. VectorXr range = VectorXr::LinSpaced(nd, 0, 2*PI);
  102. int ii;
  103. for (ii=0; ii<nd; ++ii) {
  104. Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*std::cos(range(ii)), Offsety+Radius*std::sin(range(ii)), -1e-3));
  105. }
  106. //Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*1, Offsety, -1e-3));
  107. Tx1->SetCurrent(1.);
  108. Tx1->SetNumberOfTurns(1);
  109. Tx1->SetNumberOfFrequencies(1);
  110. Tx1->SetFrequency(0,2246);
  111. return Tx1;
  112. }