-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interface tests - remove two component models (#299)
# Remove legacy two-component address type and models This PR removes the address type `BoseFS2C`, which has been superseded by `CompositeFS` and model Hamiltonians that depend on it. A new package [`RimuLegacyHamiltonians.jl`](https://github.com/RimuQMC/RimuLegacyHamiltonians.jl) has been created to house this functionality. ## Breaking changes - remove `BoseFS2C`, `BoseHubbardMom1D2C`, `BoseHubbardReal1D2C` ## New features - new module `Rimu.InterfaceTests` with functions - `test_observable_interface` - `test_operator_interface` - `test_hamiltonian_interface` - `test_hamiltonian_structure` ## Documentation changes - The previous page on the `Hamiltonians` module in the "Developer Documentation" has been split into "Hamiltonians" and "Custom Hamiltonians" and moved into the "User Documentation" - various minor changes to the documentation and docstrings, including additional links. --------- Co-authored-by: mtsch <matijacufar@gmail.com>
- Loading branch information
1 parent
3a99de5
commit 5f48b35
Showing
29 changed files
with
578 additions
and
1,055 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,110 @@ | ||
# Advanced operator usage and custom Hamiltonians | ||
|
||
`Rimu` can be used to work with custom Hamiltonians and observables that are user-defined and | ||
not part of the `Rimu.jl` package. To make this possible and reliable, `Rimu` exposes a number | ||
of interfaces and provides helper functions to test compliance with the interfaces through the | ||
submodule [`Rimu.InterfaceTests`](@ref), see [Interface tests](@ref). This section covers the | ||
relevant interfaces, the interface functions as well as potentially useful helper functions. | ||
|
||
In order to define custom Hamiltonians or observables it is useful to know how the operator | ||
type hierarchy works in `Rimu`. For an example of how to implement custom Hamiltonians that | ||
are not part of the `Rimu.jl` package, see | ||
[`RimuLegacyHamiltonians.jl`](https://github.com/RimuQMC/RimuLegacyHamiltonians.jl). | ||
|
||
## Operator type hierarchy | ||
|
||
`Rimu` offers a hierarchy of abstract types that define interfaces with different requirements | ||
for operators: | ||
```julia | ||
AbstractHamiltonian <: AbstractOperator <: AbstractObservable | ||
``` | ||
The different abstract types have different requirements and are meant to be used for different purposes. | ||
- [`AbstractHamiltonian`](@ref)s are fully featured models that define a Hilbert space and a linear operator over a scalar field. They can be passed as a Hamiltonian into [`ProjectorMonteCarloProblem`](@ref) or [`ExactDiagonalizationProblem`](@ref). | ||
- [`AbstractOperator`](@ref) and [`AbstractObservable`](@ref) are supertypes of [`AbstractHamiltonian`](@ref) with less stringent conditions. They are useful for defining observables that can be used in a three-way `dot` product, or passed as observables into a [`ReplicaStrategy`](@ref) that can be inserted with the keyword `replica_strategy` into a [`ProjectorMonteCarloProblem`](@ref). | ||
|
||
## Hamiltonians interface | ||
|
||
Behind the implementation of a particular model is a more abstract interface for defining | ||
Hamiltonians. If you want to define a new model you should make use of this interface. A new | ||
model Hamiltonian should subtype to `AbstractHamiltonian` and implement the relevant methods. | ||
|
||
```@docs | ||
AbstractHamiltonian | ||
offdiagonals | ||
diagonal_element | ||
starting_address | ||
``` | ||
|
||
The following functions may be implemented instead of [`offdiagonals`](@ref). | ||
|
||
```@docs | ||
num_offdiagonals | ||
get_offdiagonal | ||
``` | ||
|
||
The following functions come with default implementations, but may be customized. | ||
|
||
```@docs | ||
random_offdiagonal | ||
Hamiltonians.LOStructure | ||
dimension | ||
has_adjoint | ||
allows_address_type | ||
Base.eltype | ||
VectorInterface.scalartype | ||
mul! | ||
``` | ||
|
||
This interface relies on unexported functionality, including | ||
```@docs | ||
Hamiltonians.adjoint | ||
Hamiltonians.dot | ||
Hamiltonians.AbstractOffdiagonals | ||
Hamiltonians.Offdiagonals | ||
Hamiltonians.check_address_type | ||
Hamiltonians.number_conserving_dimension | ||
Hamiltonians.number_conserving_bose_dimension | ||
Hamiltonians.number_conserving_fermi_dimension | ||
``` | ||
|
||
## Operator and observable interface | ||
|
||
```@docs | ||
AbstractObservable | ||
AbstractOperator | ||
``` | ||
|
||
## Interface tests | ||
Helper functions that can be used for testing the various interfaces are provided in the | ||
(unexported) submodule `Rimu.InterfaceTests`. | ||
|
||
```@docs | ||
Rimu.InterfaceTests | ||
``` | ||
|
||
### Testing functions | ||
```@docs | ||
Rimu.InterfaceTests.test_hamiltonian_interface | ||
Rimu.InterfaceTests.test_hamiltonian_structure | ||
Rimu.InterfaceTests.test_observable_interface | ||
Rimu.InterfaceTests.test_operator_interface | ||
``` | ||
|
||
## Utilities for harmonic oscillator models | ||
Useful utilities for harmonic oscillator in Cartesian basis, see [`HOCartesianContactInteractions`](@ref) | ||
and [`HOCartesianEnergyConservedPerDim`](@ref). | ||
```@docs | ||
get_all_blocks | ||
fock_to_cart | ||
``` | ||
Underlying integrals for the interaction matrix elements are implemented in the following unexported functions | ||
```@docs | ||
Hamiltonians.four_oscillator_integral_general | ||
Hamiltonians.ho_delta_potential | ||
Hamiltonians.log_abs_oscillator_zero | ||
``` | ||
|
||
## Index | ||
```@index | ||
Pages = ["custom_hamiltonians.md"] | ||
``` |
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.