How to use the qcelemental.models function in qcelemental

To help you get started, we’ve selected a few qcelemental examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github psi4 / psi4 / tests / pytests / test_qcschema.py View on Github external
outfiles = [input_fn]
        output_fn = input_fn

    as_binary = []
    if input_enc == "msgpack-ext":
        as_binary.append(input_fn)
    if output_enc == "msgpack-ext":
        as_binary.append(output_fn)

    success, ret = run_psi4_cli(inputs, outfiles, cmds, as_binary=as_binary)
    assert compare_integers(True, success, "Computation Status")
    assert compare_integers(True, ret['stdout'] == '', "Empty stdout")

    try:
        parsed = True
        ret = qcel.models.Result.parse_raw(ret["outfiles"][output_fn], encoding=output_enc)
    except Exception as e:
        parsed = False
        print(e)

    assert compare_integers(True, parsed, "Result Model Parsed")
    assert compare_values(-76.22831410207938, ret.return_result, "Return")
github MolSSI / QCPortal / collections / optimization_dataset.py View on Github external
class OptEntry(ProtoModel):
    """Data model for the optimizations in a Dataset"""

    name: str
    initial_molecule: ObjectId
    additional_keywords: Dict[str, Any] = {}
    attributes: Dict[str, Any] = {}
    object_map: Dict[str, ObjectId] = {}


class OptEntrySpecification(ProtoModel):
    name: str
    description: Optional[str]
    optimization_spec: OptimizationSpecification
    qc_spec: QCSpecification
    protocols: qcel.models.procedures.OptimizationProtocols = qcel.models.procedures.OptimizationProtocols()


class OptimizationDataset(BaseProcedureDataset):
    class DataModel(BaseProcedureDataset.DataModel):

        records: Dict[str, OptEntry] = {}
        history: Set[str] = set()
        specs: Dict[str, OptEntrySpecification] = {}

        class Config(BaseProcedureDataset.DataModel.Config):
            pass

    def _internal_compute_add(self, spec: Any, entry: Any, tag: str, priority: str) -> ObjectId:

        # Form per-procedure keywords dictionary
        general_keywords = spec.optimization_spec.keywords
github hjkgrp / MultirefPredict / MultirefPredict / cheminfo.py View on Github external
def xyzfile2qcelemental(xyzfile, charge=0, spinmult=1):
    xyz = open(xyzfile).readlines()
    mol_str = str(charge)+" "+str(spinmult) + "\n"
    for i in range(2, len(xyz)):
        mol_str += xyz[i]
    molecule = qcelemental.models.Molecule.from_data(mol_str)
    return molecule
github MolSSI / QCPortal / models / records.py View on Github external
f"Wavefunction Key(s) `{unknown}` not understood, available keys are: {self.wavefunction['available']}"
            )

        if missing:

            # Translate a return value
            proj = {self.wavefunction["return_map"].get(x, x): True for x in missing}

            self.cache["wavefunction"].update(
                self.client.custom_query(
                    "wavefunctionstore", None, {"id": self.wavefunction_data_id}, meta={"include": proj}
                )
            )

            if "basis" in missing:
                self.cache["wavefunction"]["basis"] = qcel.models.BasisSet(**self.cache["wavefunction"]["basis"])

        # Remap once more
        ret = {}
        for k in keys:
            mkey = self.wavefunction["return_map"].get(k, k)
            ret[k] = self.cache["wavefunction"][mkey]

        if single_return:
            return ret[keys[0]]
        else:
            return ret
github MolSSI / QCPortal / models / records.py View on Github external
..., description="The Id of the molecule in the Database which the result is computed on."
    )
    basis: Optional[str] = Field(
        None,
        description="The quantum chemistry basis set to evaluate (e.g., 6-31g, cc-pVDZ, ...). Can be ``None`` for "
        "methods without basis sets.",
    )
    keywords: Optional[ObjectId] = Field(
        None,
        description="The Id of the :class:`KeywordSet` which was passed into the quantum chemistry program that "
        "performed this calculation.",
    )
    protocols: qcel.models.results.ResultProtocols = Field(qcel.models.results.ResultProtocols(), description="")

    # Output data
    return_result: Union[float, qcel.models.types.Array[float], Dict[str, Any]] = Field(
        None, description="The primary result of the calculation, output is a function of the specified ``driver``."
    )
    properties: qcel.models.ResultProperties = Field(
        None, description="Additional data and results computed as part of the ``return_result``."
    )
    wavefunction: Optional[Dict[str, Any]] = Field(None, description="Wavefunction data generated by the Result.")
    wavefunction_data_id: Optional[ObjectId] = Field(None, description="The id of the wavefunction")

    class Config(RecordBase.Config):
        """A hash index is not used for ResultRecords as they can be
        uniquely determined with queryable keys.
        """

        build_hash_index = False

    @validator("method")
github MolSSI / QCPortal / models / records.py View on Github external
)
    schema_version: int = Field(1, description="The version number of QCSchema under which this record conforms to.")

    # Input data
    initial_molecule: ObjectId = Field(
        ..., description="The Id of the molecule which was passed in as the reference for this Optimization."
    )
    qc_spec: QCSpecification = Field(
        ..., description="The specification of the quantum chemistry calculation to run at each point."
    )
    keywords: Dict[str, Any] = Field(
        {},
        description="The keyword options which were passed into the Optimization program. "
        "Note: These are a dictionary and not a :class:`KeywordSet` object.",
    )
    protocols: qcel.models.procedures.OptimizationProtocols = Field(
        qcel.models.procedures.OptimizationProtocols(), description=""
    )

    # Automatting issue currently
    # description=str(qcel.models.procedures.OptimizationProtocols.__doc__))

    # Results
    energies: List[float] = Field(None, description="The ordered list of energies at each step of the Optimization.")
    final_molecule: ObjectId = Field(
        None, description="The ``ObjectId`` of the final, optimized Molecule the Optimization procedure converged to."
    )
    trajectory: List[ObjectId] = Field(
        None,
        description="The list of Molecule Id's the Optimization procedure generated at each step of the optimization."
        "``initial_molecule`` will be the first index, and ``final_molecule`` will be the last index.",
    )
github MolSSI / QCPortal / models / records.py View on Github external
f"Wavefunction Key(s) `{unknown}` not understood, available keys are: {self.wavefunction['available']}"
            )

        if missing:

            # Translate a return value
            proj = [self.wavefunction["return_map"].get(x, x) for x in missing]

            self.cache["wavefunction"].update(
                self.client.custom_query(
                    "wavefunctionstore", None, {"id": self.wavefunction_data_id}, meta={"include": proj}
                )
            )

            if "basis" in missing:
                self.cache["wavefunction"]["basis"] = qcel.models.BasisSet(**self.cache["wavefunction"]["basis"])

        # Remap once more
        ret = {}
        for k in keys:
            mkey = self.wavefunction["return_map"].get(k, k)
            ret[k] = self.cache["wavefunction"][mkey]

        if single_return:
            return ret[keys[0]]
        else:
            return ret