oILAB
Loading...
Searching...
No Matches
BiCrystalBindings.h
Go to the documentation of this file.
1//
2// Created by Nikhil Chandra Admal on 7/9/25.
3//
4
5#ifndef OILAB_BICRYSTAL_BINDINGS_H
6#define OILAB_BICRYSTAL_BINDINGS_H
7
8#include <pybind11/pybind11.h>
9#include <LatticeModule.h>
10#include <pybind11/stl.h>
11namespace py = pybind11;
12
13namespace pyoilab {
14 template<int dim>
15 void bind_BiCrystal(py::module_ &m) {
17 using BiCrystal = gbLAB::BiCrystal<dim>;
18 using Lattice = gbLAB::Lattice<dim>;
19 using LatticeVector = gbLAB::LatticeVector<dim>;
20
21 using MatrixDimD = Eigen::Matrix<double, dim, dim>;
22 using VectorDimD = Eigen::Matrix<double, dim, 1>;
23
24 py::class_<BiCrystal> cls(m, ("BiCrystal" + std::to_string(dim) + "D").c_str());
25 cls.def(py::init<const Lattice&, const Lattice&, const bool&>(),
26 py::arg("A"), py::arg("B"), py::arg("useRLLL")=false);
27 cls.def("A",[](const BiCrystal& self) -> const Lattice& {
28 return self.A;
29 }, py::return_value_policy::reference_internal);
30 cls.def("B",[](const BiCrystal& self) -> const Lattice& {
31 return self.B;
32 }, py::return_value_policy::reference_internal);
33 cls.def_readonly("sigma",&BiCrystal::sigma);
34 cls.def_readonly("csl",&BiCrystal::csl);
35 cls.def_readonly("dscl",&BiCrystal::dscl);
36 cls.def("box", [](const BiCrystal& self,
37 std::vector<PyLatticeVector>& boxPyLatticeVectors,
38 const double& orthogonality,
39 const int& dsclFactor,
40 std::string filename,
41 bool orient){
42 std::vector<LatticeVector> boxLatticeVectors;
43 for(const auto& v : boxPyLatticeVectors)
44 boxLatticeVectors.push_back(v.lv);
45 auto latticeVectors= self.box(boxLatticeVectors,
46 orthogonality,
47 dsclFactor,
48 filename,
49 orient);
50
51 std::vector<PyLatticeVector> pyLatticeVectors;
52 for(const auto& v : latticeVectors)
53 pyLatticeVectors.push_back(PyLatticeVector(v));
54 return pyLatticeVectors;
55 }, py::arg("boxVectors"), py::arg("orthogonality"), py::arg("dsclFactor"), py::arg("filename")="", py::arg("orient")=false);
56 cls.def("getLatticeDirectionInC",[](const BiCrystal& self, const PyLatticeVector& v){
57 return PyLatticeDirection(self.getLatticeDirectionInC(v.lv));
58 });
59 }
60}
61#endif //OILAB_BICRYSTAL_BINDINGS_H
Lattice class.
Definition Lattice.h:34
LatticeVector class.
void bind_BiCrystal(py::module_ &m)