Skip to content

CREST

Danger

Solvation using CREST's new default runtime, tblite, is current buggy. For details see this issue. According to this comment only gfnff and gfn0 work correctly with either alpb or gbsa solvent option. If you want to use solvation you need to use the --legacy mode which uses xtb instead of tblite for the calculation backend. Some progress is being made on this issue in this PR.

qcop.adapters.crest.CRESTAdapter

Adapter for CREST.

Note

The ProgramInput.keywords attribute is used to create the input file for CREST. This means that the structure of the keywords attribute should match that of CREST's input specification. Keywords such as method, charge, and uhf (which are stored on the Model and Structure; uhf is multiplicity - 1) will be added to the input file automatically.

Warning

CREST does not exit with a non-zero exit code on failure. Instead, it prints "FAILED" in the stdout. This adapter will raise an ExternalProgramError if "FAILED" is found in the stdout.

Warning

CREST automatically translates the input geometry to the origin. This means that the input geometry printed to CREST's stdout will not match the input structure; however, all computed values (such as energies, gradients, etc.) are still valid because they are translationally invariant.

supported_calctypes class-attribute instance-attribute

supported_calctypes = [energy, gradient, hessian, optimization, conformer_search]

Supported calculation types.

program_version

program_version(stdout: str | None = None) -> str

Get the program version.

Parameters:

Name Type Description Default
stdout str | None

The stdout from the program.

None

Returns:

Type Description
str

The program version.

Source code in src/qcop/adapters/crest.py
60
61
62
63
64
65
66
67
68
69
70
71
def program_version(self, stdout: str | None = None) -> str:
    """Get the program version.

    Args:
        stdout: The stdout from the program.

    Returns:
        The program version.
    """
    if not stdout:
        stdout = execute_subprocess(self.program, ["--version"])
    return parse_version(stdout)

compute_data

compute_data(input_data: ProgramInput, update_func: Callable | None = None, update_interval: float | None = None, collect_rotamers: bool = False, **kwargs) -> tuple[SinglePointData | OptimizationResults | ConformerSearchResults, str]

Execute CREST on the given input.

Parameters:

Name Type Description Default
input_data ProgramInput

The qcio ProgramInput object for a computation.

required
update_func Callable | None

A function to call with the stdout at regular intervals.

None
update_interval float | None

The interval at which to call the update function.

None
collect_rotamers bool

Collect rotamers if doing a conformer_search. Defaults to False since rotamers are usually not of interest and there will be many.

False

Returns:

Type Description
tuple[SinglePointData | OptimizationResults | ConformerSearchResults, str]

A tuple of ConformerSearchResults and the stdout str.

Source code in src/qcop/adapters/crest.py
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
def compute_data(
    self,
    input_data: ProgramInput,
    update_func: Callable | None = None,
    update_interval: float | None = None,
    collect_rotamers: bool = False,
    **kwargs,
) -> tuple[SinglePointData | OptimizationResults | ConformerSearchResults, str]:
    """Execute CREST on the given input.

    Args:
        input_data: The qcio ProgramInput object for a computation.
        update_func: A function to call with the stdout at regular intervals.
        update_interval: The interval at which to call the update function.
        collect_rotamers: Collect rotamers if doing a conformer_search. Defaults to
            False since rotamers are usually not of interest and there will be many.

    Returns:
        A tuple of ConformerSearchResults and the stdout str.
    """
    # Create CREST native input files
    try:
        native_inp = qccodec.encode(input_data, self.program)
    except qccodec.exceptions.EncoderError as e:
        raise AdapterInputError(program=self.program) from e

    # Write the input files to disk
    inp_file, struct_file = Path("input.toml"), Path(native_inp.geometry_filename)
    inp_file.write_text(native_inp.input_file)
    struct_file.write_text(native_inp.geometry_file)

    # Execute CREST
    stdout = execute_subprocess(
        self.program, [inp_file.name], update_func, update_interval
    )

    # CREST does not exit with a non-zero exit code on failure
    if "FAILED" in stdout:
        raise ExternalProgramError(
            program=self.program,
            message=f"CREST calculation failed. See the stdout for more information.",
            logs=stdout,
        )

    # Parse the output
    try:
        results = qccodec.decode(
            self.program,
            input_data.calctype,
            stdout=stdout,
            directory=".",
            input_data=input_data,
        )
    except qccodec.exceptions.ParserError as e:
        raise ExternalProgramError(
            program="qccodec",
            message="Failed to parse CREST output.",
            logs=stdout,
            original_exception=e,
        ) from e

    return results, stdout