mirror of
https://github.com/pfloos/quack
synced 2024-12-22 12:23:42 +01:00
v0 of FeatherBench
This commit is contained in:
parent
2ca8557cb3
commit
2c312cfc57
@ -72,11 +72,14 @@ subroutine ppLR(TDA, nOO, nVV, Bpp, Cpp, Dpp, Om1, X1, Y1, Om2, X2, Y2, EcRPA)
|
|||||||
M( 1:nVV ,nVV+1:nOO+nVV) = - Bpp(1:nVV,1:nOO)
|
M( 1:nVV ,nVV+1:nOO+nVV) = - Bpp(1:nVV,1:nOO)
|
||||||
M(nVV+1:nOO+nVV, 1:nVV) = + transpose(Bpp(1:nVV,1:nOO))
|
M(nVV+1:nOO+nVV, 1:nVV) = + transpose(Bpp(1:nVV,1:nOO))
|
||||||
|
|
||||||
!! Diagonalize the p-p matrix
|
if((nOO .eq. 0) .or. (nVV .eq. 0)) then
|
||||||
!if(nOO+nVV > 0) call diagonalize_general_matrix(nOO+nVV, M, Om, Z)
|
|
||||||
!! Split the various quantities in p-p and h-h parts
|
|
||||||
!call sort_ppRPA(nOO, nVV, Om, Z, Om1, X1, Y1, Om2, X2, Y2)
|
|
||||||
|
|
||||||
|
! Diagonalize the p-p matrix
|
||||||
|
if(nOO+nVV > 0) call diagonalize_general_matrix(nOO+nVV, M, Om, Z)
|
||||||
|
! Split the various quantities in p-p and h-h parts
|
||||||
|
call sort_ppRPA(nOO, nVV, Om, Z, Om1, X1, Y1, Om2, X2, Y2)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
thr_d = 1d-6 ! to determine if diagonal elements of L.T x R are close enouph to 1
|
thr_d = 1d-6 ! to determine if diagonal elements of L.T x R are close enouph to 1
|
||||||
thr_nd = 1d-6 ! to determine if non-diagonal elements of L.T x R are close enouph to 1
|
thr_nd = 1d-6 ! to determine if non-diagonal elements of L.T x R are close enouph to 1
|
||||||
@ -105,6 +108,8 @@ subroutine ppLR(TDA, nOO, nVV, Bpp, Cpp, Dpp, Om1, X1, Y1, Om2, X2, Y2, EcRPA)
|
|||||||
enddo
|
enddo
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
! Compute the RPA correlation energy
|
! Compute the RPA correlation energy
|
||||||
|
26
test/export_tobench.py
Normal file
26
test/export_tobench.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def read_quantities_from_file(filename):
|
||||||
|
quantities = {}
|
||||||
|
|
||||||
|
with open(filename, 'r') as file:
|
||||||
|
lines = file.readlines()
|
||||||
|
for i in range(0, len(lines), 2):
|
||||||
|
# Remove any leading or trailing whitespace/newline characters
|
||||||
|
quantity_name = lines[i].strip()
|
||||||
|
quantity_value = float(lines[i+1].strip())
|
||||||
|
quantities[quantity_name] = quantity_value
|
||||||
|
|
||||||
|
return quantities
|
||||||
|
|
||||||
|
def print_quantities(quantities):
|
||||||
|
for key, value in quantities.items():
|
||||||
|
print(f'"{key}": {value},')
|
||||||
|
|
||||||
|
filename = sys.argv[1]
|
||||||
|
|
||||||
|
quantities = read_quantities_from_file(filename)
|
||||||
|
print_quantities(quantities)
|
||||||
|
|
@ -1,12 +1,39 @@
|
|||||||
|
|
||||||
import sqlite3
|
import argparse
|
||||||
|
|
||||||
from molecule import save_molecules_to_json, load_molecules_from_json
|
from molecule import save_molecules_to_json, load_molecules_from_json
|
||||||
from molecule import create_database, add_molecule_to_db
|
from molecule import create_database, add_molecule_to_db, remove_database
|
||||||
|
|
||||||
from feather_bench import FeatherBench
|
from feather_bench import FeatherBench
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description="Benchmark Data Sets")
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-s', '--set_type',
|
||||||
|
choices=['light', 'medium', 'heavy'],
|
||||||
|
default='light',
|
||||||
|
help="Specify the type of data set: light (default), medium, or heavy."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.set_type == 'light':
|
||||||
|
bench = 'FeatherBench'
|
||||||
|
bench_title = "\n\nSelected Light Benchmark: {}\n\n".format(bench)
|
||||||
|
elif args.set_type == 'medium':
|
||||||
|
bench = 'BalanceBench'
|
||||||
|
bench_title = "\n\nSelected Medium Benchmark: {}\n\n".format(bench)
|
||||||
|
elif args.set_type == 'heavy':
|
||||||
|
bench = 'TitanBench'
|
||||||
|
bench_title = "\n\nSelected Heavy Benchmark: {}\n\n".format(bench)
|
||||||
|
else:
|
||||||
|
bench_title = "\n\nSelected Light Benchmark: {}\n\n".format(bench)
|
||||||
|
|
||||||
|
|
||||||
|
db_name = '{}.db'.format(bench)
|
||||||
|
|
||||||
|
|
||||||
# Save molecules to JSON
|
# Save molecules to JSON
|
||||||
#save_molecules_to_json(FeatherBench, 'FeatherBench.json')
|
#save_molecules_to_json(FeatherBench, 'FeatherBench.json')
|
||||||
@ -15,8 +42,8 @@ from feather_bench import FeatherBench
|
|||||||
#loaded_molecules = load_molecules_from_json('FeatherBench.json')
|
#loaded_molecules = load_molecules_from_json('FeatherBench.json')
|
||||||
#print(loaded_molecules)
|
#print(loaded_molecules)
|
||||||
|
|
||||||
# Create a database and add molecules
|
#remove_database(db_name)
|
||||||
db_name = 'FeatherBench.db'
|
|
||||||
create_database(db_name)
|
create_database(db_name)
|
||||||
for molecule in FeatherBench:
|
for molecule in FeatherBench:
|
||||||
add_molecule_to_db(db_name, molecule)
|
add_molecule_to_db(db_name, molecule)
|
||||||
|
@ -11,43 +11,35 @@ He = Molecule(
|
|||||||
properties={
|
properties={
|
||||||
"properties_rhf":{
|
"properties_rhf":{
|
||||||
"6-31g": {
|
"6-31g": {
|
||||||
"RHF energy": -2.855160426884076,
|
"RHF energy": -2.855160426154444,
|
||||||
"RHF HOMO energy": -0.914126628614305,
|
"RHF HOMO energy": -0.914126628640145,
|
||||||
"RHF LUMO energy": 1.399859335225087,
|
"RHF LUMO energy": 1.399859335255765,
|
||||||
"RHF dipole moment": 0.000000000000000,
|
"RHF dipole moment": 0.0,
|
||||||
"RMP2 correlation energy": -0.011200122910187,
|
"MP2 correlation energy": -0.011200122909934,
|
||||||
"CCD correlation energy": -0.014985063408247,
|
"CCD correlation energy": -0.014985063116,
|
||||||
"DCD correlation energy": -0.014985062907429,
|
"CCSD correlation energy": -0.015001711549092,
|
||||||
"CCSD correlation energy": -0.015001711549550,
|
"drCCD correlation energy": -0.01884537385338,
|
||||||
"drCCD correlation energy": -0.018845374502248,
|
"rCCD correlation energy": -0.016836322809386,
|
||||||
"rCCD correlation energy": -0.016836324636164,
|
"crCCD correlation energy": 0.008524676641474,
|
||||||
"crCCD correlation energy": 0.008524677369855,
|
"lCCD correlation energy": -0.00808242082105,
|
||||||
"lCCD correlation energy": -0.008082420815100,
|
"CIS singlet excitation energy": 1.911193619991987,
|
||||||
"pCCD correlation energy": -0.014985062519068,
|
"CIS triplet excitation energy": 1.455852629458543,
|
||||||
"RCIS singlet excitation energy": 1.911193619935257,
|
"phRPA correlation energy": -0.018845374128748,
|
||||||
"RCIS triplet excitation energy": 1.455852629402236,
|
"phRPAx correlation energy": -0.015760565120758,
|
||||||
"phRRPA correlation energy": -0.018845374129105,
|
"crRPA correlation energy": -0.008868581132249,
|
||||||
"phRRPAx correlation energy": -0.015760565121283,
|
"ppRPA correlation energy": -0.008082420814972,
|
||||||
"crRRPA correlation energy": -0.008868581132405,
|
"G0F2 correlation energy": -0.011438430540104,
|
||||||
"ppRRPA correlation energy": -0.008082420815100,
|
"G0F2 HOMO energy": -0.882696116274599,
|
||||||
"RG0F2 correlation energy": -0.011438430540374,
|
"G0F2 LUMO energy": 1.383080391842522,
|
||||||
"RG0F2 HOMO energy": -0.882696116247871,
|
"G0W0 correlation energy": -0.019314094399372,
|
||||||
"RG0F2 LUMO energy": 1.383080391811630,
|
"G0W0 HOMO energy": -0.87053388021722,
|
||||||
"evRGF2 correlation energy": -0.011448483158486,
|
"G0W0 LUMO energy": 1.377171287041735,
|
||||||
"evRGF2 HOMO energy": -0.881327878713477,
|
"evGW correlation energy": -0.019335511771337,
|
||||||
"evRGF2 LUMO energy": 1.382458968133448,
|
"evGW HOMO energy": -0.868460640984803,
|
||||||
"RG0W0 correlation energy": -0.019314094399756,
|
"evGW LUMO energy": 1.376287581502582,
|
||||||
"RG0W0 HOMO energy": -0.870533880190454,
|
"G0T0pp correlation energy": -0.008161908540634,
|
||||||
"RG0W0 LUMO energy": 1.377171287010956,
|
"G0T0pp HOMO energy": -0.898869172597701,
|
||||||
"evRGW correlation energy": -0.019335511771724,
|
"G0T0pp LUMO energy": 1.383928087417952,
|
||||||
"evRGW HOMO energy": -0.868460640957913,
|
|
||||||
"evRGW LUMO energy": 1.376287581471769,
|
|
||||||
"RG0T0pp correlation energy": -0.008082420815100,
|
|
||||||
"RG0T0pp HOMO energy": -0.914126628614305,
|
|
||||||
"RG0T0pp LUMO energy": 1.399859335225087,
|
|
||||||
"evRGTpp correlation energy": -0.008082420815100,
|
|
||||||
"evRGTpp HOMO energy": -0.914126628614305,
|
|
||||||
"evRGTpp LUMO energy": 1.399859335225087
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties_uhf":{
|
"properties_uhf":{
|
||||||
@ -58,8 +50,51 @@ He = Molecule(
|
|||||||
"6-31g": {
|
"6-31g": {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties_rohf":{
|
}
|
||||||
"6-31g": {
|
)
|
||||||
|
|
||||||
|
# ---
|
||||||
|
|
||||||
|
H2O = Molecule(
|
||||||
|
name="H2O",
|
||||||
|
multiplicity=1,
|
||||||
|
geometry=[
|
||||||
|
{"element": "O", "x": 0.0000, "y": 0.0000, "z": 0.0000},
|
||||||
|
{"element": "H", "x": 0.7571, "y": 0.0000, "z": 0.5861},
|
||||||
|
{"element": "H", "x": -0.7571, "y": 0.0000, "z": 0.5861}
|
||||||
|
],
|
||||||
|
properties={
|
||||||
|
"properties_rhf":{
|
||||||
|
"cc-pvdz": {
|
||||||
|
"RHF energy": -85.21935817501823,
|
||||||
|
"RHF HOMO energy": -0.493132793449897,
|
||||||
|
"RHF LUMO energy": 0.185534869842355,
|
||||||
|
"RHF dipole moment": 0.233813698748474,
|
||||||
|
"MP2 correlation energy": -0.203978216774657,
|
||||||
|
"CCD correlation energy": -0.212571260121257,
|
||||||
|
"CCSD correlation energy": -0.213302190845899,
|
||||||
|
"drCCD correlation energy": -0.231281853419338,
|
||||||
|
"rCCD correlation energy": -0.277238348710547,
|
||||||
|
"crCCD correlation energy": 0.18014617422324,
|
||||||
|
"lCCD correlation energy": -0.15128653432796,
|
||||||
|
"CIS singlet excitation energy": 0.338828950934568,
|
||||||
|
"CIS triplet excitation energy": 0.304873339484139,
|
||||||
|
"phRPA correlation energy": -0.231281866582435,
|
||||||
|
"phRPAx correlation energy": -0.310796738307943,
|
||||||
|
"crRPA correlation energy": -0.246289801609294,
|
||||||
|
"ppRPA correlation energy": -0.151286536255888,
|
||||||
|
"G0F2 correlation energy": -0.217807591229668,
|
||||||
|
"G0F2 HOMO energy": -0.404541451101377,
|
||||||
|
"G0F2 LUMO energy": 0.16650398400197,
|
||||||
|
"G0W0 correlation energy": -0.23853664665404,
|
||||||
|
"G0W0 HOMO energy": -0.446828623007469,
|
||||||
|
"G0W0 LUMO energy": 0.173026609033024,
|
||||||
|
"evGW correlation energy": -0.239414217281308,
|
||||||
|
"evGW HOMO energy": -0.443076613314424,
|
||||||
|
"evGW LUMO energy": 0.172691758111392,
|
||||||
|
"G0T0pp correlation energy": -0.156214864467344,
|
||||||
|
"G0T0pp HOMO energy": -0.452117482732615,
|
||||||
|
"G0T0pp LUMO energy": 0.16679206983464,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,24 +102,9 @@ He = Molecule(
|
|||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
#H2O = Molecule(
|
|
||||||
# name="H2O",
|
|
||||||
# multiplicity=1,
|
|
||||||
# geometry=[
|
|
||||||
# {"element": "O", "x": 0.0000, "y": 0.0000, "z": 0.0000},
|
|
||||||
# {"element": "H", "x": 0.7571, "y": 0.0000, "z": 0.5861},
|
|
||||||
# {"element": "H", "x": -0.7571, "y": 0.0000, "z": 0.5861}
|
|
||||||
# ],
|
|
||||||
# properties={
|
|
||||||
# "cc-pvdz": {
|
|
||||||
# }
|
|
||||||
#)
|
|
||||||
|
|
||||||
# ---
|
|
||||||
|
|
||||||
FeatherBench = [
|
FeatherBench = [
|
||||||
He,
|
He,
|
||||||
#H2O
|
H2O
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# MP2 MP3
|
# MP2 MP3
|
||||||
T T
|
T T
|
||||||
# CCD pCCD DCD CCSD CCSD(T)
|
# CCD pCCD DCD CCSD CCSD(T)
|
||||||
T T T T F
|
T F F T F
|
||||||
# drCCD rCCD crCCD lCCD
|
# drCCD rCCD crCCD lCCD
|
||||||
T T T T
|
T T T T
|
||||||
# CIS CIS(D) CID CISD FCI
|
# CIS CIS(D) CID CISD FCI
|
||||||
@ -11,11 +11,11 @@
|
|||||||
# phRPA phRPAx crRPA ppRPA
|
# phRPA phRPAx crRPA ppRPA
|
||||||
T T T T
|
T T T T
|
||||||
# G0F2 evGF2 qsGF2 ufGF2 G0F3 evGF3
|
# G0F2 evGF2 qsGF2 ufGF2 G0F3 evGF3
|
||||||
T T F F F F
|
T F F F F F
|
||||||
# G0W0 evGW qsGW SRG-qsGW ufG0W0 ufGW
|
# G0W0 evGW qsGW SRG-qsGW ufG0W0 ufGW
|
||||||
T T F F F F
|
T T F F F F
|
||||||
# G0T0pp evGTpp qsGTpp ufG0T0pp
|
# G0T0pp evGTpp qsGTpp ufG0T0pp
|
||||||
T T F F
|
T F F F
|
||||||
# G0T0eh evGTeh qsGTeh
|
# G0T0eh evGTeh qsGTeh
|
||||||
F F F
|
F F F
|
||||||
# Rtest Utest Gtest
|
# Rtest Utest Gtest
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
|
||||||
|
import os
|
||||||
import json
|
import json
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
|
from utils import print_col
|
||||||
|
|
||||||
|
|
||||||
class Molecule:
|
class Molecule:
|
||||||
def __init__(self, name, multiplicity, geometry, properties):
|
def __init__(self, name, multiplicity, geometry, properties):
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -38,23 +42,64 @@ def load_molecules_from_json(filename):
|
|||||||
|
|
||||||
|
|
||||||
def create_database(db_name):
|
def create_database(db_name):
|
||||||
|
if os.path.exists(db_name):
|
||||||
conn = sqlite3.connect(db_name)
|
conn = sqlite3.connect(db_name)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute('''CREATE TABLE IF NOT EXISTS molecules
|
# Check if the table already exists
|
||||||
|
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='molecules';")
|
||||||
|
table_exists = cursor.fetchone()
|
||||||
|
|
||||||
|
if table_exists:
|
||||||
|
print_col(f"Database '{db_name}' already exists and table 'molecules' is already created.", "yellow")
|
||||||
|
else:
|
||||||
|
# Create the table if it does not exist
|
||||||
|
cursor.execute('''CREATE TABLE molecules
|
||||||
|
(name TEXT, multiplicity INTEGER, geometry TEXT, properties TEXT)''')
|
||||||
|
conn.commit()
|
||||||
|
print_col(f"Table 'molecules' created in existing database '{db_name}' successfully.", "green")
|
||||||
|
conn.close()
|
||||||
|
else:
|
||||||
|
# Create the database and table
|
||||||
|
conn = sqlite3.connect(db_name)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute('''CREATE TABLE molecules
|
||||||
(name TEXT, multiplicity INTEGER, geometry TEXT, properties TEXT)''')
|
(name TEXT, multiplicity INTEGER, geometry TEXT, properties TEXT)''')
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
print_col(f"Database '{db_name}' created and table 'molecules' added successfully.", "green")
|
||||||
|
|
||||||
def add_molecule_to_db(db_name, molecule):
|
def add_molecule_to_db(db_name, molecule):
|
||||||
|
|
||||||
conn = sqlite3.connect(db_name)
|
conn = sqlite3.connect(db_name)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# Convert geometry and properties to JSON strings
|
||||||
geometry_str = json.dumps(molecule.geometry)
|
geometry_str = json.dumps(molecule.geometry)
|
||||||
energies_str = json.dumps(molecule.properties)
|
energies_str = json.dumps(molecule.properties)
|
||||||
cursor.execute("INSERT INTO molecules VALUES (?, ?, ?, ?)",
|
|
||||||
|
# Check if the molecule already exists
|
||||||
|
cursor.execute("SELECT COUNT(*) FROM molecules WHERE name = ?", (molecule.name,))
|
||||||
|
count = cursor.fetchone()[0]
|
||||||
|
|
||||||
|
if count > 0:
|
||||||
|
print_col(f"Molecule '{molecule.name}' already exists in {db_name}.", "yellow")
|
||||||
|
else:
|
||||||
|
# Insert the molecule if it does not exist
|
||||||
|
cursor.execute("INSERT INTO molecules (name, multiplicity, geometry, properties) VALUES (?, ?, ?, ?)",
|
||||||
(molecule.name, molecule.multiplicity, geometry_str, energies_str))
|
(molecule.name, molecule.multiplicity, geometry_str, energies_str))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
print_col(f"'{molecule.name}' added to {db_name} successfully.", "green")
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
def remove_database(db_name):
|
||||||
|
if os.path.exists(db_name):
|
||||||
|
os.remove(db_name)
|
||||||
|
print_col(f"Database '{db_name}' removed successfully.", "red")
|
||||||
|
else:
|
||||||
|
print_col(f"Database '{db_name}' does not exist.", "red")
|
||||||
|
|
||||||
def get_molecules_from_db(db_name):
|
def get_molecules_from_db(db_name):
|
||||||
conn = sqlite3.connect(db_name)
|
conn = sqlite3.connect(db_name)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
Loading…
Reference in New Issue
Block a user