ACEsuit / ACE.jl

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

Weird issues with EuclideanMatrix property #104

Open MatthiasSachs opened 2 years ago

MatthiasSachs commented 2 years ago

Evaluations of a symmetric basis with property=EuclideanMatrix{Float64}

  1. are symmetric matrices as the passing of the following test shows
    @info("Check for symmetry")
    for ntest = 1:30
    local Xs, BB
    Xs = rand(PositionState{Float64}, B1p.bases[1], nX)
    BB = evaluate(basis, ACEConfig(Xs))
    print_tf(@test all([ b.val == transpose(b.val)
    for b in BB  ]))
    end
    println()
  2. have non-negligible complex components for basis functions of high degree as the passing of the following test shows
    @info("Check magnitude of complex part")
    for ntest = 1:30
    local Xs, BB
    Xs = rand(PositionState{Float64}, B1p.bases[1], nX)
    BB = evaluate(basis, ACEConfig(Xs))
    print_tf(@test all([ norm(complex(b)) < .1 
    for b in BB  ]))
    end
    println()

    Both tests have been added to the test file test_EuclideanMatrix.jl in latest commit c7cdea1 to PR #99

MatthiasSachs commented 2 years ago

I guess that issue 2 might be because of numerical error. But I find issue 1 to be more confusing? Where in the construction do we enforce symmetry of the matrix functions? Certainly, there are matrix functions that don't evaluate to symmetric matrices and at the same time satisfy the required equivariance property, e.g.,

M(r) = v_1(r) \otimes v_2(r),

where v_1 and v_2 are covariant matrix functions.

cortner commented 2 years ago

The symmetry issue suggests the basis is not complete.

cortner commented 2 years ago

The real/complex thing is weird. First though, note you shouldn't use complex but imag please.

But even then the test fails. In fact going back to this

φ = ACE.EuclideanMatrix(Float64)
pibasis = PIBasis(B1p, Bsel; property = φ)
basis = SymmetricBasis(φ, pibasis)
BB = evaluate(basis, cfg)

I don't understand at all why the elements of BB aren't real when you demand a real matrix as the property? Smells very much like a bug.