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

Non-spatial models (e.g. mean-field models) #248

Merged
merged 11 commits into from
Mar 1, 2024
Merged

Conversation

pablosanjose
Copy link
Owner

@pablosanjose pablosanjose commented Feb 29, 2024

Closes #229

This introduces the final piece required to construct mean field models. These are one example of non-spatial models, i.e. models that cannot be written as a function of site positions, but require to know site indices and cells to then index into a mean field matrix (and OrbitalSliceMatrix to be precise, see #245).

The syntax for a non-spatial model is @onsite([sitei,; params...] -> field(sitei; params...); ...), or @hopping([sitei, sitej; params...] -> field(sitei, sitej; params...); ...), etc (this works with all types of model terms and modifiers). Note the square brackets instead of parenthesis.

The updated syntax uses (...) --> ... instead of [ ... ] -> ...:

@onsite((i; params...) --> field(i; params...); ...)
@hopping((i, j; params...) --> field(i, j; params...); ...)
@onsite!((o i; params...) --> modif(i; params...); ...)
@hopping!((t, i, j; params...) --> modif(i, j; params...); ...)
...

This works with all types of model terms and modifiers.

In fact i and j are instances of CellSitePos objects, constructed internally, which can efficiently index into OrbitalSliceMatrices. Thus, we could write a model like @onsite((s; ρ = ρ0) --> ρ[s] * V(pos(s))) , where ρ is an OrbitalSliceMatrix, obtained by evaluating for example a density matrix, V is a function of position, and pos(s) returns the position of the site. We also have cell(s) and ind(s) to access cell and site indices. Examples of this kind of application will be found in the documentation.

Note: due to a current limitation of the Julia parser, we cannot do @onsite([s; p1, p2]->...) (i.e. a single site argument, two or more parameters), see JuliaLang/julia#53530. For the moment, we can use the workaroung @onsite([s,; p1, p2]->...), i.e. adding a comma after the s argument. The new --> syntax sidesteps this issue

EDIT: updated the implemented syntax to make it simpler internally and with less corner cases.

@codecov-commenter
Copy link

codecov-commenter commented Feb 29, 2024

Codecov Report

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

Project coverage is 92.05%. Comparing base (2bb98a5) to head (c052625).

Files Patch % Lines
src/types.jl 68.08% 15 Missing ⚠️
src/hamiltonian.jl 84.00% 8 Missing ⚠️
src/show.jl 0.00% 6 Missing ⚠️
src/models.jl 90.90% 2 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #248      +/-   ##
==========================================
- Coverage   92.13%   92.05%   -0.09%     
==========================================
  Files          35       35              
  Lines        5750     5805      +55     
==========================================
+ Hits         5298     5344      +46     
- Misses        452      461       +9     

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

@pablosanjose pablosanjose merged commit 624c354 into master Mar 1, 2024
4 checks passed
@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.

Self-consistent mean fields
2 participants