diff --git a/src/constraints_mod.F90 b/src/constraints_mod.F90 index 74c9749..3b0f11c 100644 --- a/src/constraints_mod.F90 +++ b/src/constraints_mod.F90 @@ -64,10 +64,9 @@ MODULE CONSTRAINTS_MOD !! The file is formated as follows: !! !! 3 #Number of freezed atoms - !! 10 #We are freezing all the coordinates of atom 10 - !! 20 #We are freezing all the coordinates of atom 10 - !! 40 #We are freezing all the coordinates of atom 10 - !! \todo Generalize this to have constrains to different coordinates. + !! 10 1 0 0 #We are freezing the x coordinate of atom 10 + !! 20 1 1 1 #We are freezing all the coordinates of atom 10 + !! 40 0 0 1 #We are freezing the z coordinate of atom 10 !! !! \param FTOT Total forces. FTOT(1,3) gives the force on x direction for atom 3. !! \param VEL Velocities. VEL(1,3) gives the velocity on x direction for atom 3. @@ -75,7 +74,7 @@ MODULE CONSTRAINTS_MOD SUBROUTINE FREEZE_ATOMS(FTOT,VEL) INTEGER, SAVE :: NFREEZE - INTEGER, SAVE, ALLOCATABLE :: FREEZEID(:) + INTEGER, SAVE, ALLOCATABLE :: FREEZEID(:), FREEZEIDX(:), FREEZEIDY(:), FREEZEIDZ(:) INTEGER :: I REAL(DP), OPTIONAL, INTENT(INOUT) :: VEL(:,:) REAL(DP), INTENT(INOUT) :: FTOT(:,:) @@ -84,20 +83,32 @@ SUBROUTINE FREEZE_ATOMS(FTOT,VEL) OPEN(444,FILE="freeze.in") READ(444,*)NFREEZE ALLOCATE(FREEZEID(NFREEZE)) + ALLOCATE(FREEZEIDX(NFREEZE)) + ALLOCATE(FREEZEIDY(NFREEZE)) + ALLOCATE(FREEZEIDZ(NFREEZE)) DO I = 1,NFREEZE - READ(444,*)FREEZEID(I) + READ(444,*)FREEZEID(I), FREEZEIDX(I), FREEZEIDY(I), FREEZEIDZ(I) + FREEZEIDX(I) = 1 - FREEZEIDX(I) + FREEZEIDY(I) = 1 - FREEZEIDY(I) + FREEZEIDZ(I) = 1 - FREEZEIDZ(I) ENDDO CLOSE(444) ENDIF IF(PRESENT(VEL))THEN DO I = 1,NFREEZE - VEL(:,FREEZEID(I)) = 0.0d0 - FTOT(:,FREEZEID(I)) = 0.0d0 + VEL(1,FREEZEID(I)) = REAL(FREEZEIDX(I),DP)*VEL(1,FREEZEID(I)) + FTOT(1,FREEZEID(I)) = REAL(FREEZEIDX(I),DP)*FTOT(1,FREEZEID(I)) + VEL(2,FREEZEID(I)) = REAL(FREEZEIDY(I),DP)*VEL(2,FREEZEID(I)) + FTOT(2,FREEZEID(I)) = REAL(FREEZEIDY(I),DP)*FTOT(2,FREEZEID(I)) + VEL(3,FREEZEID(I)) = REAL(FREEZEIDZ(I),DP)*VEL(3,FREEZEIDZ(I)) + FTOT(3,FREEZEID(I)) = REAL(FREEZEIDZ(I),DP)*FTOT(3,FREEZEID(I)) ENDDO ELSE DO I = 1,NFREEZE - FTOT(:,FREEZEID(I)) = 0.0d0 + FTOT(1,FREEZEID(I)) = REAL(FREEZEIDX(I),DP)*FTOT(1,FREEZEID(I)) + FTOT(2,FREEZEID(I)) = REAL(FREEZEIDY(I),DP)*FTOT(2,FREEZEID(I)) + FTOT(3,FREEZEID(I)) = REAL(FREEZEIDZ(I),DP)*FTOT(3,FREEZEID(I)) ENDDO ENDIF diff --git a/tests/freeze.in b/tests/freeze.in index 9873ee0..51b60bb 100644 --- a/tests/freeze.in +++ b/tests/freeze.in @@ -1,4 +1,4 @@ 3 -1 -2 -3 +1 1 1 1 +2 1 1 1 +3 1 1 1