Git Product home page Git Product logo

pymlff's Introduction

pymlff

A lightweight Python 3.7+ package for reading and writing VASP ML_AB files.

Installation

Clone the repository and install using

pip install .

Pymlff depends on numpy and click.

Examples

Command line utility

Pymlff includes a basic command line utility for merging ML_AB.

mlff merge ML_AB1 ML_AB2 ML_AB_NEW

More than 2 ML_AB files can be combined at once, e.g.

mlff merge ML_AB1 ML_AB2 ML_AB3 ML_AB4 ML_AB_NEW

Pymlff also includes a command line utility for converting ML_AB files to extended xyz (extxyz) files. The last argument is the units to use for converting the VASP kbar units. Valid units are eV/A^3 and kbar.

# Convert ML_AB to extxyz
mlff write-extxyz ML_AB ML_AB.xyz

# Convert ML_AB to extxyz and convert the units of stress from kbar to eV/A^3 (applies a negative sign)
mlff write-extxyz ML_AB ML_AB.xyz --stress-unit=eV/A^3

Python API

More functionality is available through the Python API.

Reading and writing ML_AB files

from pymlff import MLAB

# load an ML_AB file
ab = MLAB.from_file("ML_AB")

# write an ML_AB file
ab.write_file("ML_AB_NEW")

Filtering configurations

Configurations can be filtered based on a filter function. The function should accept two arguments, the index of the configuration in the configurations list and a configuration itself. If the filter function returns True, the configuration will be kept, if False, the configuration will be removed. For example, to filter configurations with less than 256 atoms:

new_ab = ab.filter_configurations(lambda i, config: config.num_atoms >= 256)

See the Configuration object for the available attributes to use for filtering.

Combining ML_AB files

MLAB objects can be combined using the Python + operator. For example,

from pymlff import MLAB

# load two ML_AB files
ab1 = MLAB.from_file("ML_AB1")
ab2 = MLAB.from_file("ML_AB2")

new_ab = ab1 + ab2

Writing to extxyz

MLAB objects can be written to the extxyz format using the write_extxyz method.

from pymlff import MLAB

# load an ML_AB file
ab = MLAB.from_file("ML_AB")

# write an extxyz file
ab.write_extxyz("ML_AB.xyz", "eV/A^3")

pymlff's People

Contributors

utf avatar antobi avatar

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.