# Constrained relaxation, relax layers rigidly

**URL:** <https://discourse.abinit.org/t/constrained-relaxation-relax-layers-rigidly/3395>\
**Category:** Ground state\
**Created:** [August 15, 2023, 12:46pm UTC](https://discourse.abinit.org/t/constrained-relaxation-relax-layers-rigidly/3395 "2023-08-15T12:46:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbennett1994](https://discourse.abinit.org/user_avatar/discourse.abinit.org/dbennett1994/32/409_2.png) [@dbennett1994](https://discourse.abinit.org/u/dbennett1994)\
**Post date:** [August 15, 2023, 12:46pm UTC](https://discourse.abinit.org/t/constrained-relaxation-relax-layers-rigidly/3395/1 "2023-08-15T12:46:55Z")

</div>

Hi all,

I am trying to run some geometry relaxations in abinit including constraints, as described by the [wtatcon](https://docs.abinit.org/variables/rlx/#wtatcon) flag. However, I’m a little bit confused on how to use the constraints and would appreciate some advice.

For context, I am looking at layered systems, e.g. MoS2, etc. I want to do a relaxation of a stack of layers, and have each layer move rigidly, optimizing only the distance between the layers. For example, for two layers of MoS2, I want to keep the bottom layer fixed (easily achieved with natfix), and then relax the top layer (z direction only), but preserving the relative positions of the atoms within the top layer.

Here is a simple input file showing how I think this could be done:

[mos2.in](https://discourse.abinit.org/uploads/short-url/aaY1XU8OjQ4juEiWZYoLb3PGQ2n.in) (2.7 KB)

although it doesn’t seem to work for me. The example for wtatcon in the documentation is a little bit too simple, since it is just one constraint equation and it says “assuming the masses are equal” (do we really need to calculate the relative masses every time we want to do a constrained relaxation?..)

I would appreciate any advice if anyone has experience using these constraints

Thanks,

Daniel Bennett

---

<div class="post-metadata">

**Author:** ![ebousquet](https://discourse.abinit.org/letter_avatar_proxy/v4/letter/e/67e7ee/32.png) [@ebousquet](https://discourse.abinit.org/u/ebousquet)\
**Post date:** [August 16, 2023, 10:53am UTC](https://discourse.abinit.org/t/constrained-relaxation-relax-layers-rigidly/3395/2 "2023-08-16T10:53:36Z")

</div>

Hi Danny,  
I would use only the natfix flags in your case, not the nconeq and co (I also have to say that I never used the later and rarely the former…).  
Isn’t atfix flags sufficient?  
Be careful that with ionmov=2 it is constrained in reduced coordinate.  
All the best,  
Eric

---

<div class="post-metadata">

**Author:** ![dbennett1994](https://discourse.abinit.org/user_avatar/discourse.abinit.org/dbennett1994/32/409_2.png) [@dbennett1994](https://discourse.abinit.org/u/dbennett1994)\
**Post date:** [August 19, 2023, 4:45pm UTC](https://discourse.abinit.org/t/constrained-relaxation-relax-layers-rigidly/3395/3 "2023-08-19T16:45:12Z")

</div>

Hi Eric,

I am in the same boat.

The natfix options work well, for fixing the atoms in the in-plane direction.

But I would like to relax the layers in the out-of-plane direction, while preserving the initial distances between the atoms within each layer. For example, in siesta, there is a geometry constraint option called rigid (see the [manual](https://siesta-project.org/SIESTA_MATERIAL/Docs/Manuals/siesta-4.1.5.pdf), page 123). This calculates the average force on a group of atoms and moves them by the same amount each time. I am trying to achieve something similar using `wtatcon` but not sure if it is so straightforward

Danny
