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=None, finder=None, imgdb=None, 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.
imgdb (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.models.mullerbrown import MullerBrown >>> paths.model = MullerBrown()
>>> from taps.visualize import view >>> view(paths, calculate_map=True, viewer='MullerBrown') [Map should be shown]
Methods
add_image_data([index, coords, force, ...])Adding a calculation data to image database
copy()Return a copy.
get_accelerations(**kwargs)Calculate acceleration If
Cartesianis cartesian, velocity is calculated viaget_covariance(**kwargs)Calculate covariance.
get_distances(**kwargs)Calculate the distances of the pathway (accumulative) It usually used for plotting, i.e. potential energy / distance Calls the
get_distances()at thepaths.model.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 index of highest potential energy simplified
get_image_data(**kwargs)" list of int; Get rowid of data
get_kinetic_energies(**kwargs)Calculate kinetic energy of the pathway
get_kinetic_energy_gradients(**kwargs)Calculate kinetic energy gradient.
Get index of lowest of covariance simplified
get_momentums(**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()inpaths.modelget_total_energy(**kwargs)Calculate kinetic + potential energy
get_velocities(**kwargs)Calculate velocity If
Cartesianis cartesian, velocity is calculated via \(\mathbf{x}_{i+1} - \mathbf{x}_{i}\)save(*args, **kwargs)Different method of writing is required for different models.
search(**kwargs)Calculate optimized pathway
to_pickle([filename, simple])Saving pickle simplified
fluctuate
get_displacements
get_kinetics
get_masses
get_speeds
- add_image_data(index=None, coords=None, force=False, cache_model=True, **kwargs)
Adding a calculation data to image database
if index given -> create coords -> add_image_data if coords given -> add_image_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.
- get_accelerations(**kwargs)
Calculate acceleration If
Cartesianis cartesian, velocity is calculated via
- get_covariance(**kwargs)
Calculate covariance. It only applies when potential is guassian
- get_distances(**kwargs)
Calculate the distances of the pathway (accumulative) It usually used for plotting, i.e. potential energy / distance Calls the
get_distances()at thepaths.model. Model calls theget_distances()in thepaths.coords.
- 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_image_data(**kwargs)
” list of int; Get rowid of data
- get_kinetic_energies(**kwargs)
Calculate kinetic energy of the pathway
- get_kinetic_energy_gradients(**kwargs)
Calculate kinetic energy gradient. differentiate Kinetic energy w.r.t. each point, That is we calculate :math: partial_{mathbf{x}}E_{mathrm{kin}}
- get_lowest_confident_idx()
Get index of lowest of covariance simplified
- get_momentums(**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()inpaths.model
- get_total_energy(**kwargs)
Calculate kinetic + potential energy
- get_velocities(**kwargs)
Calculate velocity If
Cartesianis cartesian, velocity is calculated via \(\mathbf{x}_{i+1} - \mathbf{x}_{i}\)
- save(*args, **kwargs)
Different method of writing is required for different models.
- search(**kwargs)
Calculate optimized pathway
- to_pickle(filename=None, simple=True)
Saving pickle simplified