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

KernelV0-2.cpp 4.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. int main(int argc, char** argv) {
  20. if (argc<4) {
  21. std::cout << "./KernelV0-2 earth.yaml tx.yaml rx.yaml \n";
  22. return(EXIT_SUCCESS);
  23. }
  24. std::cout << "Using earth model: " << argv[1] << std::endl;
  25. auto earth = LayeredEarthEM::DeSerialize( YAML::LoadFile(argv[1]) );
  26. std::cout << "Using transmitter: " << argv[2] << std::endl;
  27. auto Tx = PolygonalWireAntenna::DeSerialize( YAML::LoadFile(argv[2]) );
  28. std::cout << "Using receivers: " << argv[3] << std::endl;
  29. auto Rx1 = PolygonalWireAntenna::DeSerialize( YAML::LoadFile(argv[3]) );
  30. auto Kern = KernelV0::NewSP();
  31. Kern->PushCoil( "Coil 1", Tx );
  32. Kern->PushCoil( "Coil 2", Rx1 );
  33. Kern->SetLayeredEarthEM( earth );
  34. Kern->SetIntegrationSize( (Vector3r() << 200,200,200).finished() );
  35. Kern->SetIntegrationOrigin( (Vector3r() << 0,0,0).finished() );
  36. Kern->SetTolerance( 1e-10 ); // 1e-12
  37. // Kern->AlignWithAkvoDataset( YAML::LoadFile(argv[2]) );
  38. Kern->SetPulseDuration(0.020);
  39. VectorXr I(36);
  40. // off from VC by 1.075926340216996
  41. // Pulses from Wyoming Red Buttes exp 0
  42. I << 397.4208916184016, 352.364477036168, 313.0112765842783, 278.37896394065376, 247.81424224324982,
  43. 220.77925043190442, 196.76493264105017, 175.31662279234038, 156.0044839325404, 138.73983004230124,
  44. 123.42064612625474, 109.82713394836259, 97.76534468972267, 87.06061858367781, 77.56000002944572, 69.1280780096311,
  45. 61.64250263640252, 54.99473044877554, 49.091182970515476, 43.84634004556388, 39.184136917167976, 35.03619319797924,
  46. 31.347205894128976, 28.06346770557137, 25.139117042424758, 22.53420773366429, 20.214205433283347,
  47. 18.144318026099942, 16.299965972298878, 14.652633628829891, 13.184271405688083, 11.870540177313893,
  48. 10.697057141915716, 9.64778948429609, 8.709338689612677, 7.871268012862094;
  49. //Kern->SetPulseCurrent( VectorXr::LinSpaced( 1, 10, 200 ) ); // nbins, low, high
  50. Kern->SetPulseCurrent( I ); // nbins, low, high
  51. //VectorXr interfaces = VectorXr::LinSpaced( 41, .5, 45.5 ); // nlay, low, high
  52. VectorXr interfaces = VectorXr::LinSpaced( 51, .5, 45.5 ); // nlay, low, high
  53. Real thick = .5;
  54. for (int ilay=1; ilay<interfaces.size(); ++ilay) {
  55. interfaces(ilay) = interfaces(ilay-1) + thick;
  56. thick *= 1.05;
  57. }
  58. Kern->SetDepthLayerInterfaces( interfaces ); // nlay, low, high
  59. // We could, I suppose, take the earth model in here? For non-linear that
  60. // may be more natural to work with?
  61. std::vector<std::string> tx = {std::string("Coil 1")};
  62. std::vector<std::string> rx = {std::string("Coil 2")};
  63. Kern->CalculateK0( tx, rx, false );
  64. std::ofstream dout = std::ofstream(std::string("test-")+ std::string(argv[1])+ std::string(".dat"));
  65. //std::ofstream dout = std::ofstream(std::string("k-coincident.dat"));
  66. dout << interfaces.transpose() << std::endl;
  67. dout << I.transpose() << std::endl;
  68. dout << "#real\n";
  69. dout << Kern->GetKernel().real() << std::endl;
  70. dout << "#imag\n";
  71. dout << Kern->GetKernel().imag() << std::endl;
  72. dout.close();
  73. std::ofstream out = std::ofstream(std::string("test-")+std::string(argv[1])+std::string(".yaml"));
  74. //std::ofstream out = std::ofstream(std::string("k-coincident.yaml"));
  75. out << *Kern;
  76. out.close();
  77. }