9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-21 11:03:29 +01:00
qp2/bin/qp_set_frozen_core

120 lines
3.5 KiB
Plaintext
Raw Normal View History

2020-01-27 22:30:01 +01:00
#!/usr/bin/env python3
2019-01-25 11:39:31 +01:00
"""
Automatically finds n, the number of core electrons. Calls qp_set_mo_class
setting all MOs as Active, except the n/2 first ones which are set as Core.
If pseudo-potentials are used, all the MOs are set as Active.
Usage:
qp_set_frozen_core [-q|--query] [(-l|-s|--large|--small)] EZFIO_DIR
2019-01-25 11:39:31 +01:00
Options:
-q --query Prints in the standard output the number of frozen MOs
-l --large Use a small core
-s --small Use a large core
Default numbers of frozen electrons:
========== ========= ======= =======
Range Default Small Large
========== ========= ======= =======
H -> He 0 0 0
Li -> Be 0 0 2
B -> Ne 2 2 2
Na -> Mg 2 2 10
Al -> Ar 10 2 10
K -> Ca 10 10 18
Sc -> Zn 10 10 18
Ga -> Kr 18 10 18
Rb -> Sr 18 18 36
Y -> Cd 18 18 36
In -> Xe 36 18 36
Cs -> Ba 36 36 54
La -> Hg 36 36 54
Tl -> Rn 54 36 54
Fr -> Ra 54 54 86
Ac -> Cn 54 54 86
Nh -> Og 86 54 86
========== ========= ======= =======
2019-01-25 11:39:31 +01:00
"""
import os
import sys
import os.path
try:
import qp_path
except ImportError:
2020-12-04 10:40:42 +01:00
print("source quantum_package.rc")
2019-01-25 11:39:31 +01:00
raise
from docopt import docopt
from ezfio import ezfio
def main(arguments):
"""Main function"""
filename = arguments["EZFIO_DIR"]
ezfio.set_filename(filename)
n_frozen = 0
try:
do_pseudo = ezfio.pseudo_do_pseudo
except:
do_pseudo = False
2019-05-15 15:46:23 +02:00
2019-01-25 11:39:31 +01:00
if not do_pseudo:
2019-05-15 15:46:23 +02:00
if arguments["--large"]:
2019-05-15 15:46:23 +02:00
for charge in ezfio.nuclei_nucl_charge:
if charge <= 2: pass
elif charge <= 10: n_frozen += 1
elif charge <= 18: n_frozen += 5
elif charge <= 36: n_frozen += 9
elif charge <= 54: n_frozen += 18
elif charge <= 86: n_frozen += 27
elif charge <= 118: n_frozen += 43
elif arguments["--small"]:
if charge <= 4: pass
elif charge <= 18: n_frozen += 1
elif charge <= 36: n_frozen += 5
elif charge <= 54: n_frozen += 9
elif charge <= 86: n_frozen += 18
elif charge <= 118: n_frozen += 27
else: # default
2019-05-15 15:46:23 +02:00
for charge in ezfio.nuclei_nucl_charge:
if charge <= 4: pass
elif charge <= 12: n_frozen += 1
elif charge <= 30: n_frozen += 5
elif charge <= 48: n_frozen += 9
elif charge <= 80: n_frozen += 18
elif charge <= 112: n_frozen += 27
2019-01-25 11:39:31 +01:00
mo_num = ezfio.mo_basis_mo_num
if arguments["--query"]:
2020-01-27 22:30:01 +01:00
print(n_frozen)
2019-01-25 11:39:31 +01:00
sys.exit(0)
if n_frozen == 0:
os.system("""qp_set_mo_class -a "[1-%d]" %s""" %
2019-05-15 15:46:23 +02:00
(mo_num, filename))
2019-01-25 11:39:31 +01:00
else:
os.system("""qp_set_mo_class -c "[1-%d]" -a "[%d-%d]" %s""" %
2019-05-15 15:46:23 +02:00
(n_frozen, n_frozen+1, mo_num, filename))
2019-01-25 11:39:31 +01:00
if __name__ == '__main__':
ARGUMENTS = docopt(__doc__)
main(ARGUMENTS)