File Input

The File Input can be used as an escape hatch when you want to perform a calculation type that is not yet supported by qccompute or use a program not yet supported by qccompute. You can submit the program's native input files to the program and qccompute will execute the program, collect all the outputs, and return them to you. These calculations could be an MD run, some unique calculation type not supported by qccompute, or any arbitrary command you can send to any command-line executable program.

"""An example of how to create a FileInput object for a QC Program."""

from pathlib import Path

from qcdata import FileInput, Structure

from qccompute import compute

# Input files for QC Program
inp_file = Path("path/to/tc.in").read_text()  # Or your own function to create tc.in

# Structure object to XYZ file
structure = Structure.open("path/to/my/mol.xyz")
xyz_str = structure.to_xyz()  # type: ignore

# Create a FileInput object for TeraChem
file_input = FileInput(
    files={"tc.in": inp_file, "coords.xyz": xyz_str}, cmdline_args=["tc.in"]
)

# This will write the files to disk in a temporary directory and then run
# "terachem tc.in" in that directory.
prog_output = compute("terachem", file_input, print_logs=True)

# Data
prog_output.logs
prog_output.input_data
prog_output.data.files  # Has all the files terachem creates
prog_output.data.files.keys()  # Print out file names
# Saves all outputs with the exact structure produced by the QC program
prog_output.data.save_files("to/this/directory")