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.

LayeredEarthMR.cpp 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 08/28/2017 03:32:34 PM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email tirons@egi.utah.edu
  14. * @copyright Copyright (c) 2017, University of Utah
  15. * @copyright Copyright (c) 2017, Lemma Software, LLC
  16. */
  17. #include "LayeredEarthMR.h"
  18. namespace Lemma {
  19. // ==================== FRIEND METHODS =====================
  20. std::ostream &operator << (std::ostream &stream, const LayeredEarthMR &ob) {
  21. stream << ob.Serialize() << "\n---\n"; // End of doc ---
  22. return stream;
  23. }
  24. // ==================== LIFECYCLE =======================
  25. //--------------------------------------------------------------------------------------
  26. // Class: LayeredEarthMR
  27. // Method: LayeredEarthMR
  28. // Description: constructor (locked)
  29. //--------------------------------------------------------------------------------------
  30. LayeredEarthMR::LayeredEarthMR (const ctor_key&) : LayeredEarth( ) {
  31. } // ----- end of method LayeredEarthMR::LayeredEarthMR (constructor) -----
  32. //--------------------------------------------------------------------------------------
  33. // Class: LayeredEarthMR
  34. // Method: LayeredEarthMR
  35. // Description: DeSerializing constructor (locked)
  36. //--------------------------------------------------------------------------------------
  37. LayeredEarthMR::LayeredEarthMR (const YAML::Node& node, const ctor_key&) : LayeredEarth(node) {
  38. } // ----- end of method LayeredEarthMR::LayeredEarthMR (constructor) -----
  39. //--------------------------------------------------------------------------------------
  40. // Class: LayeredEarthMR
  41. // Method: NewSP()
  42. // Description: public constructor returing a shared_ptr
  43. //--------------------------------------------------------------------------------------
  44. std::shared_ptr< LayeredEarthMR > LayeredEarthMR::NewSP() {
  45. return std::make_shared< LayeredEarthMR >( ctor_key() );
  46. }
  47. //--------------------------------------------------------------------------------------
  48. // Class: LayeredEarthMR
  49. // Method: ~LayeredEarthMR
  50. // Description: destructor (protected)
  51. //--------------------------------------------------------------------------------------
  52. LayeredEarthMR::~LayeredEarthMR () {
  53. } // ----- end of method LayeredEarthMR::~LayeredEarthMR (destructor) -----
  54. //--------------------------------------------------------------------------------------
  55. // Class: LayeredEarthMR
  56. // Method: Serialize
  57. //--------------------------------------------------------------------------------------
  58. YAML::Node LayeredEarthMR::Serialize ( ) const {
  59. YAML::Node node = LayeredEarth::Serialize();
  60. node.SetTag( GetName() );
  61. // FILL IN CLASS SPECIFICS HERE
  62. node["Merlin_VERSION"] = MERLIN_VERSION;
  63. node["T2StarBins"] = T2StarBins;
  64. node["T2StarBinEdges"] = T2StarBinEdges;
  65. node["ModelMat"] = ModelMat;
  66. return node;
  67. } // ----- end of method LayeredEarthMR::Serialize -----
  68. //--------------------------------------------------------------------------------------
  69. // Class: LayeredEarthMR
  70. // Method: DeSerialize
  71. //--------------------------------------------------------------------------------------
  72. std::shared_ptr<LayeredEarthMR> LayeredEarthMR::DeSerialize ( const YAML::Node& node ) {
  73. if (node.Tag() != "LayeredEarthMR" ) {
  74. throw DeSerializeTypeMismatch( "LayeredEarthMR", node.Tag());
  75. }
  76. return std::make_shared< LayeredEarthMR > ( node, ctor_key() );
  77. } // ----- end of method LayeredEarthMR::DeSerialize -----
  78. //--------------------------------------------------------------------------------------
  79. // Class: LayeredEarthMR
  80. // Method: SetNumberOfLayers
  81. //--------------------------------------------------------------------------------------
  82. void LayeredEarthMR::SetNumberOfLayers ( const int& nlay ) {
  83. NumberOfLayers = nlay;
  84. NumberOfInterfaces = nlay+1;
  85. return ;
  86. } // ----- end of method LayeredEarthMR::SetNumberOfLayers -----
  87. //--------------------------------------------------------------------------------------
  88. // Class: LayeredEarthMR
  89. // Method: AlignWithKernel
  90. //--------------------------------------------------------------------------------------
  91. void LayeredEarthMR::AlignWithKernel ( std::shared_ptr<KernelV0> Kern ) {
  92. int nlay = Kern->GetInterfaces().size()-1;
  93. SetNumberOfLayers( nlay );
  94. LayerThickness = Kern->GetInterfaces().tail(nlay) - Kern->GetInterfaces().head(nlay) ;
  95. SetMagneticFieldComponents( Kern->GetSigmaModel()->GetMagneticField(), TESLA);
  96. return ;
  97. } // ----- end of method LayeredEarthMR::AlignWithKernel -----
  98. //--------------------------------------------------------------------------------------
  99. // Class: LayeredEarthMR
  100. // Method: SetNumberOfT2StarBins
  101. //--------------------------------------------------------------------------------------
  102. void LayeredEarthMR::SetT2StarBins ( const Real& first, const Real& last, const int& nT2 ) {
  103. T2StarBinEdges = VectorXr::Zero(nT2+1);
  104. Real m = 1./(nT2);
  105. Real quotient = std::pow(last/first, m);
  106. T2StarBinEdges[0] = first;
  107. for (int i=1; i<nT2+1; ++i) {
  108. T2StarBinEdges[i] = T2StarBinEdges[i-1]*quotient;
  109. }
  110. T2StarBins = (T2StarBinEdges.head(nT2) + T2StarBinEdges.tail(nT2)) / 2;
  111. InitModelMat();
  112. return;
  113. } // ----- end of method LayeredEarthMR::SetNumberOfT2StarBins -----
  114. //--------------------------------------------------------------------------------------
  115. // Class: LayeredEarthMR
  116. // Method: InitModelMat
  117. //--------------------------------------------------------------------------------------
  118. void LayeredEarthMR::InitModelMat ( ) {
  119. ModelMat = MatrixXr::Zero( T2StarBins.size(), NumberOfLayers );
  120. return ;
  121. } // ----- end of method LayeredEarthMR::InitModelMat -----
  122. } // ---- end of namespace Lemma ----
  123. /* vim: set tabstop=4 expandtab: */
  124. /* vim: set filetype=cpp: */