JuliaMolSim / EmpiricalPotentials.jl

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

Rethink units #14

Closed cortner closed 4 months ago

cortner commented 4 months ago
tjjarvinen commented 4 months ago
cortner commented 4 months ago

This is not nearly as obvious as you are making it sound. Right now it is highly inconsistent which makes it confusing to read the code and very hard to implement a new calculator.

E.g. we can define distance_unit(calc) but have cutoff_radius(calc) return just a unit-less number. that would be consistent with how we compute site energies and their gradients.

Secondly, the cost of applying the unit inside the loop to the energy will not make a measurable difference. For readability otoh both need to be applied inside or both need to be applied outside.

cortner commented 4 months ago

I now also notice that in some assembly loops the force units are applied outside as well. So the whole thing is inconsistent which makes it harder to maintain.

tjjarvinen commented 4 months ago

The loop where force units are applied outside it the one with parameter estimations that uses ForwardDiff that caused some issues with units and it was better to applie them outside. That being said the parameter estimation part is a bit experimental still and we need to give it a second look at some point.

cortner commented 4 months ago

At the moment the following seems to work of for me. It still feels like a hack, but maybe it is ok:

This is a relatively small modification of your current framework and probably overall consistent with what you have in mind?

cortner commented 4 months ago

move discussion to AtomsCalculatorsUtilities