Coder Social home page Coder Social logo

pymatnext's Introduction

Overview

pymatnext is a Python package for doing nested sampling (NS) which was developed as a complete rewrite of pymatnest. While it is coded with some generalizability in mind, it is designed for atomistic materials science applications, and currently supports single atomic configurations with the ASE atoms object.

Features

Nested Sampling

  • Sample on potential energy $E$, with or without enthalpy term $+ P V$ for fixed pressure and chemical potential term $- \sum_i \mu_i N_i$ for variable composition (but constant total number of atoms, i.e. semi-grand-canonical ensemble).

  • Output arbitrary sampled quantities, including NS quantity ($E + \delta_V P V - \delta_N \sum_i \mu_i N_i$), as well as configuration-type-specific quantities such as cell volume and composition.

  • Output sampled configurations, for postprocessed computation at any temperature of any quantity that can be computed from the configurations.

  • Save snapshots of population and random number generator states for restarts

  • One sample culled per NS iteration

Parallelization

  • Optionally parallelized with MPI by distributing configurations among $N_p$ MPI tasks and walking one configuration per task for a shorter trajectory length $L' = L / N_p$.

Configurations

  • Periodic or nonperiodic cells containing atoms of any chemical species. Use an extended version of the ase.atoms.Atoms class, which stores all important data in two np.ndarray objects, so that MPI parallelized runs can communicate them without having to pack/unpack the data each time.

Energy calculators

  • ASE ase.calculators.Calculator, with random walks carried out by Python code within pymatnext.

  • LAMMPS potentials with random walks carried out inside LAMMPS with a custom set of fixes.

Random walks

Walks consist of blocks of a several steps of a single type (position or cell or species).

Positions

  • Positions sampled with Galilean Monte Carlo, i.e. walking in a straight line in $3 N$ dimensional positions space until energy exceeds NS maximum, then reflecting specularly, and accepting or rejecting entire trajectory depending on on final energy.

Cell

  • Cell shape and size sampled with Monte Carlo moves. Volume may be sampled from a $V^{N}$ prior, which is the correct one for ensemble averages, or with a flat prior, which requires reweighting of the sampled configurations during analysis.

Species

  • Atom species sampled with Monte Carlso swap or semi-grand-canonical (total atom number conserving at an applied chemical potential) moves.

Usage

see here

complete parameters list

Analysis

see here

Using LAMMPS

LAMMPS compiled with cmake

To use lammps, set the env var LAMMPS_DIR to the top of the LAMMPS source directory, above src/ and cmake/, and do

cd $LAMMPS_DIR
patch_file=$( python3 -c 'import pymatnext; from pathlib import Path; print(str(Path(pymatnext.__file__).parent) + "/extras/lammps.patch")' )
patch -p1 < $patch_file

The NS package must then be added to enable the fix ns/* commands, and LAMMPS must be recompiled without MPI support. The LAMMPS python interface must then be installed.

If using cmake, this can be done by adding NS to the section set(STANDARD_PACKAGES... (the patch file in pymatnext/extras/lammps.patch should do this), and adding -D PKG_NS=ON to the cmake command (in addition to

-D BUILD_MPI=OFF
-D BUILD_SHARED_LIBS=ON
-D LAMMPS_EXCEPTIONS=ON

and whatever other options are needed). Installing the python package is most easily done with make install-python after the regular make.

TODO

(in order of priority?)

  • refactor <prefix>.NS_samples and <prefix>.traj.<suffix> truncation code (minor)
  • create ABC for NSConfig (med)
  • sample positions with TE-HMC (major)

Done

  • restart from snapshots
  • refactor NSConfig.n_quantities to be a class rather than instance attribute (minor)

pymatnext's People

Contributors

bernstei avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

mperezjigato

pymatnext's Issues

Emax is not always monotonic decreasing

There exist input files and run configurations (LAMMPS, 256 atoms, 8192 walkers, 128 MPI tasks) where the max energy goes up from one iteration to the next. This was only detected when the Z_of_T loop exit condition ended the run very early, because when the energy when up the contribution of the current iteration to the Z sum dropped by order of magnitude (due to the Boltzmann factor on the current higher energy).

TE-HMC

Add support for TE-HMC?

cell aspect ratio

The aspect ratio change of the simulation cell should be limited - what's being done currently? This should probably be a keyword as well, maybe with a sensible default as 0.8?

Pressure keyword

We should have a keyword to set the pressure for the simulation (I think the default is 0.0?)

generate initial random configs in parallel

With large numbers of walkers and atoms, generating the initial configs takes a significant amount of time. It would be helpful if, when possible, these were generated in parallel rather than all generated on the root MPI task and sent to each other MPI task.

The new config generator would need to receive the local rng, and return a logical flag indicating whether the loop should be on the root task over all configs, or a little loop on the generator on each task in parallel.

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.