Skip to content

Commit

Permalink
Clean up (#61)
Browse files Browse the repository at this point in the history
* Feature/GitHub actions (#5)

* first try of GitHub Actions

* go simpler this time

* trying to fix MPI error

* testing mpi

* separate stage mpi install

* fix

* install openmpi-dev

* try again

* testing now works, try documentation now

* new file for documentation

* install mpi for docs

* host everything on GitHub

* using default deploydocs

* fix repo

* remove workaround

* branches

* ok devbranch

* try deploying doc to my own repo

* try again with TRAVIS_REPO_SLUG

* fix typos

* DOCUMENTER_KEY

* deploy to Rimu.jl now

* fix wrong repo

* remove DOCUMENTER_KEY

* final commit

* added an example calculation with BHM with detailed descriptions

* added a new mpi example script, the old one is bit outdated

* updated documentation, still more to cover

* minor changes

* trying to fix source code not found

* temporarily changes devbranch to this branch for testing

* don't need repo in makedocs for github

* trying to fix failed doctests

* added logo

* added an exmaple page in the documentation, let's see how that looks

* modified index.md

* set a hiden r_strat in BHM-example.jl to skip writeinfo

* added RNG seed; fixed index.md

* removed "et" from FCIQMC loop

* added preview

* updated Documenter.jl in Manifest.toml

* final commit, change devbranch back to "develop"

* test out the workaround with @doc for source links in the documentation

* temporarily switch devbranch to current branch

* source links to docstrings working now, switch devbranch back

* expand run test on all feature/**, and doc for feature/doc-** branches

* fixed typos

* fixed typos in example scripts

* updated example doc

* changes as requested in review

* comment out OvershootControl

* updated install links

* devbranch for docs changed back to default master

* automate devbranch for deploydocs, testing

* now it should deploy the documentation

* remove feature/doc** for deployment

* updated the MPI section in index.md (#6)

Documentation update only.

* Bugfix/compatj1.5 (#7)

* changed == to === for comparison with nothing

* fix a vector return bug in fciqmc! 

the bus could cause the wrong coefficient vector to be returned

* fixed the tests to run with v1.5 as well as with earlier versions

Random selections from a collection changed in Julia v1.5, which made it 
necessary to change all tests that depend on spawning events.

* changed Julia version for workflows testing to latest

* run CI on push to bugfix branches

* fixed wrong version spec

* Feature/momspacebhchain (#8)

* new function numSandDoccupiedsites()

* started implementing BoseHubbardMom1D

removed superfluous code in Hamiltonians.jl;
added missing methods for numSandDoccupiedsites();
added method for numOfHops()

* added hop() and tests

* BoseHubbardMom1D is now complete and exported
beware of bugs!!!
Added diagME() for momentum space
added tests for BoseHubbardMom1D, also  in lomc!()

* add Momentum and rayleighQuotient()

* tests for Momentum and rayleighQuotient()

* fix modulo bug in momentum calculation

* fixed bugs in BoseHubbardMom1D,
numOfHops() and hops()
fixed tests

* renamed LinearOperator to AbstractHamiltonian

* slashed some bugs in BoseHubbardMom1D

* added the unexported build_sparse_matrix_from_LO()
renamed rayleigh_quotient()

* fixed and expanded tests in set BoseHubbardMom1D

* introduce nearUniformONR()
rename nearUniform(n,m) -> onr to nearUniformONR(),
keep nearUniform() for BoseFS and BosonicHamiltonian

* made address type a parameter in BoseHubbardMom1D

* cosmetic change

* fix test

* fix a docstring typo

* updated documentation for BoseHubbardMom1D

* Feature/two norm (#10)

* added `NoProjectionTwoNorm`
as a new `ProjectionStrategy`

* fix test on Julia v1.4

* added CI test with Julia v1.4

* fix workflow actions file

* change workflows to test on Julia 1.5.2

* added Norm2Projector()

* improve doc string

* Bugfix/annihilation stochastic threshold (#11)

* fixed sign bug in fciqmc_col() for
IsStochasticWithThreshold
need to fix broken tests

* fixed tests and docstring ProjectedMemory

* Feature/delayed-double-log-update (#12)

* added DelayedDoubleLogUpdate shift strategy; fixed some typos

* added DelayedDoubleLogUpdateAfterTW strategy

* corrected docstrings

* Feature/deltanoise (#13)

* introduced DeltaMemory3

* add @setThreshold and @setDeterministic

* removed wrong comment

* add missing method for BoseFS

* added growthWitness() and test

* modified tests

* fix broken test

* improved @setThreshold, @setDeterministic, new function setThreshold90
added tests

* constructors with keyword `capacity` for DVec, DFVec and FastDVec

* make NormProjector() and Norm2Projector() faster
Projection of Hamiltonian is now ommitted when specifying these 
projectors.

* Add scientific paper references

* formatting fix

* Another formatting fix

* bump version

* Feature/deltanoise (#15)

* introduced DeltaMemory3

* add @setThreshold and @setDeterministic

* removed wrong comment

* add missing method for BoseFS

* added growthWitness() and test

* modified tests

* fix broken test

* improved @setThreshold, @setDeterministic, new function setThreshold90
added tests

* constructors with keyword `capacity` for DVec, DFVec and FastDVec

* make NormProjector() and Norm2Projector() faster
Projection of Hamiltonian is now ommitted when specifying these 
projectors.

* yet another formatting fix

* define adjoint of Hamiltonian and missing*dv

* towards faster projected energy

* improve adjoint of AbstractHamiltonian, document `h_adjoint()`

* Introduce `AbstractProjector` supertype.

* fix bug

* new exported function copytight()

* add tests for copytight()

* Rework ReportingStrategy for faster calculation of projected energy
ReportingStrategy types now contain two projector fields
new external dependency Setfield
new unexported Rimu.refine_r_strat

* commment only

* testset "ReportingStrategy internals"

* remove spurious method

* fix bug in tests

* fix compatibility with Julia v1.4

* replace ks() by faster version

* BitstringAdresses.i_onr() fast and non-allocating
internal OccupationNumberIterator
single argument onr() returns SVector{M,Int32}

* faster diagME() for BoseHubbardMom1D

* fix test and bug

* new faster Hamiltonian HubbardMom1D() with tests

* return Tuple from fciqmc_col!()
to avoid allocation time identified by profiling

* extended Hops to take another field; faster Hops for HubbardMom1D

* remove allocations using Setfield.jl
new unsafe_shift_left() in BitStringAddresses and hop() for HubbardMom1D
fciqmc_col!() with HubbardMom1D is now non-allocating

* bump version number

* update package versions

* removed reference counting to be compatible with MPI.jl v0.16.0
updated package dependencies for Rimu and Rimu/test and Rimu/docs

* Bugfix/GitHub actions (#16)

* added env variable

* try @latest for actions/checkout and setup-julia

* @latest does not work, try @v2 and @v1

* Feature/embarrassinglydistributed (#18)

* make `autoblock()` handle missing values

* new module EmbarrassinglyDistributed with 4 functions

* remove tests for old julia version

* added comments to document unit test

* part 2

* improve docstrings

* update julia version for docummenter

* Feature/BoseFS2C (#19)

* introduced DeltaMemory3

* add @setThreshold and @setDeterministic

* removed wrong comment

* add missing method for BoseFS

* added growthWitness() and test

* modified tests

* fix broken test

* improved @setThreshold, @setDeterministic, new function setThreshold90
added tests

* constructors with keyword `capacity` for DVec, DFVec and FastDVec

* make NormProjector() and Norm2Projector() faster
Projection of Hamiltonian is now ommitted when specifying these 
projectors.

* yet another formatting fix

* define adjoint of Hamiltonian and missing*dv

* towards faster projected energy

* improve adjoint of AbstractHamiltonian, document `h_adjoint()`

* Introduce `AbstractProjector` supertype.

* fix bug

* new exported function copytight()

* add tests for copytight()

* Rework ReportingStrategy for faster calculation of projected energy
ReportingStrategy types now contain two projector fields
new external dependency Setfield
new unexported Rimu.refine_r_strat

* commment only

* testset "ReportingStrategy internals"

* remove spurious method

* fix bug in tests

* fix compatibility with Julia v1.4

* replace ks() by faster version

* BitstringAdresses.i_onr() fast and non-allocating
internal OccupationNumberIterator
single argument onr() returns SVector{M,Int32}

* BoseFS2C for bsa and bsb with same type only

* BoseFS2C works with different types of BitStringAddressType now

* BoseFS2C works with onr now

* BoseFS2C from two BoseFS

* faster diagME() for BoseHubbardMom1D

* fix test and bug

* new faster Hamiltonian HubbardMom1D() with tests

* return Tuple from fciqmc_col!()
to avoid allocation time identified by profiling

* reorganising code blocks

* added benchmark functions BoseFS2C_, will remove later

* extended Hops to take another field; faster Hops for HubbardMom1D

* remove allocations using Setfield.jl
new unsafe_shift_left() in BitStringAddresses and hop() for HubbardMom1D
fciqmc_col!() with HubbardMom1D is now non-allocating

* bump version number

* update package versions

* BoseFS2C type stable version; start coding BoseHubbard2CMom1D

* Hops works with BoseFS2C; fciqmc also seems working fine in real space

* fixed function orders

* fixed BH2Cinteraction

* BoseHubbard2CMom1D but missing interaction2c

* fixed numOfHops for BH2CMom1D

* trying to correct diagME

* very ugly code for hop(h::BH2CMom1D, add::BoseFS2C, chosen), but works

* an example file for testing

* update comments

* attempts to fix ham

* fixed hopacross2adds

* added BoseHubbardMom1D2C for benchmarking

* fixed diagME, now getting correct energy

* everything seems working correctly now

* updated docstrings

* new subtype TwoComponentBosonicHamiltonian

* changing code order; fixed typos

* added testsets for BoseFS2C and TwoComponentBosonicHamiltonian

* export TwoComponentBosonicHamiltonian, fixed docstrings

* fxied typos

* fixing problems for pull request

* type unstable version of BoseFS2C()

* removed add from BoseHubbardMom1D2C, added m; code much faster

* added Bose.show() for BoseFS2C

* updated docstring

* more docstring change

* removed unnecessary fields from real and mom BH1d2C

* now V is a type param for both Real and Mom 1D2C ham

Co-authored-by: Joachim Brand <j.brand@massey.ac.nz>

* fixing type parameter for HubbardMom1D (#20)

* Fix problem with reverse in `BoseFS` constructor. (#21)

* Fix weird performance problem with reverse.

Julia wasn't happy with `reverse(onr)`. This problem is not there on the Julia `master`
branch, but it exists on 1.5 and 1.6.

* Apply fix to other constructors as well.

* Feature/complexnoise (#23)

* introduced variable type shift and norm

* fixed bugs and introduced test

* changed order of arguments in norm_project()

* changed norm_project!() to four-argument call structure and updated docs

* add cRandn() and ComplexNoiseCancellation

* preparing for complex noise
MPI sync/broadcast of complex noise; bug fix in ComplexNoiseCancellation
Prepare fciqmc!, fciqmc_step!, fciqmc_col! and applyMemorynoise! for 
complex coefficients
new testset ComplexNoiseCancellation

* fixed bugs, better error message with ComplexNoiseCancellation
extended testset

* gW() new version of growth witness

* prepare Blocking for complex data

* sensible and compile-time evaluated defaults for StochasticStyle
make DoubleLogUpdate a parametric type

* new function `walkernumber` generalising the one-norm for complex walkes

* new StocjasticStyle `IsStochastic2Pop`
new `walkernumber(w)` to replace norm(w,1) dispatching on 
StochasticStyle.
intro fciqmc_col(::IsStochastic2Pop,...) but not tested yet.

* replace for loop by mapreduce() in fciqmc_step!()

* precalculating type of stats by running fciqmc_step!() once
runtests.jl now fails because of rng.

* fixed tests and remove testing version < v1.5

* added preliminary testset for complex walkers
spawning for IsStochastic2Pop still seems to be buggy as results are not 
sensible

* fixed bug in using imaginary part of shift

* unexported function purge_negative_walkers!()
needs to be generalised for mpi and threading

* new MemoryStrategy PurgeNegatives()

* IsStochastic2PopInitiator() and IsStochastic2PopWithThreshold()
The trait IsStochastic2PopWithThreshold is introduced but the relevant 
methods are still missing.

* improve multithreading
fixed multithreading for complex walkers
more efficient threading algorithm using SpittablesBase and added other 
algorithms using ThreadsX (currently not used)
consolitdated non-threaded fciqmc_step!() for use with and without MPI

* fix tests
test in "fciqmc with BoseFS" of multithreaded code was updated with new 
values after code has changed

* replace sync_MPI_cRand() with sync_cRand() defined in ConsistentRNG

* Make CRNGs be seeded at runtime when module loads
CRNGs now becomes Ref on a vector of of RNGs; length is decided by 
Threads.nthreads() at runtime.

* trying to fix DataFrames dependency bug

* Add module RimuIO for saving DataFrames in Arrow format files.

* add consistency and sanity checking during RNG seeding
check_crng_independence(v) for doing a one-off sanity check

* MPI rework 1: moving MPI functionality into module RMPI
needs more tests

* Load but do not export RMPI.

* new function mpi_seed_CRNGs!()

* rename save and load into save_df and load_df

* add mpi example script and use it for testing mpi;
fix small bug in fciqmc

* clean up

* fix Julia using system installed MPI

* free DataFrames and cleanup Project.toml and actions

* new function smoothen();
also fixed buf in gW.

* fix GMTest of EmbarrassinglyDistributed

* don't re-export Distributed; replace `mapreduce` -> `sum`

* fixes after PR review.
Removed extraneous using statment. Renamed `my_stats` into 
`combine_stats`. Replaced `reduce` and `mapreduce` with more descriptive 
`sum` and `all`.

* New DVec tests (#22)

* Implement test suite for `AbstractDVec` interface

* fix docstring

* Add KrylovKit tests

* Move other DFVec tests to DictVectors.jl

* Add test for BoseFS, formatting

* Delete Manifests (#26)

* Add coverage to Github action (#25)

* add code coverage tracking

* fix action

* change version to 1.5 so the latest 1.5.x gets used

* fix coveralls part

* DVec2 (#24)

* Move stochastic styles to DictVectors

* Clean up DVec and interface

* Apply cleanup to DFVec and FastDVec

* DVec2 implementation and tests

* move things around

* minor formatting and commented code removal
* change `ADV*Iterators` to `FDV*Iterators` as they are `FastDVec` specific

* more generic functions

* improve test coverage

* fix problems from review

* Unexport experimental `StochasticStyle` types.
Remove references in docstrings to the unexported features.
`IsStochasticNonlinear`
`IsStochastic2Pop`
`IsStochastic2PopInitiator`
`IsStochastic2PopWithThreshold`
`IsSemistochastic`

Co-authored-by: Joachim Brand <j.brand@massey.ac.nz>

* CI Benchmarking (#27)

* add benchmarks

* add benchmark action

* tweak numbers to prevent capacity overflow and get consistent timings

* update benchmarks (#32)

* Fix LOStructure for BoseHubbardReal1D2C (#33)

* Bugfix/gh actions mpi (#34)

* debug test first

* change JULIA_MPIEXEC=mpiexec

* change MPI test to print hello only

* try mpirun

* more debug

* Pkg.add("MPI")

* try running from bash

* test again

* test

* run mpi test outside julia

* using @__DIR__ for mpi_df.arrow

* test output file

* move things around

* add @. for julia mpi

* run single core julia first

* change openmpi version to 2.1.1

* change openmpi version to 2.1.1-8

* version again

* version policy

* do not apt update

* using native julia MPI

* using MPi

* export PATH

* fix PATH

* remove MPI installation

* run MPI in julia

* fix

* undo previous fix

* fix $OUTPUT_FILE var

* clean up

* Bugfix/gh actions mpi (#35)

* debug test first

* change JULIA_MPIEXEC=mpiexec

* change MPI test to print hello only

* try mpirun

* more debug

* Pkg.add("MPI")

* try running from bash

* test again

* test

* run mpi test outside julia

* using @__DIR__ for mpi_df.arrow

* test output file

* move things around

* add @. for julia mpi

* run single core julia first

* change openmpi version to 2.1.1

* change openmpi version to 2.1.1-8

* version again

* version policy

* do not apt update

* using native julia MPI

* using MPi

* export PATH

* fix PATH

* remove MPI installation

* run MPI in julia

* fix

* undo previous fix

* fix $OUTPUT_FILE var

* clean up

* checks if tests run locally

* BitStringAddresses cleanup (#28)

* reogranize benchmarks, move MPI tests to the end

* benchmark updates

* move BitStringAddress code around, remove BStringAddress

* implement interface for BSAdd*

* Use the interface with BSAdd where applicable

* add `chunks`

* rename some functions and types, tests

* fix interfaces, code reordering

* remove maxBSLength, fix Base.:~

* add specialized onr function, remove s_onr

* formatting, remove bitaddr

* optimize numberoccupiedsites

* optimize bosehubbardinteraction

* clean up and document implementations

* hopnextneighbour improvement: better bit masks

* implement occupied_orbitals iterator

* implement numSandDoccupiedsites, hopnextneighbour and bosehubbardinteraction

* fix hopnextneighbour

* Add BitString

* fix tests and bugs

* remove abstract.jl, typos

* tweaks, remove unused imports

* hardcode UInt64, remove x_bit_mask

* docstring tweaks, export reordering

* fix test that sometimes fails due to choice of random bitstring

* change BitString `show` method

* remove unnecessary if statement, tweak tests

* remove bitstring-specific functions from BoseFS

* use new benchmarks

* simplify KrylovKit test

* Hamiltonians (#36)

* add HubbardReal1D, ExtendedHubbardReal1D, refactor HubbardMom1D constructor

* rework dimension, add starting_address, rename Momentum, remove Bosonic abstract types

* implement AbstractHops

* add num_modes for hamiltonians, change HubbardMom1D

* reorder type parameters, tweak `show`

* implement specialized hops for Mom1D2C, Real1D2C

* more tests, fix isless and nearUniform for addresses

* remove unnecessary `@with_kw`

* code organization and docstrings

* rename `hops`, `diagME` and related functions

* HubbardReal1D in benchmarks

* dont remove ghost bits in usigned right shift

* remove unused benchmarks

* Julia 1.6 compatibility (#38)

* Julia 1.6 compatibility

* Fix bug with dict allocation

* Fix numbers again

* Remove Rimu from test Project.toml (#39)

* Fix Hubbard momentum-space diagonal elements (#41)

* Add missing t factor to diagonal elements in HubbardMom1D

* Move formula and code around, add tests

* Importance Sampling (#37)

* implement importance sampling

* rename to gutzwiller, add new `LOStructure`

* implement adjoint, a `LOAdjoint` trait, use said trait in refine_r_strat

* merge `LOStructure` and `LOAdjoint`. Rename `HermitianLO` to `Hermitian` for consistency

* use new function names

* remove diagMEs

* remove hops in tests

* Implement GuidingVectorSampling

* improve tests

* docstrings and minor improvements

* remove rogue HermitianLO

* fix `\\tilde`s

* Fix bug with wrong order, improve docstrings.

* Simplify offdiagonal code

* simd sum (#42)

* fixed definition of kinetic energy (#43)

* Fix bug with empty reduce error (#44)

* Fix bug with empty reduce error

* Rework fix with allocate_statss

* Use new ArrowTypes interface (#46)

* Rework RMPI directory structure (#50)

* Bugfix/mpi one sided with buffers (#51)

* use Buffer interface with one-sided communication protocol.
Needs `MPI.jl#master`!

* add tests for new MPI version

* fix package spec

* make actions test new mpi scripts

* fix another bug

* make compatible with develop branch

* MPI updates (#45)

* MPI without memory leak

* Split RMPI to directory

* add async strategy

* try slightly different exchange

* Remove async, add all_to_all

* docstrings, faster sorting

* Add barrier

* optimize sorting

* better sort for alltoall

* set default strategy to point-to-point

* Rename mpi_default to point_to_point in test

* Feature/fciqmc files (#52)

* let git ignore vscode config files

* split fciqmc.jl into multiple files;
use user installed julia executable if available

* add newline to .gitignore

* New `StochasticStyle` (#54)

* Implement new stochastic style

* Fixes

* fix diagonal step

* undo fix diagonal step

* Create new style for comparison

* Fix errors in new style

* Add docstring to and unexport `IsStochasticWithThresholdAndInitiator`

* Initiator docstring

* Fix unexporting

* Fix `IsStochasticWithThresholdAndInititator`, add basic tests (#55)

* Fix `IsStochasticWithThresholdAndInititator`, add basic tests

* fix broken test

* Feature/stats tools (#56)

Note: After merging this PR, functions from `Blocking.jl` are no longer re-exported by `Rimu`. To access data analysis feature in scripts use
```
using Rimu, Rimu.StatsTools
```
or, to use the old features from `Blocking.jl`
```
using Rimu, Rimu.Blocking
```

* stop reexporting Blocking, include StatsTools

* fix Blocking tests

* new module StatsTools

* add DataFrames dependency

* update Project.toml

* style

* add @inbounds

* fix tests actually

* `smoothen()` now preserves mean and wraps periodically; 
remove kwarg `pad`

* add tests for `StatsTools`

* add blocking and ratio estimators to StatsTools;
TODO: tests

* rename block_inplace! to blocker!

* tests for blocking.jl

* use Parameters

* ratio_of_means()

* docstring for RatioBlockingResult

* fix blocking for complex time series;
TODO: tests

* fix errors

* doc string change

* blocks field in BlockingResult; show method; docstrings

* fix passing through significance levels

* clean up

* remove Parameters.jl from StatsTools

* fix up ratio_of_means(), add tests

* towards ratio_of_means() for complex time series; WIP

* show() method for complex ratio_of_means, new tests

* fix dependencies

* fix module import

* fix again

* rename block_and_test() -> blocking_analysis(); new mean_and_se()
fix \pm methods, median for comples, add tests

* undo changes to Blocking; remove StructArrays dependency

* test that show methods run without error

* `AbstractMatrix` Hamiltonian fix (#57)

* `AbstractMatrix` Hamiltonian fix

* fix fciqmc_col! for matrix and vector; 
test matrix lomc! against Hamiltonian lomc!

Co-authored-by: Joachim Brand <j.brand@massey.ac.nz>

* Feature/matrix hamiltonian (#58)

* `AbstractMatrix` Hamiltonian fix

* fix fciqmc_col! for matrix and vector; 
test matrix lomc! against Hamiltonian lomc!

* remove restriction to AbstractFockAddress in AbstractOffDiagonals

* New wrapper MatrixHamiltonian for using abstract matrices for fciqmc.
TODO: write tests

* add LOStructure for MatrixHamiltonian;
move tests to test/Hamiltonians.jl

* remove starting address test;
pass through dimension of importance sampled Hamiltonian

Co-authored-by: mtsch <matijacufar@gmail.com>

* Feature/cleanup stochastic styles (#59)

* cleaning up unused StochasticStyles

* fix errors

* more cleanup

* faster integerization in integer walker fciqmc

* even more cleanup

* DoubleLogSumUpdate

* PopsProjector()  for CW

* NoProjectionAccumulator <: ProjectStrategy

fix test for NoProjectionAccumulator

* New `Norm1ProjectorPPop` for `dot`;

added test; norm projectors now return floats

* Update replica fciqmc!;

Allow for complex walkers; report projectors; make xHy optional

* replay changes to replica `fciqmc!()`

* replay changes to `norm_project!()`
add method for `NoProjectionAccumulator`

* fix bugs in fciqmc_col!

* fix compile and test errors

Co-authored-by: Ray Yang <mingrui.yang@outlook.com>
Co-authored-by: mtsch <matijacufar@gmail.com>
  • Loading branch information
3 people authored May 13, 2021
1 parent 5c52287 commit 7a58a8d
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 473 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@ Scientific papers using the `Rimu` code:
- "Stochastic differential equation approach to understanding the population control bias in full configuration interaction quantum Monte Carlo", J. Brand, M. Yang, E. Pahl, [arXiv:2103.07800](http://arxiv.org/abs/2103.07800) (2021).
- "Improved walker population control for full configuration interaction quantum Monte Carlo", M. Yang, E. Pahl, J. Brand, [*J. Chem. Phys.* **153**, 170143 (2020)](https://doi.org/10.1063/5.0023088); DOI: 10.1063/5.0023088; [arXiv:2008.01927](https://arxiv.org/abs/2008.01927).

**References:**
The code implements the FCIQMC algorithm described in
- "Fermion Monte Carlo without fixed nodes: A game of life, death, and annihilation in Slater determinant space", G. H. Booth, A. J. W. Thom, A. Alavi, [*J. Chem. Phys.* **131**, 054106 (2009)](https://doi.org/10.1063/1.3193710).

Scientific papers using the `Rimu` code:
- "Improved walker population control for full configuration interaction quantum Monte Carlo", M. Yang, E. Pahl, J. Brand, [*J. Chem. Phys.* **153**, 170143 (2020)](https://doi.org/10.1063/5.0023088); DOI: 10.1063/5.0023088; [arXiv:2008.01927](https://arxiv.org/abs/2008.01927).

For more information, consult the [documentation](https://joachimbrand.github.io/Rimu.jl/dev/).
1 change: 1 addition & 0 deletions src/DictVectors/DictVectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using ..FastBufs

export AbstractDVec, capacity, zero!, kvpairs, pairtype, add!, copytight
export AbstractProjector, NormProjector, Norm2Projector, UniformProjector
export Norm1ProjectorPPop
export DVec, DVec2
export DFVec, tuples, gettuple, flagtype, flags
export FastDVec
Expand Down
43 changes: 42 additions & 1 deletion src/DictVectors/abstractdvec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ LinearAlgebra.dot(::UniformProjector, y::DVecOrVec) = sum(y)
Results in computing the one-norm when used in `dot()`. E.g.
```julia
dot(NormProjector(),x)
-> norm(x,1) # with type valtype(x)
-> norm(x,1)
```
`NormProjector()` thus represents the vector `sign.(x)`.
Expand Down Expand Up @@ -386,3 +386,44 @@ struct Norm2Projector <: AbstractProjector end
LinearAlgebra.dot(::Norm2Projector, y::DVecOrVec) = norm(y,2)
# NOTE that this returns a `Float64` opposite to the convention for
# dot to return the promote_type of the arguments.

"""
Norm1ProjectorPPop()
Results in computing the one-norm per population when used in `dot()`. E.g.
```julia
dot(Norm1ProjectorPPop(),x)
-> norm(real.(x),1) + im*norm(imag.(x),1)
```
See also [`ReportingStrategy`](@ref) for use
of projectors in FCIQMC.
"""
struct Norm1ProjectorPPop <: AbstractProjector end

function LinearAlgebra.dot(::Norm1ProjectorPPop, y::DVecOrVec)
T = float(valtype(y))
return isempty(y) ? zero(T) : sum(p->abs(real(p)) + im*abs(imag(p)), y)|>T
end

# NOTE that this returns a `Float64` opposite to the convention for
# dot to return the promote_type of the arguments.
# NOTE: This operation should work for `MPIData` and is MPI synchronizing

"""
PopsProjector()
Results in computing the projection of one population on the other
when used in `dot()`. E.g.
```julia
dot(PopsProjector(),x)
-> real(x) ⋅ imag(x)
```
See also [`ReportingStrategy`](@ref) for use
of projectors in FCIQMC.
"""
struct PopsProjector <: AbstractProjector end

function LinearAlgebra.dot(::PopsProjector, y::DVecOrVec)
T = float(real(valtype(y)))
return isempty(y) ? zero(T) : sum(z -> real(z) * imag(z), y)|>T
end
75 changes: 0 additions & 75 deletions src/DictVectors/stochasticstyle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,6 @@ walkers.
"""
struct IsStochastic2Pop <: StochasticStyle end

"""
IsStochastic2PopInitiator()
Trait for generalised vector of configurations indicating stochastic
propagation with complex walker numbers representing two populations of integer
walkers. Initiator algorithm will be used.
"""
struct IsStochastic2PopInitiator <: StochasticStyle end

"""
IsStochastic2PopWithThreshold(threshold::Float32)
Trait for generalised vector of configurations indicating stochastic
propagation with complex walker numbers representing two populations of real
walkers and cutoff `threshold`.
```
> StochasticStyle(V) = IsStochastic2PopWithThreshold(threshold)
```
During stochastic propagation, walker numbers small than `threshold` will be
stochastically projected to either zero or `threshold`.
The trait can be conveniently defined on an instance of a generalised vector
with the function [`setThreshold`](@ref). Example:
```julia-repl
julia> dv = DVec(nearUniform(BoseFS{3,3}) => 2.0+3.0im; capacity = 10)
julia> setThreshold(dv, 0.6)
julia> StochasticStyle(dv)
IsStochastic2PopWithThreshold(0.6f0)
```
"""
struct IsStochastic2PopWithThreshold <: StochasticStyle
threshold::Float32
end

struct IsStochasticNonlinear <: StochasticStyle
c::Float64 # parameter of nonlinear correction applied to local shift
end

"""
IsDeterministic()
Expand Down Expand Up @@ -102,19 +67,6 @@ struct IsStochasticWithThreshold <: StochasticStyle
threshold::Float32
end

"""
IsSemistochastic(threshold::Float16, d_space)
Trait for generalised vector of configurations indicating semistochastic
propagation. Set with [`setSemistochastic!`](@ref).
```
> StochasticStyle(V) = IsSemistochastic(threshold, d_space)
```
where `d_space` is a vector of addresses defining the the stochastic subspace.
"""
struct IsSemistochastic{T} <: StochasticStyle
threshold::Float16
d_space::Vector{T} # list of addresses in deterministic space
end

"""
IsDynamicSemistochastic
Expand Down Expand Up @@ -164,33 +116,6 @@ Base.@kwdef struct IsStochasticWithThresholdAndInitiator<:StochasticStyle
proj_threshold::Float64 = 1.0
end

"""
setSemistochastic!(dv, threshold::Float16, d_space)
Set the deterministic space for `dv` with threshold `threshold`, where
`d_space` is a vector of addresses defining the the stochastic subspace.
"""
function setSemistochastic!(dv, threshold::Float16, d_space)
clearDSpace!(dv)
for add in d_space
(val, flag) = dv[add]
dv[add] = (val, flag | one(typeof(flag)))
end
StochasticStyle(dv) = IsSemistochastic(threshold, d_space)
dv
end

"""
clearDFlags!(dv)
Clear all flags in `dv` of the deterministic bit (rightmost bit).
"""
function clearDFlags!(dv)
for (add, (val, flag)) in pairs(dv)
# delete deterministic bit (rightmost) in `flag`
dv[add] = (val, flag one(typeof(flag)))
end
dv
end


###
### Style setting Macros
Expand Down
Loading

0 comments on commit 7a58a8d

Please sign in to comment.