Octopus
modelmb_density_matrix.F90
Go to the documentation of this file.
1!! Copyright (C) 2009 N. Helbig and M. Verstraete
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
22 use batch_oct_m
23 use debug_oct_m
24 use global_oct_m
26 use io_oct_m
27 use index_oct_m
28 use, intrinsic :: iso_fortran_env
30 use mesh_oct_m
34 use mpi_oct_m
37 use parser_oct_m
39 use space_oct_m
41
42 implicit none
43
44 private
45
46 public :: &
52
54 private
55 integer :: ndensmat_to_calculate
56 character(len=200) :: dirname
57 character(80), allocatable :: labels(:)
58 integer, allocatable :: particle_kept(:)
59 integer, allocatable :: nnatorb_prt(:)
60 end type modelmb_denmat_t
61
62contains
63
64 subroutine modelmb_density_matrix_init(dir, namespace, st, denmat)
65 character(len=*), intent(in) :: dir
66 type(namespace_t), intent(in) :: namespace
67 type(states_elec_t), intent(in) :: st
68 type(modelmb_denmat_t), intent(out) :: denmat
69
70 integer :: ncols, ipart
71 type(block_t) :: blk
72
74
75 !%Variable DensitytoCalc
76 !%Type block
77 !%Section States::ModelMB
78 !%Description
79 !% Choice of which particle density (event. matrices) will be calculated and output, in the
80 !% modelmb particles scheme.
81 !%
82 !% <tt>%DensitytoCalc
83 !% <br>&nbsp;&nbsp; "proton" | 1 | 10
84 !% <br>&nbsp;&nbsp; "electron" | 2 | 15
85 !% <br>%</tt>
86 !%
87 !% would ask octopus to calculate the density matrix corresponding to the 1st
88 !% particle (whose coordinates correspond to dimensions 1 to ndim_modelmb),
89 !% which is an proton, then that corresponding to the 2nd particle
90 !% (electron with dimensions ndim_modelmb+1 to 2*ndim_modelmb), printing
91 !% 10 natural orbitals for the first and 15 for the second.
92 !%
93 !% <tt>%DensitytoCalc
94 !% <br>&nbsp;&nbsp; "proton" | 1 | -1
95 !% <br>&nbsp;&nbsp; "electron" | 2 | -1
96 !% <br>%</tt>
97 !%
98 !% would ask octopus to print out just the densities for particles 1 and 2
99 !% without any density matrix output.
100 !%
101 !%End
102
103 call messages_obsolete_variable(namespace, 'DensityMatrixtoCalc', 'DensitytoCalc')
104 call messages_obsolete_variable(namespace, 'DensitiestoCalc', 'DensitytoCalc')
105
106 if (parse_block(namespace, 'DensitytoCalc', blk) /= 0) then
107 message(1) = 'To print out density (matrices), you must specify the DensitytoCalc block in input'
108 call messages_fatal(1, namespace=namespace)
109 end if
110
111 ncols = parse_block_cols(blk, 0)
112 if (ncols /= 3) then
113 call messages_input_error(namespace, "DensitytoCalc")
114 end if
115 denmat%ndensmat_to_calculate=parse_block_n(blk)
116 if (denmat%ndensmat_to_calculate < 0 .or. &
117 denmat%ndensmat_to_calculate > st%modelmbparticles%nparticle) then
118 call messages_input_error(namespace, "DensitytoCalc")
119 end if
120
121 safe_allocate(denmat%labels(1:denmat%ndensmat_to_calculate))
122 safe_allocate(denmat%particle_kept(1:denmat%ndensmat_to_calculate))
123 safe_allocate(denmat%nnatorb_prt(1:denmat%ndensmat_to_calculate))
124
125 do ipart=1,denmat%ndensmat_to_calculate
126 call parse_block_string(blk, ipart-1, 0, denmat%labels(ipart))
127 call parse_block_integer(blk, ipart-1, 1, denmat%particle_kept(ipart))
128 call parse_block_integer(blk, ipart-1, 2, denmat%nnatorb_prt(ipart))
129
130 write (message(1),'(a,a)') 'labels_densmat = ', denmat%labels(ipart)
131 write (message(2),'(a,i6)') 'particle_kept_densmat = ', denmat%particle_kept(ipart)
132 write (message(3),'(a,i6)') 'nnatorb_prt_densmat = ', denmat%nnatorb_prt(ipart)
133 call messages_info(3, namespace=namespace)
134 end do
135 call parse_block_end(blk)
136 ! END reading in of input var block DensitytoCalc
137
138 denmat%dirname = trim(dir)
139
141 end subroutine modelmb_density_matrix_init
142
143 ! ---------------------------------------------------------
144 subroutine modelmb_density_matrix_end(this)
145 type(modelmb_denmat_t), intent(inout) :: this
146
149 safe_deallocate_a(this%labels)
150 safe_deallocate_a(this%particle_kept)
151 safe_deallocate_a(this%nnatorb_prt)
155
156
157#include "undef.F90"
158#include "real.F90"
159#include "modelmb_density_matrix_inc.F90"
160#include "undef.F90"
161
162#include "complex.F90"
163#include "modelmb_density_matrix_inc.F90"
164#include "undef.F90"
165
167
168
169!! Local Variables:
170!! mode: f90
171!! coding: utf-8
172!! End:
This module implements batches of mesh functions.
Definition: batch.F90:135
This module implements the index, used for the mesh points.
Definition: index.F90:124
Definition: io.F90:116
This module defines functions over batches of mesh functions.
Definition: mesh_batch.F90:118
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:120
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:1000
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:162
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:410
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:691
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:594
general module for modelmb particles (eg 4 electrons in 1D equiv to 1 in 4D). Also calculate differen...
subroutine, public zmodelmb_density_matrix_write(space, mesh, st, wf, mm, denmat, namespace)
subroutine, public dmodelmb_density_matrix_write(space, mesh, st, wf, mm, denmat, namespace)
subroutine, public modelmb_density_matrix_init(dir, namespace, st, denmat)
subroutine, public modelmb_density_matrix_end(this)
Some general things and nomenclature:
Definition: par_vec.F90:173
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
Definition: parser.F90:818
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:623