Lemma is an Electromagnetics API
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

pyFDEM1D.cpp 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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), "Construct object from yaml representation")
  29. // print
  30. .def("Serialize", &Lemma::WireAntenna::Print, "YAML representation of the class")
  31. .def("__repr__", &Lemma::WireAntenna::Print)
  32. // modifiers
  33. .def("SetNumberOfPoints", &Lemma::WireAntenna::SetNumberOfPoints, "Sets the number of points comprising the antenna")
  34. .def("SetPoint", py::overload_cast<const int&, const Lemma::Real&, const Lemma::Real&, const Lemma::Real&>(&Lemma::WireAntenna::SetPoint), "Sets a point in the antenna")
  35. .def("SetPoint", py::overload_cast<const int&, const Lemma::Vector3r&>(&Lemma::WireAntenna::SetPoint),
  36. "Sets a point in the antenna")
  37. .def("SetNumberOfTurns", &Lemma::WireAntenna::SetNumberOfTurns, "Sets the number of turns of the antenna")
  38. .def("SetNumberOfFrequencies", &Lemma::WireAntenna::SetNumberOfFrequencies,
  39. "Sets the number of frequencies of the transmitter")
  40. .def("SetFrequency", &Lemma::WireAntenna::SetFrequency, "Sets a single frequency of the transmitter")
  41. .def("SetCurrent", &Lemma::WireAntenna::SetCurrent, "Sets the current of the transmitter in amps")
  42. // accessors
  43. .def("GetCurrent", &Lemma::WireAntenna::GetCurrent, "Returns the current of the transmitter in amps")
  44. .def("GetPoints", &Lemma::WireAntenna::GetPoints, "Returns the points defining the transmitter")
  45. .def("GetNumberOfDipoles", &Lemma::WireAntenna::GetNumberOfDipoles, "Returns the number of dipoles defining the transmitter")
  46. .def("GetNumberOfFrequencies", &Lemma::WireAntenna::GetNumberOfFrequencies,
  47. "Returns the number of frequencies for the transmitter")
  48. .def("IsHorizontallyPlanar", &Lemma::WireAntenna::IsHorizontallyPlanar, "Returns true if the transmitter is flat")
  49. .def("GetName", &Lemma::WireAntenna::GetName, "Returns the class name of the object")
  50. // operations
  51. .def("ApproximateWithElectricDipoles", &Lemma::WireAntenna::ApproximateWithElectricDipoles,
  52. "Approximates loop with electric dipoles")
  53. ;
  54. py::class_<Lemma::PolygonalWireAntenna, std::shared_ptr<Lemma::PolygonalWireAntenna> > PolygonalWireAntenna(m,
  55. "PolygonalWireAntenna", WireAntenna);
  56. // lifecycle
  57. PolygonalWireAntenna.def(py::init(&Lemma::PolygonalWireAntenna::NewSP))
  58. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::PolygonalWireAntenna::DeSerialize),
  59. "Construct object from yaml representation")
  60. // print
  61. .def("__repr__", &Lemma::PolygonalWireAntenna::Print)
  62. .def("Serialize", &Lemma::PolygonalWireAntenna::Print, "YAML representation of the class")
  63. // accessors
  64. .def("GetName", &Lemma::PolygonalWireAntenna::GetName, "Returns the name of the class")
  65. // operations
  66. .def("ApproximateWithElectricDipoles", &Lemma::PolygonalWireAntenna::ApproximateWithElectricDipoles,
  67. "Approximates loop with series of electric dipoles around loop")
  68. ;
  69. py::class_<Lemma::DipoleSource, std::shared_ptr<Lemma::DipoleSource> > DipoleSource(m, "DipoleSource");
  70. // lifecycle
  71. DipoleSource.def(py::init(&Lemma::DipoleSource::NewSP))
  72. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::DipoleSource::DeSerialize),
  73. "Construct object from yaml representation")
  74. // print
  75. .def("Serialize", &Lemma::DipoleSource::Print, "YAML representation of the class")
  76. .def("__repr__", &Lemma::DipoleSource::Print)
  77. // accessors
  78. .def("GetName", &Lemma::DipoleSource::GetName, "Returns the name of the class")
  79. .def("GetNumberOfFrequencies", &Lemma::DipoleSource::GetNumberOfFrequencies,
  80. "Returns the number of frequencies")
  81. .def("GetFrequencies", &Lemma::DipoleSource::GetFrequencies, "Returns an array of frequencies")
  82. .def("GetFrequency", &Lemma::DipoleSource::GetFrequency, "Returns the frequency of the argument index")
  83. .def("GetAngularFrequency", &Lemma::DipoleSource::GetAngularFrequency,
  84. "Returns the angular frequency of the argument index")
  85. .def("GetPhase", &Lemma::DipoleSource::GetPhase, "Returns the phase of the dipole")
  86. .def("GetMoment", &Lemma::DipoleSource::GetMoment, "Returns the moment of the dipole")
  87. .def("GetLocation", py::overload_cast< >(&Lemma::DipoleSource::GetLocation), "Returns the location of the dipole")
  88. .def("GetPolarisation", &Lemma::DipoleSource::GetPolarisation, "Returns the polarisation of the dipole")
  89. // modifiers
  90. .def("SetLocation", py::overload_cast<const Lemma::Vector3r&> (&Lemma::DipoleSource::SetLocation),
  91. "Sets the location of the dipole")
  92. .def("SetPolarisation", py::overload_cast<const Lemma::Vector3r&> (&Lemma::DipoleSource::SetPolarisation),
  93. "Sets the polarisation of the dipole")
  94. .def("SetType", &Lemma::DipoleSource::SetType, "Sets the type")
  95. .def("SetMoment", &Lemma::DipoleSource::SetMoment, "Sets the moment of the dipole")
  96. .def("SetPhase", &Lemma::DipoleSource::SetPhase, "Sets the phase of the dipole")
  97. .def("SetNumberOfFrequencies", &Lemma::DipoleSource::SetNumberOfFrequencies,
  98. "Sets the number of frequencies to calculate for the dipole")
  99. .def("SetFrequency", &Lemma::DipoleSource::SetFrequency,
  100. "Sets a single frequency, first argument is index, second argument is frequency")
  101. .def("SetFrequencies", &Lemma::DipoleSource::SetFrequencies,
  102. "Sets all frequencies, argument is numpy array of frequencies")
  103. ;
  104. }
  105. /*
  106. BOOST_PYTHON_MODULE(pyLemmaCore)
  107. {
  108. Py_Initialize();
  109. np::initialize();
  110. bp::class_<Lemma::PolygonalWireAntenna, boost::noncopyable> ("PolygonalWireAntenna", boost::python::no_init)
  111. // print
  112. .def(boost::python::self_ns::str(bp::self))
  113. // Lifecycle
  114. .def("__init__", boost::python::make_constructor(&Lemma::PolygonalWireAntenna::NewSP))
  115. //.def("Serialize", &Lemma::PolygonalWireAntenna::Serialize)
  116. //.def("DeSerialize", &Lemma::PolygonalWireAntenna::DeSerialize)
  117. // Accessors
  118. ;
  119. }
  120. */