Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify derivative testing #32

Open
cortner opened this issue Apr 27, 2021 · 1 comment
Open

Unify derivative testing #32

cortner opened this issue Apr 27, 2021 · 1 comment

Comments

@cortner
Copy link
Member

cortner commented Apr 27, 2021

For every model that we test we manually write directional derivative tests like shown below. This can most likely be unified in a little test suite implemented within ACE.Testing.

import Base.*

struct __TestSVec{T}
   val::T
end

*(a::Number, u::__TestSVec) = a * u.val
*(a::SMatrix, u::__TestSVec) = a * u.val
*(a::SArray{Tuple{N1,N2,N3}}, u::__TestSVec) where {N1, N2,N3} =
      reshape(reshape(a, Size(N1*N2, N3)) * u.val, Size(N1, N2))

Us = __TestSVec.(randn(SVector{3, Float64}, length(Xs)))
C = randn(typeof.val), length(basis))
F = t -> sum( sum(c .* b.val)
                    for (c, b) in zip(C, ACE.evaluate(basis, ACEConfig(Xs + t[1] * Us))) )
dF = t -> [ sum( sum(c .* db)
                  for (c, db) in zip(C, ACE.evaluate_d(basis, ACEConfig(Xs + t[1] * Us)) * Us) ) ]
fdtest(F, dF, [0.0], verbose=true)
@cortner
Copy link
Member Author

cortner commented May 20, 2021

this should now go into ACEbase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant