SOLIDstate
A C++ library for solid state physics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
SolverSwitcher.hpp
Go to the documentation of this file.
1 
11 #ifndef QUANTUMDYNAMICS_SOLVERS_SOLVERSWITCHER_HPP
12 #define QUANTUMDYNAMICS_SOLVERS_SOLVERSWITCHER_HPP
13 
14 #include "QuantumDynamicSolver.hpp"
15 #include "RungeKutta4.hpp"
16 #include "AdiabaticSolver.hpp"
17 #include "../../Misc/StrToInt.hpp"
18 
19 #include <string>
20 #include <cassert>
21 
22 namespace solid
23 {
24 
25 
26 
34 template <template <typename> class T1, typename T2, typename T3>
36 {
37 public:
44  static IQuantumDynamicSolver<T1, T2, T3> *Switch(const std::string label)
45  {
46  // default solver label
47  const std::string defaultSolver = RK4<T1, T2, T3>::label;
48 
49  switch (StrToInt(label.c_str()))
50  {
51 
52  // Runge Kutta 4 order Solver
54  if constexpr (std::is_same<T3, arma::cx_double>::value)
55  return new RK4<T1, T2, T3>();
56  else
57  assert(!"selected solver requires complex type! (T3 = arma::cx_double)");
58  break;
59 
60  // Adiabatic Solver
62  return new AdiabaticSolver<T1, T2, T3>();
63 
64  // default Solver
65  default:
66  // TODO move to info
67  std::cout << "Unknown solver: " << label << ". Running with default solver " << defaultSolver << std::endl;
68  return Switch(defaultSolver);
69  break;
70  }
71  }
72 };
73 
74 } // namespace solid
75 
76 #endif
Runge–Kutta forth order method (RK4) for solving differentional equations.
Definition: RungeKutta4.hpp:35
constexpr unsigned int StrToInt(const char *str, int h=0)
Covertr string to intiger copied from StackOverflow
Definition: StrToInt.hpp:14
Adiabatic Solver header.
Definition: AdiabaticSolver.hpp:38
QuantumDynamicSolver interface header.
Switcher for QuantumDynamicSolver.
Definition: SolverSwitcher.hpp:35
Adiabatic Solver (IQuantumDynamicSolver implementation) header.
Quantum Dynamic Solver interface.
Definition: QuantumDynamicSolver.hpp:35
Runge Kutta 4 method class header.
static IQuantumDynamicSolver< T1, T2, T3 > * Switch(const std::string label)
Switch between IQuantumDynamicSolvers.
Definition: SolverSwitcher.hpp:44