-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathv2rdm_helper.cc
142 lines (99 loc) · 3.71 KB
/
v2rdm_helper.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
*@BEGIN LICENSE
*
* v2RDM-CASSCF, a plugin to:
*
* Psi4: an open-source quantum chemistry software package
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (c) 2014, The Florida State University. All rights reserved.
*
*@END LICENSE
*
*/
#ifndef _python_api2_h_
#define _python_api2_h_
#include "v2rdm_solver.h"
#include "v2rdm_helper.h"
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h>
#include "psi4/libpsi4util/process.h"
#include "psi4/libmints/wavefunction.h"
using namespace psi;
namespace py = pybind11;
using namespace pybind11::literals;
namespace psi { namespace v2rdm_casscf {
void export_v2RDMHelper(py::module& m) {
py::class_<v2rdm_casscf::v2RDMHelper, std::shared_ptr<v2rdm_casscf::v2RDMHelper> >(m, "v2RDMHelper")
.def(py::init<std::shared_ptr<Wavefunction>,Options &>())
.def("set_orbitals", &v2RDMHelper::set_orbitals)
.def("get_orbitals", &v2RDMHelper::get_orbitals)
.def("get_opdm", &v2RDMHelper::get_opdm)
.def("get_tpdm", &v2RDMHelper::get_tpdm)
.def("get_opdm_sparse", &v2RDMHelper::get_opdm_sparse)
.def("get_tpdm_sparse", &v2RDMHelper::get_tpdm_sparse)
.def("compute_energy", &v2RDMHelper::compute_energy);
py::class_<v2rdm_casscf::opdm, std::shared_ptr<v2rdm_casscf::opdm> >(m, "opdm")
.def(py::init<>())
.def_readwrite("i", &opdm::i)
.def_readwrite("j", &opdm::j)
.def_readwrite("value", &opdm::value);
py::class_<v2rdm_casscf::tpdm, std::shared_ptr<v2rdm_casscf::tpdm> >(m, "tpdm")
.def(py::init<>())
.def_readwrite("i", &tpdm::i)
.def_readwrite("j", &tpdm::j)
.def_readwrite("k", &tpdm::k)
.def_readwrite("l", &tpdm::l)
.def_readwrite("value", &tpdm::value);
}
PYBIND11_MODULE(v2rdm_casscf, m) {
m.doc() = "Python API of v2rdm_casscf: a variational 2-RDM-driven CASSCF plugin to Psi4";
export_v2RDMHelper(m);
}
v2RDMHelper::v2RDMHelper(SharedWavefunction reference_wavefunction,Options & options)
{
v2rdm = (std::shared_ptr<v2RDMSolver>)(new v2RDMSolver(reference_wavefunction,options));
}
v2RDMHelper::~v2RDMHelper()
{
}
double v2RDMHelper::compute_energy() {
return v2rdm->compute_energy();
}
std::shared_ptr<Matrix> v2RDMHelper::get_opdm() {
return v2rdm->get_opdm();
}
std::vector<opdm> v2RDMHelper::get_opdm_sparse(std::string type) {
return v2rdm->get_opdm_sparse(type);
}
std::shared_ptr<Matrix> v2RDMHelper::get_tpdm() {
return v2rdm->get_tpdm();
}
std::vector<tpdm> v2RDMHelper::get_tpdm_sparse(std::string type) {
return v2rdm->get_tpdm_sparse(type);
}
void v2RDMHelper::orbital_locations(const std::string& orbitals, int* start, int* end) {
v2rdm->orbital_locations(orbitals,start,end);
}
std::shared_ptr<Matrix> v2RDMHelper::get_orbitals(const std::string& orbital_name) {
return v2rdm->get_orbitals(orbital_name);
}
void v2RDMHelper::set_orbitals(const std::string& orbital_name, SharedMatrix orbitals) {
v2rdm->set_orbitals(orbital_name, orbitals);
}
}} // End namespaces
#endif