ACEsuit / ACE.jl

Parameterisation of Equivariant Properties of Particle Systems
66 stars 15 forks source link

SparseBasis Basis selector bug #84

Closed davkovacs closed 2 years ago

davkovacs commented 2 years ago

The SparseBasis Basis selector does not filter the basis functions based on the maxlevels dictionary.

cortner commented 2 years ago

max levels shouldn't be used to filter. The filter does something else it is to introduce holes into the basis, e.g. enforce the sum l = even and sum m = 0 constraints.

cortner commented 2 years ago

Look at these lines:

level(b::Onepb, Bsel::AbstractSparseBasis, basis::OneParticleBasis) =
      degree(b, basis, Bsel.weight)

level(bb::Prodb, Bsel::AbstractSparseBasis, basis::OneParticleBasis)  =  (
      length(bb) == 0 ? 0.0
                      : norm( level.(bb, Ref(Bsel), Ref(basis)), Bsel.p ) )

maxlevel(bb::Prodb, Bsel::AbstractSparseBasis, basis::OneParticleBasis) = 
      maxlevel(length(bb), Bsel, basis)

maxlevel(ord::Integer, Bsel::AbstractSparseBasis, basis::OneParticleBasis) = 
      ( haskey(Bsel.maxlevels, ord) ? Bsel.maxlevels[ord] 
                                    : Bsel.maxlevels["default"] )

All basis functions b or bb will be constructed such that level(b or bb) <= maxlevel. The maxlevel function depends on the order.

Looking at it now, maybe we are missing a maxlevel function for 1-particle basis functions b?

cortner commented 2 years ago

CC @JPDarby

cortner commented 2 years ago

We may need to write some decent documentation for this.

JPDarby commented 2 years ago

This is not an issue anymore - I was on an old commit and misunderstanding

max levels shouldn't be used to filter. The filter does something else it is to introduce holes into the basis, e.g. enforce the sum l = even and sum m = 0 constraints.

The fix in 5b7eaf3b464a6c9397c3438286b0ccfe45d920d0 solved the problem.

cortner commented 2 years ago

So close this?

davkovacs commented 2 years ago

Yes, I think it works now. Though the dipole fits are still really bad, so there is something to debug there. I just need to figure out if it is the basis or the fitting that has the bug.

cortner commented 2 years ago

can you send me the data?