Lemma is an Electromagnetics API
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.

EarthModel.h 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author Trevor Irons
  8. @date 03/23/2010
  9. @version $Id: earthmodel.h 198 2014-12-27 06:14:05Z tirons $
  10. **/
  11. #ifndef EARTHMODEL_INC
  12. #define EARTHMODEL_INC
  13. #include "LemmaObject.h"
  14. namespace Lemma {
  15. // ===================================================================
  16. // Class: EarthModel
  17. /// \ingroup LemmaGroup
  18. /// \brief abstract class for Earth models
  19. /// \details
  20. // ===================================================================
  21. class EarthModel : public LemmaObject {
  22. // ==================== FRIENDS ===========================
  23. friend std::ostream &operator<<(std::ostream &stream,
  24. const EarthModel &ob);
  25. public:
  26. // ==================== LIFECYCLE =======================
  27. /** YAML Serializing method
  28. */
  29. YAML::Node Serialize() const;
  30. //static LayeredEarth* DeSerialize(const YAML::Node& node);
  31. // ==================== OPERATORS =======================
  32. // ==================== OPERATIONS =======================
  33. // ==================== ACCESS =======================
  34. /** Sets the earth's magnetic field, in Tesla
  35. @param[in] bfield contains the x,y, and z components of
  36. the field. EarthModel::Inc, EarthModel::Dec, and
  37. EarthModel::BMag are computed:
  38. \f{eqnarray*}{ \mathrm{Inc} = &
  39. \cos^{-1}( \mathbf{B} \cdot \hat{\mathbf{z}} / B )
  40. \\ \mathrm{Dec} =& \cos^{-1}
  41. (\mathbf{B} \cdot \hat{\mathbf{x}} / B )
  42. \\ \mathrm{Mag} =& \Vert \mathbf{B} \Vert \f}
  43. @param[in] unit specifies the units of bfield.
  44. */
  45. void SetMagneticFieldComponents(const Vector3r &bfield,
  46. const MAGUNITS &unit);
  47. /// Sets the magnetic field using inclination, declination,
  48. /// and magnitude, units of Tesla
  49. /// @param[in] inc is the field's inclination
  50. /// @param[in] dec is the field's declination
  51. /// @param[in] Mag is the field's magnitude
  52. /// @param[in] unit specifies the the units used.
  53. /// The components are set according to
  54. /// \f{eqnarray*} { B_x =& B \cos(inc (\pi/180)) \cos(dec (\pi/180))
  55. /// \\ B_y =& B \cos(inc (\pi/180)) \sin(dec (\pi/180))
  56. /// \\ B_z =& B \sin(inc (\pi/180))
  57. /// \f}
  58. void SetMagneticFieldIncDecMag(const Real& inc, const Real&dec,
  59. const Real& Mag, const MAGUNITS &unit);
  60. // ==================== INQUIRY =======================
  61. /// Gets the magnetic field of the earth, in T
  62. Vector3r GetMagneticField( );
  63. /// Gets the magnetic field of the earth, in T
  64. Vector3r GetMagneticFieldInGauss( );
  65. /// Gets the magnetic field unit vector of the earth
  66. Vector3r GetMagneticFieldUnitVector( );
  67. /// Returns the magnitude of the magnetic field \f$ \Vert
  68. /// \mathbf{B}_0 \Vert \f$
  69. Real GetMagneticFieldMagnitude();
  70. /// Returns the magnitude of the magnetic field \f$ \Vert
  71. /// \mathbf{B}_0 \Vert \f$ in Gauss units
  72. Real GetMagneticFieldMagnitudeInGauss( );
  73. /** Returns the name of the underlying class, similiar to Python's type */
  74. virtual inline std::string GetName() const {
  75. return this->CName;
  76. }
  77. protected:
  78. // ==================== LIFECYCLE =======================
  79. /// Default protected constructor.
  80. EarthModel ( );
  81. /** Deserialize constructor */
  82. EarthModel (const YAML::Node& node);
  83. /// Default protected constructor.
  84. ~EarthModel ();
  85. // ==================== DATA MEMBERS =========================
  86. private:
  87. /** ASCII string representation of the class name */
  88. static constexpr auto CName = "EarthModel";
  89. /// Magnetic field, in units of nT
  90. Vector3r BField;
  91. /// Magnetic field unit vector \f$ \hat{\mathbf{B}_0} \f$
  92. Vector3r BFieldUnit;
  93. /// Inclination of the magnetic field
  94. Real BInc;
  95. /// Declination of the magnetic field
  96. Real BDec;
  97. /// Declination of the magnetic field
  98. Real BMag;
  99. }; // ----- end of class EarthModel -----
  100. //////////////////////////////////////////////////////////////
  101. // Error Classes
  102. /** If the Earth class is NULL valued, throw this
  103. */
  104. class NullEarth : public std::runtime_error {
  105. /** Thrown when an Earth pointer is NULL
  106. */
  107. public: NullEarth ();
  108. };
  109. } // ----- end of Lemma name -----
  110. #endif // ----- #ifndef EARTHMODEL_INC -----