Skip to content

Commit

Permalink
add allocation checking
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimbrand committed Jan 9, 2024
1 parent ed8955b commit 3d789da
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ authors = ["Joachim Brand <j.brand@massey.ac.nz>"]
version = "0.9.1-dev"

[deps]
AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a"
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand Down
1 change: 1 addition & 0 deletions src/BitStringAddresses/BitStringAddresses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ using StaticArrays
using SparseArrays
using Setfield
using Parameters
using AllocCheck

using Base.Cartesian

Expand Down
6 changes: 4 additions & 2 deletions src/BitStringAddresses/occupationnumberfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ See also: [`destroy`](@ref), [`excitation`](@ref).
return (ofs, val)
end

"""
@doc """
excitation(addr::OccupationNumberFS, c::NTuple{<:Any,Int}, d::NTuple{<:Any,Int})
→ (nadd, α)
Generate an excitation on an [`OccupationNumberFS`](@ref) by applying the creation and
Expand All @@ -158,7 +158,9 @@ julia> num_particles(es)
7
```
"""
function excitation(fs::OccupationNumberFS{<:Any, T}, c::NTuple{<:Any,Int}, d::NTuple{<:Any,Int}) where {T}
excitation(fs::OccupationNumberFS{<:Any,T}, c::NTuple{<:Any,Int}, d::NTuple{<:Any,Int}) where {T}

@check_allocs function excitation(fs::OccupationNumberFS{<:Any,T}, c::NTuple{<:Any,Int}, d::NTuple{<:Any,Int}) where {T}
accu = one(T)
for i in d
fs, val = destroy(fs, i)
Expand Down
8 changes: 4 additions & 4 deletions src/Hamiltonians/FroehlichPolaron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ geometry is to provide the number of dimensions `num_dimensions`. In this case t
[`num_modes(address)`](@ref) of `address` must be a square number for `num_dimensions = 2`,
or a cube number for `num_dimensions = 3`.
The `address` must be of type [`ONRFS`](@ref).
The `address` must be of type [`OccupationNumberFS`](@ref).
"""
struct FroehlichPolaron{
P, # total momentum
T, # eltype
A<:ONRFS, # address type
A<:OccupationNumberFS, # address type
G # lattice type
} <: AbstractHamiltonian{T}
add::A
Expand All @@ -40,7 +40,7 @@ struct FroehlichPolaron{
end

function FroehlichPolaron(
addr::ONRFS{<:Any, M};
addr::OccupationNumberFS{<:Any, M};
geometry=nothing,
alpha=1.0,
total_mom=0.0,
Expand Down Expand Up @@ -91,7 +91,7 @@ Base.getproperty(h::FroehlichPolaron, ::Val{:geometry}) = getfield(h, :geometry)

num_dimensions(h::FroehlichPolaron) = num_dimensions(h.geometry)

# function diagonal_element(h::FroehlichPolaron, addr::ONRFS)
# function diagonal_element(h::FroehlichPolaron, addr::OccupationNumberFS)
# return (
# (-h.total_mom)^2 +
# num_particles(addr) +
Expand Down

0 comments on commit 3d789da

Please sign in to comment.