Giter Site home page Giter Site logo

n720720 / lindemann Goto Github PK

View Code? Open in Web Editor NEW
15.0 0.0 6.0 20.86 MB

lindemann is a python package to calculate the Lindemann index of a lammps trajectory

License: GNU General Public License v3.0

Makefile 11.74% Dockerfile 2.57% Python 85.69%
simulation molecular-dynamics lammps lindemann lindemann-index md-simulation analysis transition-phase lammps-trajectory ovito

lindemann's Introduction

lindemann

Build status Python Version Dependencies Status

Code style: black Security: bandit
Pre-commit Semantic Versions License

lindemann is a Python package to calculate the Lindemann index of a LAMMPS trajectory, as well as the progression of the Lindemann index per frame or per atom and frame of temperature ramps for phase transition analysis.

Installation

It requires python 3.7

pip install lindemann

or install with Poetry

poetry add lindemann

Usage

lindemann [OPTIONS] TRJFILE

or if installed with Poetry:

poetry run [OPTIONS] TRJFILE

Precautions:

Make sure you have enough memory available before you run any flags despite the -t flag. You can check the memory use by using the -m or the --mem_use Option. The high memory use will be fixed as soon as the numpy.nanmean() function with axis is available for numba.

Multiprocessing:

If you don't have a hpc environment available to distribute the workload, I added multiprocessing to parallize the tasks if you are using your local machine. Just add more than one filename with the -t flag. Currently multiprocessing is only implemented for the -t flag, due to the memory issues mentioned above.

Arguments:

  • TRJFILE...: The trajectory file(s). If no other option is selected, the lindemann index is calculated for the trajectory. Equivalent to the -t option. If you pass more than one trajectory they will be calculated in parallel. Only works with no flag or -t flag. [required]

Options:

  • -t: Calculates the Lindemann-Index for the Trajectory file(s) [default: False]
  • -f: Calculates the Lindemann-Index for each frame. [default: False]
  • -a: Calculates the Lindemann-Index for each atom for each frame. [default: False]
  • -p: Returns a plot Lindemann-Index vs. Frame. [default: False]
  • -l: Saves the individual Lindemann-Index of each Atom in a lammpstrj, so it can be viewed in Ovito. [default: False]
  • -v, --version: Prints the version of the lindemann package.
  • -ti, -timeit: Uses timeit module to show running time [default: False]
  • -m, -mem_use: Calculates the memory use. Run it before you use any of the cli functionality despite the -t flag [default: False]
  • --help: Show this message and exit.

Demo

Basic usage to calculate the Lindemann Index:

The package has a plotting feature. It will show the a plot Lindemann index vs. the frames. If the trajectory file is a temperature ramp, it is possible to determine the phase transition.

Usage of the of the lammpstrj file output feature to save the progression for each atom per frame into a LAMMPS trajectory file. Afterwards the trajectory can be viewed with ovito for example, here the Lindemann progression was used for the OVITO color coding feature.

Motivation

In my research I have investigated simulated annealing of brass nanoparticles. I had to determine the melting point of many different cluster sizes and zinc compositions and I have chosen the Lindemann index for this purpose. I wanted a cli tool that could be easily used with MPI due to the amount of calculations. I also wanted to get to know numba better and so I combined them in this project. numba does not really like pythonic code and can handle verbose code better.

ybyygu had already worked out a nice solution in cython with the Welford algorithm, which was found to be easy to convert into numba. whashi44 in turn had presented a great Numpy version with a GUI, his version convinced me to use ovito for read write tasks of LAMMPS trajectories.

For the determination of the melting point of nanoparticles you can often find plots in the literature which follow the following scheme. A temperature range is defined where the phase transition is likely to take place. Then step lengths for the temperature are defined and then a trajectory is calculated for the respective temperature. If a phase transition occurs, this can be recognized by a jump of the lindemann index as shown in figure 1

Figure 1.

I realized that the development of the Lindemann index can be observed across the trajectory. The Welford algorithm allows a live calculation of the mean std, which means that the development of the Lindemann index can be observed as the simulations run. Since I worked with heat ramps for simulated annaeling, I was interested in the development of the Lindemann index across the frames of these trajectories.

This could be realized by a modification of the Welford algorithm. With this method you can observe the change of the Lindemann index per frame. Here, too, a characteristic change of the Lindemann index occurs, with which the phase transition can also be determined. The development of the Lindemann index over the frames can then be visualized as a plot for the phase transition determination. If the temperature is plotted against the Lindemann index, the temperature can also be read directly for the phase transition, as seen in figure 2.

Figure 2: Note the noise of the temperature was smoothed with help of numpy.convolve with a box size of 40.

With a further modification of the Welford algorithm you can also see the contribution of each atom to the lindemann index for each frame. This was especially interesting for me because atomic properties can be easily visualized with tools like OVITO. This gives one a detailed view of the phase transition. This is especially interesting for the investigation of nanoparticles during the phase transition, as they often start melting from the surface. This is where the method in combination with OVITO offers a good starting point for further investigations.

Furthermore, computational costs can be reduced by using one heat ramp instead of many trajectories with discrete temperatures. As an example, see figures 1 and 2. In figure 1, 16 trajectories with different temperatures were chosen to determine the phase transition. The step width was reduced near the phase transition for a better determination of the phase transition. Each trajectory has 50k steps, that is 800k in total, whereas in figure 2 the heatramp has only 200k steps.

Background

A key problem with the measurement of the melting point of nanoparticles is that with decreasing size of a given nanoparticle the phase transition, defined as the temperature of a sudden change in the enthalpy, becomes less pronounced. This is caused by the surface effect: for a given cluster the surface area is larger compared to a bulk structure of the same size. Melting does not take place all at once, but is a longer melt transition and no longer really a melting point.

The Lindemann index, stated in the following equation presents a solution for this problem. It describes the root-mean-square (rms) fluctuation of the bonds or interatomic distance in the system over time (or temperature, if the temperature of the system changes as the simulation progresses). The Lindemann index is a more robust method to determine the melting point of nanoparticles, as opposed to enthalpy. Accordingly the Lindemann index is often considered, when the melting point of nano-particles is of interest. The index is defined as,

where is the number of atoms in the nano particle. is the distance between atom i and atom j. The brackets representing a time or temperature average. The rms of the bond fluctuation is considerable lower for a solid than for a liquid, due to restrained degrees of freedom. In a solid, the atoms hold on to their position and only fluctuate around their equilibrium positions. During the melting process the atoms become more mobile and are able to leave their original position. The translation movement of atoms is magnitudes larger than that of the bond fluctuations of a solid. As a result, the Lindemann index rises dramatically at the melting point and therefore gives a suitable observable to determine the transition phase. In effect, the Lindemann index measures a sort of average difussion coefficient for the atoms in the system.

A key problem with much of the literature regarding the Lindemann index, is that there is a uncertainty of where to define the phase transition within a Lindemann plot. On the grounds that the melting point is a macroscopic definition for bulk structures. But here nanoparticles differ: because of their relative small size, compared to bulk structures, melting can occur fist on their relative large surface, compared to the volume they obtain and followed by the melting of core of the particle. Therefore a temperature range, rather then a melting point, is observed, as stated by Neyts in their work.

πŸ›‘ License

License

This project is licensed under the terms of the GPLv3 license. See LICENSE for more details.

πŸ“ƒ Citation

@misc{lindemann,
  author = {Sebastian Thurm},
  title = {lindemann is a python package to calculate the Lindemann index  of a lammps trajectory as well as the progression of the Lindemann index per frame of temperature ramps  for phase transition analysis.},
  year = {2020},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/N720720/lindemann}}
}

Credits

The Lindemann index is introduced in the following paper,
F. A. Lindemann, Zeitschrift fΓΌr Phys. 1910, 11, 609–612.
This package is based on the work from ybyygu and whashi44 on calculating the Lindemann index.
The visualisations in this Readme are made with Ovito.
A. Stukowski, Model. Simul. Mater. Sci. Eng. 2010, 18, 15012. link.
This project was generated with python-package-template.
The Welford Algorith can be found in:
Donald E. Knuth ,The art of computer programming, volume 2 (3rd ed.): seminumerical algorithms, Addison-Wesley Longman Publishing Co, 1997, 232.

lindemann's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar jon-ting avatar n720720 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lindemann's Issues

Dependabot can't resolve your Python dependency files

Dependabot can't resolve your Python dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Creating virtualenv lindemann-be9HT7TC-py3.7 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...

  PackageNotFound

  Package shiboken2 (5.15.0) not found.

  at /usr/local/.pyenv/versions/3.7.9/lib/python3.7/site-packages/poetry/repositories/pool.py:144 in package
      140β”‚                     self._packages.append(package)
      141β”‚ 
      142β”‚                     return package
      143β”‚ 
    β†’ 144β”‚         raise PackageNotFound("Package {} ({}) not found.".format(name, version))
      145β”‚ 
      146β”‚     def find_packages(
      147β”‚         self, dependency,
      148β”‚     ):

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Looking forward to your reply(some questions)!

Checklist

I ran your code, but there are still some questions, I hope you can help answer them, thank you.

❓ Question

  1. Is the data in Figure 2 a rapid heating process?

  2. Can you share the data in Figure 2?

  3. For the last lindemann value output in the program, why is it divided by nframes and not divided by n-1

πŸ“Ž Additional context

BPW2NMS${KS6{A3Y() 0%XU

Update addressing memory problem

Hi

Is this library still maintained?
It is stated in the Precautions-section that an update will be made when numpy.nanmean has axis functionality. I believe that this is the case now.

I am very interested in using your library for my research and was very excited when I found it. However, I am currently getting segmentation faults running the -f flag on a desktop, presumably because I run out of memory. Systems contains 1000's of atoms, so it could be a problem. Do you have an estimate on the runtime benchmark vs systemsize of the code?

Thank you in advance
Kasper

Run lindemann -p

πŸ› Bug Report

Hello, when I run the 'lindemann -p 459_02.lammpstrj' using the example in test/test_example, it shows 'multiprocessing is implemented only for the -t flag' and doesn't have PDF file.

Environment

  • OS: Linux
  • Python version, get it with: python 3.8, lindemann-0.4.0

Screenshots

图片

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.