Skip to content
Molecular Dynamics Library
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
mdsea
tests
LICENSE
README.md
requirements.txt
setup.py

README.md

mdsea

mdsea is a stand-alone Python molecular dynamics library equipped with a flexible simulation engine and multiple analysis tools, including integrated beautiful visualization in 1, 2, and 3 dimensions.

Getting started

Prerequisites

mdsea requires Python >= 3.6. The minimal requirements for this project will be automatically installed with setup.py.

Installing

To install mdsea you need to get the source and execute the setup.py script

git clone https://github.com/TPVasconcelos/mdsea.git
cd mdsea
python setup.py install

Extra requirements

In order to install the complete set of requirements and be able to make the most use of mdsea, run

pip install -r requirements.txt

To render 3D animation with Blender, you will need to download and install it on your machine first. If you want mdsea to render mp4 animation files for you, you will also need to install ffmpeg.

Running the tests

You can find the test scripts inside the /tests directory.

You should start by running

cd tests
python initsetup.py

which will run a default simulation and store in in ./simfiles/_mdsea_testsimulation/*. You can then run tests for the multiple visualization tools (/tests/vis_*.py) - See bellow how to run the Blender tests! - The /tests/cleanup.py script will remove the /simfiles/_mdsea_testsimulation directory.

Running Blender tests

Blender uses its own python interpreter, so you will need to install mdsea there as well. Find out where the python binary is stored and execute the following command. e.g. on macOS:

cd mdsea
/path/to/blender.app/Contents/Resources/2.XX/python/bin/python setup.py  install --force

To run the tests, execute

cd tests
/path/to/blender.app/Contents/MacOS/blender --python vis_blender.py

I'd also suggest that you add

alias blender=/path/to/blender.app/Contents/MacOS/blender

to .bash_profile and .profile.

echo "alias blender=/path/to/blender.app/Contents/MacOS/blender" >> ~/.profile
echo "alias blender=/path/to/blender.app/Contents/MacOS/blender" >> ~/.bash_profile

In Blender’s documentation they only state the alias in ~/.profile but this is only read by login shells. On the other hand, ~/.bash_profile is read by interactive shells (like the one linked to Terminal).

Example

import mdsea as md

# Instantiate system manager  ---
sm = md.SysManager.new(ndim=2, num_particles=6 ** 2, steps=500,
                       vol_fraction=0.2, radius_particle=0.5,
                       pot=md.Potential.lennardjones(1, 1))

# Instantiate simulation  ---
sim = md.ContinuousPotentialSolver(sm)

# Run the simulation  ---
sim.run_simulation()

# Run 2D animation with matplotlib  ---
from mdsea.vis.mpl import Animation

anim = Animation(sm, frame_step=6)
anim.anim(colorspeed=True)

The output should look something like this (you can ignore the warning):

[INFO:mdsea.core] New simulation: {'id': '1543180726724682', 'path': 'simfiles/1543180726724682'}
[WARNING:mdsea.core] A ValueError ('Not a location (invalid object ID)') was catched while trying to update a dataset. However, we noticed that the datafile in question wasn't open. We'll try to fix this and retry...
[INFO:mdsea.simulator] ProgresBar (Simulator): {'step': '28/500', 'percentage': 6, 'ETA': '1s'}
[INFO:mdsea.simulator] ProgresBar (Simulator): {'step': '73/500', 'percentage': 15, 'ETA': '1s'}
[INFO:mdsea.simulator] ProgresBar (Simulator): {'step': '128/500', 'percentage': 26, 'ETA': '1s'}
...
[INFO:mdsea.simulator] ProgresBar (Simulator): {'step': '428/500', 'percentage': 86, 'ETA': '0s'}
[INFO:mdsea.simulator] ProgresBar (Simulator): {'step': '473/500', 'percentage': 95, 'ETA': '0s'}
[INFO:mdsea.simulator] ProgresBar (Simulator): {'status': 'finished', 'lifetime': '1.1s'}
[INFO:mdsea.vis.mpl] Plotting anim_loop...

Gallery

3D renderings

1d

1d

1d

1d

1d

1d

GIFs

1D Simulation:

1d

2D Simulation:

2d

3D Simulation with Blender's Cycles rendering engine:

3d-cycles


Licence

MIT License

You can’t perform that action at this time.