-
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.
* ParticleNumberOperator * use recent julia version for docs generation --------- Co-authored-by: Joachim Brand <[email protected]>
- Loading branch information
1 parent
2751499
commit 8c8b705
Showing
7 changed files
with
50 additions
and
3 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
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
8c8b705
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.
@JuliaRegistrator register
Release notes:
Non-breaking release with a new feature and a number of bug fixes and enhancements.
New features
ParticleNumberOperator
ParticleNumberOperator #255Bug fixes
NaN
s in harmonic oscillator Hamiltonians working around a bug inHypergeometricFunctions.jl
bugfix: dodgeNaN
in 3F2 #253Other changes
8c8b705
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.
Registration pull request created: JuliaRegistries/General/105995
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: