Paths

The Paths object is container class that handles io() or bridging to other module.

Overall Structure

Paths class contains modularized classes Cartesian, Projector, Model, Pathfinder and etc. Paths interfaces between modularized classes by sending self, the pointer of self (paths), when paths call the function of modules. Each subcontained class recieves Paths as an instance and uses that to access the other modules.

For example, Model needs Cartesian information when it calculate potential. When user call get_potential_energy() in a paths,

>>> paths.get_potential_energy()

Paths simply calls the get_potential_energy() in the Model. When calling it, Paths sends additional pointer self to it:

# paths.py
...
def get_potential_energy(self, ...):
    return self.model.get_potential_energy(self, ...)
...

Model recieves Paths as a paths instance and use it to access coords:

# model.py
def get_properties(self, paths, ...):
    ...
    coords = paths.coords
    ...

That is, simply put, Paths act as a interface between modules. This way, modules can access each module without additional creation of instance. However, user may wants to call paths only when it necessary since it is prone to trap in infinite loop.

Load & Save

There can be a lots of approach to save the python class. Since Paths contains multiple class in the class, we took simple approach. pickle saves the class instance magically by recursively serialize every attribute of the contained instance. This makes saving simply

>>> import pickle
>>> with open('filename', 'w') as f:
>>>     pickle.dump(paths, f)

and make load simply

>>> with open('file', 'r') as f:
>>>     paths = pickle.load(f)

However, It has some security issue when it read the serialized file. It would be better to separate every instance that needs to be saved and only serialize that with more secure method, like using json. Currently, we implemented dictionary contains info needs to be saved and check it is valid info or not, but detailed implementation is not yet implemented.

List of all Methods

class taps.paths.Paths(coords=None, label=None, model='Model', finder='PathFinder', imgdata='ImageData', plotter='Plotter', tag=None, **kwargs)

Paths class infterfacing other modules

Centeral class for pathway calculation. Object contains coordinates class and potential class and database

Parameters
  • coords (Cartesian class) – Coordinate representation that connect initial state to final state. Calculation involving intermediate states, such as, kinetic energy or momentum, can be found in the Cartesian class.

  • label (string) – Set of character that distinguish from other Paths classes. This can be use in other module as default filename.

  • model (Model class) – Model that calculates potential energy of intermediate coordinates.

  • finder (PathFinder class) – Class that optimize the coordinates suitable for the finder class.

  • imgdata (Database class) – Class made to easily accessible to the calculated database.

  • tag (dict) – Auxilary parameters for external use.

Example

>>> import numpy as np
>>> from taps.paths import Paths
>>> x = np.linspace(-0.55822365, 0.6234994, 300)
>>> y = np.linspace(1.44172582, 0.02803776, 300)
>>> paths = Paths(coords = np.array([x, y]))
>>> from taps.model.mullerbrown import MullerBrown
>>> paths.model = MullerBrown()
>>> from taps.visualize import view
>>> view(paths, calculate_map=True, viewer='MullerBrown')
[Map should be shown]
Attributes
A

Return a number of atoms.

D

Return dimension of the system.

N

Return number of steps.

Nk
label

string used for default name of calculation

Methods

add_data([index, coords, cache_model, ...])

Adding a calculation data to image database

copy()

Return a copy.

fluctuate([initialize, cutoff_f, ...])

Give random fluctuation

get_acceleration(**kwargs)

Calculate acceleration If Cartesian is cartesian, velocity is calculated via

get_accelerations(**kwargs)

Calculate acceleration(s) If Cartesian is cartesian, velocity is calculated via

get_covariance(**kwargs)

Calculate covariance.

get_data(**kwargs)

" list of int; Get rowid of data

get_displacements(**kwargs)

Calculate the distances of the pathway (accumulative)

get_effective_mass(**kwargs)

Calculate effective mass

get_forces(**kwargs)

Calculate - potential gradient

get_gradient(**kwargs)

Calculate potential gradient

get_gradients(**kwargs)

Calculate potential gradient(s)

get_hessian(**kwargs)

Calculate Hessian of a potential

get_higest_energy_idx()

Get index of highest potential energy simplified

get_kinetic_energy(**kwargs)

Calculate kinetic energy of the pathway

get_kinetic_energy_gradient(**kwargs)

Calculate kinetic energy gradient.

get_lowest_confident_idx()

Get index of lowest of covariance simplified

get_mass(**kwargs)

Calculate mass

get_momentum(**kwargs)

Calculate momentum of the pathway

get_potential(**kwargs)

Calculate potential

get_potential_energies(**kwargs)

Equivalanet to Calculate potentials

get_potential_energy(**kwargs)

Calculate potential( energy)

get_potentials(**kwargs)

Calculate potentials, individual energy of each atoms

get_properties(**kwargs)

Directly calls the get_properties() in paths.model

get_total_energy(**kwargs)

Calculate kinetic + potential energy

get_velocity(**kwargs)

Calculate velocity If Cartesian is cartesian, velocity is calculated via \(\mathbf{x}_{i+1} - \mathbf{x}_{i}\)

reset_cache()

Delete current cache on all modules

reset_results()

Delete current results on all modules

save(*args, **kwargs)

Different method of writing is required for different models.

search(**kwargs)

Calculate optimized pathway

simple_coords()

Simple line connecting between init and fin

to_pickle([filename, simple])

Saving pickle simplified

property A

Return a number of atoms. It only applies coords is rank 3

property D

Return dimension of the system. Usually, coords.shape[0]

property N

Return number of steps. Usually, coords.shape[-1]

add_data(index=None, coords=None, cache_model=True, regression=True, **kwargs)

Adding a calculation data to image database

if index given -> create coords -> add_data if coords given -> add_data coords : atomic configuration datum : atomic configuration with energy and forces

shape, A number of tuples
[(‘H’, desc, displacement, potential, forces, directory),

(‘C’, desc, …), (‘N’, desc, …), …]

found : list of Boolean or None, search results id : list of int or None, where it is

copy()

Return a copy.

fluctuate(initialize=False, cutoff_f=10, fluctuation=0.03, fourier={'type': 1})

Give random fluctuation

get_acceleration(**kwargs)

Calculate acceleration If Cartesian is cartesian, velocity is calculated via

get_accelerations(**kwargs)

Calculate acceleration(s) If Cartesian is cartesian, velocity is calculated via

get_covariance(**kwargs)

Calculate covariance. It only applies when potential is guassian

get_data(**kwargs)

” list of int; Get rowid of data

get_displacements(**kwargs)

Calculate the distances of the pathway (accumulative)

It usually used for plotting, i.e. potential energy / distance Calls the get_displacements() at the paths.model. Model calls the get_displacements() in the paths.coords.

get_effective_mass(**kwargs)

Calculate effective mass

get_forces(**kwargs)

Calculate - potential gradient

get_gradient(**kwargs)

Calculate potential gradient

get_gradients(**kwargs)

Calculate potential gradient(s)

get_hessian(**kwargs)

Calculate Hessian of a potential

get_higest_energy_idx()

Get index of highest potential energy simplified

get_kinetic_energy(**kwargs)

Calculate kinetic energy of the pathway

get_kinetic_energy_gradient(**kwargs)

Calculate kinetic energy gradient. differentiate Kinetic energy w.r.t. each point, That is we calculate \(\partial_{\mathbf{x}}E_{\mathrm{kin}}\)

get_lowest_confident_idx()

Get index of lowest of covariance simplified

get_mass(**kwargs)

Calculate mass

get_momentum(**kwargs)

Calculate momentum of the pathway

get_potential(**kwargs)

Calculate potential

get_potential_energies(**kwargs)

Equivalanet to Calculate potentials

get_potential_energy(**kwargs)

Calculate potential( energy)

get_potentials(**kwargs)

Calculate potentials, individual energy of each atoms

get_properties(**kwargs)

Directly calls the get_properties() in paths.model

get_total_energy(**kwargs)

Calculate kinetic + potential energy

get_velocity(**kwargs)

Calculate velocity If Cartesian is cartesian, velocity is calculated via \(\mathbf{x}_{i+1} - \mathbf{x}_{i}\)

property label

string used for default name of calculation

reset_cache()

Delete current cache on all modules

reset_results()

Delete current results on all modules

save(*args, **kwargs)

Different method of writing is required for different models.

search(**kwargs)

Calculate optimized pathway

simple_coords()

Simple line connecting between init and fin

to_pickle(filename=None, simple=True)

Saving pickle simplified