:github_url: https://github.com/srbhp/nrgplusplus .. _program_listing_file_models_spinhalf.hpp: Program Listing for File spinhalf.hpp ===================================== |exhale_lsh| :ref:`Return to documentation for file ` (``models/spinhalf.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include "models/fermionBasis.hpp" #include "nrgcore/qOperator.hpp" #include "nrgcore/qsymmetry.hpp" #include "utils/qmatrix.hpp" #include #include #include #include #include #include #include class spinhalf { std::vector> f_dag_raw; double Uint; double epsilon_d; double magnetic_field; public: // number of f operators spinhalf(double teps, double tUint, double tmag = 0) // NOLINT : Uint(tUint), epsilon_d(teps), magnetic_field(tmag) { // set up the basis fermionBasis spinhalfBasis(2, fermionBasis::chargeAndSpin); // Number of fermion channels/spins f_dag_operator = spinhalfBasis.get_f_dag_operator(); f_dag_raw = spinhalfBasis.get_raw_f_dag_operator(); // set f_operator // { // auto f_raw = f_dag_raw; // for (auto &aa : f_raw) { // aa = aa.cTranspose(); // } // f_operator = spinhalfBasis.get_block_operators(f_raw); // } // n_Q n_Q = spinhalfBasis.get_unique_Qnumbers(); // set chi_Q chi_Q.clear(); for (auto ai : n_Q) { double t_charge = std::accumulate(ai.begin(), ai.end(), 0); chi_Q.push_back(std::pow(-1., t_charge)); } // std::cout << "chi_Q: " << chi_Q << std::endl; // set up the Hamiltonian auto n_up = f_dag_raw[0].dot(f_dag_raw[0].cTranspose()); auto n_down = f_dag_raw[1].dot(f_dag_raw[1].cTranspose()); // std::cout << "n_up" << n_up << "n_down" << n_down; auto H = (n_up + n_down) * epsilon_d // onsite energy + (n_up - n_down) * magnetic_field // Magnetic Field + (n_up.dot(n_down)) * Uint; // Columb Energy // get the hamiltonian in the blocked structure auto h_blocked = spinhalfBasis.get_block_Hamiltonian(H); doubleOccupancy = spinhalfBasis.get_block_operators({n_up.dot(n_down)}); // h_blocked.display(); // Diagonalize the hamilton eigenvalues_Q.clear(); eigenvalues_Q.resize(n_Q.size(), {}); for (size_t i = 0; i < n_Q.size(); i++) { eigenvalues_Q[i] = (h_blocked.get(i, i)).value()->diag(); // NOLINT } // TODO(sp): rotate the f operator // End of the constructor } // TODO(sp): Remove the copy of the objects [[nodiscard]] std::vector> get_basis() const { return n_Q; }; [[nodiscard]] std::vector> get_eigenvaluesQ() const { return eigenvalues_Q; } [[nodiscard]] std::vector get_chi_Q() const { return chi_Q; } std::vector f_dag_operator; std::vector> eigenvalues_Q; std::vector chi_Q; std::vector> n_Q; std::vector doubleOccupancy; [[nodiscard]] auto getDoubleOcc() const { return doubleOccupancy; } };