|
| 1 | +/********************************************************************************* |
| 2 | +* Copyright (C) 2021 Mohammad Shakiba and Alexey V. Akimov |
| 3 | +* |
| 4 | +* This file is distributed under the terms of the GNU General Public License |
| 5 | +* as published by the Free Software Foundation, either version 3 of |
| 6 | +* the License, or (at your option) any later version. |
| 7 | +* See the file LICENSE in the root directory of this distribution |
| 8 | +* or <http://www.gnu.org/licenses/>. |
| 9 | +* |
| 10 | +*********************************************************************************/ |
| 11 | +/** |
| 12 | + \file liblibint2_wrappers.cpp |
| 13 | + \brief The file implements Python export function |
| 14 | + |
| 15 | +*/ |
| 16 | + |
| 17 | +#define BOOST_PYTHON_MAX_ARITY 30 |
| 18 | +#include <boost/python.hpp> |
| 19 | +#include <boost/python/suite/indexing/vector_indexing_suite.hpp> |
| 20 | + |
| 21 | +#include "libint2_wrappers.h" |
| 22 | + |
| 23 | + |
| 24 | +/// liblibra namespace |
| 25 | +namespace liblibra{ |
| 26 | + |
| 27 | +using namespace boost::python; |
| 28 | +using namespace liblinalg; |
| 29 | +using namespace libspecialfunctions; |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +/// libqobjects namespace |
| 34 | +namespace liblibint2_wrappers{ |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +void export_libint2_wrappers_objects(){ |
| 40 | +/** |
| 41 | + \brief Exporter of liblibint2_wrappers classes and functions |
| 42 | +
|
| 43 | +*/ |
| 44 | +/* |
| 45 | + double (*expt_electron_repulsion_integral_AO_v2) |
| 46 | + ( AO& AOa, AO& AOb, AO& AOc, AO& AOd, int is_normalize ) = &electron_repulsion_integral; |
| 47 | + boost::python::list (*expt_electron_repulsion_integral_AO_v3) |
| 48 | + ( AO& AOa, AO& AOb, AO& AOc, AO& AOd, int is_normalize, int is_derivs) = &electron_repulsion_integral; |
| 49 | +
|
| 50 | + // ============ Now export functions ============= |
| 51 | + // Overlaps |
| 52 | + def("gaussian_overlap", expt_gaussian_overlap_G_v1); |
| 53 | +
|
| 54 | +
|
| 55 | + void (PrimitiveG::*expt_set_position_PrimitiveG_v1)(VECTOR) = &PrimitiveG::set_position; |
| 56 | + void (AO::*expt_set_position_AO_v1)(VECTOR) = &AO::set_position; |
| 57 | +
|
| 58 | +
|
| 59 | +*/ |
| 60 | + |
| 61 | + size_t (*expt_nbasis_v1)(const std::vector<libint2::Shell>& shells) = &nbasis; |
| 62 | + def("nbasis", expt_nbasis_v1); |
| 63 | + |
| 64 | + |
| 65 | + std::vector<libint2::Shell> (*expt_initialize_shell_v1)( |
| 66 | + int l_val, bool is_spherical , const std::vector<double>& exponents, |
| 67 | + const std::vector<double>& coeff, VECTOR& coords) = &initialize_shell; |
| 68 | + |
| 69 | + def("initialize_shell", expt_initialize_shell_v1); |
| 70 | + |
| 71 | + |
| 72 | + void (*expt_add_to_shell_v1)(std::vector<libint2::Shell>& shells, |
| 73 | + int l_val, bool is_spherical , const std::vector<double>& exponents, |
| 74 | + const std::vector<double>& coeff, VECTOR& coords) = &add_to_shell; |
| 75 | + |
| 76 | + def("add_to_shell", expt_add_to_shell_v1); |
| 77 | + |
| 78 | + |
| 79 | + void (*expt_print_shells_v1)(std::vector<libint2::Shell>& shells) = &print_shells; |
| 80 | + def("print_shell", expt_print_shells_v1); |
| 81 | + |
| 82 | + |
| 83 | + class_<libint2::Shell>("libint2_Shell",init<>()) |
| 84 | + .def(init<const libint2::Shell&>()) |
| 85 | + .def("__copy__", &generic__copy__<libint2::Shell>) |
| 86 | + .def("__deepcopy__", &generic__deepcopy__<libint2::Shell>) |
| 87 | + .def_readwrite("alpha",&libint2::Shell::alpha) |
| 88 | + .def_readwrite("contr",&libint2::Shell::contr) |
| 89 | + //.def("init",&PrimitiveG::init) |
| 90 | + ; |
| 91 | + |
| 92 | + class_< libint2_ShellList >("libint2_ShellList") |
| 93 | + .def(vector_indexing_suite< libint2_ShellList >()) |
| 94 | + ; |
| 95 | + |
| 96 | + class_<Matrix>("Matrix",init<>()) |
| 97 | + .def("__copy__", &generic__copy__<Matrix>) |
| 98 | + .def("__deepcopy__", &generic__deepcopy__<Matrix>) |
| 99 | + ; |
| 100 | + |
| 101 | + MATRIX (*expt_compute_overlaps_v1) |
| 102 | + (const std::vector<libint2::Shell>& shells_1, |
| 103 | + const std::vector<libint2::Shell>& shells_2, int number_of_threads) = &compute_overlaps; |
| 104 | + |
| 105 | + def("compute_overlaps", expt_compute_overlaps_v1); |
| 106 | + |
| 107 | + MATRIX (*expt_compute_overlaps_serial_v1) |
| 108 | + (const std::vector<libint2::Shell>& shells_1, const std::vector<libint2::Shell>& shells_2) = &compute_overlaps_serial; |
| 109 | + def("compute_overlaps_serial", expt_compute_overlaps_serial_v1); |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | +/** |
| 114 | + class_<libint2::Operator>("libint2_Operator",init<>()) |
| 115 | + .def(init<const libint2::Operator&>()) |
| 116 | + .def("__copy__", &generic__copy__<libint2::Operator>) |
| 117 | + .def("__deepcopy__", &generic__deepcopy__<libint2::Operator>) |
| 118 | + //.def_readwrite("x_exp",&PrimitiveG::x_exp) |
| 119 | + .def("nbasis",&libint2::Operator::nbasis) |
| 120 | + ; |
| 121 | +
|
| 122 | +*/ |
| 123 | +/* |
| 124 | + py::class_<libint2::Operator>(m, "Operator"); |
| 125 | + m.def("nbasis", &nbasis, "A function for number of basis sets", py::return_value_policy::reference_internal); |
| 126 | + m.def("compute_1body_ints_parallel", &compute_1body_ints_parallel, "A function for computing AO overlaps parallel", py::return_value_policy::reference_internal); |
| 127 | + m.def("compute_1body_ints", &compute_1body_ints, "A function for computing integrals serial", py::return_value_policy::reference_internal); |
| 128 | + m.def("initialize_shell", &initialize_shell, "A function for creating shells", py::return_value_policy::reference_internal); |
| 129 | + m.def("initialize_atom", &initialize_atom, "A function for initializing Atom", py::return_value_policy::reference_internal); |
| 130 | + m.def("add_to_shell", &add_to_shell, "A function to add the exponents, contraction coefficients, and Atom structure to a predefined shell", py::return_value_policy::reference_internal); |
| 131 | + m.def("print_shell", &print_shell, "A function for printing a shell", py::return_value_policy::reference_internal); |
| 132 | + m.def("compute_overlaps", &compute_overlaps, "A function that computes overlaps between pairs of shells", py::return_value_policy::reference_internal); |
| 133 | +
|
| 134 | +*/ |
| 135 | + |
| 136 | +} |
| 137 | + |
| 138 | + |
| 139 | +#ifdef CYGWIN |
| 140 | +BOOST_PYTHON_MODULE(cyglibint2_wrappers){ |
| 141 | +#else |
| 142 | +BOOST_PYTHON_MODULE(liblibint2_wrappers){ |
| 143 | +#endif |
| 144 | + |
| 145 | + // Register converters: |
| 146 | + // See here: https://misspent.wordpress.com/2009/09/27/how-to-write-boost-python-converters/ |
| 147 | + //to_python_converter<std::vector<DATA>, VecToList<DATA> >(); |
| 148 | + |
| 149 | + export_libint2_wrappers_objects(); |
| 150 | + |
| 151 | +} |
| 152 | + |
| 153 | + |
| 154 | +}// namespace libqobject |
| 155 | +}// namespace liblibra |
| 156 | + |
0 commit comments