/
ExportAdcc.cc
118 lines (105 loc) · 3.79 KB
/
ExportAdcc.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//
// Copyright (C) 2018 by the adcc authors
//
// This file is part of adcc.
//
// adcc is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// adcc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with adcc. If not, see <http://www.gnu.org/licenses/>.
//
#include <adcc/exceptions.hh>
#include <adcc/metadata.hh>
#include <pybind11/pybind11.h>
namespace py = pybind11;
namespace adcc {
namespace py_iface {
void export_AdcIntermediates(py::module& m);
void export_AdcMatrix(py::module& m);
void export_AdcMemory(py::module& m);
void export_amplitude_vector_enforce_spin_kind(py::module& m);
void export_AmplitudeVector(py::module& m);
void export_CachingPolicy(py::module& m);
void export_compute_modified_transition_moments(py::module& m);
void export_compute_one_particle_densities(py::module& m);
void export_CtxMap(py::module& m);
void export_guesses(py::module& m);
void export_HartreeFockProvider(py::module& m);
void export_LazyMp(py::module& m);
void export_MoIndexTranslation(py::module& m);
void export_MoSpaces(py::module& m);
void export_OneParticleOperator(py::module& m);
void export_ReferenceState(py::module& m);
void export_Symmetry(py::module& m);
void export_Tensor(py::module& m);
void export_ThreadPool(py::module& m);
#ifdef ADCC_WITH_ADCMAN
void export_solve_adcman_davidson(py::module& m);
#endif
} // namespace py_iface
} // namespace adcc
PYBIND11_MODULE(libadcc, m) {
namespace pyif = adcc::py_iface;
pyif::export_CtxMap(m);
pyif::export_AdcMemory(m);
pyif::export_ThreadPool(m);
pyif::export_CachingPolicy(m);
pyif::export_HartreeFockProvider(m);
pyif::export_MoSpaces(m);
pyif::export_Symmetry(m);
pyif::export_MoIndexTranslation(m);
pyif::export_Tensor(m);
pyif::export_ReferenceState(m);
pyif::export_OneParticleOperator(m);
pyif::export_LazyMp(m);
pyif::export_AdcIntermediates(m);
pyif::export_AmplitudeVector(m);
pyif::export_AdcMatrix(m);
pyif::export_guesses(m);
pyif::export_amplitude_vector_enforce_spin_kind(m);
pyif::export_compute_modified_transition_moments(m);
pyif::export_compute_one_particle_densities(m);
#ifdef ADCC_WITH_ADCMAN
pyif::export_solve_adcman_davidson(m);
#endif
// Set metadata about libadcc
m.attr("__version__") = adcc::version::version_string();
m.attr("__build_type__") = adcc::version::is_debug() ? "Debug" : "Release";
m.attr("__authors__") = adcc::__authors__();
m.attr("__email__") = adcc::__email__();
// Set libadcc feature list
py::list features;
for (auto& feature : adcc::__features__()) features.append(feature);
m.attr("__features__") = features;
// Set libadcc components list
py::list components;
for (const adcc::Component& comp : adcc::__components__()) {
py::dict d;
d["name"] = comp.name;
d["version"] = comp.version;
d["description"] = comp.description;
d["authors"] = comp.authors;
d["doi"] = comp.doi;
d["website"] = comp.website;
d["licence"] = comp.licence;
components.append(d);
}
m.attr("__components__") = components;
py::register_exception_translator([](std::exception_ptr p) {
try {
if (p) std::rethrow_exception(p);
} catch (const adcc::not_implemented_error& ex) {
PyErr_SetString(PyExc_NotImplementedError, ex.what());
} catch (const adcc::invalid_argument& ex) {
PyErr_SetString(PyExc_ValueError, ex.what());
}
});
}