Branch data Line data Source code
1 : : !!****m* ABINIT/m_pred_langevin_pimd
2 : : !! NAME
3 : : !! m_pred_langevin_pimd
4 : : !!
5 : : !! FUNCTION
6 : : !! This module provides an interface to call PIMD Langevin dynamics algorithm,
7 : : !! for conventional NVT molecular dynamics.
8 : : !!
9 : : !! COPYRIGHT
10 : : !! Copyright (C) 2024-2026 ABINIT group (A. Blanchet)
11 : : !! This file is distributed under the terms of the
12 : : !! GNU General Public License, see ~abinit/COPYING
13 : : !! or http://www.gnu.org/copyleft/gpl.txt .
14 : : !!
15 : : !! SOURCE
16 : :
17 : : #if defined HAVE_CONFIG_H
18 : : #include "config.h"
19 : : #endif
20 : :
21 : : #include "abi_common.h"
22 : :
23 : : module m_pred_langevin_pimd
24 : :
25 : : use defs_basis
26 : : use m_abicore
27 : : use m_abimover
28 : : use m_abihist
29 : : use m_pimd
30 : : use m_pimd_langevin, only : pimd_langevin_nvt,pimd_langevin_npt
31 : : use m_geometry, only : metric
32 : :
33 : : implicit none
34 : : public :: pred_langevin_pimd
35 : :
36 : : contains
37 : :
38 : : !!***
39 : : !!****f* ABINIT/pred_langevin_pimd
40 : : !! NAME
41 : : !! pred_langevin_pimd
42 : : !!
43 : : !! FUNCTION
44 : : !! Ionmov predictors (16) Langevin dynamics algorithm using PIMD predictor
45 : : !!
46 : : !! IONMOV 16:
47 : : !! Uses a Langevin dynamics algorithm :
48 : : !! see Quigley,Probert, JCP 120, 11432 (2004) [[cite:Quigley2004]], part III
49 : : !!
50 : : !! INPUTS
51 : : !! ab_mover <type(abimover)> : Datatype with all the information needed by the preditor
52 : : !! itime : Index of the present iteration
53 : : !! zDEBUG : if true print some debugging information
54 : : !! pimd_param=datastructure that contains all the parameters necessary to Path-Integral MD
55 : : !!
56 : : !! OUTPUT
57 : : !!
58 : : !! SIDE EFFECTS
59 : : !! hist <type(abihist)> : History of positions,forces acell, rprimd, stresses
60 : : !!
61 : : !! SOURCE
62 : :
63 : 10 : subroutine pred_langevin_pimd(ab_mover,hist,itime,zDEBUG,pimd_param)
64 : :
65 : : ! Arguments -------------------------------
66 : : ! Scalars
67 : : type(abimover),intent(in) :: ab_mover
68 : : type(abihist),intent(inout) :: hist
69 : : type(pimd_type),intent(in) :: pimd_param
70 : : integer,intent(in) :: itime
71 : : logical,intent(in) :: zDEBUG
72 : :
73 : : ! Local variables -------------------------
74 : : ! Scalars
75 : : integer :: ihist_prev
76 : : real(dp) :: ucvol
77 : : real(dp) :: etotal
78 : : ! Arrays
79 : : real(dp) :: acell(3),rprimd(3,3),rprimd_next(3,3),rprimd_prev(3,3),gprimd(3,3)
80 : 20 : real(dp) :: gmet(3,3),rmet(3,3),strten(6),fcart(3,ab_mover%natom)
81 : 20 : real(dp) :: xred(3,ab_mover%natom),vel(3,ab_mover%natom),vel_cell(3,3),vel_cell_next(3,3)
82 : 20 : real(dp) :: pimd_etotal(1),pimd_stressin(3,3,1),pimd_xred(3,ab_mover%natom,1)
83 : 20 : real(dp) :: pimd_xred_next(3,ab_mover%natom,1),pimd_xred_prev(3,ab_mover%natom,1)
84 : 20 : real(dp) :: pimd_forces(3,ab_mover%natom,1),pimd_vel(3,ab_mover%natom,1)
85 : 20 : real(dp) :: pimd_vel_next(3,ab_mover%natom,1)
86 : :
87 : : ! *********************************************************************
88 : : ! Initialize arrays
89 : 10 : ihist_prev=0
90 : 10 : ucvol=zero
91 : 10 : etotal=zero
92 : 10 : acell=zero
93 : 10 : rprimd=zero
94 : 10 : rprimd_next=zero
95 : 10 : rprimd_prev=zero
96 : 10 : gprimd=zero
97 : 10 : gmet=zero
98 : 10 : rmet=zero
99 : 10 : strten=zero
100 [ + + + + ]: 250 : fcart=zero
101 [ + + + + ]: 250 : xred=zero
102 [ + + + + ]: 250 : vel=zero
103 : 10 : vel_cell=zero
104 : 10 : vel_cell_next=zero
105 : 10 : pimd_etotal=zero
106 : 10 : pimd_stressin=zero
107 [ + + + + : 260 : pimd_xred=zero
+ + ]
108 [ + + + + : 260 : pimd_xred_next=zero
+ + ]
109 [ + + + + : 260 : pimd_xred_prev=zero
+ + ]
110 [ + + + + : 260 : pimd_forces=zero
+ + ]
111 [ + + + + : 260 : pimd_vel=zero
+ + ]
112 [ + + + + : 260 : pimd_vel_next=zero
+ + ]
113 : : ! Get last positions
114 : 10 : call hist2var(acell,hist,ab_mover%natom,rprimd,xred,zDEBUG)
115 [ + + + + ]: 250 : fcart(:,:)=hist%fcart(:,:,hist%ihist)
116 [ + + ]: 70 : strten(:) =hist%strten(:,hist%ihist)
117 [ + + + + ]: 250 : vel(:,:) =hist%vel(:,:,hist%ihist)
118 [ + + + + ]: 130 : vel_cell =hist%vel_cell(:,:,hist%ihist)
119 : 10 : etotal =hist%etot(hist%ihist)
120 : 10 : call metric(gmet,gprimd,-1,rmet,rprimd,ucvol)
121 : :
122 : : ! Set PIMD corresponding variables
123 : 10 : pimd_etotal(1)=etotal
124 : 10 : pimd_stressin(1,1,1)=strten(1)
125 : 10 : pimd_stressin(2,2,1)=strten(2)
126 : 10 : pimd_stressin(3,3,1)=strten(3)
127 : 10 : pimd_stressin(3,2,1)=strten(4)
128 : 10 : pimd_stressin(3,1,1)=strten(5)
129 : 10 : pimd_stressin(2,1,1)=strten(6)
130 [ + + + + ]: 250 : pimd_xred(:,:,1)=xred(:,:)
131 : : ! Get quantities from previous step
132 [ + + ]: 10 : if(itime==1) then
133 [ + + + + ]: 50 : pimd_xred_prev(:,:,1)=xred(:,:)
134 : 2 : rprimd_prev(:,:)=rprimd(:,:)
135 : : else
136 : 8 : ihist_prev = abihist_findIndex(hist,-1)
137 [ + + + + ]: 200 : pimd_xred_prev(:,:,1)=hist%xred(:,:,ihist_prev)
138 [ + + + + ]: 104 : rprimd_prev(:,:)=hist%rprimd(:,:,ihist_prev)
139 : : endif
140 [ + + + + ]: 250 : pimd_forces(:,:,1)=fcart(:,:)
141 [ + + + + ]: 250 : pimd_vel(:,:,1)=vel(:,:)
142 : :
143 : : ! Compute next values
144 [ + + ]: 10 : if(pimd_param%optcell==0) then
145 : : call pimd_langevin_nvt(pimd_etotal,pimd_forces,itime,ab_mover%natom,pimd_param,&
146 : 5 : & 0,rprimd,pimd_stressin,1,pimd_vel,pimd_vel_next,ucvol,pimd_xred,pimd_xred_next,pimd_xred_prev)
147 : 5 : rprimd_next=rprimd ! We do not change primitive vectors
148 : 5 : vel_cell=zero ! Cell velocities are set to zero
149 [ + - ]: 5 : elseif(pimd_param%optcell==2) then
150 : : call pimd_langevin_npt(pimd_etotal,pimd_forces,itime,ab_mover%natom,pimd_param,&
151 : : & 0,rprimd,rprimd_next,rprimd_prev,pimd_stressin,1,pimd_vel,pimd_vel_next,vel_cell,&
152 : : & vel_cell_next,ucvol,&
153 : 5 : & pimd_xred,pimd_xred_next,pimd_xred_prev)
154 : : endif
155 : :
156 : : ! Update hist
157 : 10 : hist%ihist = abihist_findIndex(hist,+1)
158 : 10 : call var2hist(acell,hist,ab_mover%natom,rprimd_next,pimd_xred_next(:,:,1),zDEBUG)
159 [ + + + + ]: 250 : hist%vel(:,:,hist%ihist)=pimd_vel(:,:,1)
160 [ + + + + ]: 130 : hist%vel_cell(:,:,hist%ihist)=vel_cell(:,:)
161 : 10 : hist%time(hist%ihist)=real(itime,kind=dp)*ab_mover%dtion
162 : :
163 : 10 : end subroutine pred_langevin_pimd
164 : : !!***
165 : :
166 : : end module m_pred_langevin_pimd
167 : : !!***
|