JuliaMolSim / EmpiricalPotentials.jl

Empirical interatomic potentials with Julia, AtomsBase and AtomsCalculators
MIT License
2 stars 0 forks source link

More Flexible Initialization in SitePotentials #10

Closed cortner closed 1 month ago

cortner commented 2 months ago

The initialization in the implementation of site potentials

init=[ zero(V), AtomsCalculators.zero_forces(at, V), zero(SMatrix{3, 3, typeof(zero(V))})]

assumes that V can by itself know what the output of a calculation is. This cannot always be the case. The output type will be a combination of the number types in the atoms object, the calculator object, and the parameters object.

E.g. I might run an energy calculation with parameters or positions being dual numbers. But the calculator V cannot know this.

The way this was handled in older versions of JuLIP and ACE was to have initiatlizations that depend on the inputs. Here, I think this could take the form

allocate_whatever(V, at, ps, st)

The alternative - and maybe preferrable - would be to enforce that E, F, V are of a very specific structure, namely.

T,    Vector{SVector{3, T}},   SMatrix{3, 3, T}

If we do this, then we the calculators would need to provide

out_number_type(V, at, ps, st)

or a similar name.

cortner commented 1 month ago

AtomsCalculatorsUtilities now uses

      E = init_energy(sys, V)
      frc = init_forces(sys, V)
      vir = init_virial(sys, V)

which addresses this issue for now. Once we implemente the low-level parameterized variants the params can be added in.