Octopus
ps_cpi.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
21module ps_cpi_oct_m
22 use atomic_oct_m
23 use debug_oct_m
24 use global_oct_m
25 use io_oct_m
26 use logrid_oct_m
32
33 implicit none
34
35 private
36 public :: &
37 ps_cpi_t, &
39 ps_cpi_end, &
42
43 type ps_cpi_t
44 ! Components are public by default
45 type(ps_cpi_file_t), allocatable, private :: cpi_file
46 type(ps_in_grid_t), allocatable :: ps_grid
47
48 type(valconf_t), allocatable, private :: conf
49 end type ps_cpi_t
50
51contains
52
53 ! ---------------------------------------------------------
54 subroutine ps_cpi_init(ps_cpi, filename, namespace)
55 type(ps_cpi_t), intent(inout) :: ps_cpi
56 character(len=*), intent(in) :: filename
57 type(namespace_t), intent(in) :: namespace
58
59 integer :: iunit
60 logical :: found
61
62 push_sub(ps_cpi_init)
63
64 ! allocate data
65 safe_allocate(ps_cpi%cpi_file)
66 safe_allocate(ps_cpi%ps_grid)
67 safe_allocate(ps_cpi%conf)
68
69 inquire(file = filename, exist = found)
70 if (.not. found) then
71 call messages_write("Pseudopotential file '" // trim(filename) // "' not found")
72 call messages_fatal(namespace=namespace)
73 end if
74
75 iunit = io_open(filename, action='read', form='formatted', status='old')
76 call ps_cpi_file_read(iunit, ps_cpi%cpi_file)
77 call io_close(iunit)
78
79 ! Fills the valence configuration data.
80 !call valconf_guess(ps_cpi%conf, )
81
82 call ps_cpi_file_to_grid(ps_cpi%cpi_file, ps_cpi%ps_grid)
83
84 pop_sub(ps_cpi_init)
85 end subroutine ps_cpi_init
86
87
88 ! ---------------------------------------------------------
89 subroutine ps_cpi_end(ps_cpi)
90 type(ps_cpi_t), intent(inout) :: ps_cpi
91
92 call ps_in_grid_end (ps_cpi%ps_grid)
93 call ps_cpi_file_end(ps_cpi%cpi_file)
94
95 safe_deallocate_a(ps_cpi%cpi_file)
96 safe_deallocate_a(ps_cpi%ps_grid)
97 safe_deallocate_a(ps_cpi%conf)
98
99 end subroutine ps_cpi_end
100
101
102 !----------------------------------------------------------------
103 subroutine ps_cpi_file_to_grid(cpi_file, ps_grid)
104 type(ps_cpi_file_t), intent(in) :: cpi_file
105 type(ps_in_grid_t), intent(out) :: ps_grid
106
107 ! Initializes the pseudo in the logarithmic grid.
108 call ps_in_grid_init(ps_grid, &
109 logrid_cpi, cpi_file%a, cpi_file%rofi(2), cpi_file%nr, &
110 cpi_file%no_l_channels, 0)
111
112 ps_grid%zval = cpi_file%zval
113 ps_grid%vps(:,:) = cpi_file%vps(:,:)
114 ps_grid%rphi(:,:,1) = cpi_file%rphi(:,:)
115 ps_grid%rphi(:,:,2) = cpi_file%rphi(:,:)
116 ps_grid%rphi(:,:,3) = cpi_file%rphi(:,:)
117
118 ps_grid%core_corrections = cpi_file%core_corrections
119 if (ps_grid%core_corrections) then
120 ps_grid%chcore(:) = cpi_file%chcore(:)
121 end if
122
123 end subroutine ps_cpi_file_to_grid
124
125
126 ! ---------------------------------------------------------
127 subroutine ps_cpi_process(ps_cpi, lloc, namespace)
128 type(ps_cpi_t), intent(inout) :: ps_cpi
129 integer, intent(in) :: lloc
130 type(namespace_t), intent(in) :: namespace
131
132 push_sub(ps_cpi_process)
133
134 ! check norm of rphi
135 call ps_in_grid_check_rphi(ps_cpi%ps_grid, namespace)
137 ! Fix the local potential. Final argument is the core radius
138 call ps_in_grid_vlocal(ps_cpi%ps_grid, lloc, m_three, namespace)
140 ! Calculate kb cosines and norms
141 call ps_in_grid_kb_cosines(ps_cpi%ps_grid, lloc)
142
143 ! Define the KB-projector cut-off radii
144 call ps_in_grid_cutoff_radii(ps_cpi%ps_grid, lloc)
145
146 ! Calculate KB-projectors
147 call ps_in_grid_kb_projectors(ps_cpi%ps_grid)
148
149 pop_sub(ps_cpi_process)
150 end subroutine ps_cpi_process
151
152end module ps_cpi_oct_m
153
154!! Local Variables:
155!! mode: f90
156!! coding: utf-8
157!! End:
real(real64), parameter, public m_three
Definition: global.F90:190
Definition: io.F90:114
subroutine, public io_close(iunit, grp)
Definition: io.F90:468
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
Definition: io.F90:395
integer, parameter, public logrid_cpi
log grid used in FHI code
Definition: logrid.F90:135
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:420
subroutine, public ps_cpi_file_read(unit, psf)
subroutine, public ps_cpi_file_end(psf)
subroutine, public ps_cpi_file_to_grid(cpi_file, ps_grid)
Definition: ps_cpi.F90:197
subroutine, public ps_cpi_end(ps_cpi)
Definition: ps_cpi.F90:183
subroutine, public ps_cpi_init(ps_cpi, filename, namespace)
Definition: ps_cpi.F90:148
subroutine, public ps_cpi_process(ps_cpi, lloc, namespace)
Definition: ps_cpi.F90:221
subroutine, public ps_in_grid_kb_projectors(ps)
KB-projectors kb = (vps - vlocal) |phi> * dknorm.
Definition: ps_in_grid.F90:284
subroutine, public ps_in_grid_end(ps)
Definition: ps_in_grid.F90:208
subroutine, public ps_in_grid_cutoff_radii(ps, lloc)
Definition: ps_in_grid.F90:358
subroutine, public ps_in_grid_init(ps, flavor, a, b, nrval, no_l, so_no_l)
Definition: ps_in_grid.F90:169
subroutine, public ps_in_grid_kb_cosines(ps, lloc)
KB-cosines and KB-norms: dkbcos stores the KB "cosines:" || (v_l - v_local) phi_l ||^2 / < (v_l - v_l...
Definition: ps_in_grid.F90:313
subroutine, public ps_in_grid_vlocal(ps, l_loc, rcore, namespace)
Definition: ps_in_grid.F90:238
subroutine, public ps_in_grid_check_rphi(ps, namespace)
checks normalization of the pseudo wavefunctions
Definition: ps_in_grid.F90:412