Follow-up from "Draft: Resolve "AMMLConstraint""
The following discussion from !79 (merged) should be addressed:
-
@jk7683 started a discussion: (+2 comments) We have to check if all DOF are frozen after applying all constraints whether the calculation has to be started or skipped. This trick is used in the oxycat use case.
We can use
constr.get_removed_dof(atoms)
but this returns only the number of frozen DOF from one constraint and several constraints may have common frozen DOF. If we have only one constraint then this can be used, i.e. ifconstr.get_removed_dof(atoms) == 3*len(atoms)
then all the positions are fixed.If we have 2 or more constraints, we can proceed like this:
new_positions = atoms.positions - 1.0 for constr in constraints: constr.adjust_positions(atoms, new_positions) if numpy.sum(numpy.abs(atoms.positions - new_positions)) < numpy.finfo.tiny: # all positions are frozen
The calculation should be skipped if
- it requires changing the positions of the nuclei (molecular dynamics, local and global structure optimization, numerical first or second derivatives), and
- all DOF are removed by the constraints
The behavior can be either to raise an exception or return silently the initial structure.
One big problem to implement this is the implicitness of self.requires_dof = True
.
The need of DOF may arise from the calculator parameters, for example requesting numerical energy derivatives, ionic relaxation, molecular dynamics etc. that will be done by the calculator itself.
But if such parameters are missing it does not mean that this is the intended behavior. There should be an extension in the language to make this intention explicit / obvious / unambiguous.
There should be an additional annotation to indicate this intention, for example by extending the property rule with an additional keyword with the algorithm to be applied:
h2o_props = Property energy, forces for h2o with calc, Relax with constraints (water_plane)
Further keywords can be
-
Molecular dynamics
- VelocityVerlet/NVE
- Langevin/NVT
- Andersen/NVT
- Berendsen/NVT
- Nosé-Hoover/NVT
- Berendsen/NPT
- Nosé-Hoover/NPT
-
Structure optimization
- Local minimum search: Relax, BFGS, BFGSLineSearch, LBFGS, LBFGSLineSearch, GPMin, MDMin, QuasiNewton, FIRE
- Local transition state search: BFGSClimbFixInternals, NEB, Dimer
- Global minimum search: Simulated Annealing, BasinHopping, MinimaHopping, Genetic Algorithm, Particle Swarm Optimization