diff --git a/BasisSetSelector/basissetselector.py b/BasisSetSelector/basissetselector.py new file mode 100644 index 00000000..128d1175 --- /dev/null +++ b/BasisSetSelector/basissetselector.py @@ -0,0 +1,64 @@ +import pandas as pd +from rdkit.Chem import AllChem as Chem +import sys +from ast import literal_eval + +def find_precision(theoretical, experimental): + return abs((theoretical-experimental)/experimental) + +def find_optimal_basis_sets(smile, precisionInPercent, homoLumoConvergance): + bestBasisSets = [] + bestHomoLumo = [] + precisionDecimal = precisionInPercent / 100 + groundStateDF = pd.read_csv("groundstateenergies.csv",index_col=0) + if(".pdb" in smile): + mol = Chem.MolFromPDBFile(smile) + else: + mol = Chem.MolFromSmiles(smile) + arrayOfAtomsInSmile = [atom.GetSymbol() for atom in mol.GetAtoms()] + groundStateSum = 0 + ccpVTZb3lypSum = 0 + augccpDZb3lypSum = 0 + sixthreeoneb3lypsum = 0 + for atom in arrayOfAtomsInSmile: + groundStateSum += groundStateDF["Experimental Ground State Energy from AE17 UMN (Hartree)"][atom] + ccpVTZb3lypSum += groundStateDF["cc-pVTZ + B3LYP"][atom] + sixthreeoneb3lypsum += groundStateDF["6-31G + B3LYP"][atom] + augccpDZb3lypSum += groundStateDF["aug-cc-pVDZ + B3LYP"][atom] + + if(find_precision(ccpVTZb3lypSum,groundStateSum) <= precisionDecimal): + bestBasisSets.append("cc-pVTZ + B3LYP") + if(find_precision(sixthreeoneb3lypsum,groundStateSum) <= precisionDecimal): + bestBasisSets.append("6-31G + B3LYP") + if(find_precision(augccpDZb3lypSum,groundStateSum) <= precisionDecimal): + bestBasisSets.append("aug-cc-pVDZ + B3LYP") + if((find_precision(ccpVTZb3lypSum,groundStateSum) > precisionDecimal) and (find_precision(sixthreeoneb3lypsum,groundStateSum) > precisionDecimal) and (find_precision(augccpDZb3lypSum,groundStateSum) > precisionDecimal)): + bestBasisSets.append("cc-pVTZ + B3LYP,6-31G + B3LYP, and aug-cc-pVDZ + B3LYP are too imprecise. Please try another basis set") + + if homoLumoConvergance == "homoLumoConvergance": + g3HomoLumoSum= 0 + ccpVTZb3lypHomoLumoSum = 0 + augccpDZb3lypHomoLumoSum = 0 + sixthreeoneb3lypHomoLumosum = 0 + for atom in arrayOfAtomsInSmile: + g3HomoLumoSum += groundStateDF["Gaussian3 (G3) HOMO-LUMO gap"][atom] + ccpVTZb3lypHomoLumoSum += groundStateDF["cc-pVTZ + B3LYP HOMO-LUMO gap"][atom] + sixthreeoneb3lypHomoLumosum += groundStateDF["6-31G + B3LYP HOMO-LUMO gap"][atom] + augccpDZb3lypHomoLumoSum += groundStateDF["aug-cc-pVDZ + B3LYP HOMO-LUMO gap"][atom] + minConvergance = min([g3HomoLumoSum,ccpVTZb3lypHomoLumoSum,augccpDZb3lypHomoLumoSum,sixthreeoneb3lypHomoLumosum]) + if g3HomoLumoSum == minConvergance: + bestHomoLumo.append("Gaussian3 (G3)") + if ccpVTZb3lypHomoLumoSum == minConvergance: + bestHomoLumo.append("cc-pVTZ + B3LYP") + if sixthreeoneb3lypHomoLumosum == minConvergance: + bestHomoLumo.append("6-31G + B3LYP") + if augccpDZb3lypHomoLumoSum == minConvergance: + bestHomoLumo.append("aug-cc-pVDZ + B3LYP") + outputJSON = {"Best Basis Sets Based on Ground State Precision": bestBasisSets, "Best Basis Sets Based on HOMO-LUMO Gap Convergance": bestHomoLumo} + return outputJSON + +if __name__ == '__main__': + if len(sys.argv) < 2: + print("Syntax: python basissetselector.py [.pdb file name location or smiles string] [percetage of precision wihtout %] [homoLumoConverganceif you want check for the HOMO-LUMO convergance]") + else: + print(find_optimal_basis_sets(sys.argv[1], literal_eval(sys.argv[2]), sys.argv[3])) \ No newline at end of file diff --git a/BasisSetSelector/groundstateenergies.csv b/BasisSetSelector/groundstateenergies.csv new file mode 100644 index 00000000..b4ce586b --- /dev/null +++ b/BasisSetSelector/groundstateenergies.csv @@ -0,0 +1,18 @@ +Element/Compound,Experimental Ground State Energy from AE17 UMN (Hartree),cc-pVTZ + B3LYP,6-31G + B3LYP,aug-cc-pVDZ + B3LYP,Gaussian3 (G3) HOMO-LUMO gap,cc-pVTZ + B3LYP HOMO-LUMO gap,6-31G + B3LYP HOMO-LUMO gap,aug-cc-pVDZ + B3LYP HOMO-LUMO gap +H,-0.50000,-0.502156,-0.500273,-0.501657,1.414,0.567,1.027,0.356 +He,-2.90372,-2.914507,-2.907049,-2.909096,1.100,1.023,1.631,0 +Li,-7.47806,-7.492016,-7.490902,-7.491452,0.207,0,0.108,0 +Be,-14.66736,-14.672445,-14.668063,-14.671272,0.331,0,0.188,0 +B,-24.65391,-24.663753,-24.652810,-24.661583,0.335,0.092,0.092,0.091 +C,-37.84500,-37.858574,-37.843662,-37.854195,0.446,0.113,0.111,0.111 +N,-54.58920,-54.601781,-54.582875,-54.593843,0.705,0.778,0.977,0.416 +O,-75.06730,-75.091863,-75.058330,-75.077162,1.482,0.899,1.163,0.469 +F,-99.73390,-99.762866,-99.713650,-99.739495,0.941,1.121,1.525,0.591 +Ne,-128.93760,-128.961856,-128.894298,-128.927993,0.664,1.419,1.950,0.724 +Na,-162.25460,-162.296979,-162.279879,-162.290737,0,0,0.109,0 +Mg,-200.05300,-200.097698,-200.077941,-200.091270,0.274,0,0.164,0 +Al,-242.34600,-242.389511,-242.365764,-242.383457,0.238,0.056,0.054,0.056 +Si,-289.35900,-289.396332,-289.368888,-289.389841,0.287,0.066,0.062,0.065 +P,-341.25900,-341.285850,-341.255345,-341.278393,0.461,0.494,0.475,0.283 +S,-398.11000,-398.138716,-398.100687,-398.127993,0.494,0.555,0.539,0.319 +Cl,-460.14800,-460.174665,-460.131370,-460.161474,0.992,0.663,0.681,0.401 \ No newline at end of file diff --git a/BasisSetSelector/proline.pdb b/BasisSetSelector/proline.pdb new file mode 100644 index 00000000..afba1610 --- /dev/null +++ b/BasisSetSelector/proline.pdb @@ -0,0 +1,38 @@ +COMPND 145742 +AUTHOR GENERATED BY OPEN BABEL 3.1.0 +ATOM 1 O PRO A 1 2.162 -0.951 -0.112 1.00 0.00 O +ATOM 2 OXT PRO A 1 1.569 1.216 -0.495 1.00 0.00 O +ATOM 3 N PRO A 1 -0.781 0.931 0.777 1.00 0.00 N +ATOM 4 CA PRO A 1 0.083 -0.248 0.725 1.00 0.00 C +ATOM 5 CB PRO A 1 -0.724 -1.317 -0.003 1.00 0.00 C +ATOM 6 CG PRO A 1 -1.989 -0.611 -0.475 1.00 0.00 C +ATOM 7 CD PRO A 1 -1.650 0.864 -0.393 1.00 0.00 C +ATOM 8 C PRO A 1 1.329 0.115 -0.024 1.00 0.00 C +ATOM 9 HA PRO A 1 0.362 -0.552 1.739 1.00 0.00 H +ATOM 10 HB1 PRO A 1 -0.987 -2.143 0.667 1.00 0.00 H +ATOM 11 HB2 PRO A 1 -0.192 -1.741 -0.862 1.00 0.00 H +ATOM 12 HG1 PRO A 1 -2.280 -0.916 -1.485 1.00 0.00 H +ATOM 13 HG2 PRO A 1 -2.819 -0.849 0.202 1.00 0.00 H +ATOM 14 HD1 PRO A 1 -1.120 1.193 -1.294 1.00 0.00 H +ATOM 15 HD2 PRO A 1 -2.542 1.483 -0.269 1.00 0.00 H +ATOM 16 H PRO A 1 -0.251 1.800 0.802 1.00 0.00 H +ATOM 17 H PRO A 1 2.984 -0.734 -0.601 1.00 0.00 H +CONECT 1 8 17 +CONECT 2 8 8 +CONECT 3 4 7 16 +CONECT 4 3 5 8 9 +CONECT 5 4 6 10 11 +CONECT 6 5 7 12 13 +CONECT 7 3 6 14 15 +CONECT 8 1 2 2 4 +CONECT 9 4 +CONECT 10 5 +CONECT 11 5 +CONECT 12 6 +CONECT 13 6 +CONECT 14 7 +CONECT 15 7 +CONECT 16 3 +CONECT 17 1 +MASTER 0 0 0 0 0 0 0 0 17 0 17 0 +END