-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengine.f90
163 lines (130 loc) · 3.59 KB
/
engine.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
!====================
program main
implicit none
! A test main program
!
!
!====================
! input data zone
integer :: ncenters,imult,icharge,atomchg(3) ! natoms, multiplicity, charge
character :: baselable*30,functional_in*30 ! basis lable, functional
real(8) :: coord(3,3) ! coordinate, atomcharge
! output data zone
integer :: iconv ! converge
real(8) :: energy_out,econv ! total energy, converge level
real(8) :: force_out(3,3),MLcharge_out(3)
! force, Mullikencharge
ncenters = 3
imult = 2
icharge = -1
baselable = '6-31g'
coord(1,1)= -2.13
coord(1,2)= -0.248
coord(1,3)= 0.000
coord(2,1)= -1.17
coord(2,2)= -0.248
coord(2,3)= 0.00
coord(3,1)= -2.45
coord(3,2)= 0.657
coord(3,3)= 0.00
atomchg(1) = 16
atomchg(2) = 1
atomchg(3) = 1
functional_in ='PBE_PBE'
call EngineUp(ncenters,imult,icharge,functional_in,&
coord,atomchg,baselable,&
force_out,energy_out,MLcharge_out,iconv,econv)
end program main
!================================
subroutine EngineUp(ncenters,imult,icharge,functional_in,&
coord,atomchg,baselable,&
force_out,energy_out,MLcharge_out,iconv,econv)
! Main program of Engine
!
!===============================
use GRID_INFO
use MOL_info
implicit none
include "parameter.h"
! input data zone
integer :: ncenters,imult,icharge,atomchg(ncenters) ! natoms, multiplicity, charge
character :: baselable*30,functional_in*30 ! basis lable, functional
real(8) :: coord(ncenters,3) ! coordinate, atomcharge
! output data zone
integer :: iconv ! converge
real(8) :: energy_out,econv ! total energy, converge level
real(8) :: force_out(ncenters,3),MLcharge_out(ncenters)
real(8) :: Emax,Erms,Pmax,Prms
integer :: itmax
integer :: Gtype ! guesstype, 1: Pseudo Huckel 2:Hcore
! force, Mullikencharge
integer :: i, j ,k,l
integer :: info
real(8) :: dist
!###
real(8) :: rho
!
!
!====
!============
!# 0. Preparing basic data
! prepare data
Natoms = ncenters
Multi = imult
Charge = icharge
Functional = functional_in
E = 0
allocate(atoms(Natoms))
! read coordinate
coreChg = 0
do i = 1,Natoms
atoms(i)%coor = coord(i,:)
atoms(i)%charge = atomchg(i)
coreChg = atoms(i)%charge + coreChg
write (atoms(i)%base,"(I0.2,A1,A27)") atomchg(i),'-',baselable
enddo
print *,atoms(1)%base
n_alpha = 0.5*(Multi-Charge+coreChg-1)
n_beta = 0.5*(-Multi-Charge+coreChg+1)
print *,n_alpha,n_beta
! Build linkage matrix
allocate(linkMat(natoms,natoms))
linkMat = 0
do i = 1,natoms
do j = i+1,natoms
dist = sum((atoms(i)%coor - atoms(j)%coor)**2)
if (dist**0.5 < 1.2*(covrad(atoms(i)%charge) + covrad(atoms(j)%charge))) then
linkMat(i,j) = 1
linkMat(j,i) = 1
endif
enddo
enddo
!print *,linkMat
!# 1. Read basis set in and do basis set integral.
call basisint(info)
!# 2. Generate Grid and
call gridgen(info)
call GTOeval(info)
!# 3. Build initial guess
Gtype = 2
call guess(info,Gtype)
!# 4. SCF interation
Emax =1.00E-06
Pmax =1.00E-05
itmax =150
call SCFcycle(info,Emax,Pmax,itmax)
!! TEST Density !!
rho = 0
do i = 1,ngrids
do j = 1,nconts
do k =1,nconts
! rho = rho + (Pa(j,k) +Pb(j,k)) * gridVal0(i,j)*gridVal0(i,k)*grids(i)%weight
rho = rho + (Pa(j,k) +Pb(j,k)) * grids(i)%val0(j)*grids(i)%val0(k)*grids(i)%weight
enddo
enddo
enddo
print *,rho
!!!!!!!!!!!!!!
call calc_force(info)
!call prtMat(Pa+Pb,nconts,"Density")
end subroutine EngineUp