ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
main.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * ALPS MPS DMRG Project
4  *
5  * Copyright (C) 2013 Institute for Theoretical Physics, ETH Zurich
6  * 2011-2013 by Michele Dolfi <dolfim@phys.ethz.ch>
7  *
8  * This software is part of the ALPS Applications, published under the ALPS
9  * Application License; you can use, redistribute it and/or modify it under
10  * the terms of the license, either version 1 or (at your option) any later
11  * version.
12  *
13  * You should have received a copy of the ALPS Application License along with
14  * the ALPS Applications; see the file LICENSE.txt. If not, the license is also
15  * available from http://alps.comp-phys.org/.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  *
25  *****************************************************************************/
26 
27 #include <alps/utility/copyright.hpp>
28 #include <iostream>
29 
30 #include "dmrg/version.h"
31 
32 #include <complex>
36 
38 #include "dmrg/mp_tensors/mps.h"
39 #include "dmrg/mp_tensors/mpo.h"
43 
44 #include <boost/program_options.hpp>
45 
46 
47 /// build with NU1 symmetry
48 typedef NU1 grp;
49 
50 
51 template <class Matrix, class SymmGroup>
52 void run (std::string const& chkp1, std::string const& chkp2)
53 {
54  MPS<Matrix, grp> mps1, mps2;
55  load(chkp1, mps1);
56  load(chkp2, mps2);
57 
58  std::cout << "<mps1 | mps2> = " << overlap(mps1, mps2) << std::endl;
59 }
60 
61 int main(int argc, char ** argv)
62 {
63  try {
64  std::cout << "ALPS/MPS version " DMRG_VERSION_STRING " (2013-2014)\n"
65  << " Density Matrix Renormalization Group algorithm\n"
66  << " available from http://alps.comp-phys.org/\n"
67  << " copyright (c) 2013 Institute for Theoretical Physics, ETH Zurich\n"
68  << " copyright (c) 2010-2011 by Bela Bauer\n"
69  << " copyright (c) 2011-2013 by Michele Dolfi\n"
70  << " for details see the publication: \n"
71  << " M. Dolfi et al, in preparation\n"
72  << std::endl;
73  alps::print_copyright(std::cout);
74 
75  /// parse options
76  std::string chkp1, chkp2;
77 
78  namespace po = boost::program_options;
79  po::options_description desc("Allowed options");
80  desc.add_options()
81  ("help,h", "produce help message")
82  ("version", "print program version")
83  ("complex", "use complex numbers")
84  ("mps1", po::value<std::string>(&chkp1)->required(), "path to chkp of mps1")
85  ("mps2", po::value<std::string>(&chkp2)->required(), "path to chkp of mps2");
86  po::positional_options_description p;
87  p.add("mps1", 1);
88  p.add("mps2", 1);
89 
90  po::variables_map vm;
91  po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
92 
93  if (vm.count("help")) {
94  std::cout << desc << std::endl;
95  return 0;
96  }
97  if (vm.count("version")) {
98  std::cout << alps::version_string() << std::endl;
99  std::cout << DMRG_VERSION_STRING << std::endl;
100  return 0;
101  }
102 
103  po::notify(vm);
104 
105  /// compute
106  if (vm.count("complex")) run<cmatrix, grp>(chkp1, chkp2);
107  else run<matrix, grp>(chkp1, chkp2);
108 
109  } catch (std::exception & e) {
110  std::cerr << "Exception thrown:" << std::endl;
111  std::cerr << e.what() << std::endl;
112  exit(1);
113  }
114 }
void load(alps::hdf5::archive &ar, std::string const &path, TrivialGroup::charge &value, std::vector< std::size_t > chunk=std::vector< std::size_t >(), std::vector< std::size_t > offset=std::vector< std::size_t >())
Definition: none.h:81
void run(std::string const &chkp1, std::string const &chkp2)
Definition: main.cpp:52
declaration of the MPS class (vector of MPSTensor)
alps::numeric::matrix< double > matrix
Definition: main.cpp:34
NU1 grp
build with NU1 symmetry
Definition: main.cpp:48
utility functions for the MPO
include one of the Index class definitions
MPS< Matrix, SymmGroup >::scalar_type overlap(MPS< Matrix, SymmGroup > const &mps1, MPS< Matrix, SymmGroup > const &mps2)
Definition: mps_mpo_ops.h:136
definition of MPO class (vector of MPOTensor)
Definition: mps.h:40
#define DMRG_VERSION_STRING
Definition: version.h:35
functions to operate on MPS and MPO (compute expectation values, etc.)
int main(int argc, char **argv)
Definition: main.cpp:34
alps::numeric::matrix< std::complex< double > > cmatrix
Definition: main.cpp:35
functions to contract tensor network states