Octopus
scissor.F90
Go to the documentation of this file.
1!! Copyright (C) 2016 X. Andrade, N. Tancogne-Dejean
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., 59 Temple Place - Suite 330, Boston, MA
16!! 02111-1307, USA.
17
18#include "global.h"
19
20module scissor_oct_m
21 use batch_oct_m
23 use debug_oct_m
24 use global_oct_m
27 use mesh_oct_m
32 use parser_oct_m
33 use phase_oct_m
36 use space_oct_m
42
43 implicit none
44
45 private
46
47 public :: &
48 scissor_t, &
54
55 type scissor_t
56 private
57 logical, public :: apply = .false.
58 real(real64) :: gap
59 type(states_elec_t) :: gs_st
60 end type scissor_t
61
62 interface scissor_commute_r
64 end interface
65
66contains
67
68 subroutine scissor_init(this, namespace, space, st, mesh, d, kpoints, phase, gap, mc)
69 type(scissor_t), intent(inout) :: this
70 type(namespace_t), intent(in) :: namespace
71 class(space_t), intent(in) :: space
72 type(states_elec_t), intent(in) :: st
73 class(mesh_t), intent(in) :: mesh
74 type(kpoints_t), intent(in) :: kpoints
75 type(states_elec_dim_t), intent(in) :: d
76 type(phase_t), intent(in) :: phase
77 real(real64), intent(in) :: gap
78 type(multicomm_t), intent(in) :: mc
79
80 type(restart_t) :: restart_gs
81 integer :: ierr
82 integer :: ist, ik
83 complex(real64), allocatable :: temp_state(:,:)
84
85 push_sub(scissor_init)
86
87 assert(.not. this%apply)
88 assert(.not. states_are_real(st))
89
90 call messages_print_with_emphasis(msg="TDScissor", namespace=namespace)
91
92 if (st%parallel_in_states) then
93 call messages_not_implemented("Scissor operator parallel in states", namespace=namespace)
94 end if
95 if (mesh%parallel_in_domains) then
96 call messages_not_implemented("Scissor operator parallel in domains", namespace=namespace)
97 end if
98
99 this%apply = .true.
100 this%gap = gap
101
102 write(message(1),'(a)') 'Start loading GS states.'
103 call messages_info(1, namespace=namespace)
104 !We need to load GS states and to store them in this%gs_st
105 call states_elec_copy(this%gs_st, st)
106
107 call restart_init(restart_gs, namespace, restart_proj, restart_type_load, mc, ierr, mesh=mesh)
108 if (ierr /= 0) then
109 message(1) = "Unable to read states information."
110 call messages_fatal(1, namespace=namespace)
111 end if
112
113 call states_elec_load(restart_gs, namespace, space, this%gs_st, mesh, kpoints, ierr, label = ': gs for TDScissor')
114 if (ierr /= 0 .and. ierr /= (this%gs_st%st_end-this%gs_st%st_start+1)*this%gs_st%nik*this%gs_st%d%dim) then
115 message(1) = "Unable to read wavefunctions for TDScissor."
116 call messages_fatal(1, namespace=namespace)
117 end if
118 call restart_end(restart_gs)
119
120 if (space%is_periodic() .and. .not. (kpoints_number(kpoints) == 1 .and. kpoints_point_is_gamma(kpoints, 1))) then
121
122 write(message(1),'(a)') 'Adding the phase for GS states.'
123 call messages_info(1, namespace=namespace)
124
125 safe_allocate(temp_state(1:mesh%np_part, 1:this%gs_st%d%dim))
126 ! We apply the phase to these states, as we need it for the projectors later
127 do ik=this%gs_st%d%kpt%start, this%gs_st%d%kpt%end
128
129 do ist = this%gs_st%st_start, this%gs_st%st_end
130 call states_elec_get_state(this%gs_st, mesh, ist, ik, temp_state)
131 call phase%apply_to_single(temp_state, mesh%np, this%gs_st%d%dim, ik, .false.)
132 call states_elec_set_state(this%gs_st, mesh, ist, ik,temp_state)
133 end do
134
135 end do
136
137 safe_deallocate_a(temp_state)
138 end if
139
140 call messages_print_with_emphasis(namespace=namespace)
141
142 pop_sub(scissor_init)
143 end subroutine scissor_init
144
145 subroutine scissor_end(this)
146 type(scissor_t), intent(inout) :: this
147
148 push_sub(scissor_end)
149
150 this%apply = .false.
151 call states_elec_end(this%gs_st)
153 pop_sub(scissor_end)
154 end subroutine scissor_end
156#include "undef.F90"
157#include "real.F90"
158#include "scissor_inc.F90"
159
160#include "undef.F90"
161#include "complex.F90"
162#include "scissor_inc.F90"
163end module scissor_oct_m
164
165!! Local Variables:
166!! mode: f90
167!! coding: utf-8
168!! End:
This module implements batches of mesh functions.
Definition: batch.F90:133
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:116
logical pure function, public kpoints_point_is_gamma(this, ik)
Definition: kpoints.F90:1549
integer pure function, public kpoints_number(this)
Definition: kpoints.F90:1099
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:118
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
Definition: messages.F90:930
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1125
character(len=512), private msg
Definition: messages.F90:165
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
Definition: messages.F90:624
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:160
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:420
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:145
subroutine, public restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
Initializes a restart object.
Definition: restart.F90:514
integer, parameter, public restart_proj
Definition: restart.F90:229
integer, parameter, public restart_type_load
Definition: restart.F90:225
subroutine, public restart_end(restart)
Definition: restart.F90:720
subroutine zscissor_commute_r(this, mesh, ik, psi, gpsi)
Definition: scissor.F90:528
subroutine, public scissor_init(this, namespace, space, st, mesh, d, kpoints, phase, gap, mc)
Definition: scissor.F90:162
subroutine, public zscissor_apply(this, mesh, psib, hpsib)
Definition: scissor.F90:485
subroutine dscissor_commute_r(this, mesh, ik, psi, gpsi)
Definition: scissor.F90:359
subroutine, public dscissor_apply(this, mesh, psib, hpsib)
Definition: scissor.F90:316
subroutine, public scissor_end(this)
Definition: scissor.F90:239
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
subroutine, public states_elec_end(st)
finalize the states_elec_t object
subroutine, public states_elec_copy(stout, stin, exclude_wfns, exclude_eigenval, special)
make a (selective) copy of a states_elec_t object
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_load(restart, namespace, space, st, mesh, kpoints, ierr, iter, lr, lowest_missing, label, verbose, skip)
returns in ierr: <0 => Fatal error, or nothing read =0 => read all wavefunctions >0 => could only rea...
int true(void)