Octopus
propagator_data_classical_particles.F90
Go to the documentation of this file.
1!! Copyright (C) 2021 S. Ohlmann, I. Albar, A. Obzhirov, A. Geondzhian, M. Lawan
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
23 use debug_oct_m
24 use global_oct_m
25 use io_oct_m
33
34 implicit none
35
36 private
37 public :: &
39
40 type :: propagator_data_t
42 real(real64), allocatable :: acc(:,:)
43 real(real64), allocatable :: prev_acc(:,:,:)
44 real(real64), allocatable :: save_pos(:,:)
45 real(real64), allocatable :: save_vel(:,:)
46 real(real64), allocatable :: prev_tot_force(:,:)
47 real(real64), allocatable :: prev_pos(:,:,:)
48 real(real64), allocatable :: prev_vel(:,:,:)
49 real(real64), allocatable :: hamiltonian_elements(:,:)
50 logical :: initialized = .false.
51 contains
52 procedure :: restart_write => propagator_data_restart_write
53 procedure :: restart_read => propagator_data_restart_read
54 procedure :: initialize => propagator_data_initialize
55 procedure :: end => propagator_data_end
56 procedure :: propagator_data_copy
57 generic :: assignment(=) => propagator_data_copy
58 end type propagator_data_t
59
60contains
61 ! ---------------------------------------------------------
62 subroutine propagator_data_restart_write(this, namespace, prop)
63 class(propagator_data_t), intent(inout) :: this
64 type(namespace_t), intent(in) :: namespace
65 class(algorithm_t), intent(in) :: prop
66
67 integer :: restart_file_unit
68
70 call io_mkdir('restart/'//td_dir, namespace, parents=.true.)
71 restart_file_unit = io_open('restart/'//td_dir// 'restart_classical_particles_propagation', &
72 namespace, action='write')
73
74 select type(prop)
75 type is (propagator_verlet_t)
76 write(restart_file_unit,*) this%acc(:,:)
77 write(restart_file_unit,*) this%prev_acc(:,:,:)
78 type is (propagator_beeman_t)
79 write(restart_file_unit,*) this%acc(:,:)
80 write(restart_file_unit,*) this%prev_acc(:,:,:)
81 if (prop%predictor_corrector) then
82 write(restart_file_unit,*) this%prev_tot_force(:,:)
83 write(restart_file_unit,*) this%save_vel(:,:)
84 write(restart_file_unit,*) this%save_pos(:,:)
85 end if
87 write(restart_file_unit,*) this%prev_vel(:,:,:)
88 write(restart_file_unit,*) this%prev_pos(:,:,:)
89 write(restart_file_unit,*) this%save_vel(:,:)
90 write(restart_file_unit,*) this%save_pos(:,:)
91 end select
92
93 call io_close(restart_file_unit)
94
97
98 ! ---------------------------------------------------------
99 logical function propagator_data_restart_read(this, namespace, prop)
100 class(propagator_data_t), intent(inout) :: this
101 type(namespace_t), intent(in) :: namespace
102 class(algorithm_t), intent(in) :: prop
103
104 integer :: restart_file_unit
105
107
108 call io_mkdir('restart/'//td_dir, namespace, parents=.true.)
109 restart_file_unit = io_open('restart/'//td_dir// 'restart_classical_particles_propagation', namespace, &
110 action='read', die=.false.)
111 if (restart_file_unit > 0) then
112 select type(prop)
113 type is (propagator_verlet_t)
114 read(restart_file_unit,*) this%acc(:,:)
115 read(restart_file_unit,*) this%prev_acc(:,:,:)
116
117 type is (propagator_beeman_t)
118 read(restart_file_unit,*) this%acc(:,:)
119 read(restart_file_unit,*) this%prev_acc(:,:,:)
120 if (prop%predictor_corrector) then
121 read(restart_file_unit,*) this%prev_tot_force(:,:)
122 read(restart_file_unit,*) this%save_vel(:,:)
123 read(restart_file_unit,*) this%save_pos(:,:)
124 end if
126 read(restart_file_unit,*) this%prev_vel(:,:,:)
127 read(restart_file_unit,*) this%prev_pos(:,:,:)
128 read(restart_file_unit,*) this%save_vel(:,:)
129 read(restart_file_unit,*) this%save_pos(:,:)
130 end select
131
132 call io_close(restart_file_unit)
134 else
135 ! error opening file
137 end if
142 ! ---------------------------------------------------------
143 subroutine propagator_data_initialize(this, prop, dim, np)
144 class(propagator_data_t), intent(inout) :: this
145 class(algorithm_t), intent(in) :: prop
146 integer, intent(in) :: dim
147 integer, intent(in) :: np
151 if (.not. this%initialized) then
152 select type(prop)
153 type is (propagator_verlet_t)
154 safe_allocate(this%acc(1:dim, 1:np))
155 safe_allocate(this%prev_acc(1:dim, 1:np, 1))
156 type is (propagator_beeman_t)
157 if (prop%predictor_corrector) then
158 safe_allocate(this%save_pos(1:dim, 1:np))
159 safe_allocate(this%save_vel(1:dim, 1:np))
160 safe_allocate(this%prev_tot_force(1:dim, 1:np))
161 end if
162 safe_allocate(this%acc(1:dim, 1:np))
163 safe_allocate(this%prev_acc(1:dim, 1:np, 1:2))
165 safe_allocate(this%save_pos(1:dim, 1:np))
166 safe_allocate(this%save_vel(1:dim, 1:np))
167 safe_allocate(this%hamiltonian_elements(1:dim, 1:np))
168 safe_allocate(this%prev_pos(1:dim, 1:np, 1))
169 safe_allocate(this%prev_vel(1:dim, 1:np, 1))
170 end select
171 this%initialized = .true.
172 end if
173
175 end subroutine propagator_data_initialize
176
177 ! ---------------------------------------------------------
178 subroutine propagator_data_end(this)
179 class(propagator_data_t), intent(inout) :: this
180
181 push_sub(propagator_data_end)
182
183 safe_deallocate_a(this%acc)
184 safe_deallocate_a(this%prev_acc)
185 safe_deallocate_a(this%prev_tot_force)
186 safe_deallocate_a(this%save_pos)
187 safe_deallocate_a(this%save_vel)
188 safe_deallocate_a(this%hamiltonian_elements)
189 safe_deallocate_a(this%prev_pos)
190 safe_deallocate_a(this%prev_vel)
191
193 end subroutine propagator_data_end
194
195 ! ---------------------------------------------------------
196 subroutine propagator_data_copy(this, prop_data_in)
197 class(propagator_data_t), intent(inout) :: this
198 class(propagator_data_t), intent(in) :: prop_data_in
199
200 push_sub(propagator_data_copy)
201
202 safe_allocate_source_a(this%acc, prop_data_in%acc)
203 safe_allocate_source_a(this%prev_acc, prop_data_in%prev_acc)
204 safe_allocate_source_a(this%save_pos, prop_data_in%save_pos)
205 safe_allocate_source_a(this%save_vel, prop_data_in%save_vel)
206 safe_allocate_source_a(this%prev_tot_force, prop_data_in%prev_tot_force)
207 safe_allocate_source_a(this%prev_pos, prop_data_in%prev_pos)
208 safe_allocate_source_a(this%prev_vel, prop_data_in%prev_vel)
209 safe_allocate_source_a(this%hamiltonian_elements, prop_data_in%hamiltonian_elements)
210
211 pop_sub(propagator_data_copy)
212 end subroutine propagator_data_copy
214
215!! Local Variables:
216!! mode: f90
217!! coding: utf-8
218!! End:
This module implements the basic elements defining algorithms.
Definition: algorithm.F90:141
character(len= *), parameter, public td_dir
Definition: global.F90:250
Definition: io.F90:114
subroutine, public io_close(iunit, grp)
Definition: io.F90:468
subroutine, public io_mkdir(fname, namespace, parents)
Definition: io.F90:354
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
Definition: io.F90:395
logical function propagator_data_restart_read(this, namespace, prop)
This module implements the basic propagator framework.
Definition: propagator.F90:117
An algorithm is a list of algorithmic operations executed sequentially.
Definition: algorithm.F90:200
Implements the Beeman propagator (with or without SCF)
Implements the implicit exponential midpoint propagator with predictor-corrector.
Implements a propagator for the velocity Verlet algorithm.
int true(void)