:github_url: https://github.com/srbhp/nrgplusplus .. _program_listing_file_models_freeModel.hpp: Program Listing for File freeModel.hpp ====================================== |exhale_lsh| :ref:`Return to documentation for file ` (``models/freeModel.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 #include #include class freeModel : public fermionBasis { public: freeModel() : fermionBasis(2, fermionBasis::chargeAndSpin) { createBasis(); // create the basis in nstates x nstates } [[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> eigenvalues_Q; std::vector chi_Q; std::vector> n_Q; // ######################################## private: void createBasis() { // createFermionBasis(2); std::cout << "FermionBasis Size" << fermionOprMat.size() << "\n"; auto Hamiltonian = fermionOprMat[0] * 0; // Set Hamiltonian to Zero // create_QuantumNspinCharge(); create_Block_structure(); // #################################################################### n_Q = 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)); } // // set foperator auto h_blocked = get_block_Hamiltonian(Hamiltonian); // std::cout << "h_blocked: " << h_blocked << std::endl; // std::cout << "Hamiltonian: " << Hamiltonian << std::endl; // 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(); } // std::cout << "Eigenvalues: " << eigenvalues_Q << std::endl; // TODO(sp): rotate the f operator // #################################################################### f_dag_operator = get_block_operators({fermionOprMat[0], fermionOprMat[1]}); std::cout << "f_dag_operators: " << f_dag_operator.size() << std::endl; std::vector topr(f_dag_operator.size(), qOperator()); for (size_t ip = 0; ip < f_dag_operator.size(); ip++) { for (size_t i = 0; i < n_Q.size(); i++) { for (size_t j = 0; j < n_Q.size(); j++) { auto tfopr = f_dag_operator[ip].get(i, j); if (tfopr) { topr[ip].set((h_blocked.get(i, i)) .value() ->cTranspose() .dot(*tfopr.value()) .dot(*(h_blocked.get(j, j)).value()), i, j); } } } } f_dag_operator = topr; } // ###################################### };