v2DM-DOCI  1.0
gen-pairing.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 <iostream>
25 #include <cmath>
26 #include <getopt.h>
27 
28 // from CheMPS2
29 #include "Hamiltonian.h"
30 #include "OptIndex.h"
31 
32 
39 int main(int argc,char **argv)
40 {
41  using std::cout;
42  using std::endl;
43 
44  std::string output;
45  int L = 0;
46  int N = 0;
47  double g = 0;
48 
49  struct option long_options[] =
50  {
51  {"output", required_argument, 0, 'o'},
52  {"pairing", required_argument, 0, 'g'},
53  {"sites", required_argument, 0, 'L'},
54  {"particles", required_argument, 0, 'N'},
55  {"help", no_argument, 0, 'h'},
56  {0, 0, 0, 0}
57  };
58 
59  int i,j;
60 
61  while( (j = getopt_long (argc, argv, "ho:g:L:N:", long_options, &i)) != -1)
62  switch(j)
63  {
64  case 'h':
65  case '?':
66  cout << "Usage: " << argv[0] << " [OPTIONS]\n"
67  "\n"
68  " -o, --output=output-filename Set the output filename\n"
69  " -L, --sites=L Set the number of sites\n"
70  " -N, --particles=N Set the number of particles\n"
71  " -g, --pairing=g Set the pairing strength\n"
72  " -h, --help Display this help\n"
73  "\n";
74  return 0;
75  break;
76  case 'o':
77  output = optarg;
78  break;
79  case 'g':
80  g = atof(optarg);
81  break;
82  case 'L':
83  L = atoi(optarg);
84  break;
85  case 'N':
86  N = atoi(optarg);
87  break;
88  }
89 
90  if(! (L && N))
91  {
92  std::cerr << "You need to specifiy the system!" << endl;
93  return 1;
94  }
95 
96  cout << "Creating for L= " << L << " N= " << N << " g= " << g << endl;
97 
98  const std::vector<int> orb2irrep (L, 0);
99 
100  CheMPS2::Hamiltonian ham(L, 0, orb2irrep.data());
101  // put everything to zero
102  ham.reset();
103  ham.setNe(N);
104  ham.setEconst(0);
105 
106  // one-particle integrals
107  for(int i=0;i<L;i++)
108  ham.setTmat(i, i, i+1);
109 
110  // two-particle integrals
111  for(int i=0;i<L;i++)
112  for(int j=0;j<L;j++)
113  ham.setVmat(i, i, j, j, g);
114 
115  if(output.empty())
116  output = "pairing-integrals-" + std::to_string(L) + "-" + std::to_string(N) + "-" + std::to_string(g) + ".h5";
117 
118  cout << "Writing Hamiltonian to " << output << endl;
119 
120  ham.save2(output);
121 
122  return 0;
123 }
124 
125 /* vim: set ts=3 sw=3 expandtab :*/
void reset()
set everything to zero
int main(int argc, char **argv)
Definition: gen-pairing.cpp:39