In [1]:
import qcfractal.interface as ptl
client = ptl.FractalClient()
client
Out[1]:
We can query results from the database based off a variety of values, but for this example we will query a known result from the database.
In [2]:
record = client.query_procedures(id=1683293)[0]
record
Out[2]:
There are a variety of helper functions on this object to find quantities related to the computation.
In [3]:
record.get_final_molecule()
Out[3]:
In [4]:
record.show_history()
We can also observe the program, method, and basis for which the optimization was executed under.
In [5]:
record.qc_spec.dict()
Out[5]:
We can also find all keywords passed into the geometry optimization. Here we see that this geometry optimization was evaluated under a dihedral constraint.
In [6]:
record.keywords
Out[6]:
Finally, every Result generated in the computational trajectory can be queried and observed. Here we will obtain the very last computed Result.
In [7]:
record.get_trajectory()[-1]
Out[7]:
In [8]:
from qcfractal import FractalSnowflakeHandler
snowflake = FractalSnowflakeHandler()
client = snowflake.client()
client
Out[8]:
In [9]:
methane = ptl.Molecule.from_data("pubchem:methane")
methane
Out[9]:
To run a optimization on this methane molecule we need to specify the full input as shown below. It should be noted that this function is also organized in such a way where the optimization of many molecules with the same level of theory is most efficient.
In [11]:
options = {
"keywords": {'coordsys': 'tric'}, # Geometry optimization program options
"qc_spec": { # Quantum chemistry specifications
"driver": "gradient",
"method": "HF",
"basis": "sto-3g",
"keywords": None,
"program": "psi4"
},
}
compute = client.add_procedure("optimization", "geometric", options, [methane])
compute
Out[11]:
The id
s of the submitted optimization can then be queried and examined. As a note the computation is not instantaneous, you may need to wait a moment and requery for this small molecule.
In [15]:
result = client.query_procedures(id=compute.ids)[0]
result
Out[15]:
In [20]:
ch_bond_original = result.get_initial_molecule().measure([0, 1])
ch_bond_optimized = result.get_final_molecule().measure([0, 1])
print(f"Optimized/Original C-H bond {ch_bond_original}/{ch_bond_optimized} (bohr)")
In [21]:
result.show_history()
In [ ]: