Lemma is an Electromagnetics API
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

pyFDEM1D.cpp 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 22/04/19 14:06:32
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email Trevor.Irons@utah.edu
  14. * @copyright Copyright (c) 2019, University of Utah
  15. * @copyright Copyright (c) 2019, Lemma Software, LLC
  16. */
  17. #include <pybind11/pybind11.h>
  18. #include <pybind11/iostream.h>
  19. #include <pybind11/eigen.h>
  20. #include "FDEM1D"
  21. namespace py = pybind11;
  22. PYBIND11_MODULE(FDEM1D, m) {
  23. py::add_ostream_redirect(m, "ostream_redirect");
  24. m.doc() = "Python binding of Lemma::FDEM1D, additional details can be found at https://lemmasoftware.org";
  25. py::class_<Lemma::WireAntenna, std::shared_ptr<Lemma::WireAntenna> > WireAntenna(m, "WireAntenna");
  26. // lifecycle
  27. WireAntenna.def(py::init(&Lemma::WireAntenna::NewSP))
  28. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::WireAntenna::DeSerialize),
  29. "Construct object from yaml representation")
  30. // print
  31. .def("Serialize", &Lemma::WireAntenna::Print, "YAML representation of the class")
  32. .def("__repr__", &Lemma::WireAntenna::Print)
  33. // modifiers
  34. .def("SetNumberOfPoints", &Lemma::WireAntenna::SetNumberOfPoints, "Sets the number of points comprising the antenna")
  35. .def("SetPoint", py::overload_cast<const int&, const Lemma::Real&, const Lemma::Real&, const Lemma::Real&>(&Lemma::WireAntenna::SetPoint),
  36. "Sets a point in the antenna")
  37. .def("SetPoint", py::overload_cast<const int&, const Lemma::Vector3r&>(&Lemma::WireAntenna::SetPoint),
  38. "Sets a point in the antenna")
  39. .def("SetNumberOfTurns", &Lemma::WireAntenna::SetNumberOfTurns, "Sets the number of turns of the antenna")
  40. .def("SetNumberOfFrequencies", &Lemma::WireAntenna::SetNumberOfFrequencies,
  41. "Sets the number of frequencies of the transmitter")
  42. .def("SetFrequency", &Lemma::WireAntenna::SetFrequency, "Sets a single frequency of the transmitter")
  43. .def("SetCurrent", &Lemma::WireAntenna::SetCurrent, "Sets the current of the transmitter in amps")
  44. // accessors
  45. .def("GetCurrent", &Lemma::WireAntenna::GetCurrent, "Returns the current of the transmitter in amps")
  46. .def("GetPoints", &Lemma::WireAntenna::GetPoints, "Returns the points defining the transmitter")
  47. .def("GetNumberOfDipoles", &Lemma::WireAntenna::GetNumberOfDipoles,
  48. "Returns the number of dipoles defining the transmitter")
  49. .def("GetNumberOfFrequencies", &Lemma::WireAntenna::GetNumberOfFrequencies,
  50. "Returns the number of frequencies for the transmitter")
  51. .def("IsHorizontallyPlanar", &Lemma::WireAntenna::IsHorizontallyPlanar, "Returns true if the transmitter is flat")
  52. .def("GetName", &Lemma::WireAntenna::GetName, "Returns the class name of the object")
  53. // operations
  54. .def("ApproximateWithElectricDipoles", &Lemma::WireAntenna::ApproximateWithElectricDipoles,
  55. "Approximates loop with electric dipoles")
  56. ;
  57. py::class_<Lemma::PolygonalWireAntenna, std::shared_ptr<Lemma::PolygonalWireAntenna> > PolygonalWireAntenna(m,
  58. "PolygonalWireAntenna", WireAntenna);
  59. // lifecycle
  60. PolygonalWireAntenna.def(py::init(&Lemma::PolygonalWireAntenna::NewSP))
  61. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::PolygonalWireAntenna::DeSerialize),
  62. "Construct object from yaml representation")
  63. // print
  64. .def("__repr__", &Lemma::PolygonalWireAntenna::Print)
  65. .def("Serialize", &Lemma::PolygonalWireAntenna::Print, "YAML representation of the class")
  66. // accessors
  67. .def("GetName", &Lemma::PolygonalWireAntenna::GetName, "Returns the name of the class")
  68. // operations
  69. .def("ApproximateWithElectricDipoles", &Lemma::PolygonalWireAntenna::ApproximateWithElectricDipoles,
  70. "Approximates loop with series of electric dipoles around loop")
  71. ;
  72. py::class_<Lemma::DipoleSource, std::shared_ptr<Lemma::DipoleSource> > DipoleSource(m, "DipoleSource");
  73. // lifecycle
  74. DipoleSource.def(py::init(&Lemma::DipoleSource::NewSP))
  75. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::DipoleSource::DeSerialize),
  76. "Construct object from yaml representation")
  77. // print
  78. .def("Serialize", &Lemma::DipoleSource::Print, "YAML representation of the class")
  79. .def("__repr__", &Lemma::DipoleSource::Print)
  80. // accessors
  81. .def("GetName", &Lemma::DipoleSource::GetName, "Returns the name of the class")
  82. .def("GetNumberOfFrequencies", &Lemma::DipoleSource::GetNumberOfFrequencies,
  83. "Returns the number of frequencies")
  84. .def("GetFrequencies", &Lemma::DipoleSource::GetFrequencies, "Returns an array of frequencies")
  85. .def("GetFrequency", &Lemma::DipoleSource::GetFrequency, "Returns the frequency of the argument index")
  86. .def("GetAngularFrequency", &Lemma::DipoleSource::GetAngularFrequency,
  87. "Returns the angular frequency of the argument index")
  88. .def("GetPhase", &Lemma::DipoleSource::GetPhase, "Returns the phase of the dipole")
  89. .def("GetMoment", &Lemma::DipoleSource::GetMoment, "Returns the moment of the dipole")
  90. .def("GetLocation", py::overload_cast< >(&Lemma::DipoleSource::GetLocation), "Returns the location of the dipole")
  91. .def("GetPolarisation", &Lemma::DipoleSource::GetPolarisation, "Returns the polarisation of the dipole")
  92. // modifiers
  93. .def("SetLocation", py::overload_cast<const Lemma::Vector3r&> (&Lemma::DipoleSource::SetLocation),
  94. "Sets the location of the dipole")
  95. .def("SetPolarisation", py::overload_cast<const Lemma::Vector3r&> (&Lemma::DipoleSource::SetPolarisation),
  96. "Sets the polarisation of the dipole")
  97. .def("SetType", &Lemma::DipoleSource::SetType, "Sets the type")
  98. .def("SetMoment", &Lemma::DipoleSource::SetMoment, "Sets the moment of the dipole")
  99. .def("SetPhase", &Lemma::DipoleSource::SetPhase, "Sets the phase of the dipole")
  100. .def("SetNumberOfFrequencies", &Lemma::DipoleSource::SetNumberOfFrequencies,
  101. "Sets the number of frequencies to calculate for the dipole")
  102. .def("SetFrequency", &Lemma::DipoleSource::SetFrequency,
  103. "Sets a single frequency, first argument is index, second argument is frequency")
  104. .def("SetFrequencies", &Lemma::DipoleSource::SetFrequencies,
  105. "Sets all frequencies, argument is numpy array of frequencies")
  106. ;
  107. py::class_<Lemma::LayeredEarthEM, std::shared_ptr<Lemma::LayeredEarthEM> > LayeredEarthEM(m, "LayeredEarthEM");
  108. // lifecycle
  109. LayeredEarthEM.def(py::init(&Lemma::LayeredEarthEM::NewSP))
  110. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::LayeredEarthEM::DeSerialize),
  111. "Construct object from yaml representation")
  112. // print
  113. .def("Serialize", &Lemma::LayeredEarthEM::Print, "YAML representation of the class")
  114. .def("__repr__", &Lemma::LayeredEarthEM::Print)
  115. // accessors
  116. .def("GetName", &Lemma::LayeredEarthEM::GetName, "Returns the name of the class")
  117. .def("GetLayerConductivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerConductivity),
  118. "Returns the conductivity of all layers")
  119. .def("GetLayerConductivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerConductivity),
  120. "Returns the conductivity of the specified layer")
  121. .def("GetLayerSusceptibility", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerSusceptibility),
  122. "Returns the susceptibility of all layers")
  123. .def("GetLayerSusceptibility1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerSusceptibility),
  124. "Returns the susceptibilty of the specified layer")
  125. .def("GetLayerLowFreqSusceptibility", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerLowFreqSusceptibility),
  126. "Returns the low frequqncy permitivity of all layers")
  127. .def("GetLayerLowFreqSusceptibility1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerLowFreqSusceptibility),
  128. "Returns the low frequency permitivity of the specified layer")
  129. .def("GetLayerHighFreqSusceptibility", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerHighFreqSusceptibility),
  130. "Returns the low frequency permitivity of all layers")
  131. .def("GetLayerHighFreqSusceptibility1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerHighFreqSusceptibility),
  132. "Returns the low frequency permitivity of the specified layer")
  133. .def("GetLayerTauSusceptibility", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerTauSusceptibility),
  134. "Returns the tau permitivity of all layers")
  135. .def("GetLayerTauSusceptibility1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerTauSusceptibility),
  136. "Returns the tau permitivity of the specified layer")
  137. .def("GetLayerBreathSusceptibility", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerBreathSusceptibility),
  138. "Returns the breth permitivity of all layers")
  139. .def("GetLayerBreathSusceptibility1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerBreathSusceptibility),
  140. "Returns the breath permitivity of the specified layer")
  141. .def("GetLayerPermitivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerPermitivity),
  142. "Returns the permitivity of all layers")
  143. .def("GetLayerPermitivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerPermitivity),
  144. "Returns the permitivity of the specified layer")
  145. .def("GetLayerLowFreqPermitivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerLowFreqPermitivity),
  146. "Returns the low frequqncy permitivity of all layers")
  147. .def("GetLayerLowFreqPermitivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerLowFreqPermitivity),
  148. "Returns the low frequency permitivity of the specified layer")
  149. .def("GetLayerHighFreqPermitivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerHighFreqPermitivity),
  150. "Returns the low frequency permitivity of all layers")
  151. .def("GetLayerHighFreqPermitivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerHighFreqPermitivity),
  152. "Returns the low frequency permitivity of the specified layer")
  153. .def("GetLayerTauPermitivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerTauPermitivity),
  154. "Returns the tau permitivity of all layers")
  155. .def("GetLayerTauPermitivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerTauPermitivity),
  156. "Returns the tau permitivity of the specified layer")
  157. .def("GetLayerBreathPermitivity", py::overload_cast<>(&Lemma::LayeredEarthEM::GetLayerBreathPermitivity),
  158. "Returns the breth permitivity of all layers")
  159. .def("GetLayerBreathPermitivity1", py::overload_cast<const int&>(&Lemma::LayeredEarthEM::GetLayerBreathPermitivity),
  160. "Returns the breath permitivity of the specified layer")
  161. // modifiers
  162. .def("SetNumberOfLayers", &Lemma::LayeredEarthEM::SetNumberOfLayers, "Sets the number of layers in the model")
  163. .def("SetLayerConductivity", py::overload_cast< const Lemma::VectorXcr& >(&Lemma::LayeredEarthEM::SetLayerConductivity),
  164. "Sets the conductivity of the layers, the input is a complex array of conductivity")
  165. .def("SetLayerConductivity1", py::overload_cast< const int&, const Lemma::Complex& >(&Lemma::LayeredEarthEM::SetLayerConductivity),
  166. "Sets the conductivity of a single layer, the first input is the layer index, and the secondinput is a complex conductivity")
  167. .def("SetLayerThickness", &Lemma::LayeredEarthEM::SetLayerThickness,
  168. "Sets the thickness of layers, excluding the air and bottom which are infinite")
  169. .def("SetLayerHighFreqSusceptibility", &Lemma::LayeredEarthEM::SetLayerHighFreqSusceptibility,
  170. "Sets the high frequency susceptibility for Cole-COle model")
  171. .def("SetLayerLowFreqSusceptibility", &Lemma::LayeredEarthEM::SetLayerLowFreqSusceptibility,
  172. "Sets the low frequency susceptibility for Cole-COle model")
  173. .def("SetLayerBreathSusceptibility", &Lemma::LayeredEarthEM::SetLayerBreathSusceptibility,
  174. "Sets thesusceptibility breath for Cole-COle model")
  175. .def("SetLayerHighFreqPermitivity", &Lemma::LayeredEarthEM::SetLayerHighFreqPermitivity,
  176. "Sets the high frequency permitivity for Cole-COle model")
  177. .def("SetLayerLowFreqPermitivity", &Lemma::LayeredEarthEM::SetLayerLowFreqPermitivity,
  178. "Sets the low frequency permitivity for Cole-COle model")
  179. .def("SetLayerBreathPermitivity", &Lemma::LayeredEarthEM::SetLayerBreathPermitivity,
  180. "Sets the permitivity breath for Cole-COle model")
  181. // methods
  182. .def("EvaluateColeColeModel", &Lemma::LayeredEarthEM::EvaluateColeColeModel,
  183. "Calculates complex resistivity based on cole-cole parameters")
  184. ;
  185. }