Running qc2-ASE calculators via qc2Data class
One of the key features of qc2Data is its ability to run qc2-ASE calculators on-the-fly.
This is achieved by invoking its run() method.
An example is given below:
1from ase.build import molecule
2from qc2.ase import PySCF
3from qc2.data import qc2Data
4
5# set ASE Atoms object
6mol = molecule('H2')
7
8# instantiate qc2Data class
9qc2data = qc2Data(
10 molecule=mol,
11 filename='h2.hdf5',
12 schema='qcschema'
13)
14
15# attach a calculator to the molecule attribute
16qc2data.molecule.calc = PySCF()
17
18# run qc2-ASE calculator
19qc2data.run()
Please note that, before invoking the run() method, it is necessary to attach a qc2-ASE calculator to qc2data.molecule
via the ASE calc attribute. As described in Running stand-alone qc2-ASE calculations, we can attach any implemented calculator.
run() will then execute the calculator and automatically save the relevant qchem data into h2.hdf5.
Important
If you intend to use qc2 in conjunction with ROSE, you should instantiate qc2Data
with an empty molecule parameter [1].
Indeed, differently from standard ASE calculators,
ROSE relies on custom dataclasses for reading molecular information and
does not depend on information typically contained in ASE Atoms.
See the example code below:
1from qc2.ase import ROSE, ROSETargetMolecule, ROSEFragment 2from qc2.data import qc2Data 3 4# define ROSE target molecule and fragments 5molecule = ROSETargetMolecule(...) 6frag1 = ROSEFragment(...) 7fragn = ROSEFragment(...) 8 9# instantiate qc2Data - no Atoms() needed 10qc2data = qc2Data( 11 filename='ibo.fcidump', 12 schema='fcidump' 13) 14 15# attach ROSE calculator to an empty Atoms() 16qc2data.molecule.calc = ROSE( 17 rose_calc_type='atom_frag', 18 rose_target=molecule, 19 rose_frags=[frag1, ..., fragn], 20 rose_mo_calculator='pyscf' 21) 22 23# run ROSE calculator 24qc2data.run()
Footnotes