Octopus
states_elec_dim.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
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
26!
28 use debug_oct_m
31 use global_oct_m
33 use math_oct_m
38
39 implicit none
40
41 private
42
43 public :: &
49
51 integer, public, parameter :: &
52 SPIN_DOWN = 1, &
53 spin_up = 2
54
55 ! TODO(Alex) Issue #672. Remove kpts indices and weights from states_elec_dim_t
58 ! Components are public by default
59 integer :: dim
62 integer :: ispin
65 integer :: nspin
68 integer :: spin_channels
69 type(distributed_t) :: kpt
70
71 contains
72 procedure :: get_spin_index => states_elec_dim_get_spin_index
73 procedure :: get_kpoint_index => states_elec_dim_get_kpoint_index
74 end type states_elec_dim_t
75
76contains
77
78 ! ---------------------------------------------------------
79 subroutine states_elec_dim_copy(dout, din)
80 type(states_elec_dim_t), intent(inout) :: dout
81 type(states_elec_dim_t), intent(in) :: din
82
83 push_sub(states_elec_dim_copy)
84
85 call states_elec_dim_end(dout)
86
87 dout%dim = din%dim
88 dout%ispin = din%ispin
89 dout%nspin = din%nspin
90 dout%spin_channels = din%spin_channels
91
92
93 call distributed_copy(din%kpt, dout%kpt)
94
96 end subroutine states_elec_dim_copy
97
98
99 ! ---------------------------------------------------------
100 subroutine states_elec_dim_end(dim)
101 type(states_elec_dim_t), intent(inout) :: dim
102
103 push_sub(states_elec_dim_end)
104
105 call distributed_end(dim%kpt)
106
107
108 pop_sub(states_elec_dim_end)
109 end subroutine states_elec_dim_end
110
111
112 ! ---------------------------------------------------------
114 !
115 logical pure function is_spin_up(ik)
116 integer, intent(in) :: ik
117
118 is_spin_up = odd(ik)
119
120 end function is_spin_up
121
122
123 ! ---------------------------------------------------------
125 !
126 logical pure function is_spin_down(ik)
127 integer, intent(in) :: ik
128
129 is_spin_down = even(ik)
130
131 end function is_spin_down
132
133 ! ---------------------------------------------------------
135 !
136 integer pure function states_elec_dim_get_spin_index(this, iq) result(index)
137 class(states_elec_dim_t), intent(in) :: this
138 integer, intent(in) :: iq
139
140 if (this%ispin == spin_polarized) then
141 index = 1 + mod(iq - 1, 2)
142 else
143 index = 1
144 end if
145
147
148
149 ! ---------------------------------------------------------
151 !
152 integer pure function states_elec_dim_get_kpoint_index(this, iq) result(index)
153 class(states_elec_dim_t), intent(in) :: this
154 integer, intent(in) :: iq
156 if (this%ispin == spin_polarized) then
157 index = 1 + (iq - 1)/2
158 else
159 index = iq
160 end if
163
164
167end module states_elec_dim_oct_m
168
169
170!! Local Variables:
171!! mode: f90
172!! coding: utf-8
173!! End:
subroutine, public distributed_end(this)
subroutine, public distributed_copy(in, out)
@Brief Create a copy of a distributed instance
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:115
logical pure function, public odd(n)
Returns if n is odd.
Definition: math.F90:699
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:145
This module handles spin dimensions of the states and the k-point distribution.
integer pure function states_elec_dim_get_spin_index(this, iq)
extract the spin index from the combined spin and k index
integer, parameter, public spin_up
integer pure function states_elec_dim_get_kpoint_index(this, iq)
extract the k-point index from the combined spin and k index
subroutine, public states_elec_dim_copy(dout, din)
logical pure function, public is_spin_up(ik)
Returns true if k-point ik denotes spin-up, in spin-polarized case.
subroutine, public states_elec_dim_end(dim)
logical pure function, public is_spin_down(ik)
Returns true if k-point ik denotes spin-down, in spin-polarized case.
class for organizing spins and k-points