Lemma is an Electromagnetics API
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

pyFDEM1D.cpp 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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, "Returns the number of dipoles defining the transmitter")
  48. .def("GetNumberOfFrequencies", &Lemma::WireAntenna::GetNumberOfFrequencies,
  49. "Returns the number of frequencies for the transmitter")
  50. .def("IsHorizontallyPlanar", &Lemma::WireAntenna::IsHorizontallyPlanar, "Returns true if the transmitter is flat")
  51. .def("GetName", &Lemma::WireAntenna::GetName, "Returns the class name of the object")
  52. // operations
  53. .def("ApproximateWithElectricDipoles", &Lemma::WireAntenna::ApproximateWithElectricDipoles,
  54. "Approximates loop with electric dipoles")
  55. ;
  56. py::class_<Lemma::PolygonalWireAntenna, std::shared_ptr<Lemma::PolygonalWireAntenna> > PolygonalWireAntenna(m,
  57. "PolygonalWireAntenna", WireAntenna);
  58. // lifecycle
  59. PolygonalWireAntenna.def(py::init(&Lemma::PolygonalWireAntenna::NewSP))
  60. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::PolygonalWireAntenna::DeSerialize),
  61. "Construct object from yaml representation")
  62. // print
  63. .def("__repr__", &Lemma::PolygonalWireAntenna::Print)
  64. .def("Serialize", &Lemma::PolygonalWireAntenna::Print, "YAML representation of the class")
  65. // accessors
  66. .def("GetName", &Lemma::PolygonalWireAntenna::GetName, "Returns the name of the class")
  67. // operations
  68. .def("ApproximateWithElectricDipoles", &Lemma::PolygonalWireAntenna::ApproximateWithElectricDipoles,
  69. "Approximates loop with series of electric dipoles around loop")
  70. ;
  71. py::class_<Lemma::DipoleSource, std::shared_ptr<Lemma::DipoleSource> > DipoleSource(m, "DipoleSource");
  72. // lifecycle
  73. DipoleSource.def(py::init(&Lemma::DipoleSource::NewSP))
  74. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::DipoleSource::DeSerialize),
  75. "Construct object from yaml representation")
  76. // print
  77. .def("Serialize", &Lemma::DipoleSource::Print, "YAML representation of the class")
  78. .def("__repr__", &Lemma::DipoleSource::Print)
  79. // accessors
  80. .def("GetName", &Lemma::DipoleSource::GetName, "Returns the name of the class")
  81. .def("GetNumberOfFrequencies", &Lemma::DipoleSource::GetNumberOfFrequencies,
  82. "Returns the number of frequencies")
  83. .def("GetFrequencies", &Lemma::DipoleSource::GetFrequencies, "Returns an array of frequencies")
  84. .def("GetFrequency", &Lemma::DipoleSource::GetFrequency, "Returns the frequency of the argument index")
  85. .def("GetAngularFrequency", &Lemma::DipoleSource::GetAngularFrequency,
  86. "Returns the angular frequency of the argument index")
  87. .def("GetPhase", &Lemma::DipoleSource::GetPhase, "Returns the phase of the dipole")
  88. .def("GetMoment", &Lemma::DipoleSource::GetMoment, "Returns the moment of the dipole")
  89. .def("GetLocation", py::overload_cast< >(&Lemma::DipoleSource::GetLocation), "Returns the location of the dipole")
  90. .def("GetPolarisation", &Lemma::DipoleSource::GetPolarisation, "Returns the polarisation of the dipole")
  91. // modifiers
  92. .def("SetLocation", py::overload_cast<const Lemma::Vector3r&> (&Lemma::DipoleSource::SetLocation),
  93. "Sets the location of the dipole")
  94. .def("SetPolarisation", py::overload_cast<const Lemma::Vector3r&> (&Lemma::DipoleSource::SetPolarisation),
  95. "Sets the polarisation of the dipole")
  96. .def("SetType", &Lemma::DipoleSource::SetType, "Sets the type")
  97. .def("SetMoment", &Lemma::DipoleSource::SetMoment, "Sets the moment of the dipole")
  98. .def("SetPhase", &Lemma::DipoleSource::SetPhase, "Sets the phase of the dipole")
  99. .def("SetNumberOfFrequencies", &Lemma::DipoleSource::SetNumberOfFrequencies,
  100. "Sets the number of frequencies to calculate for the dipole")
  101. .def("SetFrequency", &Lemma::DipoleSource::SetFrequency,
  102. "Sets a single frequency, first argument is index, second argument is frequency")
  103. .def("SetFrequencies", &Lemma::DipoleSource::SetFrequencies,
  104. "Sets all frequencies, argument is numpy array of frequencies")
  105. ;
  106. py::class_<Lemma::LayeredEarthEM, std::shared_ptr<Lemma::LayeredEarthEM> > LayeredEarthEM(m, "LayeredEarthEM");
  107. // lifecycle
  108. LayeredEarthEM.def(py::init(&Lemma::LayeredEarthEM::NewSP))
  109. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::LayeredEarthEM::DeSerialize),
  110. "Construct object from yaml representation")
  111. // print
  112. .def("Serialize", &Lemma::LayeredEarthEM::Print, "YAML representation of the class")
  113. .def("__repr__", &Lemma::LayeredEarthEM::Print)
  114. // accessors
  115. .def("GetName", &Lemma::LayeredEarthEM::GetName, "Returns the name of the class")
  116. // modifiers
  117. .def("SetNumberOfLayers", &Lemma::LayeredEarthEM::SetNumberOfLayers, "Sets the number of layers in the model")
  118. .def("SetLayerConductivity", py::overload_cast< const Lemma::VectorXcr& >(&Lemma::LayeredEarthEM::SetLayerConductivity),
  119. "Sets the conductivity of the layers, the input is a complex array of conductivity")
  120. .def("SetLayerConductivity1", py::overload_cast< const int&, const Lemma::Complex& >(&Lemma::LayeredEarthEM::SetLayerConductivity),
  121. "Sets the conductivity of a single layer, the first input is the layer index, and the secondinput is a complex conductivity")
  122. .def("SetLayerThickness", &Lemma::LayeredEarthEM::SetLayerThickness,
  123. "Sets the thickness of layers, excluding the air and bottom which are infinite")
  124. // methods
  125. .def("EvaluateColeColeModel", &Lemma::LayeredEarthEM::EvaluateColeColeModel,
  126. "Calculates complex resistivity based on cole-cole parameters")
  127. ;
  128. }