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
37
38 implicit none
39
40 private
41
42 public :: &
47
49 integer, public, parameter :: &
50 SPIN_DOWN = 1, &
51 spin_up = 2
52
53 ! TODO(Alex) Issue #672. Remove kpts indices and weights from states_elec_dim_t
56 ! Components are public by default
57 integer :: dim
60 integer :: ispin
63 integer :: nspin
66 integer :: spin_channels
67 type(distributed_t) :: kpt
68
69 contains
70 procedure :: get_spin_index => states_elec_dim_get_spin_index
71 procedure :: get_kpoint_index => states_elec_dim_get_kpoint_index
72 end type states_elec_dim_t
73
74contains
75
76 ! ---------------------------------------------------------
77 subroutine states_elec_dim_copy(dout, din)
78 type(states_elec_dim_t), intent(inout) :: dout
79 type(states_elec_dim_t), intent(in) :: din
80
81 push_sub(states_elec_dim_copy)
82
83 call states_elec_dim_end(dout)
84
85 dout%dim = din%dim
86 dout%ispin = din%ispin
87 dout%nspin = din%nspin
88 dout%spin_channels = din%spin_channels
89
90
91 call distributed_copy(din%kpt, dout%kpt)
92
94 end subroutine states_elec_dim_copy
95
96
97 ! ---------------------------------------------------------
98 subroutine states_elec_dim_end(dim)
99 type(states_elec_dim_t), intent(inout) :: dim
100
101 push_sub(states_elec_dim_end)
102
103 call distributed_end(dim%kpt)
104
105
106 pop_sub(states_elec_dim_end)
107 end subroutine states_elec_dim_end
108
109
110 ! ---------------------------------------------------------
112 !
113 logical pure function is_spin_up(ik)
114 integer, intent(in) :: ik
115
116 is_spin_up = odd(ik)
117
118 end function is_spin_up
119
120 ! ---------------------------------------------------------
123 integer pure function states_elec_dim_get_spin_index(this, iq) result(index)
124 class(states_elec_dim_t), intent(in) :: this
125 integer, intent(in) :: iq
126
127 if (this%ispin == spin_polarized) then
128 index = 1 + mod(iq - 1, 2)
129 else
130 index = 1
131 end if
132
134
135
136 ! ---------------------------------------------------------
138 !
139 integer pure function states_elec_dim_get_kpoint_index(this, iq) result(index)
140 class(states_elec_dim_t), intent(in) :: this
141 integer, intent(in) :: iq
142
143 if (this%ispin == spin_polarized) then
144 index = 1 + (iq - 1)/2
145 else
146 index = iq
147 end if
148
151
153
154end module states_elec_dim_oct_m
156
157!! Local Variables:
158!! mode: f90
159!! coding: utf-8
160!! End:
subroutine, public distributed_end(this)
subroutine, public distributed_copy(in, out)
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:659
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