d3tales_api.Calculators package

Submodules

d3tales_api.Calculators.calculators module

class d3tales_api.Calculators.calculators.AvgEHalfCalculator(connector=None)[source]

Bases: D3Calculator

calculate(data: list, precision: int = 3, sci_notation: bool = False)[source]

Average E half calculation

Connection Points
e

E1/2 (default = V)

scan_data

optional, if e not provided, scan data will be used to find e (default = None)

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

  • sci_notation (bool) – return in scientific notation if True

Returns

average E1/2 (in units V)

class d3tales_api.Calculators.calculators.CAResistanceCalculator(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, offset_factor: float = 5, return_error: bool = False)[source]

Calculator for calculating resistance after a CA experiment.

Connection Points
i_s

list, current points (s)

t_s

list, time points (s)

pulse_width

float, time width of a pulse (s)

steps

int, number of potentiostat sweeps

low_e

float, lowest voltage (V)

Parameters
  • data (dict) – data for calculation

  • offset_factor (int) – factor by which to consider the voltage offset

  • return_error (bool) – return error and resistance if True

Returns

array [resistance, resistance error] if return_error is True, else resistance

class d3tales_api.Calculators.calculators.CVChargeTransferCalculator(connector=None)[source]

Bases: D3Calculator

calculate(data: list, precision: int = 3, sci_notation: bool = False)[source]

Charge transfer rate calculation

Connection Points:
T

Temperature (default = 293 K)

D

Diffusion constant (default = cm^2/s)

v

scan rate (default = V/s)

n

number of electrons

X

peak shift (default = V)

Parameters
  • data (list) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

  • sci_notation (bool) – return in scientific notation if True

Returns

array[[“scan_rate”, “k_0_i”]] for ith CV (cm/s)

class d3tales_api.Calculators.calculators.CVDescriptorCalculator(connector=None)[source]

Bases: D3Calculator

e_half(data: dict, **kwargs)[source]

Get CV E 1/2

Connection Points:
scan_data

scanned data from CV file (potentials in V)

sample_interval

sample interval value (V)

low_e

lowest energy value (V)

Parameters

data (dict) – data for calculation

Returns

list of E 1/2 for peaks

middle_sweep(data)[source]

CV middle sweep

Connection Points:
scan_data

scanned data from CV file (potentials in V)

Parameters

data (dict) – data for calculation

Returns

middle sweep from the CV

peak_splittings(data: dict, **kwargs)[source]

CV peak splitting

Connection Points:
scan_data

scanned data from CV file (potentials in V)

sample_interval

sample interval value (V)

low_e

lowest energy value (V)

Parameters

data (dict) – data for calculation

Returns

list of peak splittings for peaks

peaks(data: dict, width: float = 1, middle_sweep=True)[source]

Gather CV peaks

Connection Points:
scan_data

scanned data from CV file

Parameters
  • data (dict) – data for calculation (rows of voltage, current)

  • width (float) – required width of peaks to identify

  • middle_sweep (bool) – ensure the middle sweep in analyzed if True

Returns

dictionary containing list of forward peaks and list of reverse peaks

peaks_for_analysis(data: dict, get_max=True, cut_extras=False, **kwargs)[source]

Get peaks for analysis

Parameters
  • data – data for calculation

  • cut_extras – cut extra peaks off the end of the appropriate array if True and there are not the same number of forward and reverse peaks

  • kwargs

Returns

forward_peaks, reverse_peaks

static prominent_peaks(peaks_data: list, orig_data: dict, cutoff: float = 0.0999)[source]

Get prominent peaks from the CV data :param peaks_data: output data from scipy peak find_peaks function :param orig_data: original peak data :param cutoff: percentage as decimal for peaks to disregard :type peaks_data: list :type orig_data: dict :type cutoff: float :return:

reversibility(data: dict, rev_upperbound: float = 63, quasi_rev_upperbound: float = 200, **kwargs)[source]

Categorization of CV reversibility

Connection Points:
scan_data

scanned data from CV file (potentials in V)

sample_interval

sample interval value (V)

low_e

lowest energy value (V)

Parameters

data – data for calculation

:param rev_upperbound : upperbound for reversibility (mV) :param quasi_rev_upperbound : upperbound for quasi reversibility (mV) :type data: dict :type rev_upperbound: float :type quasi_rev_upperbound: float

Returns

list of reversibility categorizations for peaks

class d3tales_api.Calculators.calculators.CVDiffusionCalculator(connector=None)[source]

Bases: D3Calculator

calculate(data: list, precision: int = 3, sci_notation: bool = False)[source]

Diffusion constant using Randles-Scidwick equation

Connection Points:
i_p

peak current (default = A)

A

electrode area (default = cm^2)

v

scan rate (default = V/s)

n

number of electrons, default 1

C

concentration of the solution (default = mol/cm^3)

middle_scan

optional, if i_p is not provided, scan data will be used to find i_p (default = None)

scan_data

optional, if i_p is not provided and middle_scan not provided, scan data will be used to find i_p (default = None)

Parameters
  • data (list) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

  • sci_notation (bool) – return in scientific notation if True

Returns

average diffusion constant for single redox event (cm^2/s)

class d3tales_api.Calculators.calculators.ConcentrationCalculator(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, precision: int = 3)[source]

Diffusion constant using Randles-Scidwick equation

Connection Points:
smiles

SMILES string

volume

Volume

weight

actual weight

solv_density

density for solvent

redox_density

density for redox-active molecule

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

Returns

concentrations (eV)

class d3tales_api.Calculators.calculators.D3Calculator(connector=None)[source]

Bases: ABC

D3Calculators base class

Parameters

connector – dictionary describing connections between calculator variables (keys) and location in data

variable. EX: {“smiles”: “mol_info.smiles”, “volume”: “experimental_data.volume”}. If no connector is provided, the connections default to the connections found in default_connector.json.

__init__(connector=None)[source]
property all_connections
calculate(data)[source]
description()[source]
make_connections(obj)[source]
class d3tales_api.Calculators.calculators.DeltaGSolvCalc(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, precision: int = 3)[source]

Change in Gibbs energy for solvation calculator

Connection Points:
init_eng

initial energy (default = eV)

init_corr

initial entropy correction (default = eV)

init_eng_solv

initial energy of solvation (default = eV)

fin_eng

final energy (default = eV)

fin_corr

final entropy correction (default = eV)

fin_eng_solv

final energy of solvation (default = eV)

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

Returns

delta G solv (in units A)

class d3tales_api.Calculators.calculators.DirtyElectrodeDetector(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, max_current_range: float = 1e-05)[source]

Detect dirty electrode

Connection Points
scan_data

optional, if e not provided, scan data will be used to find e (default = None)

Parameters
  • data (dict) – data for calculation

  • max_current_range (float) – maximum rango of current points allowed for a clean electrode

Returns

average E1/2 (in units V)

class d3tales_api.Calculators.calculators.EnergyDiffCalc(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, precision: int = 3)[source]

Difference between two energies calculation

Connection Points:
energy_final

energy final (default = eV)

energy_initial

energy initial (default = eV)

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

Returns

solvation energy in units eV

class d3tales_api.Calculators.calculators.RMSDCalc(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, precision: int = 3)[source]

Root mean squared error calculator

Connection Points:
geom_final

geometry final (default = A)

geom_initial

geometry initial (default = A)

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

Returns

RMSD (in units A)

class d3tales_api.Calculators.calculators.RSSCalc(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, precision: int = 3)[source]

Radical stability score. Uses DBSTEP.

Connection Points:
log_file

calculation output file. Must be readable with CCLIB

spin_type

type of CCLIB spin to extract (default = Mulliken)

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

Returns

radical stability score

class d3tales_api.Calculators.calculators.RadBuriedVolCalc(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, precision: int = 3)[source]

Radical buried volume for the atom with the atom with the highest portion of spin. Uses DBSTEP.

Connection Points:
log_file

calculation output file. Must be readable with CCLIB

spin_type

type of CCLIB spin to extract (default = Mulliken)

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

Returns

radical buried volume (in units A^3)

class d3tales_api.Calculators.calculators.RadicalSpinCalc(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, precision: int = 3)[source]

Radical spin density. Uses DBSTEP.

Connection Points:
log_file

calculation output file. Must be readable with CCLIB

spin_type

type of CCLIB spin to extract (default = Mulliken)

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

Returns

radical stability score

class d3tales_api.Calculators.calculators.RedoxPotentialCalc(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, precision: int = 3)[source]

Redox potential calculator

Connection Points:
init_eng

initial energy (default = eV)

init_corr

initial entropy correction (default = eV)

init_eng_solv

initial energy of solvation (default = eV)

fin_eng

final energy (default = eV)

fin_corr

final entropy correction (default = eV)

fin_eng_solv

final energy of solvation (default = eV)

num_electrons

number of electrons (default = 1)

electrode

electrode name as str or potential as float (default = standard_hydrogen_electrode)

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

Returns

redox potential (in units A)

class d3tales_api.Calculators.calculators.RelaxationCalc(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, precision: int = 3)[source]

Relaxation energy calculation from high energy geometry to optimized geometry

Connection Points:
opt_energy

optimized energy (default = eV)

energy

energy another geometry (default = eV)

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

Returns

relaxation energy (in units eV)

class d3tales_api.Calculators.calculators.ReorganizationCalc(connector=None)[source]

Bases: D3Calculator

calculate(data: dict, precision: int = 3)[source]

Reorganization energy calculation

Connection Points:
gs_opt

ground state optimized energy (default = eV)

ion_opt

ion optimized energy (default = eV)

gs_energy

ground state energy at ion geometry (default = eV)

ion_energy

ion energy at ground state geometry (default = eV)

Parameters
  • data (dict) – data for calculation

  • precision (int) – number of significant figures (in scientific notation)

Returns

reorganization energy (in units eV)

d3tales_api.Calculators.ocelot_transform module

Code taken from the OCELOT API to transform molecule objects. https://github.com/caer200/ocelot_api Code copied from: https://github.com/caer200/ocelot_api/blob/master/ocelot/routines/conformerparser.py

class d3tales_api.Calculators.ocelot_transform.ACParser(ac: ndarray, charge, atomnumberlist, sani=True, apriori_radicals=None)[source]

Bases: object

BO_is_OK(BO, DU_from_AC, atomicNumList, charged_fragments, valences)[source]

check bond order matrix based on

Parameters
  • BO

  • DU_from_AC – based on valences arg

  • atomicNumList

  • charged_fragments

  • valences – valence assignment related to current BO

Returns

__init__(ac: ndarray, charge, atomnumberlist, sani=True, apriori_radicals=None)[source]
Variables

self.valences_list – a list of possible valence assignment, valences_list[i] is one possbile way to assign jth atom

valence based on valences_list[i][j]. :var self.atomic_valence_electrons: atomic_valence_electrons[i] is the #_of_ve of ith atom :var self.apriori_radicals: a dict to mark the atoms that can will have a lower valence in generating BO

addBO2mol(rdmol, BO_matrix, charged_fragments, force_single=False)[source]
static getUADU(maxValence_list, valence_list)[source]

get unsaturated atoms (UA) and degree of unsaturation (DU) between two possible assignments

Parameters
  • maxValence_list

  • valence_list

Returns

static get_BO(AC, DU_init, valences, UA_pairs)[source]

for a valence assignment, get BO BO[i][j] is the bond order between ith and jth AC is a BO with all single bond the algo is to increase bond order s.t. degree of unsaturation (DU) does not change notice DU is calculated based on the given valences

Parameters
  • DU_init

  • AC

  • valences

  • UA_pairs

Returns

static get_UA_pairs(UA, AC)[source]

find the largest list of bonds in which all atom appears at most once

Parameters
  • UA

  • AC

Returns

static get_atomic_charge(atomic_number, atomic_valence_electrons, BO_valence)[source]

atomic charge from #_valence_electrons - bond_order #TODO test robustness

Parameters
  • atomic_number

  • atomic_valence_electrons

  • BO_valence

Returns

static get_bonds(UA, AC)[source]

get a list of unique bond tuples (i, j) between UAs

Parameters
  • UA

  • AC

Returns

get_valence_info()[source]
init_rdmol()[source]
parse(charged_fragments=False, force_single=False, expliciths=True)[source]
parse_bonds(charged_fragments)[source]

find the best BO

Parameters

charged_fragments

Returns

set_atomic_charges(mol, BO_valences, BO_matrix)[source]
set_atomic_radicals(mol, BO_valences)[source]
static valences_not_too_large(BO, vs)[source]
d3tales_api.Calculators.ocelot_transform.chiral_stereo_check(mol)[source]
d3tales_api.Calculators.ocelot_transform.clean_charges(mol)[source]
d3tales_api.Calculators.ocelot_transform.pmgmol_to_rdmol(pmg_mol)[source]
d3tales_api.Calculators.ocelot_transform.valence_electron(element)[source]

count valence electrons based on electronic configuration if a subshell has > 10 electrons, this subshell is ignored

d3tales_api.Calculators.plotters module

class d3tales_api.Calculators.plotters.CVPlotter(connector=None)[source]

Bases: D3Plotter

live_plot(data, fig_path=None, self_standard=False, a_to_ma=False, current_density=False, **plt_kwargs)[source]

Live Matplotlib plot for data

Connection Points:
scan_data

scanned data from CV file

Parameters
  • data (dict) – data for calculation

  • fig_path (str) – path to which to save the figure

  • self_standard (bool) – establish self standard (e_half=0V) if True

Returns

shows matplotlib plot

live_plot_multi(data, fig_path=None, sort=True, self_standard=False, a_to_ma=False, current_density=False, **plt_kwargs)[source]

Live Matplotlib plot for data

Connection Points:
scan_data

scanned data from CV file

variable_prop

property that varies between CVs

Parameters
  • data (list) – data for calculation

  • fig_path (str) – path to which to save the figure

  • sort (bool) – sort by variable_prop if True

  • self_standard (bool) – establish self standard (e_half=0V) if True

Returns

shows matplotlib plot

plot_data(data, self_standard=False, a_to_ma=False, current_density=False)[source]

CV plot data for plotly

Connection Points:
scan_data

scanned data from CV file

we_surface_area

working electrode surface area

param data

data for calculation

type data

dict

param self_standard

establish self standard (e_half=0V) if True

type self_standard

bool

param a_to_ma

convert current values (assumed to be in A) to mA if True

type a_to_ma

bool

param current_density

convert current values to current density if True (requires we_surface_area connection)

)
type current_density

bool

return

plot data for plotly

class d3tales_api.Calculators.plotters.D3Plotter(connector=None)[source]

Bases: D3Calculator

D3Plotters base class, based on D3Calculators base class

plot_data(data)[source]
class d3tales_api.Calculators.plotters.DFTSpecPlotter(connector=None)[source]

Bases: D3Plotter

live_plot(data, fig_path=None, **plt_kwargs)[source]

Live Matplotlib plot for data

Connection Points:
transitions

A list of tuple for each transition such as [(energy (eV), lambda (nm), oscillatory strength), … ]

sigma

(default = 0.10)

step

(default = 0.01)

Parameters
  • data (dict) – data for calculation

  • fig_path (str) – path to which to save the figure

Returns

shows matplotlib plot

plot_data(data)[source]

Spectrum plot data for plotly

Connection Points:
transitions

A list of tuple for each transition such as [(energy (eV), lambda (nm), oscillatory strength), … ]

sigma

(default = 0.10)

step

(default = 0.01)

Parameters

data (dict) – data for calculation

Returns

plot data for plotly

d3tales_api.Calculators.utils module

d3tales_api.Calculators.utils.dict2obj(d: dict, master_obj: Optional[object] = None)[source]

Convert a dictionary to a base object if mater_obj is specified, else generic object Adapted from: https://www.geeksforgeeks.org/convert-nested-python-dictionary-to-object/

Parameters
  • d (dict) – dictionary to be converted

  • master_obj (object) – base object to which to convert the dictionary

Returns

object from dictionary

d3tales_api.Calculators.utils.get_electrode_potential(electrode)[source]

Get electrode potential by searching the D3TaLES electrode parameters database :param electrode: name of an electrode or the electrode potential :return:

d3tales_api.Calculators.utils.get_periodic_table()[source]

List elements in the periodic table :return: List of element abbreviations for elements in the periodic table

d3tales_api.Calculators.utils.json2obj(json_file, **kwargs)[source]

Apply dict2obj to contents of a JSON file :param json_file: path to JSON file :type json_file: str :return: object from dictionary

d3tales_api.Calculators.utils.rgetattr(obj, attr, *args)[source]
d3tales_api.Calculators.utils.rgetkeys(_dict, keys, *args)[source]
d3tales_api.Calculators.utils.unit_conversion(measurement, default_unit: str, density=None)[source]

Convert a measurement into a default unit using pint.

Parameters
  • measurement – Measurements can be pint object, int or float(in which case it will be assumed to already be in the default unit), string of magnitude and unit, or a measurement dictionary (EX: {“value”: 0.5, “unit”: “eV”}

  • default_unit (str) – default unit / unit to be converted to

  • density (str) – molecular density (in case needed for conversion)

Returns

float magnitude for the converted measurement

Module contents