JuLIP.jl icon indicating copy to clipboard operation
JuLIP.jl copied to clipboard

Consider redesign of constraints

Open cortner opened this issue 7 years ago • 19 comments

to make it easy to implement much more general constraints, Including bound constraints, box constraints, all sorts of useful stuff.

cortner avatar Oct 01 '16 15:10 cortner

FixedCell and VariableCell would either become DofManagers or alternatively VariableCell could be the default while FixedCell just becomes another constraint to add to the system.

cortner avatar Oct 12 '16 10:10 cortner

Constraints which maintain cubic symmetry of the cell (or other symmetries) during minimisation would be helpful. I occasionally get 1e-5 variation in side lengths for the unit cell, which can lead to significant asymmetry when constructing large systems.

thudso avatar Oct 30 '18 13:10 thudso

We have this in Python already :-)

jameskermode avatar Oct 30 '18 13:10 jameskermode

https://gitlab.com/ase/ase/merge_requests/950

jameskermode avatar Oct 30 '18 13:10 jameskermode

interesting - how would one implement this?

cortner avatar Oct 30 '18 13:10 cortner

Are these just linear constraints on the cell matrix?

cortner avatar Oct 30 '18 13:10 cortner

Essentially we use spglib to find the symmetry group and project out contributions to force and stress that depart from symmetry.

jameskermode avatar Oct 30 '18 13:10 jameskermode

force as well?

cortner avatar Oct 30 '18 13:10 cortner

Yes - atomic positions may be symmetry-constrained for multilattices

jameskermode avatar Oct 30 '18 13:10 jameskermode

Maybe this is a good example of a special-case that should be coded once, and this provides an opportunity to improve JuLIP <---> ASE convenience bindings

jameskermode avatar Oct 30 '18 13:10 jameskermode

It's currently implemented by wrapping the Calculator, but I've agreed to try to turn it into an ASE constraint. Could we add an ASEConstraint wrapper to JuLIP that calls adjust_forces() and adjust_positions()?

jameskermode avatar Oct 30 '18 13:10 jameskermode

But we would allow this only for linear constraints. Even then I'm a bit nervous... One also needs to incorporate the constraint into the preconditioners...

cortner avatar Oct 30 '18 13:10 cortner

That's fair. In the ASE implementation we just project back on to the constraint manifold after each step and it seems to work (most of the time), even with the preconditioned optimizers.

Perhaps an advantage of keeping it as a Calculator wrapper is that a non-linear transformation of the forces and stresses is then ok?

Code is not huge it you want to reimplement in Julia, I'm just worried about the overhead if we have to code/test/maintain everything twice

https://gitlab.com/ase/ase/merge_requests/950/diffs?view=inline

jameskermode avatar Oct 30 '18 13:10 jameskermode

Well, my suggestion would be as a first step to not automate it as you did, but to put the burden onto the user :). I.e. just offer the option of a linear constraint on the cell.

As a second step we could maybe find out how to "read" the constraint from ASE but then implement it within the JuLIP framework.

cortner avatar Oct 30 '18 13:10 cortner

Sounds like a good plan

jameskermode avatar Oct 30 '18 13:10 jameskermode

Tom - can we have a chat at some point about how to implement - and more important test - this?

cortner avatar Oct 30 '18 13:10 cortner

Certainly!

thudso avatar Oct 30 '18 13:10 thudso

Some thoughts on a new DoF Manager Design:

  • have a generic Dog Manager
  • the atoms mask can be a specific constraint that we can apply set_constraint!(Clamp(free = , clamp = , mask = , clampx = , clampy = , ... )) set_contraint!(InPlane), set_constraint!(AntiPlane)
  • set_variablecell!(true/false) or set_fixedcell!(true / false) or set_constraint!(FixedCell), set_constraint!(VariableCell)
  • clear_constraints!(at)

cortner avatar Jul 08 '19 09:07 cortner

new dof manager is done. Will look at linear constraints when there is time / a need!

cortner avatar Jul 16 '19 06:07 cortner