The Elk Code
 
Loading...
Searching...
No Matches
moldyn.f90
Go to the documentation of this file.
1
2! Copyright (C) 2023 J. K. Dewhurst and S. Sharma.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6subroutine moldyn
7use modmain
8use modtddft
9use modmpi
10use modomp
11use moddelf
12implicit none
13! local variables
14integer is,ia
15! initialise universal variables
16call init0
17! store original parameters
18atposl0(:,:,:)=atposl(:,:,:)
19atposc0(:,:,:)=atposc(:,:,:)
23! no shifting of atomic basis allowed
24tshift=.false.
25! calculate atomic forces
26tforce=.true.
27! average force can be non-zero (allow for translation of atomic basis)
28tfav0=.false.
29! generate the time step grid
30call gentimes
31! flag for starting at t=0 or a restart
32tdt0=(task == 420)
33if (tdt0) then
34! start from t=0
35 itimes0=1
36else
37! restart if required
38 call readtimes
40 trdatdv=.true.
41end if
42if (trdatdv) then
43! read the atomic displacements and velocities
44 call readatdvc
45else
46! set the displacements and velocities to zero
47 atdvc(:,:,:,:)=0.d0
48end if
49trdstate=.false.
50if (tdt0.and.mp_mpi) then
51 call delfile('TOTENERGY_TD.OUT')
52 if (spinpol) then
53 call delfile('MOMENT_TD.OUT')
54 call delfile('MOMENTM_TD.OUT')
55 call delfile('MOMENTMT_TD.OUT')
56 call delfile('MOMENTIR_TD.OUT')
57 end if
58 call delfile('FORCETOT_TD.OUT')
59 call delfile('FORCEMAX_TD.OUT')
60 call delfile('ATDISPL_TD.OUT')
61 call delfile('ATDISPC_TD.OUT')
62end if
64 if (mp_mpi) then
65 write(*,'("Info(moldyn): time step ",I8," of ",I8,", t = ",G18.10)') &
67 end if
68! reset the OpenMP thread variables
69 call omp_reset
70! add the displacements to the atomic positions
71 do is=1,nspecies
72 do ia=1,natoms(is)
73 atposc(:,ia,is)=atposc0(:,ia,is)+atdvc(:,0,ia,is)
74 call r3mv(ainv,atposc(:,ia,is),atposl(:,ia,is))
75 end do
76 end do
77! calculate the ground-state and atomic forces
78 call gndstate
79! subsequent calculations will read in the potential from STATE.OUT
80 trdstate=.true.
81! time step the atomic positions within the adiabatic approximation
82 call atptstep(forcetot)
83 if (mp_mpi) then
84! write the time step to file
85 call writetimes
86! write time-dependent total energy
87 call writetdengy
88! write spin moments if required
89 if (spinpol) call writemomtd
90! write time-dependent atomic forces
91 call writetdforces
92! write the time-dependent atomic displacements
93 call writeatdisp
94! write the XCrysden animation file crystal.axsf
95 call writeaxsf
96 end if
97 if (tstop) exit
98end do
99! restore original input parameters
100atposl(:,:,:)=atposl0(:,:,:)
104! synchronise MPI processes
105call mpi_barrier(mpicom,ierror)
106end subroutine
107
subroutine atptstep(ft)
Definition atptstep.f90:7
subroutine gentimes
Definition gentimes.f90:7
subroutine gndstate
Definition gndstate.f90:10
subroutine init0
Definition init0.f90:10
subroutine moldyn
Definition moldyn.f90:7
subroutine delfile(fname)
Definition moddelf.f90:15
logical tshift
Definition modmain.f90:352
logical tfav00
Definition modmain.f90:1000
real(8), dimension(3, maxatoms, maxspecies) atposc
Definition modmain.f90:54
integer, dimension(maxspecies) natoms
Definition modmain.f90:36
logical spinpol
Definition modmain.f90:228
logical trdatdv
Definition modmain.f90:62
logical tshift0
Definition modmain.f90:352
logical tstop
Definition modmain.f90:1052
logical tfav0
Definition modmain.f90:1000
real(8), dimension(3, maxatoms, maxspecies) atposl0
Definition modmain.f90:51
logical trdstate
Definition modmain.f90:682
integer task
Definition modmain.f90:1298
real(8), dimension(3, maxatoms, maxspecies) atposc0
Definition modmain.f90:54
real(8), dimension(:,:), allocatable forcetot
Definition modmain.f90:990
real(8), dimension(3, 3) ainv
Definition modmain.f90:14
logical tforce
Definition modmain.f90:986
integer nspecies
Definition modmain.f90:34
real(8), dimension(3, 0:1, maxatoms, maxspecies) atdvc
Definition modmain.f90:64
logical tforce0
Definition modmain.f90:986
real(8), dimension(3, maxatoms, maxspecies) atposl
Definition modmain.f90:51
integer ierror
Definition modmpi.f90:19
integer mpicom
Definition modmpi.f90:11
logical mp_mpi
Definition modmpi.f90:17
subroutine omp_reset
Definition modomp.f90:71
real(8), dimension(:), allocatable times
Definition modtddft.f90:48
integer ntsforce
Definition modtddft.f90:98
logical tdt0
Definition modtddft.f90:50
integer itimes0
Definition modtddft.f90:44
integer itimes
Definition modtddft.f90:46
integer ntimes
Definition modtddft.f90:42
pure subroutine r3mv(a, x, y)
Definition r3mv.f90:10
subroutine readatdvc
Definition readatdvc.f90:7
subroutine readtimes
Definition readtimes.f90:7
subroutine writeatdisp
subroutine writeaxsf
Definition writeaxsf.f90:7
subroutine writemomtd
Definition writemomtd.f90:7
subroutine writetdengy
subroutine writetdforces
subroutine writetimes
Definition writetimes.f90:7