votca 2026-dev
Loading...
Searching...
No Matches
interface.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2023 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
18#include "xtp_bind_tools.h"
19#include <iostream>
20#include <pybind11/complex.h>
21#include <pybind11/iostream.h>
22#include <pybind11/pybind11.h>
23#include <pybind11/stl.h>
24
25namespace py = pybind11;
26
27PYBIND11_MODULE(xtp_binds, module) {
28 module.doc() =
29 "VOTCA-XTP is a library which allows you to calculate the electronic "
30 "properties of organic materials,"
31 "https://votca.github.io";
32
33 module.def(
34 "call_calculator",
35 [](const std::string& name,
36 const std::map<std::string, std::string>& dict) {
37 py::scoped_ostream_redirect redirect_cout(
38 std::cout, py::module_::import("sys").attr("stdout"));
39 py::scoped_ostream_redirect redirect_cerr(
40 std::cerr, py::module_::import("sys").attr("stderr"));
41 pyxtp::call_calculator(name, dict);
42 },
43 R"pbdoc(
44 Invoke a Votca XTP calculator
45
46 Parameters
47 ----------
48 name
49 Calculator's name
50 dict
51 Calculator options
52 )pbdoc");
53
54 module.def(
55 "call_tool",
56 [](const std::string& name, Index nthreads, const std::string& xml_file) {
57 py::scoped_ostream_redirect redirect_cout(
58 std::cout, py::module_::import("sys").attr("stdout"));
59 py::scoped_ostream_redirect redirect_cerr(
60 std::cerr, py::module_::import("sys").attr("stderr"));
61 pyxtp::call_tool(name, nthreads, xml_file);
62 },
63 R"pbdoc(
64 Invoke a Votca XTP Tool
65
66 Parameters
67 ----------
68 name
69 Tool's name
70 threads
71 Number of threads to perform the computation
72 xml_file
73 Input file specification
74 )pbdoc");
75}
PYBIND11_MODULE(xtp_binds, module)
Definition interface.cc:27
void call_calculator(const std::string &calculatorName, const std::map< std::string, std::string > &dict)
Construct a new pybind11 module object to invoke a votca-xtp Calculator.
void call_tool(const std::string &calculatorName, Index nThreads, std::string xmlfile)
Construct a new pybind11 module object to invoke a votca-xtp QMTool.
Definition xtp_tools.cc:25