Code Monkey home page Code Monkey logo

diffusionanalysis's Introduction

DiffusionAnalysis

DiffusionAnalysis is a Python package for analyzing diffusion properties from molecular dynamics (MD) trajectories. It offers a suite of tools to calculate and visualize various quantities that characterize diffusive behavior, including mean squared displacements (MSD), van Hove correlation functions, and time-dependent mean squared displacements (tMSD).

:)

###TODO VAC's .. COM VAC's ... watch this space!

Features

  • Efficient calculation of mean squared displacements (MSD) for selected atoms or groups of atoms
  • Drift correction options for MSD calculations to account for system-wide translations
  • Calculation of MSD along specific lattice vectors to study anisotropic diffusion
  • Flexible plotting functions for visualizing MSD data with customizable options
  • Computation of van Hove correlation functions to analyze dynamical heterogeneity
  • Calculation of time-dependent mean squared displacements (tMSD) to study diffusion behavior over time
  • Probability distribution analysis of displacements along lattice vectors and in 3D space

Package Structure

DiffusionAnalysis/
│
├── analysis/
│   ├── msd_analysis.py
│   ├── tMSD_analysis.py
│   └── van_hove_analysis.py
│
├── examples/
│   ├── dat_directory/
│   └── example.ipynb
│
├── loaders/
│   ├── ase_atoms_loader.py
│   ├── base_structure_loader.py
│   ├── dat_directory_structure_loader.py
│   └── xyz_directory_structure_loader.py
│
├── trajectory/
│   ├── displacement_trajectory.py
│   ├── smoothing.py
│   └── time_unit.py
│
├── utils/
│   └── __init__.py
│
├── diffusionanalysis.egg-info/
├── .gitignore
├── LICENCE
├── README.md
├── requirements.txt
└── setup.py

Loaders The loaders module provides classes for loading and storing an iterable of structures that lazy load. The key classes include:

  • StructureLoader: An abstract base class that defines the interface for structure loaders.
  • DatDirectoryStructureLoader: A loader class for loading structures from a directory of .dat files.
  • XYZDirectoryStructureLoader: A loader class for loading structures from a directory of .xyz files.
  • ASEAtomsLoader: A loader class for loading structures using the ASE (Atomic Simulation Environment) library.

These loaders allow you to easily load MD trajectories from various file formats and integrate them seamlessly with the DiffusionAnalysis package.

Analysis

The analysis module contains classes for performing different types of diffusion analysis on the loaded trajectories. The main classes include:

  • MSDAnalysis: Performs mean squared displacement (MSD) analysis, including drift correction and calculation of MSD along specific lattice vectors. msd plot msd_dist plot

  • VanHoveAnalysis: Calculates van Hove correlation functions to analyze dynamical heterogeneity. van_hove+plot

  • tMSDAnalysis: Calculates time-dependent mean squared displacements (tMSD) to study diffusion behavior over time. tmsd plot tmsd_dist plot

Usage

Here's an example demonstrating how to use DiffusionAnalysis to calculate and plot the MSD: python

from DiffusionAnalysis.loaders import DatDirectoryStructureLoader
from DiffusionAnalysis.trajectory import DisplacementTrajectory
from DiffusionAnalysis.analysis import MSDAnalysis

# Load the MD trajectory
loader = DatDirectoryStructureLoader("path/to/trajectory")
trajectory = DisplacementTrajectory(loader)
trajectory.generate_displacement_trajectory()

# Perform MSD analysis
msd_analysis = MSDAnalysis(trajectory)
msd_data = msd_analysis.calculate_msd()

# Plot the MSD
fig = msd_analysis.plot_msd(msd_data)
fig.savefig("msd_plot.png")

For more detailed examples and usage instructions, please refer to the examples directory.

Installation

You can easily install DiffusionAnalysis:

git clone https://github.com/chrisdavi3s/DiffusionAnalysis.git
cd DiffusionAnalysis
pip install -r requirements.txt

Install the package in development mode:

pip install -e .

Getting Started

Look at loaders/base_structure_loader.py to see how structures are loaded.

Trajectories are assumed wrapped and then unwrapped as default ... (I have NOT tested on a already unwrapped trajectory)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.