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 :: &
48
50 integer, public, parameter :: &
51 SPIN_DOWN = 1, &
52 spin_up = 2
53
54 ! TODO(Alex) Issue #672. Remove kpts indices and weights from states_elec_dim_t
57 ! Components are public by default
58 integer :: dim
61 integer :: ispin
64 integer :: nspin
67 integer :: spin_channels
68 type(distributed_t) :: kpt
69
70 contains
71 procedure :: get_spin_index => states_elec_dim_get_spin_index
72 procedure :: get_kpoint_index => states_elec_dim_get_kpoint_index
73 end type states_elec_dim_t
74
75contains
76
77 ! ---------------------------------------------------------
78 subroutine states_elec_dim_copy(dout, din)
79 type(states_elec_dim_t), intent(inout) :: dout
80 type(states_elec_dim_t), intent(in) :: din
81
82 push_sub(states_elec_dim_copy)
83
84 call states_elec_dim_end(dout)
85
86 dout%dim = din%dim
87 dout%ispin = din%ispin
88 dout%nspin = din%nspin
89 dout%spin_channels = din%spin_channels
90
91
92 call distributed_copy(din%kpt, dout%kpt)
93
95 end subroutine states_elec_dim_copy
96
97
98 ! ---------------------------------------------------------
99 subroutine states_elec_dim_end(dim)
100 type(states_elec_dim_t), intent(inout) :: dim
101
102 push_sub(states_elec_dim_end)
103
104 call distributed_end(dim%kpt)
105
106
107 pop_sub(states_elec_dim_end)
108 end subroutine states_elec_dim_end
109
110
111 ! ---------------------------------------------------------
113 !
114 logical pure function is_spin_up(ik)
115 integer, intent(in) :: ik
116
117 is_spin_up = odd(ik)
118
119 end function is_spin_up
120
121 ! ---------------------------------------------------------
123 !
124 integer pure function states_elec_dim_get_spin_index(this, iq) result(index)
125 class(states_elec_dim_t), intent(in) :: this
126 integer, intent(in) :: iq
127
128 if (this%ispin == spin_polarized) then
129 index = 1 + mod(iq - 1, 2)
130 else
131 index = 1
132 end if
133
135
136
137 ! ---------------------------------------------------------
139 !
140 integer pure function states_elec_dim_get_kpoint_index(this, iq) result(index)
141 class(states_elec_dim_t), intent(in) :: this
142 integer, intent(in) :: iq
143
144 if (this%ispin == spin_polarized) then
145 index = 1 + (iq - 1)/2
146 else
147 index = iq
148 end if
149
152
154
155end module states_elec_dim_oct_m
157
158!! Local Variables:
159!! mode: f90
160!! coding: utf-8
161!! 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:117
logical pure function, public odd(n)
Returns if n is odd.
Definition: math.F90:650
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:147
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)
class for organizing spins and k-points