scine_puffin.jobs.templates.scine_hessian_job

Classes

HessianJob()

A common interface for all jobs in Puffin that use the Scine::Core::Calculator interface to calculate a Hessian and carry out a Thermochemistry analysis.

class scine_puffin.jobs.templates.scine_hessian_job.HessianJob[source]

A common interface for all jobs in Puffin that use the Scine::Core::Calculator interface to calculate a Hessian and carry out a Thermochemistry analysis.

archive(archive: str) None

Archives all files existent in the job’s directory into tarball named with the job’s ID. The tarball is then moved to the given destination.

Parameters:
archivestr

The path to move the resulting tarball to.

calculation_postprocessing(success: bool, systems: Dict[str, utils.core.Calculator | None], keys: List[str], expected_results: List[str] | None = None) db.Results

Performs a verification protocol that a Scine Calculation was successful. If not throws an exception, if yes, the model is updated and the cleared db.Results object of the configured calculation is returned to be added with actual results.

Parameters:
successbool

Whether the calculation was successful (either forwarded from readuct task or specified if not relevant).

systemsDict[str, utils.core.Calculator] (Scine::Core::Calculator)

The dictionary holding calculators.

keysList[str]

The list of keys of the systems dict to be checked.

expected_resultsOptional[List[str]]

The results to be required to be present in systems to qualify as successful calculations. If None is given, this defaults to the expected results of the class, see expected_results().

Notes

  • Requires run configuration

  • May throw Exception

capture_raw_output() Tuple[str, str]

Tries to capture the raw output of the calculation context and save it in the raw_output field of the configured calculation. This should never throw.

Notes

  • Requires run configuration

classmethod check_configuration(instance: T) typing_extensions.TypeGuard[T]
static check_duplicate_property(structure: db.Structure, properties: db.Collection, property_name: str, model: db.Model) db.ID | bool

Checks for a property that is an exact match for the one queried here. Exact match meaning that key and model both are matches.

Parameters:
propertiesdb.Collection (Scine::Database::Collection)

The collection housing all properties.

property_namestr

The name (key) of the queried property, e.g. electronic_energy.

modeldb.Model (Scine::Database::Model)

The model used in the calculation that resulted in this property.

structuredb.Structure (Scine::Database::Structure)

The structure to be checked in. The structure has to be linked to its collection.

Returns:
IDdb.ID (Scine::Database::ID)

Returns False if there is no existing property like the one queried or the ID of the first duplicate.

clear() None

Clears the directory in which the job was run.

complete_job() None

Saves the executing Puffin, changes status to db.Status.COMPLETE.

config: Configuration
configure_run(manager: db.Manager, calculation: db.Calculation, config: Configuration) None

Configures a job for a given Calculation to do tasks in the run function

Parameters:
managerdb.Manager (Scine::Database::Manager)

The manager of the database holding all collections

calculationdb.Calculation (Scine::Database::Calculation)

The calculation to be performed

configConfiguration

The configuration of the Puffin doing the job

create_helpers(structure: db.Structure) Tuple[SettingsManager, ProgramHelper | None]

Creates a Scine SettingsManager and ProgramHelper based on the configured job and the given structure. The ProgramHelper is None if no ProgramHelper is specified for the specified program or no program was specified in the model

Parameters:
structuredb.Structure (Scine::Database::Structure)

The structure on which a Calculation is performed.

Returns:
helper_tupleTuple[SettingsManager, Optional[ProgramHelper]

A tuple of the SettingsManager for Scine Calculators and ProgramHelper if available.

Notes

  • Requires run configuration

create_new_structure(calculator: utils.core.Calculator, label: db.Label) db.Structure

Add a new structure to the database based on the given calculator and label.

Parameters:
calculatorutils.core.Calculator

The calculator holding the optimized structure

labeldb.Label

The label of the new structure

Returns:
db.Structure

The new structure

Notes

  • Requires run configuration

classmethod expected_results() List[str]

Gives a list of str specifying the results expected to be present for a system within a job based on the class member and all its parents.

Returns:
expected_resultsList[str]

The results to be expected as str corresponding to the members of the Scine::Utils::Results class.

expected_results_check(systems: Dict[str, utils.core.Calculator | None], keys: List[str], expected_results: List[str] | None = None) Tuple[bool, str]

Checks the results of the given systems based on the expected results. If the expected results are not given, they default to the expected results of the class, see expected_results(). Throws exception if expected result is not present.

Parameters:
systemsDict[str, Optional[utils.core.Calculator]] (Scine::Core::Calculator)

The dictionary holding calculators.

keysList[str]

The list of keys of the systems dict to be checked.

expected_resultsOptional[List[str]]

The results to be required to be present in systems to qualify as successful calculations. If None is given, this defaults to the expected results of the class, see expected_results().

Returns:
Tuple[bool, str]

Whether the results are correct and an error message, describing failure in expected results.

Notes

  • Requires run configuration

  • May throw Exception

fail_job() None

Saves the executing Puffin, changes status to db.Status.FAILED.

failed_file() str

Returns the path to the file indicating a failed calculation, None if job has not been prepared

get_calc(name: str, systems: Dict[str, utils.core.Calculator | None]) utils.core.Calculator

Get a calculator from the given map and ensures the system is present

Parameters:
namestr

The name of the system to get

systemsDict[str, Optional[utils.core.Calculator]]

The map of systems

Returns:
utils.core.Calculator

The calculator

Notes

  • May throw exception

get_calculation() db.Calculation

Getter for the current calculation. Throws if not configured.

Returns:
calculationdb.Calculation (Scine::Database::Calculation)

The current calculation being carried out.

Notes

  • Requires run configuration

  • May throw Exception

static get_charge(calculator: utils.core.Calculator) int

Get the molecular charge of a calculator’s settings.

Parameters:
calculatorutils.core.Calculator

The calculator

Returns:
int

The molecular charge

get_energy(calculator: utils.core.Calculator) float

Get the energy of a calculator’s results.

Parameters:
calculatorutils.core.Calculator

The calculator

Returns:
float

The energy

static get_multiplicity(calculator: utils.core.Calculator) int

Get the spin multiplicity of a calculator’s settings. Return 0 if the setting is not present.

Parameters:
calculatorutils.core.Calculator

The calculator

Returns:
int

The molecular charge

own_expected_results: List[str] = ['energy', 'hessian', 'thermochemistry']
postprocess_calculation_context() bool

Postprocesses a calculation context, pushing all errors and comments.

Returns:
True if the job succeeded, False otherwise.
prepare(job_dir: str, id: db.ID) None

Prepares the actual job. This function has to be implemented by any job that shall be added to Puffins job portfolio.

Parameters:
job_dirstr

The path to the directory in which all jobs are executed.

iddb.ID (Scine::Database::ID)

The calculation that triggered the execution of this job.

prepend_to_comment(message: str) None

Prepends given message to the comment field of the currently configured calculation.

Parameters:
messagestr

The message to be prepended.

Notes

  • Requires run configuration

raise_named_exception(error_message: str, exception_type: ~typing.Type[BaseException] = <class 'BaseException'>) None

Raises an error including the name/description of the current job.

static required_programs() List[str][source]

This function has to be implemented by any job that shall be added to Puffins job portfolio.

Returns:
requirementsList[str]

A list of names of programs/packages that are required for the execution of the job.

abstract run(manager: db.Manager, calculation: db.Calculation, config: Configuration) bool

Runs the actual job. This function has to be implemented by any job that shall be added to Puffins job portfolio.

Parameters:
managerdb.Manager (Scine::Database::Manager)

The manager/database to work on/with.

calculationdb.Calculation (Scine::Database::Calculation)

The calculation that triggered the execution of this job.

configscine_puffin.config.Configuration

The configuration of Puffin.

sp_postprocessing(success: bool, systems: Dict[str, utils.core.Calculator | None], keys: List[str], structure: db.Structure, program_helper: ProgramHelper | None) None

Performs a verification and results saving protocol for a Scine Single Point Calculation.

Parameters:
successbool

Whether the calculation was successful (either forwarded from readuct task or specified if not relevant).

systemsDict[str, utils.core.Calculator] (Scine::Core::Calculator)

The dictionary holding calculators.

keysList[str]

The list of keys of the systems dict to be checked.

structuredb.Structure (Scine::Database::Structure)

The structure on which the calculation was performed.

program_helperProgramHelper

The possible ProgramHelper that may also want to do some postprocessing after a calculation.

Notes

  • Requires run configuration

  • May throw Exception

stderr_path: str = 'stderr'
stdout_path: str = 'stdout'
store_bond_orders(bond_orders: utils.BondOrderCollection, structure: db.Structure) None
store_energy(system: utils.core.Calculator, structure: db.Structure) None

Stores an ‘electronic_energy’ property for the given structure based on the energy in the results of the given system. Does not perform checks.

Parameters:
systemutils.core.Calculator (Scine::Core::Calculator)

A Scine calculator holding a results object with the energy property.

structuredb.Structure (Scine::Database::Structure)

A structure for which the property is saved.

Notes

  • Requires run configuration

store_hessian_data(system: utils.core.Calculator, structure: db.Structure) None[source]

Stores results from a Hessian calculation and Thermochemistry for the specified structure based on the given calculator. Does not perform checks.

Parameters:
systemutils.core.Calculator (Scine::Core::Calculator)

A Scine calculator holding a results object with energy, Hessian, and Thermochemistry properties.

structuredb.Structure (Scine::Database::Structure)

A structure for which the property is saved.

Notes

  • Requires run configuration

store_property(properties: db.Collection, property_name: str, property_type: str, data: Any, model: db.Model, calculation: db.Calculation, structure: db.Structure, replace: bool = True) db.Property | None

Adds a single property into the database, connecting it with a given structure and calculation (it’s results section) and also

Parameters:
propertiesdb.Collection (Scine::Database::Collection)

The collection housing all properties.

property_namestr

The name (key) of the new property, e.g. electronic_energy.

property_typestr

The type of property to be added, e.g. NumberProperty.

dataAny (According to ‘property_type’)

The data to be stored in the property, the type of this object is dependent on the type of property requested. A NumberProperty will require a float, a VectorProperty will require a List[float], etc.

modeldb.Model (Scine::Database::Model)

The model used in the calculation that resulted in this property.

calculationdb.Calculation (Scine::Database::Calculation)

The calculation that resulted in this property. The calculation has to be linked to its collection.

structuredb.Structure (Scine::Database::Structure)

The structure for which the property is to be added. The properties field of the structure will receive an additional entry, or have an entry replaced, based on the options given to this function. The structure has to be linked to its collection.

replacebool

If true, replaces an existing property (identical name and model) with the new one. This option is true by default. If false, doesnothing in the previous case, and returns None

Returns:
propertyDerived of db.Property (Scine::Database::Property)

The property, a derived class of db.Property, linked to the properties’ collection, or None if no property was generated due to duplication.

success_file() str

Returns the path to the file indicating a successful calculation, empty string if job has not been prepared

throw_if_not_successful(success: bool, systems: Dict[str, utils.core.Calculator | None], keys: List[str], expected_results: List[str] | None = None, sub_task_error_line: str = '') None

Throw an exception if some calculations results are unexpected.

Parameters:
successbool

Whether the calculation was successful (either forwarded from readuct task or specified if not relevant).

systemsDict[str, Optional[utils.core.Calculator]] (Scine::Core::Calculator)

The dictionary holding calculators.

keysList[str]

The list of keys of the systems dict to be checked.

expected_resultsOptional[List[str]]

The results to be required to be present in systems to qualify as successful calculations. If None is given, this defaults to the expected results of the class, see expected_results().

sub_task_error_linestr

An additional line for the error message to specify in which subtask the calculation crashed.

Notes

  • Requires run configuration

  • Will throw Exception or do nothing

transfer_properties(old_structure: db.Structure, new_structure: db.Structure, transfer_helper: TransferHelper | None = None) None

Copies property IDs from one structure to another one based on the specified properties in the class member.

Parameters:
old_structuredb.Structure (Scine::Database::Structure)

The structure holding the properties. If a specified property is not present for the structure, no error is given.

new_structuredb.Structure (Scine::Database::Structure)

The structure for which the properties are to be added.

transfer_helperOptional[TransferHelper]

An optional helper for more difficult transfer task. Otherwise, the specified properties are just copied.

verify_connection() None

Verifies the connection to the database. Returns only if a connection is established, if it is not, the function will attempt to generate a connection every 10 seconds, indefinitely.

Notes

  • Requires run configuration

work_dir: str