-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/geometry
- Loading branch information
Showing
11 changed files
with
64 additions
and
8 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
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
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,36 @@ | ||
""" | ||
ParticleNumberOperator([address]) <: AbstractHamiltonian | ||
The number operator in Fock space. This operator is diagonal in the Fock basis and | ||
returns the number of particles in the Fock state. Passing an address is optional. | ||
```jldoctest | ||
julia> h = FroehlichPolaron(fs"|0 0⟩{}"; mode_cutoff=5, v=3); bsr = BasisSetRep(h); | ||
julia> gs = DVec(zip(bsr.basis, eigen(Matrix(bsr)).vectors[:,1])); # ground state | ||
julia> dot(gs, ParticleNumberOperator(), gs) # particle number expectation value | ||
2.8823297252925917 | ||
``` | ||
See also [`AbstractHamiltonian`](@ref). | ||
""" | ||
struct ParticleNumberOperator{A} <: AbstractHamiltonian{Float64} | ||
address::A | ||
end | ||
ParticleNumberOperator() = ParticleNumberOperator(BoseFS(1,)) | ||
|
||
function Base.show(io::IO, n::ParticleNumberOperator) | ||
io = IOContext(io, :compact => true) | ||
print(io, "ParticleNumberOperator(") | ||
n.address === BoseFS(1,) || show(io, n.address) # suppress if default | ||
print(io, ")") | ||
end | ||
|
||
LOStructure(::Type{<:ParticleNumberOperator}) = IsDiagonal() | ||
starting_address(n::ParticleNumberOperator) = n.address | ||
|
||
function diagonal_element(::ParticleNumberOperator, addr::AbstractFockAddress) | ||
return float(num_particles(addr)) | ||
end | ||
allowed_address_type(::ParticleNumberOperator) = AbstractFockAddress |
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