alframework.tools.tools module

annealing_schedule(t, tmax, amp, per, srt, end)[source]

Defines the overall temperature profile in the molecular dynamics simulation.

Args:

t (float): Current simulation time. tmax (float): Total simulation time. amp (float): Amplitude of the temperature oscillation. per (float): Period of the temperature oscillation. srt (float): Initial temperature. end (float): Final temperature.

Returns:

(float): Temperature at step ‘t’ given the specified annealing schedule.

build_ANI_info(directory)[source]

Scrapes directory and create a dictionary containing the information that can be passed to ‘ensemblemolecule’.

Args:

directory (str): Directory to look for the information needed to fill the dict.

Returns:

(dict): Dictionary that can be passed into ‘ensemblemolecule’ in ase_interface module.

build_input_dict(function, dictionary_list, use_local_space=False, raise_on_fail=False)[source]

Builds an input dict by matching the parameters of a function with the keys of dictionaries in a list.

Args:

function (function): Callable object whose parameters going to be extracted. dictionary_list (list): List of dictionaries to search. use_local_space (bool): If True also looks for the parameters in the local symbol table. raise_on_fail (bool): If True raises a value error if this function fails.

Returns:

(dict): Dictionary containing whose keys are the parameters of ‘function’.

compute_empirical_formula(S)[source]

Computes an empirical formula to describe a chemical system.

Args:

S (list): List of strings where each strings represents an atom in the system.

Returns:

(str): An empircal formula representing the system.

find_empty_directory(pattern)[source]

Find an empty directory to restart.

Args:

(str): Common prefix of the directories to check.

Returns:

(int): Number of the empty directory.

load_config_file(path, master_directory=None)[source]

Extracts the main parameters to run ALF from the master json file.

Args:

path (str): Path of the master json file. master_directory (str): Master directory to run ALF.

Returns:

(dict): Dictionary containing the main parameters needed to configure ALF.

load_module_from_config(config, module_field)[source]

Loads a module from a config json file.

Args:

config (dict): Dictionary representing the config json file. module_field (str): Module to load.

Returns:

(type): Type of the class that was loaded from the config file.

load_module_from_string(module_field)[source]

Loads a python module from a string.

Args:

module_field (str): Strings that contains the modules to be loaded.

Returns:

(type): Type of the class that was loaded from module_field.

class parsl_task_queue[source]

Bases: object

add_task(task)[source]

Add a task to the task list

get_completed_number()[source]

Get the number of completed tasks.

get_exec_done_number()[source]
get_failed_number()[source]
get_number()[source]

Get the the number of tasks in the task list.

get_queued_number()[source]

Get the number of queued tasks.

get_running_number()[source]

Get the number of running tasks.

get_task_results()[source]

Get the reults of the tasks

Returns:
(tuple): A tuple containing, respectively, a list that stores the task results and an int that tells

the number of failed tasks.

get_task_status()[source]

Get the status of the tasks.

Returns:

(list): List containing the status of the tasks.

print_status()[source]

Prints the status of the tasks.

random_rotation_matrix(deflection=1.0, randnums=None)[source]

Returns a random rotation matrix

Args:

deflection (float): Pole deflection. randnums (ndarray): A (3,) numpy array containing the parameters theta, phi, and z.

Returns:

(ndarray): Random 3x3 rotation matrix.

store_current_data(h5path, system_data, properties)[source]

Stores the key results of the QM calculations in the database.

Args:

h5path (str): Path to store the .h5 files. system_data (list): A list of MoleculesObjects objects. properties (dict): Dictionary defined in master.json whose keys are the properties that we want to retrieve

from the QM calculations and store in the database.

Returns:

(None)

system_checker(system, kill_on_fail=True, print_error=True)[source]

Checks if the system returned by the builder meets all requeriments.

Args:
system (list): A list containing three elements. The first is a dict containing metadata of the system,

and one of its keys must be ‘moleculeid’ whose value is a unique identifier of the system. The second element is an ASE Atoms object. The third element is a dict that stores the desired properties from the QM calculation (e.g. forces and energies).

kill_on_fail (bool): Kills the process if something goes wrong. print_error (bool): If True prints the error message if something goes wrong.

Returns:

(bool): True if ‘system’ meets all requirements and False otherwise.