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.

ForwardFID.h 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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 08:49:51 AM
  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. #ifndef FORWARDFID_INC
  18. #define FORWARDFID_INC
  19. #pragma once
  20. #include <random>
  21. #include "LayeredEarthEM.h"
  22. #include "PolygonalWireAntenna.h"
  23. #include "EMEarth1D.h"
  24. #include "MerlinObject.h"
  25. #include "DataFID.h"
  26. #include "KernelV0.h"
  27. #include "LayeredEarthMR.h"
  28. namespace Lemma {
  29. /**
  30. * \ingroup Merlin
  31. * \brief Forward modelling for FID sNMR pulses
  32. * \details This class performs forward modelling of sNMR
  33. * FID experiments.
  34. */
  35. class ForwardFID : public MerlinObject {
  36. friend std::ostream &operator<<(std::ostream &stream, const ForwardFID &ob);
  37. protected:
  38. /*
  39. * This key is used to lock the constructor. It is protected so that inhereted
  40. * classes also have the key to contruct their base class.
  41. */
  42. struct ctor_key {};
  43. public:
  44. // ==================== LIFECYCLE =======================
  45. /**
  46. * Default constructor.
  47. * @note This method is locked, and cannot be called directly.
  48. * The reason that the method is public is to enable the use
  49. * of make_shared whilst enforcing the use of shared_ptr,
  50. * in c++-17, this curiosity may be resolved.
  51. * @see ForwardFID::NewSP
  52. */
  53. explicit ForwardFID ( const ctor_key& );
  54. /**
  55. * DeSerializing constructor.
  56. * @note This method is locked, and cannot be called directly.
  57. * The reason that the method is public is to enable the use
  58. * of make_shared whilst enforcing the use of shared_ptr,
  59. * in c++-17, this curiosity may be resolved.
  60. * @see ForwardFID::DeSerialize
  61. */
  62. ForwardFID ( const YAML::Node& node, const ctor_key& );
  63. /**
  64. * Default destructor.
  65. * @note This method should never be called due to the mandated
  66. * use of smart pointers. It is necessary to keep the method
  67. * public in order to allow for the use of the more efficient
  68. * make_shared constructor.
  69. */
  70. virtual ~ForwardFID ();
  71. /**
  72. * Uses YAML to serialize this object.
  73. * @return a YAML::Node
  74. * @see ForwardFID::DeSerialize
  75. */
  76. virtual YAML::Node Serialize() const;
  77. /*
  78. * Factory method for generating concrete class.
  79. * @return a std::shared_ptr of type ForwardFID
  80. */
  81. static std::shared_ptr< ForwardFID > NewSP();
  82. /**
  83. * Constructs an ForwardFID object from a YAML::Node.
  84. * @see ForwardFID::Serialize
  85. */
  86. static std::shared_ptr<ForwardFID> DeSerialize(const YAML::Node& node);
  87. // ==================== OPERATORS =======================
  88. // ==================== OPERATIONS =======================
  89. /**
  90. * Performs forward model calculation based on input parameters
  91. * @return Merlin class representing data
  92. */
  93. std::shared_ptr<DataFID> ForwardModel( std::shared_ptr<LayeredEarthMR> );
  94. // ==================== ACCESS =======================
  95. /**
  96. * Sets windows using the edges in a Eigen VectorXr
  97. * @param[in] Edges are the edges of the time gate windows
  98. */
  99. void SetWindowEdges( const VectorXr& Edges );
  100. /**
  101. * Sets the windows for calculation as a series of log spaced windows.
  102. * This method calculates the window edges, so the centres will be n-1
  103. * @param[in] first is the beginning of the vector
  104. * @param[in] last is the last element in the vector
  105. * @param[in] n is the number of elements
  106. */
  107. void SetLogSpacedWindows(const Real& first, const Real& last, const int& n);
  108. /**
  109. * @param[in] K0 is the initial amplitude imaging kernel
  110. */
  111. void SetKernel( std::shared_ptr< KernelV0 > K0 );
  112. /**
  113. * @param[in] floor is the standard deviation of the noise (zero mean),
  114. * defaults to zero
  115. */
  116. void SetNoiseFloor( const Real& floor );
  117. // ==================== INQUIRY =======================
  118. /**
  119. * Returns the name of the underlying class, similiar to Python's type
  120. * @return string of class name
  121. */
  122. virtual inline std::string GetName() const {
  123. return CName;
  124. }
  125. protected:
  126. // ==================== LIFECYCLE =======================
  127. /** Copy is disabled */
  128. ForwardFID( const ForwardFID& ) = delete;
  129. private:
  130. /**
  131. * Calculates the QT matrix
  132. * @param[in] T2StarBins are the T2* bins to use
  133. */
  134. void CalcQTMatrix( VectorXr T2StarBins );
  135. // ==================== DATA MEMBERS =========================
  136. /** ASCII string representation of the class name */
  137. static constexpr auto CName = "ForwardFID";
  138. /** Imaging kernel used in calculation */
  139. std::shared_ptr< KernelV0 > Kernel = nullptr;
  140. /** Noise floor for additive Gaussian noise */
  141. Real NoiseFloor = 0.;
  142. /** Time gate windows */
  143. VectorXr WindowEdges;
  144. /** Time gate centres */
  145. VectorXr WindowCentres;
  146. /** QT matrix */
  147. MatrixXcr QT;
  148. /** Include RDP effects? */
  149. bool RDP = false;
  150. }; // ----- end of class ForwardFID -----
  151. } // ----- end of namespace Lemma ----
  152. /* vim: set tabstop=4 expandtab: */
  153. /* vim: set filetype=cpp: */
  154. #endif // ----- #ifndef FORWARDFID_INC -----