-
Notifications
You must be signed in to change notification settings - Fork 7
Model Hamiltonians #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wavefunction91
wants to merge
8
commits into
master
Choose a base branch
from
feature/model
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5175a96
Added Hubbard Hamiltonian generator + UT
wavefunction91 ebb7ef4
Committing clang-format changes
84b219d
Committing license headers
65f56b3
Add PBC
wavefunction91 e0ef771
Committing clang-format changes
9ab4627
Merge branch 'master' into feature/model
wavefunction91 d56989c
Included new HamiltonianGenerator, particularly efficient for impurit…
CarlosMejZ 614f5ff
Committing clang-format changes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * MACIS Copyright (c) 2023, The Regents of the University of California, | ||
| * through Lawrence Berkeley National Laboratory (subject to receipt of | ||
| * any required approvals from the U.S. Dept. of Energy). All rights reserved. | ||
| * | ||
| * See LICENSE.txt for details | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <macis/types.hpp> | ||
|
|
||
| namespace macis { | ||
|
|
||
| /** | ||
| * @brief Generate Hamiltonian Data for 1D Hubbard | ||
| */ | ||
| void hubbard_1d(size_t nsites, double t, double U, std::vector<double>& T, | ||
| std::vector<double>& V); | ||
|
|
||
| } // namespace macis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * MACIS Copyright (c) 2023, The Regents of the University of California, | ||
| * through Lawrence Berkeley National Laboratory (subject to receipt of | ||
| * any required approvals from the U.S. Dept. of Energy). All rights reserved. | ||
| * | ||
| * See LICENSE.txt for details | ||
| */ | ||
|
|
||
| #include <macis/model/hubbard.hpp> | ||
|
|
||
| namespace macis { | ||
|
|
||
| void hubbard_1d(size_t nsites, double t, double U, std::vector<double>& T, | ||
| std::vector<double>& V) { | ||
| T.resize(nsites * nsites); | ||
| V.resize(nsites * nsites * nsites * nsites); | ||
|
|
||
| for(size_t p = 0; p < nsites; ++p) { | ||
| // Half-filling Chemical Potential | ||
| T[p * (nsites + 1)] = -U / 2; | ||
|
|
||
| // On-Site Interaction | ||
| V[p * (nsites * nsites * nsites + nsites * nsites + nsites + 1)] = U; | ||
|
|
||
| // Hopping | ||
| if(p < nsites - 1) { | ||
| T[p + (p + 1) * nsites] = -t; | ||
| T[(p + 1) + p * nsites] = -t; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } // namespace macis | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * MACIS Copyright (c) 2023, The Regents of the University of California, | ||
| * through Lawrence Berkeley National Laboratory (subject to receipt of | ||
| * any required approvals from the U.S. Dept. of Energy). All rights reserved. | ||
| * | ||
| * See LICENSE.txt for details | ||
| */ | ||
|
|
||
|
|
||
|
|
||
| #include <spdlog/sinks/null_sink.h> | ||
| #include <spdlog/spdlog.h> | ||
|
|
||
| #include <iostream> | ||
| #include <macis/model/hubbard.hpp> | ||
|
|
||
| #include "ut_common.hpp" | ||
|
|
||
| TEST_CASE("Hubbard") { | ||
| ROOT_ONLY(MPI_COMM_WORLD); | ||
|
|
||
| const size_t nsites = 4; | ||
| const size_t nsites2 = nsites * nsites; | ||
| const size_t nsites3 = nsites2 * nsites; | ||
| const double t = 1.0, U = 4.0; | ||
| std::vector<double> T, V; | ||
|
|
||
| SECTION("1D") { | ||
| macis::hubbard_1d(nsites, t, U, T, V); | ||
|
|
||
| // Check two-body term | ||
| for(int p = 0; p < nsites; ++p) | ||
| for(int q = 0; q < nsites; ++q) | ||
| for(int r = 0; r < nsites; ++r) | ||
| for(int s = 0; s < nsites; ++s) { | ||
| const auto mat_el = V[p + nsites * q + nsites2 * r + nsites3 * s]; | ||
| if(p == q and p == r and p == s) | ||
| REQUIRE(mat_el == U); | ||
| else | ||
| REQUIRE(mat_el == 0.0); | ||
| } | ||
|
|
||
| // Check 1-body term | ||
| for(int p = 0; p < nsites; ++p) | ||
| for(int q = 0; q < nsites; ++q) { | ||
| const auto mat_el = T[p + q * nsites]; | ||
| if(p == q) | ||
| REQUIRE(mat_el == Approx(-U / 2)); | ||
| else if(std::abs(p - q) == 1) | ||
| REQUIRE(mat_el == -t); | ||
| else | ||
| REQUIRE(mat_el == 0.0); | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.