Skip to content

Commit

Permalink
allow empty sublats
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosanjose committed Oct 12, 2023
1 parent 2eb373f commit ffc3715
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 0 additions & 6 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
struct Sublat{T<:AbstractFloat,E}
sites::Vector{SVector{E,T}}
name::Symbol
function Sublat{T,E}(sites, name) where {T<:AbstractFloat,E}
isempty(sites) && argerror("Sublattices cannot be empty")
return new(sites, name)
end
end

struct Unitcell{T<:AbstractFloat,E}
Expand Down Expand Up @@ -41,8 +37,6 @@ end

#region ## Constructors ##

Sublat(sites::Vector{SVector{E,T}}, name::Symbol) where {T,E} = Sublat{T,E}(sites, name)

Bravais(::Type{T}, E, m) where {T} = Bravais(T, Val(E), m)
Bravais(::Type{T}, ::Val{E}, m::Tuple{}) where {T,E} =
Bravais{T,E,0}(sanitize_Matrix(T, E, ()))
Expand Down
5 changes: 4 additions & 1 deletion test/test_greenfunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function testgreen(h, s; kw...)
return nothing
end

@testset "bare greenfunctions" begin
@testset "basic greenfunctions" begin
h0 = LP.honeycomb() |> hamiltonian(hopping(SA[0 1; 1 0]), orbitals = 2) |> supercell(region = RP.circle(10))
s0 = GS.SparseLU()
h1 = LP.square() |> hamiltonian(@onsite((; o = 1) -> o*I) + hopping(SA[0 1; 1 0]), orbitals = 2) |> supercell((1,0), region = r -> abs(r[2]) < 2)
Expand Down Expand Up @@ -66,6 +66,9 @@ end
testgreen(oh, s)
end
end
# contacts that don't include all sublattices
h = lattice(sublat(0, name = :L), sublat(1, name = :R)) |> hamiltonian
@test h |> attach(onsite->1), sublats = :L) |> greenfunction isa GreenFunction
end

@testset "greenfunction KPM" begin
Expand Down
2 changes: 1 addition & 1 deletion test/test_lattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
end
@test sublat((3,)) isa Sublat{Float64,1}
@test sublat(()) isa Sublat{Float64,0}
@test_throws ArgumentError sublat(SVector{3,Float64}[])
@test sublat(SVector{3,Float64}[]) isa Sublat{Float64,3}
end

@testset "lattice construction" begin
Expand Down

0 comments on commit ffc3715

Please sign in to comment.