Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time evolution binding #113

Merged
merged 15 commits into from
Nov 24, 2023
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,6 @@ GTAGS
# Validated input files produced during testing
validated*.json
.ccls-cache


_skbuild/
2 changes: 1 addition & 1 deletion cmake/custom/fetch_mrcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else()
GIT_REPOSITORY
https://github.com/MRChemSoft/mrcpp.git
GIT_TAG
5320eb433dcea82b177f5181ce12ab89f0b04a92
master
edinvay marked this conversation as resolved.
Show resolved Hide resolved
)

set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER})
Expand Down
36 changes: 36 additions & 0 deletions src/vampyr/core/filter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* \date Oct 30, 2023
* \author Evgueni Dinvay <evgueni.dinvay@uit.no> \n
* Hylleraas Centre for Quantum Molecular Sciences \n
* UiT - The Arctic University of Norway
*/

#include <pybind11/operators.h>
#include <pybind11/pybind11.h>

#include <MRCPP/core/MWFilter.h>

namespace vampyr {

void filter(pybind11::module &m)
{
using namespace mrcpp;
namespace py = pybind11;
using namespace pybind11::literals;


py::class_<MWFilter>(m, "Filter")
.def(py::init<int, int>(),
"order"_a,
"type"_a)
.def(
"getFilter",
&MWFilter::getFilter, py::return_value_policy::reference_internal)
.def(
"getReconstructionSubFilter",
&MWFilter::getReconstructionSubFilter,
py::return_value_policy::reference_internal,
py::arg("i"));
}

} // namespace vampyr
2 changes: 2 additions & 0 deletions src/vampyr/export_vampyr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <MRCPP/version.h>

#include "core/bases.h"
#include "core/filter.h"
#include "functions/functions.h"
#include "operators/convolutions.h"
#include "operators/derivatives.h"
Expand Down Expand Up @@ -94,5 +95,6 @@ PYBIND11_MODULE(_vampyr, m) {
bind_vampyr<2>(m);
bind_vampyr<3>(m);
bases(m);
filter(m);
}
} // namespace vampyr
28 changes: 28 additions & 0 deletions src/vampyr/operators/convolutions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
#include <MRCPP/operators/HelmholtzOperator.h>
#include <MRCPP/operators/IdentityConvolution.h>
#include <MRCPP/operators/PoissonOperator.h>
#include <MRCPP/operators/TimeEvolutionOperator.h>
#include <MRCPP/treebuilders/apply.h>

namespace vampyr {

void cartesian_convolution(pybind11::module &);
void helmholtz_operator(pybind11::module &);
void poisson_operator(pybind11::module &);
void time_evolution_operator(pybind11::module &m);

template <int D> void convolutions(pybind11::module &m) {
namespace py = pybind11;
Expand Down Expand Up @@ -50,6 +52,7 @@ template <int D> void convolutions(pybind11::module &m) {
if constexpr (D == 3) cartesian_convolution(m);
if constexpr (D == 3) helmholtz_operator(m);
if constexpr (D == 3) poisson_operator(m);
if constexpr (D == 1) time_evolution_operator(m);
}

void cartesian_convolution(pybind11::module &m) {
Expand Down Expand Up @@ -117,4 +120,29 @@ void helmholtz_operator(pybind11::module &m) {
"inp"_a);
}


void time_evolution_operator(pybind11::module &m)
{
namespace py = pybind11;
using namespace mrcpp;
using namespace pybind11::literals;

py::class_<TimeEvolutionOperator<1>, ConvolutionOperator<1>>(m, "TimeEvolutionOperator")
.def(py::init<const MultiResolutionAnalysis<1> &, double, double, int, bool, int>(),
"mra"_a,
"prec"_a,
"time"_a,
"finest_scale"_a,
"imaginary"_a,
"max_Jpower"_a = 20)
.def(
"__call__",
[](TimeEvolutionOperator<1> &T, FunctionTree<1> *inp) {
auto out = std::make_unique<FunctionTree<1>>(inp->getMRA());
apply<1>(T.getBuildPrec(), *out, T, *inp);
return out;
},
"inp"_a);
}

} // namespace vampyr
14 changes: 14 additions & 0 deletions src/vampyr/treebuilders/applys.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <pybind11/pybind11.h>

#include <MRCPP/treebuilders/apply.h>
//#include <MRCPP/treebuilders/complex_apply.h>

namespace vampyr {
template <int D> void applys(pybind11::module &m) {
Expand Down Expand Up @@ -61,6 +62,19 @@ template <int D> void advanced_applys(pybind11::module &m) {
"oper"_a,
"inp"_a,
"dir"_a = -1);
/*
m.def
(
"apply",
py::overload_cast<double, ComplexObject< FunctionTree<D> > &, ComplexObject< ConvolutionOperator<D> > &, ComplexObject< FunctionTree<D> > &, int, bool>(&apply<D>),
"prec"_a,
"out"_a,
"oper"_a,
"inp"_a,
"max_iter"_a = -1,
"abs_prec"_a = false
);
*/
edinvay marked this conversation as resolved.
Show resolved Hide resolved
}

} // namespace vampyr