From acbcd248a8cbf5054b4b8c688b6515659da1aca7 Mon Sep 17 00:00:00 2001 From: Felix Moncada Date: Wed, 28 Feb 2024 01:25:19 +0100 Subject: [PATCH] Modified the lowdin bash script to generate basis files in demon2k format directly from the input --- bin/lowdin | 32 +++++++++- test/HemuH-CUSTOM_BASIS.lowdin | 105 +++++++++++++++++++++++++++++++++ test/HemuH-CUSTOM_BASIS.py | 88 +++++++++++++++++++++++++++ 3 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 test/HemuH-CUSTOM_BASIS.lowdin create mode 100644 test/HemuH-CUSTOM_BASIS.py diff --git a/bin/lowdin b/bin/lowdin index bfd955d..9976b19 100755 --- a/bin/lowdin +++ b/bin/lowdin @@ -335,8 +335,27 @@ if [ $extFile="lowdin" ]; then } ' | $SED "s/,/./g" >> $nameFile.aux + ########################################### + # Check custom basis sets in the input + ########################################### + + BASIS_NAMES=(`gawk '($1~/BASIS/){print toupper($2)}' $nameFile`) + if [ ${#BASIS_NAMES[@]} -gt "0" ] + then + for BASIS_NAME in ${BASIS_NAMES[@]} + do + if [ -e $LOWDIN_DATA/basis/$BASIS_NAME ] + then + echo "## ERROR: ## The custom basis file already exists in " $LOWDIN_DATA/basis/$BASIS_NAME + echo "Modify the BASIS block in your input and select a different name" + exit 1 + fi + gawk '($1~/BASIS/ && toupper($2)~/^'$BASIS_NAME'$/){flag=1; next} + ($0~/END/){flag=0}; + (flag==1){print toupper($0)}' $nameFile > $LOWDIN_DATA/basis/$BASIS_NAME + done + fi - # rm -f $nameFile ########################################### # Exec lowdin.x @@ -466,7 +485,16 @@ if [ $extFile="lowdin" ]; then if [ $keepScratch = "F" ]; then rm -rf $LOWDIN_SCRATCH/$nameFile fi - + + ### Clean custom basis files + if [ ${#BASIS_NAMES[@]} -gt "0" ] + then + for BASIS_NAME in ${BASIS_NAMES[@]} + do + rm $LOWDIN_DATA/basis/$BASIS_NAME + done + fi + else echo $1 ", this file does not exist. " exit 1 diff --git a/test/HemuH-CUSTOM_BASIS.lowdin b/test/HemuH-CUSTOM_BASIS.lowdin new file mode 100644 index 0000000..19b2108 --- /dev/null +++ b/test/HemuH-CUSTOM_BASIS.lowdin @@ -0,0 +1,105 @@ + +GEOMETRY + e-[H] cc-pvtz 0.0000 0.0000 0.00000 + e-[H] CUSTOM_1 0.0000 0.0000 0.74144 + H_1 CUSTOM_2 0.0000 0.0000 0.00000 + U- CUSTOM_3 0.0000 0.0000 0.74144 + He_4 CUSTOM_3 0.0000 0.0000 0.74144 +END GEOMETRY + +TASKS + method = "RHF" +END TASKS + +CONTROL + readCoefficients=F + removeTranslationalContamination=T +END CONTROL + +BASIS CUSTOM_1 +O-HYDROGEN H (CC-PVTZ+LOCAL) BASIS TYPE: 1 +# +9 +1 0 1 +103.8700000 1.00000000 +2 0 1 +33.8700000 1.00000000 +3 0 1 +5.09500000 1.00000000 +4 0 1 +1.15900000 1.00000000 +5 0 1 +0.32580000 1.00000000 +6 0 1 +0.10270000 1.00000000 +7 1 1 +1.40700000 1.00000000 +8 1 1 +0.38800000 1.00000000 +9 2 1 +1.05700000 1.00000000 +END BASIS + +BASIS CUSTOM_2 +O-HYDROGEN H_1 (3S2P1D) BASIS TYPE: 2 +# +6 +1 0 1 +10.1 1.0 +2 0 1 +14.5 1.0 +3 0 1 +20.5 1.0 +4 1 1 +6.9 1.0 +5 1 1 +13.8 1.0 +6 2 1 +9.0 1.0 +END BASIS + +BASIS CUSTOM_3 +O-HE_4 HE_4 (9S) BASIS TYPE: 2 +# (1S)-[1S] +9 +1 0 1 +16729.31181641 1.00000000 +2 0 1 +36042.20971709 1.00000000 +3 0 1 +77650.58691876 1.00000000 +4 0 1 +167293.11815664 1.00000000 +5 0 1 +360422.09715492 1.00000000 +6 0 1 +776505.86915312 1.00000000 +7 0 1 +1672931.18149208 1.00000000 +8 0 1 +3604220.97138922 1.00000000 +9 0 1 +7765058.69118643 1.00000000 + +O-U- U- (9S) BASIS TYPE: 2 +# (1S)-[1S] +9 +1 0 1 +470.63607188 1.00000000 +2 0 1 +1013.95467961 1.00000000 +3 0 1 +2184.49913585 1.00000000 +4 0 1 +4706.36071854 1.00000000 +5 0 1 +10139.54679568 1.00000000 +6 0 1 +21844.99135749 1.00000000 +7 0 1 +47063.60718332 1.00000000 +8 0 1 +101395.46795228 1.00000000 +9 0 1 +218449.91356518 1.00000000 +END BASIS \ No newline at end of file diff --git a/test/HemuH-CUSTOM_BASIS.py b/test/HemuH-CUSTOM_BASIS.py new file mode 100644 index 0000000..7d461f1 --- /dev/null +++ b/test/HemuH-CUSTOM_BASIS.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +from __future__ import print_function +import os +import sys +from colorstring import * + +if len(sys.argv)==2: + lowdinbin = sys.argv[1] +else: + lowdinbin = "lowdin2" + +testName = sys.argv[0][:-3] +inputName = testName + ".lowdin" +outputName = testName + ".out" +# Reference values and tolerance + +refValues = { +"HF energy" : [-343.383191892820,1E-8], +"U-HOMO" : [-371.890049816287,1E-1], +"H_1-HOMO" : [-1.019360160964,1E-4], +"He_4-HOMO" : [-652.366876763392,1E-1], +"e-HOMO" : [-0.585414450602,1E-4], +} + +testValues = dict(refValues) #copy +for value in testValues: #reset + testValues[value] = 0 #reset + +# Run calculation + +status = os.system(lowdinbin + " -i " + inputName) + +if status: + print(testName + str_red(" ... NOT OK")) + sys.exit(1) + +output = open(outputName, "r") +outputRead = output.readlines() + +# Values +checkArray=[0,0,0,0] +for i in range(0,len(outputRead)): + line = outputRead[i] + if "TOTAL ENERGY =" in line: + testValues["HF energy"] = float(line.split()[3]) + if "Eigenvalues for:" in line: + species=line.split()[2] + if species == "E-": + checkArray[0]=1 + elif species == "H_1": + checkArray[1]=1 + elif species == "MUON": + checkArray[2]=1 + elif species == "HE_4": + checkArray[3]=1 + + if "1 " in line and checkArray[0]==1: + checkArray[0]=0 + testValues["e-HOMO"] = float(line.split()[1]) + if "1 " in line and checkArray[1]==1: + checkArray[1]=0 + testValues["H_1-HOMO"] = float(line.split()[1]) + if "1 " in line and checkArray[2]==1: + checkArray[2]=0 + testValues["U-HOMO"] = float(line.split()[1]) + if "1 " in line and checkArray[3]==1: + checkArray[3]=0 + testValues["He_4-HOMO"] = float(line.split()[1]) + + +output.close() + +passTest = True + +for value in refValues: + diffValue = abs(refValues[value][0] - testValues[value]) + if ( diffValue <= refValues[value][1] ): + passTest = passTest * True + else : + passTest = passTest * False + print("%s %.8f %.8f %.2e" % ( value, refValues[value][0], testValues[value], diffValue)) + +if passTest : + print(testName + str_green(" ... OK")) +else: + print(testName + str_red(" ... NOT OK")) + sys.exit(1) +