Line data Source code
1 : !!****m* ABINIT/m_lattice_lwf_mover
2 : !! NAME
3 : !! m_lattice_lwf_mover
4 : !!
5 : !! FUNCTION
6 : !! This module contains the mover for coupled lattice lwf dynamics
7 : !!
8 : !!
9 : !! COPYRIGHT
10 : !! Copyright (C) 2001-2026 ABINIT group (hexu)
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 : !! For the initials of contributors, see ~abinit/doc/developers/contributors.txt .
15 : !!
16 : !! SOURCE
17 :
18 : #if defined HAVE_CONFIG_H
19 : #include "config.h"
20 : #endif
21 : #include "abi_common.h"
22 :
23 : module m_lattice_lwf_mover
24 :
25 : use defs_basis
26 : use m_errors
27 : use m_abicore
28 : use m_xmpi
29 : use m_io_tools, only : get_unit, open_file, close_unit
30 : use m_mpi_scheduler, only: mpi_scheduler_t, init_mpi_info
31 :
32 :
33 : use m_abstract_potential, only: abstract_potential_t
34 : use m_abstract_mover, only: abstract_mover_t
35 : use m_lattice_mover, only: lattice_mover_t
36 : use m_lwf_mover, only: lwf_mover_t
37 : use m_hashtable_strval, only: hash_table_t
38 :
39 : implicit none
40 :
41 : private
42 :
43 : !!***
44 :
45 : type, public, extends(abstract_mover_t) :: lattice_lwf_mover_t
46 : class(lattice_mover_t), pointer :: lattice_mover => null()
47 : class(lwf_mover_t), pointer :: lwf_mover => null()
48 : CONTAINS
49 : procedure :: initialize
50 : procedure :: finalize
51 : procedure :: run_time
52 :
53 : end type lattice_lwf_mover_t
54 :
55 : contains
56 0 : subroutine initialize(self, lattice_mover, lwf_mover)
57 : class(lattice_lwf_mover_t),intent(inout) :: self
58 : class(lattice_mover_t), target:: lattice_mover
59 : class(lwf_mover_t), target:: lwf_mover
60 0 : self%lattice_mover=>lattice_mover
61 0 : self%lwf_mover=>lwf_mover
62 0 : self%dt=self%lattice_mover%dt
63 0 : self%thermal_time=self%lattice_mover%thermal_time
64 0 : end subroutine initialize
65 :
66 0 : subroutine finalize(self)
67 : class(lattice_lwf_mover_t),intent(inout) :: self
68 0 : nullify(self%lattice_mover)
69 0 : nullify(self%lwf_mover)
70 0 : end subroutine finalize
71 :
72 0 : subroutine run_time(self, effpot, displacement, strain, spin, lwf, energy_table)
73 : class(lattice_lwf_mover_t),intent(inout) :: self
74 : ! array of effective potentials so that there can be multiple of them.
75 : class(abstract_potential_t), intent(inout) :: effpot
76 : real(dp), optional, intent(inout) :: displacement(:,:), strain(:,:), spin(:,:), lwf(:)
77 : type(hash_table_t), optional, intent(inout) :: energy_table
78 : integer :: i, nstep
79 : character(len=90) :: msg
80 0 : if(present(displacement) .or. present(strain)) then
81 0 : ABI_ERROR("displacement and strain should not be input for lattice mover")
82 : end if
83 0 : ABI_UNUSED_A(effpot)
84 0 : ABI_UNUSED_A(spin)
85 0 : ABI_UNUSED_A(lwf)
86 0 : ABI_UNUSED_A(energy_table)
87 :
88 :
89 0 : msg=repeat("=", 90)
90 0 : call wrtout(std_out,msg,'COLL')
91 0 : call wrtout(ab_out, msg, 'COLL')
92 0 : write(msg, '(A22)') "Lattice dynamic steps:"
93 0 : call wrtout(std_out,msg,'COLL')
94 0 : call wrtout(ab_out, msg, 'COLL')
95 0 : msg=repeat("=", 90)
96 0 : call wrtout(std_out,msg,'COLL')
97 0 : call wrtout(ab_out, msg, 'COLL')
98 :
99 : write(msg, "(A13, 4X, A15, 4X, A15, 4X, A15, 4X, A15)") &
100 0 : & "Iteration", "temperature(K)", "Ekin(Ha/uc)", &
101 0 : & "Epot(Ha/uc)", "ETOT(Ha/uc)"
102 0 : call wrtout(std_out,msg,'COLL')
103 0 : call wrtout(ab_out, msg, 'COLL')
104 :
105 0 : nstep=floor(self%lattice_mover%thermal_time/self%lattice_mover%dt)
106 0 : do i =1, nstep
107 : call self%lattice_mover%run_one_step(effpot=effpot, displacement=self%lattice_mover%displacement, &
108 0 : & strain=strain, spin=spin, lwf=self%lwf_mover%lwf, energy_table=energy_table)
109 : !call self%lwf_mover%run_one_step(effpot=effpot, displacement=self%lattice_mover%displacement, strain=strain, spin=spin, &
110 : ! & lwf=lwf, energy_table=energy_table)
111 0 : call self%lwf_mover%hist%set_hist(lwf=self%lwf_mover%lwf, energy=self%lattice_mover%energy )
112 : end do
113 :
114 0 : nstep=floor(self%lattice_mover%total_time/self%lattice_mover%dt)
115 0 : do i =1, nstep
116 : call self%lattice_mover%run_one_step(effpot=effpot, displacement=self%lattice_mover%displacement, &
117 0 : & lwf=self%lwf_mover%lwf, energy_table=energy_table)
118 0 : call self%lwf_mover%hist%set_hist(lwf=self%lwf_mover%lwf, energy=self%lattice_mover%energy )
119 :
120 0 : if(modulo(i, self%lattice_mover%params%nctime)==0) then
121 0 : write(msg, "(I13, 4X, F15.5, 4X, ES15.5, 4X, ES15.5, 4X, ES15.5)") i, self%lattice_mover%T_ob*Ha_K, &
122 0 : & self%lattice_mover%Ek/self%lattice_mover%supercell%ncell, &
123 0 : & self%lattice_mover%energy/self%lattice_mover%supercell%ncell, &
124 0 : & (self%lattice_mover%Ek+self%lattice_mover%energy)/self%lattice_mover%supercell%ncell
125 0 : call wrtout(std_out,msg,'COLL')
126 0 : call wrtout(ab_out, msg, 'COLL')
127 :
128 0 : self%lattice_mover%current_xcart(:, :) = self%lattice_mover%supercell%lattice%xcart(:,:)+self%lattice_mover%displacement
129 : call self%lattice_mover%ncfile%write_one_step(self%lattice_mover%current_xcart, &
130 0 : & self%lattice_mover%current_vcart, self%lattice_mover%energy, self%lattice_mover%Ek)
131 :
132 0 : call self%lwf_mover%ncfile%write_one_step(self%lwf_mover%hist)
133 :
134 : end if
135 : end do
136 :
137 0 : msg=repeat("=", 90)
138 0 : call wrtout(std_out,msg,'COLL')
139 0 : call wrtout(ab_out, msg, 'COLL')
140 0 : end subroutine run_time
141 :
142 0 : end module m_lattice_lwf_mover
|