Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Shirong Wang
pyAutoMR
Commits
b39a1d95
Commit
b39a1d95
authored
Aug 02, 2021
by
hebrewsnabla
Browse files
update dftcasci
parent
a9d6a9a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
automr/dftmr.py
View file @
b39a1d95
...
...
@@ -2,6 +2,10 @@ from automr import autocas, mcpdft
from
pyscf
import
mcscf
,
lib
from
pyscf.dft
import
rks
,
uks
import
numpy
as
np
from
functools
import
partial
print
=
partial
(
print
,
flush
=
True
)
einsum
=
partial
(
np
.
einsum
,
optimize
=
True
)
def
get_veff
(
ks
,
mol
=
None
,
dm
=
None
,
dm_last
=
0
,
vhf_last
=
0
,
hermi
=
1
):
'''Coulomb + XC functional for UKS. See pyscf/dft/rks.py
...
...
@@ -78,37 +82,39 @@ def get_veff(ks, mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1):
vklr
*=
(
alpha
-
hyb
)
vk
+=
vklr
vxc
+=
vj
-
vk
if
ground_state
:
exc
-=
(
np
.
einsum
(
'ij,ji'
,
dm
[
0
],
vk
[
0
]).
real
+
exc0
=
exc
ek
=
-
(
np
.
einsum
(
'ij,ji'
,
dm
[
0
],
vk
[
0
]).
real
+
np
.
einsum
(
'ij,ji'
,
dm
[
1
],
vk
[
1
]).
real
)
*
.
5
if
ground_state
:
ecoul
=
np
.
einsum
(
'ij,ji'
,
dm
[
0
]
+
dm
[
1
],
vj
).
real
*
.
5
else
:
ecoul
=
None
vxc
=
lib
.
tag_array
(
vxc
,
ecoul
=
ecoul
,
exc
=
exc
,
vj
=
vj
,
vk
=
vk
)
return
vxc
#
vxc = lib.tag_array(vxc, ecoul=ecoul, exc=exc, vj=vj, vk=vk)
return
vxc
,
exc0
,
ecoul
,
ek
def
ks_decomp
(
ks
):
e_nn
=
ks
.
energy_nuc
()
dm1
=
ks
.
make_rdm1
()
dm1t
=
dm1
[
0
]
+
dm1
[
1
]
e_core
=
np
.
dot
(
ks
.
get_hcore
(),
dm1t
)
vhf
=
uks
.
get_veff
(
ks
,
dm
=
dm1
)
e_coul
=
vhf
.
ecoul
e_core
=
einsum
(
'ij,ji->'
,
ks
.
get_hcore
(),
dm1t
)
vhf
,
e_xcdft
,
e_coul
,
e_xhf
=
get_veff
(
ks
)
#
e_coul = vhf.ecoul
#print('e_mc : %15.8f' % e_mcscf)
print
(
'e_nn : %15.8f'
%
e_nn
)
print
(
'e_core : %15.8f'
%
e_core
)
print
(
'e_coul : %15.8f'
%
e_coul
)
#
print('e_x : %15.8f' % e_x)
#
print('e_
otx
: %15.8f' % e_
otx
)
print
(
'e_x
hf
: %15.8f'
%
e_x
hf
)
print
(
'e_
xcdft
: %15.8f'
%
e_
xcdft
)
# print('e_otc : %15.8f' % e_otc)
# print('e_c : %15.8f' % e_c)
def
dftcasci
(
ks
,
act_user
):
#mo = ks.mo_coeff
ks_decomp
(
ks
)
nacto
=
act_user
[
0
]
nacta
,
nactb
=
act_user
[
1
]
nopen
=
nacta
-
nactb
...
...
@@ -124,5 +130,4 @@ def dftcasci(ks, act_user):
mc
.
verbose
=
4
mc
.
kernel
()
ks_decomp
(
ks
)
e_nn
,
e_core
,
e_coul
,
e_x
,
_
,
_
,
e_c
=
mcpdft
.
get_energy_decomposition
(
mc
)
\ No newline at end of file
automr/guess.py
View file @
b39a1d95
...
...
@@ -9,7 +9,7 @@ from automr import stability, dump_mat
import
time
import
copy
def
gen
(
xyz
,
bas
,
charge
,
spin
,
conv
=
'tight'
,
level_shift
=
0
):
def
gen
(
xyz
,
bas
,
charge
,
spin
,
conv
=
'tight'
,
level_shift
=
0
,
xc
=
None
):
'''for states other than singlets'''
mol
=
gto
.
Mole
()
mol
.
atom
=
xyz
...
...
@@ -19,7 +19,11 @@ def gen(xyz, bas, charge, spin, conv='tight', level_shift=0):
mol
.
verbose
=
4
mol
.
build
()
mf
=
scf
.
UHF
(
mol
)
if
xc
is
None
:
mf
=
scf
.
UHF
(
mol
)
else
:
mf
=
dft
.
UKS
(
mol
)
mf
.
xc
=
xc
if
conv
==
'loose'
:
mf
.
conv_tol
=
1e-6
mf
.
max_cycle
=
10
...
...
automr/mcpdft.py
View file @
b39a1d95
...
...
@@ -43,6 +43,7 @@ def get_energy_decomposition (mc, ot=None, mo_coeff=None, ci=None):
#else:
if
True
:
print
(
'energy decomposition of MCPDFT'
)
e_nn
,
e_core
,
e_coul
,
e_x
,
e_otx
,
e_otc
,
e_c
=
_get_e_decomp
(
mc
,
ot
,
mo_coeff
,
ci
,
e_mcscf
)
print
(
'e_mc : %15.8f'
%
e_mcscf
)
print
(
'e_nn : %15.8f'
%
e_nn
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment