- 
                Notifications
    You must be signed in to change notification settings 
- Fork 7
Molecular Hamiltonian #327
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
Conversation
| Benchmark resultJudge resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 
 
 
 
 
 
 
 
 ResultsA ratio greater than  
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoTargetBaselineTarget resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoBaseline resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoRuntime information
 
 Architecture: x86_64 
 Benchmark resultJudge resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 
 
 
 
 
 
 
 
 ResultsA ratio greater than  
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoTargetBaselineTarget resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoBaseline resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoRuntime information
 
 Architecture: x86_64 
 Benchmark resultJudge resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 
 
 
 
 
 
 
 
 ResultsA ratio greater than  
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoTargetBaselineTarget resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoBaseline resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoRuntime information
 
 Architecture: x86_64 
 Benchmark resultJudge resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 
 
 
 
 
 
 
 
 ResultsA ratio greater than  
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoTargetBaselineTarget resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoBaseline resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoRuntime information
 
 Architecture: x86_64 
 Benchmark resultJudge resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 
 
 
 
 
 
 
 
 ResultsA ratio greater than  
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoTargetBaselineTarget resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoBaseline resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoRuntime information
 
 Architecture: x86_64 
 Benchmark resultJudge resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 
 
 
 
 
 
 
 
 ResultsA ratio greater than  
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoTargetBaselineTarget resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoBaseline resultBenchmark Report for /home/runner/work/Rimu.jl/Rimu.jlJob Properties
 ResultsBelow is a table of this job's results, obtained by running the benchmarks. 
 Benchmark Group ListHere's a list of all the benchmark groups executed by this job: 
 Julia versioninfoRuntime information
 
 Architecture: x86_64 | 
bb044f3    to
    257ae36      
    Compare
  
    | Pull Request Test Coverage Report for Build 17467385451Details
 
 
 💛 - Coveralls | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just another small comment. Otherwise this looks very promising.
| Had a quick look at the failing tests: This might be the same issue @mtsch saw recently and fixed on the  | 
508227f    to
    36c3b09      
    Compare
  
    6e31c0e    to
    af50074      
    Compare
  
    981aa3c    to
    0d76a6c      
    Compare
  
    0d76a6c    to
    3bedfec      
    Compare
  
    424a9e1    to
    af7ed0e      
    Compare
  
    d3f04a5    to
    ee3cb1c      
    Compare
  
    f11f0d7    to
    382866d      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is nice to see that you got iteration working without allocations. This is great progress!
I appreciate the comments and docstrings and improved readability of the iteration code. I think that the code can still be simplified, which can also make the code more readable and faster.
I'm not quite sure whether iteration works as it should, as repeatedly 'void' states are being returned (and I thought they shouldn't):
julia> while result != nothing
       elem, state = result
       println(state)
       result = iterate(od, state)
       end
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (1, 0), (2, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (1, 0), (3, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (1, 0), (4, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (1, 0), (5, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (1, 0), (6, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (2, 0), (1, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (2, 0), (2, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (2, 0), (3, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (2, 0), (4, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (2, 0), (5, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (2, 0), (6, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 1), (0, 0), (0, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (1, 0), (2, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (1, 0), (3, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (1, 0), (4, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (1, 0), (5, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (1, 0), (6, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (2, 0), (1, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (2, 0), (2, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (2, 0), (3, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (2, 0), (4, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (2, 0), (5, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (2, 0), (6, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((1, 0), (0, 0), (0, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (1, 3))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (1, 4))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (1, 5))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (1, 6))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (2, 3))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (2, 4))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (2, 5))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (2, 6))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (3, 4))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (3, 5))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (3, 6))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (4, 5))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (4, 6))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (1, 2), (5, 6))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((0, 2), (0, 0), (0, 0))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((2, 0), (1, 2), (1, 3))
Rimu.Hamiltonians.MolecularHamiltonianOffDiagonalsIteratorState((2, 0), (1, 2), (1, 4))
...This was for the h2_dual Hamiltonian and offdiagonals from the starting address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few quick comments on the formula in the docstring. I see that some tests are failing so I leave that before I review the code again.
b485cab    to
    61e1337      
    Compare
  
    Add initial skeleton implementation for MolecularHamiltonian type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more comments from me.
It would be good to have the unexported docstrings show up in Documenter as well.
Finally, please check the Codecoverage report, as parts of the Molecular.jl code are not tested currently. Please either add tests, or delete the code if it is obsolete!
| # ```julia | ||
| # s = solve(p) | ||
| # ``` | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should warn here that this may require larger computational resources.
I'm actually not sure what exactly happens and why this seems to stall. solve(p; full_basis=true) seems a good idea, as initialising the LinearOperator is done much faster (12s on my laptop), but the matrix-vector multiplications seem to stall. We can deal with this later, though, as I don't think it is an issue related to this PR.
| df = DataFrame(result); | ||
|  | ||
| # To analyse the energy shift, we can use [`shift_estimator`](@ref). | ||
| se = shift_estimator(df; skip=steps_equilibrate) No newline at end of file | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a bit of interpretation here, i.e. that the mean is an estimator for the energy. Also explain that and why you used the initiator and what this means for the energy estimate.
1. Improve the document. 2. Remove obsolete code.
7a9206f    to
    072e1f6      
    Compare
  
    072e1f6    to
    477499e      
    Compare
  
    Make ElemCo an optional dependency through a package extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice progress 👍
The package extension mechanism seems to work well.
See comments below, mostly for readability and documentation.
This should be ready to be merged any time.
Don't forget to change the status from Draft to Ready!
| function MolecularHamiltonian( | ||
| fcidump_path::String, | ||
| starting_address::Union{Nothing,FermiFS2C}=nothing, | ||
| specifier::String="", | ||
| ) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string that is printed at the REPL currently does not parse as a valid constructor:
julia> h = MolecularHamiltonian(fcidump)
MolecularHamiltonian("/Users/brand/git/code/Rimu/test/examples/h2o.FCIDUMP", starting_addresss=fs"|⇅⇅⇅⇅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⟩")
julia> h == MolecularHamiltonian("/Users/brand/git/code/Rimu/test/examples/h2o.FCIDUMP", starting_addresss=fs"|⇅⇅⇅⇅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⟩")
ERROR: MethodError: no method matching MolecularHamiltonian(::String; starting_addresss::FermiFS2C{4, 4, 23, 8, FermiFS{…}, FermiFS{…}})
This method may not support any kwargs.
Closest candidates are:
  MolecularHamiltonian(::String) got unsupported keyword argument "starting_addresss"
   @ Rimu ~/git/code/Rimu/src/Hamiltonians/Molecular.jl:46
  MolecularHamiltonian(::String, ::Union{Nothing, FermiFS2C{N1, N2, M} where {N1, N2, M}}) got unsupported keyword argument "starting_addresss"
   @ Rimu ~/git/code/Rimu/src/Hamiltonians/Molecular.jl:46
  MolecularHamiltonian(::String, ::Union{Nothing, FermiFS2C{N1, N2, M} where {N1, N2, M}}, ::String) got unsupported keyword argument "starting_addresss"
   @ Rimu ~/git/code/Rimu/src/Hamiltonians/Molecular.jl:46
  ...This can be fixed by making the optional arguments keyword arguments:
| function MolecularHamiltonian( | |
| fcidump_path::String, | |
| starting_address::Union{Nothing,FermiFS2C}=nothing, | |
| specifier::String="", | |
| ) | |
| function MolecularHamiltonian( | |
| fcidump_path::String; | |
| starting_address::Union{Nothing,FermiFS2C}=nothing, | |
| specifier::String="", | |
| ) | 
If you make this change, please update the docstring such that it is accurate!
I'd also like to see this tested, e.g. by adding something like this to the tests:
            @test eval(Meta.parse(repr(H))) == HObviously, this only works when constructing from a path, and when the path is still available and accurate.
Update: I notice that for this to work you may need to define a method for isequal for the TFDump struct. This can be done in the package extension (or ideally as a PR to ElemCo.jl, as otherwise it would be type piracy 😄) .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea!
1. Improve `MolecularHamiltonian` constructor. 2. Rename functions calculating diagonal term. 3. Fix document display error. 4. Improve imath equation for clarity under REPL. 5. Improve method `unrank_combination` document.
1. Fix the test of `MolecularHamiltonian`. 2. Fix the typo in documents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to get the formulas right in the documentation. Otherwise this is looking good.
Improve the docstring of `MolecularHamiltonian`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the latest updates and for the big effort that went into this project! The PR looks good now and is ready be merged 🚀
New features
This PR addresses issue #321 by introducing the
MolecularHamiltoniantype along with its related types and methods. These additions enableRimu.jlto be used for post–Hartree-Fock calculations in quantum chemistry research accompanied withElemCo.jl.A detailed description to the PR could be find at #348 .