v2DM-DOCI
1.0
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
read_patrick.cpp
Go to the documentation of this file.
1
/*
2
* @BEGIN LICENSE
3
*
4
* Copyright (C) 2014-2015 Ward Poelmans
5
*
6
* This file is part of v2DM-DOCI.
7
*
8
* v2DM-DOCI is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* Foobar is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
20
*
21
* @END LICENSE
22
*/
23
24
#include <cassert>
25
#include <cstring>
26
#include <fstream>
27
#include <sstream>
28
#include <getopt.h>
29
#include <iostream>
30
31
// from CheMPS2
32
#include "
Hamiltonian.h
"
33
#include "
OptIndex.h
"
34
35
int
main
(
int
argc,
char
**argv)
36
{
37
using
std::cout;
38
using
std::endl;
39
40
cout.precision(10);
41
42
std::string one;
43
std::string two;
44
std::string output;
45
int
L(0), N(0);
46
47
struct
option long_options[] =
48
{
49
{
"one"
, required_argument, 0,
'1'
},
50
{
"two"
, required_argument, 0,
'2'
},
51
{
"output"
, required_argument, 0,
'o'
},
52
{
"orbitals"
, required_argument, 0,
'l'
},
53
{
"particles"
, required_argument, 0,
'n'
},
54
{
"help"
, no_argument, 0,
'h'
},
55
{0, 0, 0, 0}
56
};
57
58
int
i,j;
59
60
while
( (j = getopt_long (argc, argv,
"h1:2:o:l:n:"
, long_options, &i)) != -1)
61
switch
(j)
62
{
63
case
'h'
:
64
case
'?'
:
65
cout <<
"Usage: "
<< argv[0] <<
" [OPTIONS]\n"
66
"\n"
67
" -1, --one=one-electron One-electron integrals\n"
68
" -2, --two=two-electron Two-electron integrals\n"
69
" -o, --output=output-file Set output filename\n"
70
" -l, --orbitals=num Set the number of orbitals\n"
71
" -n, --particles=num Set the number of particles\n"
72
" -h, --help Display this help\n"
73
"\n"
;
74
return
0;
75
break
;
76
case
'1'
:
77
one = optarg;
78
break
;
79
case
'2'
:
80
two = optarg;
81
break
;
82
case
'o'
:
83
output = optarg;
84
break
;
85
case
'l'
:
86
L = atoi(optarg);
87
break
;
88
case
'n'
:
89
N = atoi(optarg);
90
break
;
91
}
92
93
/*
94
if(one.empty() || two.empty() || output.empty() || !L || !N)
95
{
96
cout << "Read --help!" << endl;
97
return 1;
98
}
99
100
assert(L>0 && N>0);
101
102
cout << "Reading one-electron: " << one << endl;
103
cout << "Reading two-electron: " << two << endl;
104
cout << "L = " << L << "\tN = " << N << endl;
105
106
const std::vector<int> orb2irrep(L, 0);
107
*/
108
109
auto
ham =
CheMPS2::Hamiltonian
(one);
110
ham.setNe(8);
111
112
/*
113
auto ham = CheMPS2::Hamiltonian(L, 0, orb2irrep.data());
114
ham.reset();
115
ham.setNe(N);
116
ham.setEconst(7.6349206349);
117
118
std::ifstream onefile(one);
119
string line;
120
121
while(getline(onefile, line))
122
{
123
std::istringstream ss(line);
124
int a, b;
125
double val;
126
127
ss >> a >> b >> val;
128
129
// cout << "a=" << a << " b=" << b << " val=" << val << endl;
130
ham.setTmat(a-1,b-1,val);
131
}
132
133
onefile.close();
134
135
std::ifstream twofile(two);
136
137
while(getline(twofile, line))
138
{
139
std::istringstream ss(line);
140
int a, b, c, d;
141
double val;
142
143
ss >> a >> b >> c >> d >> val;
144
145
ham.setVmat(a-1,b-1,d-1,c-1,val);
146
}
147
148
twofile.close();
149
*/
150
151
cout <<
"Writing to "
<< output << endl;
152
ham.save2(output);
153
154
return
0;
155
}
156
157
/* vim: set ts=3 sw=3 expandtab :*/
OptIndex.h
main
int main(int argc, char **argv)
Definition:
read_patrick.cpp:35
Hamiltonian.h
CheMPS2::Hamiltonian
Definition:
Hamiltonian.h:56
read_patrick.cpp
Generated by
1.8.9.1