Hi, Dexi,

I think you are right. In the constri.f as I have written, the movement of the 20 atoms along x and y is fixed while they can move rigidly along z direction, i.e., they would have the very same displacement along z direction. Turn to the method Nick pointed out, the movement of the 20 atoms along x and y is also frozen, but they can move separately along z direction, that is to say, the displacement along z direction for each of the 20 atoms would most probably not the same.

Best regards,

Guangping Zhang

On 2015/3/3 3:05, 邵德喜 wrote:
Dear teacher Zhang and Nick
Maybe there's a little different between the two. First in the subroutine, movement of the 20 atoms along the z aixs is allowed, but for the first/last 10 atoms only uniform movement are existed , any reletively movement between the 10 atoms are not allowed. While follow Nick's idea, movement of the 20 atoms along the z aixs is allowed, whenever the movement is uniform or relative.
Is that all right?
Best
Dexi Shao

2014-08-14 15:26 GMT+08:00 zgp121 <zgp...@126.com <mailto:zgp...@126.com>>:

    Dear Nick,
    Thanks for your suggestion.
    I have tried it, and it succeeded. If I want to fix atom 1 to 3
    the x and y coordinates, I should write two lines,
    position from 1 to 3  1.0  0.0  0.0  # no movement in x-direction
    position from 1 to 3  0.0  1.0  0.0  # no movement in y-direction
    which can not be written in one line,
    position from 1 to 3  1.0  1.0  0.0
    Dear Roberto,
    Also, the method I mentioned first can achive the same thing. When
    I run again for the same job, it succeeded.
    Thanks very much for your suggestions and discussions.
    /Guangping Zhang
    2014-08-14
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    *发件人:*"zgp121"<zgp...@126.com <mailto:zgp...@126.com>>
    *发送时间:*2014-08-13 17:37
    *主题:*Re: [SIESTA-L] can not constrain atom using constr.f (with
    attched constr.f)
    *收件人:*"siesta-l"<siesta-l@uam.es <mailto:siesta-l@uam.es>>
    *抄送:*
    Dear Nick,
    Thanks very much for your suggestion.
    I will try it.
    With best regards.
    Guangping
    2014-08-13
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    *发件人:*Nick Papior Andersen <nickpap...@gmail.com
    <mailto:nickpap...@gmail.com>>
    *发送时间:*2014-08-13 16:26
    *主题:*Re: [SIESTA-L] can not constrain atom using constr.f (with
    attched constr.f)
    *收件人:*"siesta-l@uam.es
    <mailto:siesta-l@uam.es>"<siesta-l@uam.es <mailto:siesta-l@uam.es>>
    *抄送:*
    In some versions of siesta you can do:
    %block GeometryConstraints
    position from 1 to 10 1. 0. 0. # no movement in x-direction
    position from 1 to 10 0. 1. 0. # no movement in y-direction
    position from -10 to -1 1. 0. 0.
    position from -10 to -1 0. 1. 0.
    %endblock GeometryConstraints

    Try it out and see if it works.


    2014-08-13 8:19 GMT+00:00 zgp121 <zgp...@126.com
    <mailto:zgp...@126.com>>:

        Dear all,
        I wan to do molecular dynamics for part of my system. So I use
        constr.f to constrain some of the atoms. As attached my
        constr.f, during the molecular dynamics, I want only my first
        10 and last 10 atoms rigidly move along z axis. So, there only
        two dimensions unstricted for the 20 atoms.
        But the results show that the x, y coodinates of the 20 atoms
        also move.
        So, can anyone give some suggestions?
        Guangping Zhang
        =========constr.f======
        !
        ! This file is part of the SIESTA package.
        !
        ! Copyright (c) Fundacion General Universidad Autonoma de Madrid:
        ! E.Artacho, J.Gale, A.Garcia, J.Junquera, P.Ordejon,
        D.Sanchez-Portal
        ! and J.M.Soler, 1996- .
        !
        ! Use of this software constitutes agreement with the full
        conditions
        ! given in the SIESTA license, as signed by all legitimate users.
        !
        c $Id: constr.f,v 1.6 2003/06/23 09:46:16 ordejon Exp $
              subroutine constr( cell, na, isa, amass, xa, stress, fa,
        ntcon )
        c
        *****************************************************************
        c User-written routine to implement specific geometric
        constraints,
        c by orthogonalizing the forces and stress to undesired changes.
        c Arguments:
        c real*8  cell(3,3)    : input lattice vectors (Bohr)
        c integer na           : input number of atoms
        c integer isa(na)      : input species indexes
        c real*8  amass(na)    : input atomic masses
        c real*8  xa(3,na)     : input atomic cartesian coordinates (Bohr)
        c real*8  stress( 3,3) : input/output stress tensor (Ry/Bohr**3)
        c real*8  fa(3,na)     : input/output atomic forces (Ry/Bohr)
        c integer ntcon        : total number of positions constr. imposed
        c
        *****************************************************************
              implicit         none
              integer          na, isa(na), ntcon
              double precision amass(na), cell(3,3), fa(3,na),
             . stress(3,3), xa(3,na), fz, tmass
        c Write here your problem-specific code.
              fz = fa(3,1)+fa(3,2)+fa(3,3)+fa(3,4)+fa(3,5)+fa(3,6)+fa(3,7)
        & +fa(3,8)+fa(3,9)+fa(3,10)

         tmass=amass(1)+amass(2)+amass(3)+amass(4)+amass(5)+amass(6)
        & +amass(7)+amass(8)+amass(9)+amass(10)

              fa(3,1) = fz * amass(1)/tmass
              fa(3,2) = fz * amass(2)/tmass
              fa(3,3) = fz * amass(3)/tmass
              fa(3,4) = fz * amass(4)/tmass
              fa(3,5) = fz * amass(5)/tmass
              fa(3,6) = fz * amass(6)/tmass
              fa(3,7) = fz * amass(7)/tmass
              fa(3,8) = fz * amass(8)/tmass
              fa(3,9) = fz * amass(9)/tmass
              fa(3,10) = fz * amass(10)/tmass
              fa(1,1) = 0.0d0
              fa(1,2) = 0.0d0
              fa(1,3) = 0.0d0
              fa(1,4) = 0.0d0
              fa(1,5) = 0.0d0
              fa(1,6) = 0.0d0
              fa(1,7) = 0.0d0
              fa(1,8) = 0.0d0
              fa(1,9) = 0.0d0
              fa(1,10) = 0.0d0
              fa(2,1) = 0.0d0
              fa(2,2) = 0.0d0
              fa(2,3) = 0.0d0
              fa(2,4) = 0.0d0
              fa(2,5) = 0.0d0
              fa(2,6) = 0.0d0
              fa(2,7) = 0.0d0
              fa(2,8) = 0.0d0
              fa(2,9) = 0.0d0
              fa(2,10) = 0.0d0
              fz = fa(3,92)+fa(3,93)+fa(3,94)+fa(3,95)+fa(3,96)+fa(3,97)
        & +fa(3,98)+fa(3,99)+fa(3,100)+fa(3,101)
         tmass=amass(92)+amass(93)+amass(94)+amass(95)+amass(96)+amass(97)
        & +amass(98)+amass(99)+amass(100)+amass(101)
              fa(3,92) = fz * amass(92)/tmass
              fa(3,93) = fz * amass(93)/tmass
              fa(3,94) = fz * amass(94)/tmass
              fa(3,95) = fz * amass(95)/tmass
              fa(3,96) = fz * amass(96)/tmass
              fa(3,97) = fz * amass(97)/tmass
              fa(3,98) = fz * amass(98)/tmass
              fa(3,99) = fz * amass(99)/tmass
              fa(3,100) = fz * amass(100)/tmass
              fa(3,101) = fz * amass(101)/tmass
              fa(1,92) = 0.0d0
              fa(1,93) = 0.0d0
              fa(1,94) = 0.0d0
              fa(1,95) = 0.0d0
              fa(1,96) = 0.0d0
              fa(1,97) = 0.0d0
              fa(1,98) = 0.0d0
              fa(1,99) = 0.0d0
              fa(1,100) = 0.0d0
              fa(1,101) = 0.0d0
              fa(2,92) = 0.0d0
              fa(2,93) = 0.0d0
              fa(2,94) = 0.0d0
              fa(2,95) = 0.0d0
              fa(2,96) = 0.0d0
              fa(2,97) = 0.0d0
              fa(2,98) = 0.0d0
              fa(2,99) = 0.0d0
              fa(2,100) = 0.0d0
              fa(2,101) = 0.0d0

              ntcon=58

         end
        2014-08-12
        ------------------------------------------------------------------------




-- Kind regards Nick



Responder a