Coder Social home page Coder Social logo

justingilmer / garnett Goto Github PK

View Code? Open in Web Editor NEW

This project forked from glotzerlab/garnett

0.0 1.0 0.0 29.52 MB

Collection of file parsers and writers for particle trajectory formats used by the Glotzer Group.

Home Page: https://garnett.readthedocs.io/

License: BSD 3-Clause "New" or "Revised" License

Python 99.74% Shell 0.26%

garnett's Introduction

garnett

CircleCI RTD Contributors License

About

This is a collection of samples, parsers and writers for formats used in the Glotzer Group at the University of Michigan, Ann Arbor.

Maintainers

Setup

To install this package with pip, execute:

pip install garnett --user

Documentation

The package's documentation is available at: https://garnett.readthedocs.io/

To build the documentation yourself using sphinx, execute within the repository:

cd doc
make html
open _build/html/index.html

Quickstart

Reading and writing

import garnett

# Autodetects file format for a uniform trajectory API
with garnett.read('gsdfile.gsd') as traj:
    for frame in traj:
        pos = frame.position

# Simple conversion of trajectory formats
with garnett.read('posfile.pos') as traj:
    garnett.write(traj, 'gsdfile.gsd')

Data access

Access individual frames by indexing or create sub trajectories with slicing:

first_frame = traj[0]
last_frame = traj[-1]
n_th_frame = traj[n]
# and so on

sub_trajectory = traj[i:j]

Access properties of trajectories:

traj.load_arrays()
traj.position        # MxNx3
traj.orientation     # MxNx4
traj.velocity        # MxNx3
traj.mass            # MxN
traj.charge          # MxN
traj.diameter        # MxN
traj.moment_inertia  # MxNx3
traj.angmom          # MxNx4
traj.types           # MxN

# where M=len(traj) and N=max((len(f) for f in traj))

Access properties of individual frames:

frame = traj[i]
frame.box              # 3x3 matrix (not required to be upper-triangular)
frame.types            # N
frame.position         # Nx3
frame.orientation      # Nx4
frame.velocity         # Nx3
frame.mass             # N
frame.charge           # N
frame.diameter         # N
frame.moment_inertia   # Nx3
frame.angmom           # Nx4
frame.data             # A dictionary of lists for each attribute
frame.data_key         # A list of strings
frame.shapedef         # A ordered dictionary of instances of ShapeDefinition

All matrices are numpy arrays.

Example use with HOOMD-blue

See the examples directory for additional examples.

#!python
pos_reader = PosFileReader()
with open('cube.pos') as posfile:
    traj = pos_reader.read(posfile)

# Initialize from last frame
snapshot = traj[-1].to_hoomd_snapshot()
system = init.read_snapshot(snapshot)

# Restore last frame
snapshot = system.take_snapshot()
traj[-1].to_hoomd_snapshot(snapshot)

Testing

To run all garnett tests, ddt, HOOMD-blue (hoomd), and pycifrw must be installed in the testing environments.

Execute the tests with

python -m unittest discover tests

garnett's People

Contributors

csadorf avatar lyrivera avatar bdice avatar klywang avatar vyasr avatar klarh avatar syjlee avatar erteich avatar gaofy95 avatar j-proc avatar tcmoore3 avatar djulia avatar jdaaph avatar zinebbe avatar jamesaan avatar harperic avatar

Watchers

James Cloos 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.