TABLE OF CONTENTS


ABINIT/m_spin_mover [ Modules ]

[ Top ] [ Modules ]

NAME

 m_spin_mover

FUNCTION

 This module contains the spin mover, which controls how the spin 


 Datatypes:

 * spin_mover_t

 Subroutines:

 * spin_mover_t_initialize
 * spin_mover_t_run_one_step
 * spin_mover_t_run_time

COPYRIGHT

 Copyright (C) 2001-2017 ABINIT group (hexu)
 This file is distributed under the terms of the
 GNU General Public License, see ~abinit/COPYING
 or http://www.gnu.org/copyleft/gpl.txt .
 For the initials of contributors, see ~abinit/doc/developers/contributors.txt .

SOURCE

32 #if defined HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35 module m_spin_mover
36   use defs_basis
37   use m_errors
38   use m_abicore
39   use m_spin_terms, only: spin_terms_t_get_dSdt, spin_terms_t_get_Langevin_Heff, spin_terms_t_get_gamma_l, spin_terms_t
40   !use m_mathfuncs
41   use m_spin_hist, only: spin_hist_t, spin_hist_t_set_vars, spin_hist_t_get_s
42   use m_spin_ncfile, only: spin_ncfile_t, spin_ncfile_t_write_one_step
43   implicit none

m_spin_mover/spin_mover_t [ Types ]

[ Top ] [ m_spin_mover ] [ Types ]

NAME

 spin_mover_t

FUNCTION

 this type contains the parameters for the spin mover.

 It contains:
 dt: time step
 total_time
 temperature.
 nmatoms number of magnetic atoms

SOURCE

62   type spin_mover_t
63      integer :: nmatoms
64      real(dp) :: dt, total_time, temperature
65      !CONTAINS
66      !   procedure :: initialize => spin_mover_t_initialize
67      !   procedure :: run_one_step => spin_mover_t_run_one_step
68      !   procedure :: run_time => spin_mover_t_run_time
69   end type spin_mover_t

m_spin_mover/spin_mover_t_finalize [ Functions ]

[ Top ] [ m_spin_mover ] [ Functions ]

NAME

  spin_mover_t_finalize

FUNCTION

 finalize spin mover.

INPUTS

OUTPUT

NOTES

   does nothing. But it's better to preserve initialize-finalize symmetry.

PARENTS

CHILDREN

SOURCE

282   subroutine spin_mover_t_finalize(self)
283 
284 
285 !This section has been created automatically by the script Abilint (TD).
286 !Do not modify the following lines by hand.
287 #undef ABI_FUNC
288 #define ABI_FUNC 'spin_mover_t_finalize'
289 !End of the abilint section
290 
291     class(spin_mover_t), intent(inout):: self
292   end subroutine spin_mover_t_finalize

m_spin_mover/spin_mover_t_initialize [ Functions ]

[ Top ] [ m_spin_mover ] [ Functions ]

NAME

  spin_mover_t_initialize

FUNCTION

  initialize the spin mover

INPUTS

OUTPUT

NOTES

PARENTS

CHILDREN

SOURCE

 93   subroutine spin_mover_t_initialize(self, nmatoms, dt, total_time, temperature)
 94     !class (spin_mover_t):: self
 95 
 96 !This section has been created automatically by the script Abilint (TD).
 97 !Do not modify the following lines by hand.
 98 #undef ABI_FUNC
 99 #define ABI_FUNC 'spin_mover_t_initialize'
100 !End of the abilint section
101 
102     type(spin_mover_t), intent(inout) :: self
103     real(dp), intent(in) :: dt, total_time, temperature
104     integer, intent(in) :: nmatoms
105     self%nmatoms=nmatoms
106     self%dt=dt
107     self%total_time=total_time
108     self%temperature=temperature
109   end subroutine spin_mover_t_initialize

m_spin_mover/spin_mover_t_run_one_step [ Functions ]

[ Top ] [ m_spin_mover ] [ Functions ]

NAME

  spin_mover_t_run_one_step

FUNCTION

 run one spin step

INPUTS

OUTPUT

NOTES

 Currently Heun's  (HeunP) integration Method is implemented
 should be able to call multi method when implemented

PARENTS

CHILDREN

SOURCE

136   subroutine spin_mover_t_run_one_step(self, calculator, S_in, S_out, etot)
137     !class (spin_mover_t), intent(inout):: self
138 
139 !This section has been created automatically by the script Abilint (TD).
140 !Do not modify the following lines by hand.
141 #undef ABI_FUNC
142 #define ABI_FUNC 'spin_mover_t_run_one_step'
143 !End of the abilint section
144 
145     type(spin_mover_t), intent(inout):: self
146     type(spin_terms_t), intent(inout) :: calculator
147     real(dp), intent(in) :: S_in(3,self%nmatoms)
148     real(dp), intent(out) :: S_out(3,self%nmatoms), etot
149     integer :: i
150     real(dp) ::  dSdt(3, self%nmatoms), dSdt2(3, self%nmatoms), &
151          & Heff(3, self%nmatoms), Heff2(3, self%nmatoms), &
152          & H_lang(3, self%nmatoms)
153     ! predict
154 
155     !call calculator%get_Langevin_Heff(self%dt, self%temperature, H_lang)
156     call spin_terms_t_get_Langevin_Heff(calculator, self%dt, self%temperature, H_lang)
157 
158     !call calculator%get_dSdt(S_in, H_lang, dSdt)
159     call spin_terms_t_get_dSdt(calculator, S_in, H_lang, dSdt)
160     !$OMP PARALLEL DO
161     do i =1, self%nmatoms
162        S_out(:,i)=  S_in(:,i) +dSdt(:,i) * self%dt
163     end do
164     !$OMP END PARALLEL DO
165 
166     ! correction
167     !call calculator%get_dSdt(S_out, H_lang, dSdt2)
168     call spin_terms_t_get_dSdt(calculator, S_out, H_lang, dSdt2)
169     etot=calculator%etot
170     !$OMP PARALLEL DO
171     do i =1, self%nmatoms
172        S_out(:,i)=  S_in(:,i) +(dSdt(:,i)+dSdt2(:,i)) * (0.5_dp*self%dt)
173     end do
174     !$OMP END PARALLEL DO
175     !print *, "S before norm", S_out
176     do i=1, self%nmatoms
177        S_out(:,i)=S_out(:,i)/sqrt(sum(S_out(:,i)**2))
178     end do
179     !print *, "dt: ",self%dt
180     !print *, "S:", S_out
181   end subroutine spin_mover_t_run_one_step

m_spin_mover/spin_mover_t_run_time [ Functions ]

[ Top ] [ m_spin_mover ] [ Functions ]

NAME

  spin_mover_t_run_time

FUNCTION

 run all spin step

INPUTS

OUTPUT

NOTES

PARENTS

CHILDREN

SOURCE

205   subroutine spin_mover_t_run_time(self, calculator, hist, ncfile)
206 
207 
208 !This section has been created automatically by the script Abilint (TD).
209 !Do not modify the following lines by hand.
210 #undef ABI_FUNC
211 #define ABI_FUNC 'spin_mover_t_run_time'
212 !End of the abilint section
213 
214     class(spin_mover_t), intent(inout):: self
215     type(spin_terms_t), intent(inout) :: calculator
216     type(spin_hist_t), intent(inout) :: hist
217     type(spin_ncfile_t), intent(inout) :: ncfile
218     real(dp) ::  S(3, self%nmatoms), etot
219     real(dp):: t
220     integer :: counter
221     character(len=100) :: msg
222     t=0.0
223     counter=0
224     write(msg, *) " Begining spin dynamic steps :"
225     write(std_out,*) msg
226     write(ab_out, *) msg
227     write(msg, *)  "==================================================================================" 
228     write(std_out,*) msg
229     write(ab_out, *) msg
230 
231     write(msg, "(A13, 4X, A13, 4X, A13, 4X, A13)")  "Iteration", "time(s)", "average M", "Energy"
232     write(std_out,*) msg
233     write(ab_out, *) msg
234     write(msg, *)  "-----------------------------------------------------------------------------------" 
235     write(std_out,*) msg
236     write(ab_out, *) msg
237 
238     do while(t<self%total_time)
239        counter=counter+1
240        !call self%run_one_step(calculator, hist%current_S, S)
241        call spin_mover_t_run_one_step(self, calculator, spin_hist_t_get_S(hist), S, etot)
242        call spin_hist_t_set_vars(hist=hist, S=S, time=t,etot=etot, inc=.True.)
243        if(mod(counter, hist%spin_nctime)==0) then
244           call spin_ncfile_t_write_one_step(ncfile, hist)
245           write(msg, "(I13, 4X, ES13.5, 4X, ES13.5, 4X, ES13.5)") counter, t, sqrt(sum((sum(S, dim=2)/self%nmatoms)**2)), &
246                & hist%etot(hist%ihist_prev)
247           write(std_out,*) msg
248           write(ab_out, *) msg
249        endif
250        !call wrtout_myproc(std_out,msg)
251           !print "(I8, 4X, 4ES13.5)", self%current_step, anorm, (a(i) , i=1, 3)
252        t=t+self%dt
253     enddo
254     write(msg, *)  "=====================================================================================" 
255     write(std_out,*) msg
256     write(ab_out, *) msg
257 
258   end subroutine spin_mover_t_run_time