1.0.0 • Published 6 years ago

@atomistics/pairwise-potential v1.0.0

Weekly downloads
-
License
Unlicense
Repository
-
Last release
6 years ago

pairwise-potential

Takes a pairwise function and returns a function that can calculate the energy from a set of 3D positions.

Example

const LJ = require("@atomistics/lennard-jones-pairwise-js");
const PairwisePotential = require("@atomistics/pairwise-potential");

const ljp = PairwisePotential(LJ());

console.log(ljp([0,0,0, 1.01,0,0]));

> { energy: -0.9966412452432595,
>   force: Float32Array [ 0.6486654877662659, 0, 0, -0.6486654877662659, 0, 0 ] }

API

const PairwisePotential = require('@atomistics/pairwise-potential');

const potential = PairwisePotential(pairwise)
ParameterTypeDescription
pairwisepairwise potentialA pairwise potential like @atomistics/lennard-jones-pairwise-js

Returns a function that calculates the potential energy of and force on from a set of positions:

const result = potential(positions);
ParameterTypeDescription
positionsarrayA set of 3D positions in a flat array of floats, e.g., 0.0, 0.0, 0.0, 1.0, 0.0, 1.0

Returns an object containing the energy and force:

NameTypeDescription
result.energyfloatThe energy of the potential.
result.forcefloatThe force of the potential.