27
27
!real*8 e_qmmm_e,e_qmmm_q,e_qmmm_lj,e_mmmm_q,e_mmmm_lj
28
28
real*8 e_lj,e_q,e_spring
29
29
real*8 ehsic,phsic,exsic,pxsic,ehfx,phfx
30
real*8 exc_atom,pxc_atom,ehartree_atom,ecmp_cmp,ecmp_pw
32
33
* **** external functions ****
33
34
integer psi_neq,control_version
34
35
real*8 dng_1ehartree
36
real*8 psi_1vl,psi_1v_field
37
real*8 psi_1vl,psi_1v_field,dng_1vlpaw_pw
43
44
external psi_neq,control_version
44
45
external dng_1ehartree
46
external psi_1vl,psi_1v_field
47
external psi_1vl,psi_1v_field,dng_1vlpaw_pw
64
65
external pspw_charge_Energy_ion,pspw_charge_Energy_charge
66
67
* ***** pspw_SIC and pspw_HFX external functions ****
67
logical pspw_SIC,pspw_HFX
68
external pspw_SIC,pspw_HFX
68
logical pspw_SIC,pspw_HFX,psp_U_psputerm,meta_found
69
external pspw_SIC,pspw_HFX,psp_U_psputerm,meta_found
70
71
* ***** PAW functions ****
71
72
logical psp_pawexist
72
real*8 psp_kinetic_core,psi_1ke_atom,psi_1vloc_atom,psi_1xc_atom
73
real*8 psp_ion_core,psi_1valence_core_atom
73
real*8 psp_kinetic_core,psi_1ke_atom,psi_1vloc_atom
74
real*8 psp_ion_core,psi_1valence_core_atom,psi_1hartree_atom
75
real*8 psi_1hartree_cmp_cmp,dng_1hartree_cmp_pw
74
76
external psp_pawexist
75
external psp_kinetic_core,psi_1ke_atom,psi_1vloc_atom,psi_1xc_atom
76
external psp_ion_core,psi_1valence_core_atom
77
external psp_kinetic_core,psi_1ke_atom,psi_1vloc_atom
78
external psp_ion_core,psi_1valence_core_atom,psi_1hartree_atom
79
external psi_1hartree_cmp_cmp,dng_1hartree_cmp_pw
81
logical nwpw_meta_gga_on
82
external nwpw_meta_gga_on
83
real*8 psi_1meta_gga_pxc
84
external psi_1meta_gga_pxc
78
88
call Pack_npack(1,npack1)
79
89
neall = psi_neq(1)+psi_neq(2)
109
125
E(8) = psi_1vnl()
110
126
E(9) = 2.0d0*ehartree
129
* ***** qmmm energies *****
112
130
if (pspw_qmmm_found()) then
113
e_lj = pspw_qmmm_LJ_E()
114
e_q = pspw_qmmm_Q_E()
115
e_spring = pspw_qmmm_spring_E()
131
e_lj = pspw_qmmm_LJ_E() !*** independent of psi ***
132
e_q = pspw_qmmm_Q_E() !*** independent of psi ***
133
e_spring = pspw_qmmm_spring_E() !*** independent of psi ***
116
134
E(1) = E(1) + e_lj + e_q + e_spring
123
141
* **** paw energies ****
124
142
if (psp_pawexist()) then
125
E(14) = psi_1ke_atom() !*** kinetic atom ***
126
E(15) = psp_kinetic_core() !*** kinetic core ***
127
E(16) = psi_1vloc_atom() !*** vlocal atom ***
128
E(17) = 0.0d0 !*** vcoulomb atom ***
129
E(18) = psi_1xc_atom() !*** exc atom ***
130
E(30) = psp_ion_core() !*** ion core energy ****
131
E(31) = psi_1valence_core_atom() !*** valence core energy
143
E(35) = psi_1ke_atom() !*** kinetic atom ***
144
E(36) = psp_kinetic_core() !*** kinetic core - independent of psi ***
146
E(37) = psi_1valence_core_atom() !*** valence core energy ***
147
E(38) = dng_1vlpaw_pw() !*** Vlocal_paw (pw basis) ***
148
E(39) = psi_1vloc_atom() !*** Vlocal (local basis) - nv*Vsrloc + nloc*Vloc - ncmp*Vloc ***
150
ehartree_atom = psi_1hartree_atom()
151
ecmp_cmp = psi_1hartree_cmp_cmp()
152
ecmp_pw = dng_1hartree_cmp_pw()
153
E(40) = ehartree_atom !*** vcoulomb atom ***
154
E(41) = ecmp_cmp !*** ncmp-ncmp coulomb energy ***
155
E(42) = ecmp_pw !*** ncmp-pw coulomb energy ***
157
!call psi_1xc_atom(exc_atom,pxc_atom)
160
E(43) = exc_atom !*** exc atom ***
161
E(44) = pxc_atom !*** pxc atom ***
163
E(45) = psp_ion_core() !*** ion core energy - independent of psi ***
165
E(1) = E(1) + E(36) + E(45)
166
> - E(40) - E(41) + E(43) - E(44)
134
169
* **** get pspw_charge energies ****
135
170
if (pspw_charge_found()) then
136
171
E(19) = psi_1v_field()
137
E(20) = pspw_charge_Energy_ion()
138
E(21) = pspw_charge_Energy_charge()
172
E(20) = pspw_charge_Energy_ion() !*** independent of psi ***
173
E(21) = pspw_charge_Energy_charge() !*** independent of psi ***
139
174
E(1) = E(1) + E(20) + E(21)
194
* **** HFX terms ****
195
if (psp_U_psputerm()) then
196
call electron_U_energies(ehfx,phfx)
201
* **** Metadynamics potential terms ****
202
if (meta_found()) then
203
call electron_meta_energies(ehfx,phfx)
160
209
value = MA_free_heap(G1(2))