Coder Social home page Coder Social logo

senpai-molecular-dynamics / senpai Goto Github PK

View Code? Open in Web Editor NEW
125.0 12.0 16.0 1.08 MB

Molecular dynamics simulation software

Home Page: https://senpaimd.org

License: GNU General Public License v3.0

Makefile 0.88% C 99.12%
molecular-dynamics chemistry molecular-dynamics-simulation simulation science science-research research cheminformatics

senpai's Introduction

SENPAI

Molecular Dynamics (MD) simulations made easy

GitHub

Website: https://senpaimd.org

SENPAI is a \molecular dynamics (MD) simulation software aimed at students and academia.

It provides a way to simulate molecular systems of educative and academic interest on just about any device.

It just works, out of the box.

SENPAI being used with VMDSENPAI being used with VMD to simulate a urea-ChCl deep eutectic solvent

Keeping it simple

  • Integrated potential reduction: Easily mitigate the issue of "garbage in, garbage out"! If told to do so, SENPAI will reduce the potential energy of the system to a user-selected target value before simulating. SENPAI sequentially runs several algorithms like gradient descent to properly set the system up for simulation.

  • No potential differentiation: Traditional MD simulators compute a particle's total potential and numerically differentiate it to compute the applied force. SENPAI analytically solves for the force vector, resulting in an extreme speedup. Should you prefer numerical potential differentiation, SENPAI offers two different numerical differentiation methods which can be configured as well!

  • No complicated file formats: The MDS, MDM, and MDP file formats developped for SENPAI can be hand-written! No need for special software. Quickly and easily prepare simulations and adjust them with no hassle. Simulations are rendered as XYZ, and can be immediately viewed using existing software without prior conversion!

  • Efficient computing model: the ONICHaN (Optimized Numerical Integration, Classical Harmonics, and N-body) force field was tailored for SENPAI over months of work. Inspired by the AMBER family of force fields, it allows SENPAI to compute forces with unprecedented efficiency.

Documentation

Documentation is available on the Official SENPAI website.

Installation Manual

Your first simulation

Creating substrates (MDS files)

Creating models (MDM files)

senpai's People

Contributors

benoit-dubreuil avatar chelsea486mhz avatar coti avatar eli-schwartz avatar gwenya avatar munvoseli avatar raresraf avatar vainiovano avatar

Stargazers

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

Watchers

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

senpai's Issues

Invalid bond angle forces on PBC enforcement

As a particle is relocated as part of PBC enforcement, the applied bond angle restoration force becomes invalid, introducing energy to the system and breaking the thermodynamics.

Load simulation parameters from a separate file

It might be a good idea to add the possibility to run SENPAI with simulation parameters loaded from an external file.
This would for example ease running the same simulation on multiple files in sequence with same parameters without having to re-type them every time or the opposite: run more simulations one after the other while just changing the conditions.
Also it's quite the standard when working with cluster computers to have the simulation parameters and the substrate on which to run it in two distinct files.

Implement loadable models

To run a simulatujion, SENPAI is given a modified .mol file containing an atom block and a bond block.

The atom block has a line for each atom, which contains:

  • Its cartesian coordinates (in Angstroms)
  • Its type (as defined in headers/model.h
  • Its electrostatic charge (in multiples of the elementary charge)
  • Its Lennard-Jones parameters (in Angstroms and kJ.mol-1)

The bond block contains a line for each bond, containing:

  • The ID of the first atom
  • The ID of the second atom
  • The bond's force constant (in N.m-1)

Such files take time to write. Actually, it takes more time making the damn file than running the simulation. Working with SENPAI is working with a simulator, not with a half-assed file format. From the beginning, SENPAI was meant to be a program that takes in a molecule and thermodynamical parameters and outputs a rendered simulation in the .xyz format.

As such, this format issue must be fixed. The first solution I had, a month ago, was to implement the full periodic table in model.h and model.c, have SENPAI read a pure MOLV2000 file, and figure out the other values by itself. The issue with this "solution" is that it forces the user to use a limited set of atom types that may not fit their use cases.

The proposed solution here is to have SENPAI read both a semi-pure MOLV2000 file, where only the atom symbol is changed to the desired atom type; and a model file. This would imply loading two files instead of one, and means considerable work.

However, the beauty of this solution is that SENPAI would be able to use existing peer-reviewed models, effectively making it more usable than it currently is, and possibly opening the way to rival other simulators in the future.

Potential is fucky

The potential evalutation functions are wrong and the numerical differentiation mode cannot be used.

Inefficient potential reduction

Some STP water for you thirsty gamer boys

Let's consider the following simulation, 100 water molecules at STP:

senpai --in examples/water.mol --out render.xyz --copy 100

The --copy flag tells SENPAI to insert 100 copies of the substrate described in examples/water.mol into the universe. But what is the process behind this?

SENPAI's way of loading the simulation

universe_init is responsible for initialising the universe before the simulation. It itself calls universe_load, which loads atoms from the input file into a special array, universe->ref_atom. This array has universe->ref_atom_nb elements. It contains each atom from the input file, and their information.

universe_init will then call universe_populate, a function that places copies of universe->ref_atom at random locations within the universe.

The universe, as a set of matter, is nothing but an array, universe->atom, of size (args->copies)*(universe->ref_atom_nb). The universe->atom array therefore is a concatenation of several modified universe->ref_atom arrays. The modification I was referrencing is the introduction of an offset, identical between all copies of the universe->ref_atom array.

TL;DR: SENPAI places copies of the loaded substrate at random locations within space.


The issue here is "at random". SENPAI doesn't care if atoms are located at the same physical coordinates. As such, another step is required before starting the simulation: potential reduction.

SENPAI will apply algebraic transformations to the coordinates of each atom within space, so as to lower the potential energy. This process can be tuned through headers/config.h:

/* PRE-SIMULATION POTENTIAL ENERGY REDUCTION
 *
 * Before starting a simulation, SENPAI will use a two-stage algorithm to reduce
 * the potential energy of the system.
 *
 * STAGE 1: COARSE (brute force)
 * The first stage consists of iterating through the particles and relocating
 * them to random offsets, discarding the relocation should the total potential
 * increase. The magnitude of the relocation offset gets lowered after a set
 * number of attempts. The first stage ends when the potential reaches a
 * defined multiple of the target potential.
 *   UNIVERSE_REDUCEPOT_COARSE_STEP_MAGNITUDE: start magnitude of the relocation
 *   UNIVERSE_REDUCEPOT_COARSE_MAX_ATTEMPTS: Max attempts before lowering the
 *                                           magnitude.
 *   UNIVERSE_REDUCEPOT_COARSE_MAGNITUDE_MULTIPLIER: Reduce the magnitude by
 *                                                   multiplying it.
 *   UNIVERSE_REDUCEPOT_COARSE_THRESHOLD: Target (multiple of the pre-reduction
                                          potential)
 *
 * STAGE 2: FINE (fine)
 * The second stage consists of tuning the coordinates of each atom so as to
 * lower the total potential energy. Gradient descent is used here, since the
 * analytical gradient is easily computable from the force (F = -nabla*U).
 *   UNIVERSE_REDUCEPOT_FINE_MAX_STEP: Maximum step an atom can take
 *   UNIVERSE_REDUCEPOT_FINE_TIMESTEP: Used to compute the step (dx=(dt^2)/2)
 */
#define UNIVERSE_REDUCEPOT_COARSE_STEP_MAGNITUDE       (double)1E-9
#define UNIVERSE_REDUCEPOT_COARSE_MAX_ATTEMPTS         (size_t)1E2
#define UNIVERSE_REDUCEPOT_COARSE_MAGNITUDE_MULTIPLIER (double)1E-1
#define UNIVERSE_REDUCEPOT_COARSE_THRESHOLD            (double)2E0
#define UNIVERSE_REDUCEPOT_FINE_MAX_STEP               (double)1E-10
#define UNIVERSE_REDUCEPOT_FINE_TIMESTEP               (double)1E-15

It is mathematically impossible to find the absolute minima of the potential function. As such, SENPAI has to rely on a randomization stage AND a gradient descent stage to properly reduce the potential.

However, this method is extremely computationally intensive. So much that I considered moving it out of SENPAI into another project that would spit out a .mol file that SENPAI could load and not care about. But for now, it shall stay here.


The issue being described here is the following: this method is inefficient, and sometimes SENPAI will spend more time reducing the potential than actually simulating the universe. This has to change, any ideas?

Add Monte Carlo potential reduction

The program could benefit from a way to reduce the potential energy before the simulation.

As an example, it could execute a certain number of cycles, each performing random physical transformations until the total potential energy of the system decreases.

It would be computationally intensive, but simple, to go with this "random" or Monte-Carlo approach to minimise the potential energy.

Add variable number of bonds

Currently, an atom has a fixed number of covalent bonds (7). The file format and potential/force logic should be updated to use a variable number of covalent bonds.

Implement bond torsion

SENPAI does not yet understand the concept of bond torsion.

As an example, ethylene is supposed to be a planar molecule, but SENPAI will allow unrestricted rotation over the C=C double bond.
300px-Energetics_1

Invalid force and potential computation

So here's me realising for months I've been rendering simulations using invalid computations. Behold the extent of my misery:

  • The Lennard-Jones force (force_lennardjones)
  • The Lennard-Jones potential (potential_lennardjones)
  • The bond angle potential (potential_angle)
  • The electrostatic potential (potential_electrostatic)

All provide incorrect results, with consequences ranging from invalid potential reduction to dead on system explosion.

I'll now have a break, have a beer, and proceeed to f@#! kill myself

MOLV2000 format not entirely supported.

Satanic molecules such as

 OpenBabel10281909393D

 76 88  0  0  1  0  0  0  0  0999 V2000
    0.0000    0.0000   -0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  1  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  1  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  1  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  1  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  2  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 C   0  0  2  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 C   0  0  1  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000   -0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  2  0  0  0  0
  2  3  1  0  0  0  0
  2 33  1  0  0  0  0
  3  4  1  0  0  0  0
  3 49  1  0  0  0  0
  3 50  1  0  0  0  0
  4  5  2  0  0  0  0
  4 34  1  0  0  0  0
  5 51  1  0  0  0  0
  6  5  1  0  0  0  0
  6  7  1  0  0  0  0
  6 46  1  0  0  0  0
  6 52  1  1  0  0  0
  7  8  2  0  0  0  0
  7 53  1  0  0  0  0
  8  9  1  0  0  0  0
  8 44  1  0  0  0  0
  9 10  1  0  0  0  0
  9 54  1  0  0  0  0
  9 55  1  0  0  0  0
 10 11  2  0  0  0  0
 10 47  1  0  0  0  0
 11 12  1  0  0  0  0
 11 56  1  0  0  0  0
 12 14  1  0  0  0  0
 12 13  2  0  0  0  0
 14 15  1  0  0  0  0
 14 57  1  0  0  0  0
 14 58  1  0  0  0  0
 15 16  2  0  0  0  0
 15 47  1  0  0  0  0
 16 17  1  0  0  0  0
 16 59  1  0  0  0  0
 17 18  2  0  0  0  0
 17 42  1  0  0  0  0
 18 60  1  0  0  0  0
 19 18  1  0  0  0  0
 19 20  1  0  0  0  0
 19 40  1  0  0  0  0
 19 61  1  1  0  0  0
 20 62  1  0  0  0  0
 20 63  1  0  0  0  0
 21 20  1  0  0  0  0
 21 22  1  0  0  0  0
 21 48  1  0  0  0  0
 21 64  1  1  0  0  0
 22 23  2  0  0  0  0
 22 65  1  0  0  0  0
 23 25  1  0  0  0  0
 23 24  2  0  0  0  0
 25 26  1  0  0  0  0
 25 66  1  0  0  0  0
 25 67  1  0  0  0  0
 26 27  2  0  0  0  0
 26 48  1  0  0  0  0
 27 28  1  0  0  0  0
 27 68  1  0  0  0  0
 28 29  2  0  0  0  0
 28 38  1  0  0  0  0
 29 69  1  0  0  0  0
 30 29  1  0  0  0  0
 30 31  1  0  0  0  0
 30 36  1  0  0  0  0
 30 70  1  1  0  0  0
 31 32  1  0  0  0  0
 31 71  1  0  0  0  0
 31 72  1  0  0  0  0
 32 33  2  0  0  0  0
 32 34  1  0  0  0  0
 33 73  1  0  0  0  0
 34 35  1  0  0  0  0
 35 36  2  0  0  0  0
 35 46  1  0  0  0  0
 36 37  1  0  0  0  0
 38 37  1  0  0  0  0
 38 39  1  0  0  0  0
 38 74  1  1  0  0  0
 39 40  2  0  0  0  0
 39 48  1  0  0  0  0
 40 41  1  0  0  0  0
 42 41  1  0  0  0  0
 42 43  1  0  0  0  0
 42 75  1  1  0  0  0
 43 44  2  0  0  0  0
 43 47  1  0  0  0  0
 44 45  1  0  0  0  0
 46 45  1  0  0  0  0
 46 76  1  1  0  0  0
M  END

Are immediately accepted with an atom count of 0 as seen

Lowering potential energy to 10.000000 pJ...
+---------------------+
|         FILE        |
+---------------------+
Path...................satan3.mol
Name...................*****
Author................. OpenBabel10281909393D
Comment................ 76 88  0  0  1  0  0  0  0  0999 V2000
Atoms..................0
Bonds..................0

+---------------------+
|       UNIVERSE      |
+---------------------+
Duplicates to simulate.10
Atoms..................0
Temperature............273.000000 K
Pressure...............1.000000 hPa
Density................1.000000 g.cm-1
Total potential energy.0.000000 pJ
Universe size  ........0.000000 pm
Simulation time........1.000000 ns
Timestep...............1.000000 fs
Frameskip..............0
Iterations.............1000000

Simulation started
Simulation ended

<<< here

Note that this molecule is never supposed to have been created and will bring upon the end of worlds upon simulation start, as was prophesied thousands of years ago in ancient Sumeria.

Closed universe

The universe currently is thermodynamically anomalous, having an infinite volume ruining the entire purpose of allowing the user to choose a pressure.

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.