Skip to content
Snippets Groups Projects
Commit 24654ad2 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

small formatting corrections to pair python style

parent 8d46aa60
No related branches found
No related tags found
No related merge requests found
...@@ -80,7 +80,7 @@ class LAMMPSPairPotential(object): ...@@ -80,7 +80,7 @@ class LAMMPSPairPotential(object):
self.pmap=dict() self.pmap=dict()
self.units='lj' self.units='lj'
def map_coeff(self,name,ltype): def map_coeff(self,name,ltype):
self.pmap[ltype]=name self.pmap\[ltype\]=name
def check_units(self,units): def check_units(self,units):
if (units != self.units): if (units != self.units):
raise Exception("Conflicting units: %s vs. %s" % (self.units,units)) raise Exception("Conflicting units: %s vs. %s" % (self.units,units))
...@@ -91,7 +91,7 @@ from this class and should be initialize in a similar fashion to the ...@@ -91,7 +91,7 @@ from this class and should be initialize in a similar fashion to the
example given below. NOTE: The class constructor has to set up a data example given below. NOTE: The class constructor has to set up a data
structure containing the potential parameters supported by this class. structure containing the potential parameters supported by this class.
It should also define a variable {self.units} containing a string It should also define a variable {self.units} containing a string
matching one of the options of LAMMPS' "units command"_units.html, which matching one of the options of LAMMPS' "units"_units.html command, which
is used to verify, that the potential definition in the python class and is used to verify, that the potential definition in the python class and
in the LAMMPS input match. Example for a single type Lennard-Jones in the LAMMPS input match. Example for a single type Lennard-Jones
potential class {LJCutMelt} in reducted units, which defines an atom potential class {LJCutMelt} in reducted units, which defines an atom
...@@ -121,19 +121,19 @@ value of the internal potential parameter data structure. Following ...@@ -121,19 +121,19 @@ value of the internal potential parameter data structure. Following
the {LJCutMelt} example, here are the two functions: the {LJCutMelt} example, here are the two functions:
def compute_force(self,rsq,itype,jtype): def compute_force(self,rsq,itype,jtype):
coeff = self.coeff[self.pmap[itype]][self.pmap[jtype]] coeff = self.coeff\[self.pmap\[itype\]\]\[self.pmap\[jtype\]\]
r2inv = 1.0/rsq r2inv = 1.0/rsq
r6inv = r2inv*r2inv*r2inv r6inv = r2inv*r2inv*r2inv
lj1 = coeff[0] lj1 = coeff\[0\]
lj2 = coeff[1] lj2 = coeff\[1\]
return (r6inv * (lj1*r6inv - lj2))*r2inv :pre return (r6inv * (lj1*r6inv - lj2))*r2inv :pre
def compute_energy(self,rsq,itype,jtype): def compute_energy(self,rsq,itype,jtype):
coeff = self.coeff[self.pmap[itype]][self.pmap[jtype]] coeff = self.coeff\[self.pmap\[itype\]\]\[self.pmap\[jtype\]\]
r2inv = 1.0/rsq r2inv = 1.0/rsq
r6inv = r2inv*r2inv*r2inv r6inv = r2inv*r2inv*r2inv
lj3 = coeff[2] lj3 = coeff\[2\]
lj4 = coeff[3] lj4 = coeff\[3\]
return (r6inv * (lj3*r6inv - lj4)) :pre return (r6inv * (lj3*r6inv - lj4)) :pre
IMPORTANT NOTE: for consistency with the C++ pair styles in LAMMPS, IMPORTANT NOTE: for consistency with the C++ pair styles in LAMMPS,
...@@ -149,7 +149,7 @@ IMPORTANT NOTE: The evaluation of scripted python code will slow down ...@@ -149,7 +149,7 @@ IMPORTANT NOTE: The evaluation of scripted python code will slow down
the computation pair-wise interactions quite significantly. However, the computation pair-wise interactions quite significantly. However,
this can be largely worked around through using the python pair style this can be largely worked around through using the python pair style
not for the actual simulation, but to generate tabulated potentials not for the actual simulation, but to generate tabulated potentials
on the fly using the "pair_write command"_pair_write.html . Please on the fly using the "pair_write"_pair_write.html command. Please
see below for an example LAMMPS input of how to build a table file: see below for an example LAMMPS input of how to build a table file:
pair_style python 2.5 pair_style python 2.5
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment