From 0e3ba6b1c9d51f6313823598572381b907e5e5cf Mon Sep 17 00:00:00 2001 From: "Christian F. A. Negre" Date: Tue, 28 May 2019 10:31:22 -0600 Subject: [PATCH 1/4] Generalized freeze subroutine --- src/constraints_mod.F90 | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/constraints_mod.F90 b/src/constraints_mod.F90 index 74c9749..1337182 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 y and z coordinates of atom 10 + !! 20 0 0 0 #We are freezing all the coordinates of atom 10 + !! 40 1 1 0 #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. @@ -85,19 +84,25 @@ SUBROUTINE FREEZE_ATOMS(FTOT,VEL) READ(444,*)NFREEZE ALLOCATE(FREEZEID(NFREEZE)) DO I = 1,NFREEZE - READ(444,*)FREEZEID(I) + READ(444,*)FREEZEID(I), FREEZEIDX(I), FREEZEIDY(I), 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)) = FREEZEIDX(I)*VEL(1,FREEZEID(I)) + FTOT(1,FREEZEID(I)) = FREEZEIDX(I)*FTOT(1,FREEZEID(I)) + VEL(2,FREEZEID(I)) = FREEZEIDY(I)*VEL(2,FREEZEID(I)) + FTOT(2,FREEZEID(I)) = FREEZEIDY(I)*FTOT(2,FREEZEID(I)) + VEL(3,FREEZEID(I)) = FREEZEIDZ(I)*VEL(3,FREEZEIDZ(I)) + FTOT(3,FREEZEID(I)) = FREEZEIDZ(I)*FTOT(3,FREEZEID(I)) ENDDO ELSE DO I = 1,NFREEZE - FTOT(:,FREEZEID(I)) = 0.0d0 + FTOT(1,FREEZEID(I)) = FREEZEIDX(I)*FTOT(1,FREEZEID(I)) + FTOT(2,FREEZEID(I)) = FREEZEIDY(I)*FTOT(2,FREEZEID(I)) + FTOT(3,FREEZEID(I)) = FREEZEIDZ(I)*FTOT(3,FREEZEID(I)) ENDDO ENDIF From 59f22c73c22d4ae6243981f8f27dded78bc45a5a Mon Sep 17 00:00:00 2001 From: "Christian F. A. Negre" Date: Tue, 28 May 2019 10:40:55 -0600 Subject: [PATCH 2/4] Generalized freeze subroutine --- src/constraints_mod.F90 | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/constraints_mod.F90 b/src/constraints_mod.F90 index 1337182..f0c3287 100644 --- a/src/constraints_mod.F90 +++ b/src/constraints_mod.F90 @@ -64,9 +64,9 @@ MODULE CONSTRAINTS_MOD !! The file is formated as follows: !! !! 3 #Number of freezed atoms - !! 10 1 0 0 #We are freezing the y and z coordinates of atom 10 - !! 20 0 0 0 #We are freezing all the coordinates of atom 10 - !! 40 1 1 0 #We are freezing the z coordinate of atom 10 + !! 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. @@ -74,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,25 +84,28 @@ SUBROUTINE FREEZE_ATOMS(FTOT,VEL) READ(444,*)NFREEZE ALLOCATE(FREEZEID(NFREEZE)) DO I = 1,NFREEZE - READ(444,*)FREEZEID(I), FREEZEIDX(I), FREEZEIDY(I), FREEZEIDZ(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(1,FREEZEID(I)) = FREEZEIDX(I)*VEL(1,FREEZEID(I)) - FTOT(1,FREEZEID(I)) = FREEZEIDX(I)*FTOT(1,FREEZEID(I)) - VEL(2,FREEZEID(I)) = FREEZEIDY(I)*VEL(2,FREEZEID(I)) - FTOT(2,FREEZEID(I)) = FREEZEIDY(I)*FTOT(2,FREEZEID(I)) - VEL(3,FREEZEID(I)) = FREEZEIDZ(I)*VEL(3,FREEZEIDZ(I)) - FTOT(3,FREEZEID(I)) = FREEZEIDZ(I)*FTOT(3,FREEZEID(I)) + 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(1,FREEZEID(I)) = FREEZEIDX(I)*FTOT(1,FREEZEID(I)) - FTOT(2,FREEZEID(I)) = FREEZEIDY(I)*FTOT(2,FREEZEID(I)) - FTOT(3,FREEZEID(I)) = FREEZEIDZ(I)*FTOT(3,FREEZEID(I)) + 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 From 304bddb49911d21c6426d106473d77eeb9022659 Mon Sep 17 00:00:00 2001 From: "Christian F. A. Negre" Date: Tue, 28 May 2019 10:56:27 -0600 Subject: [PATCH 3/4] Added freeze.in --- tests/freeze.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 From 147efdd5ba4d67663ead7df9aace6737596defd4 Mon Sep 17 00:00:00 2001 From: "Christian F. A. Negre" Date: Tue, 28 May 2019 10:56:52 -0600 Subject: [PATCH 4/4] Added freeze.in --- src/constraints_mod.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/constraints_mod.F90 b/src/constraints_mod.F90 index f0c3287..3b0f11c 100644 --- a/src/constraints_mod.F90 +++ b/src/constraints_mod.F90 @@ -83,6 +83,9 @@ 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), FREEZEIDX(I), FREEZEIDY(I), FREEZEIDZ(I) FREEZEIDX(I) = 1 - FREEZEIDX(I)