Xped
Loading...
Searching...
No Matches
CTMSolver.hpp
Go to the documentation of this file.
1#ifndef XPED_CTM_SOLVER_HPP_
2#define XPED_CTM_SOLVER_HPP_
3
4#include <filesystem>
5
6#include "yas/serialize.hpp"
7#include "yas/std_types.hpp"
8
10
11#include "Xped/PEPS/CTM.hpp"
12#include "Xped/PEPS/CTMOpts.hpp"
13
14namespace Xped {
15
16template <typename Scalar_, typename Symmetry_, Opts::CTMCheckpoint CPOpts = Opts::CTMCheckpoint{}, std::size_t TRank = 2>
18{
19public:
20 using Scalar = Scalar_;
21 using Symmetry = Symmetry_;
22 template <typename Sym>
24
25 CTMSolver() = default;
26
28 : opts(opts)
29 {
30 Jack = CTM<Scalar, Symmetry, TRank, false>(opts.chi, opts.init); //, opts.cell);
31 if(opts.load != "") {
32 Jack.loadFromMatlab(std::filesystem::path(opts.load), "cpp", opts.qn_scale);
33 REINIT_ENV = false;
34 // Jack.info();
35 }
36 }
37
38 template <typename HamScalar, bool AD>
39 typename ScalarTraits<Scalar>::Real solve(std::shared_ptr<iPEPS<Scalar, Symmetry>> Psi, Scalar* gradient, Hamiltonian<Symmetry>& H);
40
41 XPED_CONST CTM<Scalar, Symmetry, TRank, false>& getCTM() XPED_CONST { return Jack; }
42
43 void setCTM(XPED_CONST CTM<Scalar, Symmetry, TRank, false>& in) { Jack = in; }
44
45 template <typename Ar>
46 void serialize(Ar& ar)
47 {
48 ar& YAS_OBJECT_NVP("CTMSolver", ("solver", Jack), ("opts", opts), ("REINIT_ENV", REINIT_ENV), ("grad_norm", grad_norm));
49 }
50
52
53private:
55 bool REINIT_ENV = true;
56 typename ScalarTraits<Scalar>::Real grad_norm = 1000.;
57};
58
59} // namespace Xped
60
61#ifndef XPED_COMPILED_LIB
62# include "PEPS/CTMSolver.cpp"
63#endif
64
65#endif
Definition: CTMSolver.hpp:18
XPED_CONST CTM< Scalar, Symmetry, TRank, false > & getCTM() XPED_CONST
Definition: CTMSolver.hpp:41
Symmetry_ Symmetry
Definition: CTMSolver.hpp:21
CTMSolver()=default
void setCTM(XPED_CONST CTM< Scalar, Symmetry, TRank, false > &in)
Definition: CTMSolver.hpp:43
ScalarTraits< Scalar >::Real solve(std::shared_ptr< iPEPS< Scalar, Symmetry > > Psi, Scalar *gradient, Hamiltonian< Symmetry > &H)
Definition: CTMSolver.cpp:12
Opts::CTM opts
Definition: CTMSolver.hpp:51
void serialize(Ar &ar)
Definition: CTMSolver.hpp:46
CTMSolver(Opts::CTM opts)
Definition: CTMSolver.hpp:27
Scalar_ Scalar
Definition: CTMSolver.hpp:20
Definition: CTM.hpp:62
void loadFromMatlab(const std::filesystem::path &p, const std::string &root_name, int qn_scale=1)
Definition: CTM.cpp:199
Definition: iPEPS.hpp:39
Definition: bench.cpp:62
Definition: CTMOpts.hpp:28
int qn_scale
Definition: CTMOpts.hpp:44
CTM_INIT init
Definition: CTMOpts.hpp:39
std::size_t chi
Definition: CTMOpts.hpp:29
std::string load
Definition: CTMOpts.hpp:43
Definition: ScalarTraits.hpp:10
Definition: TwoSiteObservable.hpp:22