Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
696e79e
tests passing for tol = 1e-5
Oct 29, 2021
e6ba036
more accurate rotation coefficients added
MatthiasSachs Jan 5, 2022
884ebf9
fixed fio for EquivariantMatrix
cortner Jan 7, 2022
8dc3526
renaming
MatthiasSachs Jan 7, 2022
75d5b6a
Merge branch 'main' into ms/equivarinat_matrices
MatthiasSachs Jan 7, 2022
d1fa412
rebased branch and adapted implementation
MatthiasSachs Jan 7, 2022
f81c451
conversion issue fixed. All tests pass!
MatthiasSachs Jan 8, 2022
c085a44
added `test_EuclideanMatrix.jl` to test set
MatthiasSachs Jan 8, 2022
f445e56
derivative test removed
MatthiasSachs Jan 8, 2022
9dcc9bb
`show` modified and test for complex version of `EuclideanMatrix` added
MatthiasSachs Jan 8, 2022
f6ea6e8
small fix
MatthiasSachs Jan 9, 2022
c7cdea1
additional tests added (some don't pass!)
MatthiasSachs Jan 11, 2022
fa885f2
small changes to show and testing
cortner Jan 11, 2022
ff7a05e
changes to rotation coefficients
MatthiasSachs Jan 24, 2022
28ac1fb
several changes
MatthiasSachs Jan 29, 2022
b035504
Merge branch 'main' into ms/equivarinat_matrices
MatthiasSachs Jan 29, 2022
48bca83
small change to tests
MatthiasSachs Jan 31, 2022
0991821
clean-up in tests for bond basis selectors
MatthiasSachs Jan 31, 2022
a06a303
update
MatthiasSachs Jan 31, 2022
e856741
Documentation of filter function EvenL updated
MatthiasSachs Feb 2, 2022
e02dd36
edit fixed
MatthiasSachs Feb 2, 2022
9f1d9a8
Basic (apparantly) working version for BasisSelector intersections
MatthiasSachs Feb 3, 2022
4b82aec
Merge remote-tracking branch 'upstream/main' into ms/equivarinat_matr…
MatthiasSachs Feb 3, 2022
4a1477b
Merge branch 'ms/equivarinat_matrices' into ms/BSel_intersection
MatthiasSachs Feb 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 84 additions & 7 deletions src/basisselectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ maxorder(Bsel::SimpleSparseBasis, args...) =
"""
`AbstractSparseBasis`: Super-type for sparse basis selection as sub-levelsets of
the levelset function `level` and corresponding (possibly order-dependent)
levels provided in the dictionary `maxdegs::Dict{Any, Float64}`. In the default
levels provided in the dictionary `maxlevels::Dict{Any, Float64}`. In the default
implementation the levelset function and the degree function are identical.

Basis functions are selected in two steps. First, "admissible" basis
Expand Down Expand Up @@ -183,15 +183,15 @@ function SparseBasis(; maxorder::Integer = nothing,
p = 1,
weight = Dict(:l => 1.0, :n => 1.0),
default_maxdeg = nothing,
maxdegs = nothing )
if (default_maxdeg != nothing) && (maxdegs == nothing )
maxlevels = nothing )
if (default_maxdeg != nothing) && (maxlevels == nothing )
return SparseBasis(maxorder, weight,
Dict{Any, Float64}("default" => default_maxdeg),
p)
elseif (default_maxdeg == nothing) && (maxdegs != nothing)
SparseBasis(maxorder, weight, maxdegs, p)
elseif (default_maxdeg == nothing) && (maxlevels != nothing)
SparseBasis(maxorder, weight, maxlevels, p)
else
error("""Either both or neither optional arguments `maxdegs` and
error("""Either both or neither optional arguments `maxlevels` and
`default_maxdeg` were provided. To avoid ambiguity ensure that
exactly one of these arguments is provided.""")
end
Expand Down Expand Up @@ -282,10 +282,87 @@ cat_weighted_degree(bb::Prodb, Bsel::CategorySparseBasis, basis::OneParticleBasi
)


# ---------------------------
# ---------------------------
# Some useful filters

struct NoConstant
end

(::NoConstant)(bb) = (length(bb) > 0)


"""
`EvenL`: selects all basis functions where the sum `L = sum_i l_i` of the degrees `l_i` of the spherical harmonics is even.
"""
struct EvenL
isym::Symbol
categories
end

function (f::ACE.EvenL)(bb)
if isempty(bb)
return true
else
suml(s) = sum( [getl(O3(), b) for b in bb if getproperty(b, f.isym) == s])
return all(iseven(suml(s)) for s in f.categories)
end
end



"""
`DownsetIntersection`: Basis selector whose set of admissible specifications is the intersection
of the sets of admissible specifications of the sparse basis selectors contained in the lists `DBsels` and `ABsels`.
"""
struct DownsetIntersection <: DownsetBasisSelector
DBsels::Vector{DownsetBasisSelector}
ABsels::Vector{AbstractBasisSelector}
maxorder::Int
end

maxlevel(Bsel::DownsetIntersection, basis::OneParticleBasis) = 1.0

maxlevel(bb::Prodb, Bsel::DownsetIntersection, basis::OneParticleBasis) = 1.0


maxorder(Bsel::DownsetIntersection) = Bsel.maxorder

const MAXORDER = 10000
function Base.intersect(Bsel1::DownsetIntersection,Bsel2::DownsetBasisSelector)
return DownsetIntersection(vcat(Bsel1.DBsels,[Bsel2]), Bsel1.ABsels, minimum([maxorder(Bsel1),maxorder(Bsel2)]))
end

function Base.intersect(Bsel1::DownsetIntersection,Bsel2::AbstractBasisSelector)
return DownsetIntersection(Bsel1.DBsels, vcat(Bsel1.ABsels,[Bsel2]), minimum([maxorder(Bsel1),maxorder(Bsel2)]))
end

function Base.intersect(Bsel1::DownsetBasisSelector, Bsel2::AbstractBasisSelector)
Bsel = DownsetIntersection(Vector{DownsetBasisSelector}([]), Vector{AbstractBasisSelector}([]), MAXORDER)
return intersect(intersect(Bsel, Bsel1), Bsel2)
end

function Base.intersect(Bsel1::DownsetBasisSelector, Bsel2::DownsetBasisSelector)
Bsel = DownsetIntersection(Vector{DownsetBasisSelector}([]), Vector{AbstractBasisSelector}([]), MAXORDER)
return intersect(intersect(Bsel, Bsel1), Bsel2)
end

Base.intersect(Bsel1::AbstractBasisSelector, Bsel2::DownsetBasisSelector) = intersect(Bsel2,Bsel1)
Base.intersect(Bsel1::AbstractBasisSelector, Bsel2::DownsetIntersection) = intersect(Bsel2,Bsel1)

function Base.intersect(Bsel1::DownsetIntersection, Bsel2::DownsetIntersection)
Bsel = deepcopy(Bsel1)
for b in Bsel2
Bsel = intersect(Bsel, b)
end
return Bsel
end

function level(bb, Bsel::DownsetIntersection, basis::OneParticleBasis)
return maximum([ level(bb, bsel, basis)/maxlevel(bsel,basis) for bsel in Bsel.DBsels])
#return maximum([ level(bb, bsel, basis)/maxlevel(length(bb),bsel,basis) for bsel in Bsel.DBsels])
end

function filter(bb, Bsel::DownsetIntersection, basis::OneParticleBasis)
return all([filter(bb, bsel, basis) for bsel in Bsel.DBsels]) && all([filter(bb, bsel, basis) for bsel in Bsel.ABsels])
end

2 changes: 1 addition & 1 deletion src/bonds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cutoff_env(env::CylindricalBondEnvelope) = sqrt(env.rcut^2 + (env.r0cut + env.zc
cutoff_radialbasis(env::CylindricalBondEnvelope) = sqrt(env.rcut^2 + (env.zcut + env.floppy * env.λ * env.r0cut)^2)

struct EllipsoidBondEnvelope{T} <: BondEnvelope{T}
r0cut::T
r0cut::T # bond-length cutoff
rcut::T
zcut::T # must satisfy zcut >= r0cut/2
p0::Int
Expand Down
29 changes: 29 additions & 0 deletions src/cov_coeffs_dict.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
crmatrices=Dict(
(l=1, m=-1, mu=-1, i=1) => SVector{3,ComplexF64}(0.1666666666666667+0.0im, 0.0+0.1666666666666667im, 0.0+0.0im),
(l=1, m=-1, mu=0, i=1) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=-1, mu=1, i=1) => SVector{3,ComplexF64}(-0.1666666666666667+0.0im, 0.0+-0.1666666666666667im, 0.0+0.0im),
(l=1, m=0, mu=-1, i=1) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, -0.2357022603955158+0.0im),
(l=1, m=0, mu=0, i=1) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=0, mu=1, i=1) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.2357022603955158+0.0im),
(l=1, m=1, mu=-1, i=1) => SVector{3,ComplexF64}(-0.1666666666666667+0.0im, 0.0+0.1666666666666667im, 0.0+0.0im),
(l=1, m=1, mu=0, i=1) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=1, mu=1, i=1) => SVector{3,ComplexF64}(0.1666666666666667+0.0im, 0.0+-0.1666666666666667im, 0.0+0.0im),
(l=1, m=-1, mu=-1, i=2) => SVector{3,ComplexF64}(0.0+-0.1666666666666667im, 0.1666666666666667+0.0im, 0.0+0.0im),
(l=1, m=-1, mu=0, i=2) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=-1, mu=1, i=2) => SVector{3,ComplexF64}(0.0+-0.1666666666666667im, 0.1666666666666667+0.0im, 0.0+0.0im),
(l=1, m=0, mu=-1, i=2) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.2357022603955158im),
(l=1, m=0, mu=0, i=2) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=0, mu=1, i=2) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.2357022603955158im),
(l=1, m=1, mu=-1, i=2) => SVector{3,ComplexF64}(0.0+0.1666666666666667im, 0.1666666666666667+0.0im, 0.0+0.0im),
(l=1, m=1, mu=0, i=2) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=1, mu=1, i=2) => SVector{3,ComplexF64}(0.0+0.1666666666666667im, 0.1666666666666667+0.0im, 0.0+0.0im),
(l=1, m=-1, mu=-1, i=3) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=-1, mu=0, i=3) => SVector{3,ComplexF64}(-0.2357022603955158+0.0im, 0.0+-0.2357022603955158im, 0.0+0.0im),
(l=1, m=-1, mu=1, i=3) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=0, mu=-1, i=3) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=0, mu=0, i=3) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.3333333333333333+0.0im),
(l=1, m=0, mu=1, i=3) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=1, mu=-1, i=3) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im),
(l=1, m=1, mu=0, i=3) => SVector{3,ComplexF64}(0.2357022603955158+0.0im, 0.0+-0.2357022603955158im, 0.0+0.0im),
(l=1, m=1, mu=1, i=3) => SVector{3,ComplexF64}(0.0+0.0im, 0.0+0.0im, 0.0+0.0im)
)
Loading