Skip to content
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

Factor out Hamiltonian builders #261

Merged
merged 4 commits into from
Apr 17, 2024
Merged

Factor out Hamiltonian builders #261

merged 4 commits into from
Apr 17, 2024

Conversation

pablosanjose
Copy link
Owner

This is a first step towards addressing #4

Here we split (internally) the process of building a Hamiltonian, which was formerly a single step hamiltonian(lattice, model; orbitals), to a multistep process: b = builder(lattice; orbitals) (of type ParametricHamiltonianBuilder), add!(b, model), and finally hamiltonian(b). We can also do push!(b, modifiers...) to inject Modifiers into the builder before assembly into a Hamiltonian.

These builder and add! functions are unexported for the moment, and meant to be used internally only. add! also has a method add!(b, value, ::CellSites, ::CellSites) to add a single or a group of values to a Hamiltonian build before assembly. This is not exported for a good reason: we don't do matrix-size checks of value for performance reasons here. Hence, improper use in inhomogeneous multiorbital cases could in principle lead to malformed block elements (i.e. with nonzeros out of place).

The advantage of this refactor is that we can now envision making a Wannierization object that wraps two builders that are populated as the wannier90 file is read, one for the Hamiltonian and another for the position matrix elements. Then, it becomes possible to combine the hamiltonian builder inside this object with other models (even parametric models) so that we can mix Wannier90 presents with flexible parametric models and modifiers.

builder with modifiers

fixes

fixes

completed API (unexported)

cleanup

remove unnecessary mutable
@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2024

Codecov Report

Attention: Patch coverage is 87.58170% with 19 lines in your changes are missing coverage. Please review.

Project coverage is 92.30%. Comparing base (a26d181) to head (a83b850).
Report is 1 commits behind head on master.

Files Patch % Lines
src/builders.jl 83.11% 13 Missing ⚠️
src/hamiltonian.jl 92.18% 5 Missing ⚠️
src/specialmatrices.jl 50.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #261      +/-   ##
==========================================
- Coverage   92.48%   92.30%   -0.19%     
==========================================
  Files          36       36              
  Lines        5885     5942      +57     
==========================================
+ Hits         5443     5485      +42     
- Misses        442      457      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pablosanjose pablosanjose merged commit 526cb05 into master Apr 17, 2024
9 checks passed
@pablosanjose pablosanjose mentioned this pull request Apr 17, 2024
@pablosanjose pablosanjose deleted the builder branch April 24, 2024 16:06
@pablosanjose pablosanjose mentioned this pull request Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants