TdWorkflowHeisenbergModel.cpp 1.49 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "qcor_qsim.hpp"

// High-level usage of Model Builder for Heisenberg model.
// The Heisenberg Hamiltonian is parameterized using ArQTiC scheme.

// Compile and run with:
/// $ qcor -qpu qpp TdWorkflowHeisenbergModel.cpp
/// $ ./a.out
int main(int argc, char **argv) {
  using ModelType = qcor::QuaSiMo::ModelFactory::ModelType;

  // Example ArQTiC input:
  // *Jz 
  // 0.01183898
  // *h_ext
  // 0.01183898
  // *initial_spins 
  // 0 0 0
  // *freq
  // 0.0048
  // *ext_dir
  // X
  // *num_spins
  // 3
  auto problemModel = QuaSiMo::ModelFactory::createModel(ModelType::Heisenberg,
                                                      {{"Jz", 0.01183898},
                                                       {"h_ext", 0.01183898},
                                                       {"freq", 0.0048},
                                                       {"ext_dir", "X"},
                                                       {"num_spins", 3}});
  // Workflow parameters:
  // *delta_t
  // 3
  // *steps
  // 20
  auto workflow = QuaSiMo::getWorkflow(
      "td-evolution", {{"dt", 3.0}, {"steps", 20}});

  // Result should contain the observable expectation value along Trotter steps.
  auto result = workflow->execute(problemModel);
  // Get the observable values (average magnetization)
  const auto obsVals = result.get<std::vector<double>>("exp-vals");

  // Print out for debugging:
  for (const auto &val : obsVals) {
    std::cout << "<Magnetization> = " << val << "\n";
  }

  return 0;
}