bring your own forcefieldΒΆ

Although pylj was originally designed to use only the Lennard-Jones potential model, hence pyLennard-Jones. Following the release of pylj-1.1.0, it is now possible to pass custom forcefields to the simulation.

A quick caveat is that currently the particle size in the cellview is defined only by the box size, therefore not by the atom being simulated. The result is that if you try and simulated something significantly different in size to argon, things might look a bit funny. If you have any ideas of how to fix this please check this issue in the GitHub repository.

Writing your own forcefield and passing it to the pylj engine is very simple, firstly the forcefield should have the following form,

def forcefield(dr, constants, force=False):
    if force:
        return force
    else:
        return energy

An example of this for the Lennard-Jones forcefield (which is the default for pylj) and be found in the pylj.forcefields module.

It is necessary to pass this forcefield to the pylj engine. This can be achieved during the initialisation of the System class object, by passing the defined function as the variable forcefield. This can be seen for the Lennard-Jones forcefield in the System class definition in the pylj.util module.