Skip to content

Commit

Permalink
temporary fix the python module by commenting broken pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
toxa81 committed Jul 11, 2023
1 parent 5dea7a3 commit 7385152
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions python_module/py_sirius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ PYBIND11_MODULE(py_sirius, m)
return py::array_t<double>({nrows}, {1 * sizeof(double)}, matrix_storage.at(sddk::memory_t::host),
obj);
})
.def("component", py::overload_cast<int>(&Field4D::component), py::return_value_policy::reference_internal)
.def("symmetrize", py::overload_cast<>(&Field4D::symmetrize));
.def("component", py::overload_cast<int>(&Field4D::component), py::return_value_policy::reference_internal);
//.def("symmetrize", py::overload_cast<>(&Field4D::symmetrize));

py::class_<Potential, Field4D>(m, "Potential")
.def(py::init<Simulation_context&>(), py::keep_alive<1, 2>(), "ctx"_a)
.def("generate", &Potential::generate, "density"_a, "use_sym"_a, "transform_to_rg"_a)
.def("symmetrize", py::overload_cast<>(&Potential::symmetrize))
//.def("symmetrize", py::overload_cast<>(&Potential::symmetrize))
.def("fft_transform", &Potential::fft_transform)
.def("save", &Potential::save)
.def("load", &Potential::load)
Expand All @@ -298,36 +298,36 @@ PYBIND11_MODULE(py_sirius, m)
.def("check_num_electrons", &Density::check_num_electrons)
.def("fft_transform", &Density::fft_transform)
.def("mix", &Density::mix)
.def("symmetrize", py::overload_cast<>(&Density::symmetrize))
.def("symmetrize_density_matrix", &Density::symmetrize_density_matrix)
//.def("symmetrize", py::overload_cast<>(&Density::symmetrize))
//.def("symmetrize_density_matrix", &Density::symmetrize_density_matrix)
.def("generate", py::overload_cast<K_point_set const&, bool, bool, bool>(&Density::generate<double>),
"kpointset"_a, "symmetrize"_a = false, "add_core"_a = true, "transform_to_rg"_a = false)
.def("generate_paw_loc_density", &Density::generate_paw_loc_density)
.def("compute_atomic_mag_mom", &Density::compute_atomic_mag_mom)
.def("save", &Density::save)
.def("check_num_electrons", &Density::check_num_electrons)
.def("get_magnetisation", &Density::get_magnetisation)
.def_property(
"density_matrix",
[](py::object& obj) -> py::array_t<complex_double> {
Density& density = obj.cast<Density&>();
auto& dm = density.density_matrix();
if (dm.at(sddk::memory_t::host) == nullptr) {
RTE_THROW("trying to access null pointer");
}
return py::array_t<complex_double, py::array::f_style>({dm.size(0), dm.size(1), dm.size(2), dm.size(3)},
dm.at(sddk::memory_t::host), obj);
},
[](py::object& obj) -> py::array_t<complex_double> {
Density& density = obj.cast<Density&>();
auto& dm = density.density_matrix();
if (dm.at(sddk::memory_t::host) == nullptr) {
RTE_THROW("trying to access null pointer");
}
return py::array_t<complex_double, py::array::f_style>({dm.size(0), dm.size(1), dm.size(2), dm.size(3)},
dm.at(sddk::memory_t::host), obj);
},
py::return_value_policy::reference_internal)
//.def_property(
// "density_matrix",
// [](py::object& obj) -> py::array_t<complex_double> {
// Density& density = obj.cast<Density&>();
// auto& dm = density.density_matrix();
// if (dm.at(sddk::memory_t::host) == nullptr) {
// RTE_THROW("trying to access null pointer");
// }
// return py::array_t<complex_double, py::array::f_style>({dm.size(0), dm.size(1), dm.size(2), dm.size(3)},
// dm.at(sddk::memory_t::host), obj);
// },
// [](py::object& obj) -> py::array_t<complex_double> {
// Density& density = obj.cast<Density&>();
// auto& dm = density.density_matrix();
// if (dm.at(sddk::memory_t::host) == nullptr) {
// RTE_THROW("trying to access null pointer");
// }
// return py::array_t<complex_double, py::array::f_style>({dm.size(0), dm.size(1), dm.size(2), dm.size(3)},
// dm.at(sddk::memory_t::host), obj);
// },
// py::return_value_policy::reference_internal)
.def("load", &Density::load);

py::class_<Band>(m, "Band")
Expand Down

0 comments on commit 7385152

Please sign in to comment.