add harmonic/cut to python example folder. small tweaks to docs and examples

This commit is contained in:
Axel Kohlmeyer
2022-03-18 17:58:30 -04:00
parent 6c6a6b7c64
commit a7fce6dc39
18 changed files with 1354 additions and 213 deletions

View File

@ -1,4 +1,5 @@
from __future__ import print_function
import math
class LAMMPSPairPotential(object):
def __init__(self):
@ -10,6 +11,34 @@ class LAMMPSPairPotential(object):
if (units != self.units):
raise Exception("Conflicting units: %s vs. %s" % (self.units,units))
class Harmonic(LAMMPSPairPotential):
def __init__(self):
super(Harmonic,self).__init__()
self.units = 'real'
# set coeffs: K, r0
self.coeff = {'A' : {'A' : (0.2,9.0),
'B' : (math.sqrt(0.2*0.4),9.0)},
'B' : {'A' : (math.sqrt(0.2*0.4),9.0),
'B' : (0.4,9.0)}}
def compute_force(self,rsq,itype,jtype):
coeff = self.coeff[self.pmap[itype]][self.pmap[jtype]]
r = math.sqrt(rsq)
delta = coeff[1]-r
if (r <= coeff[1]):
return 2.0*delta*coeff[0]/r
else:
return 0.0
def compute_energy(self,rsq,itype,jtype):
coeff = self.coeff[self.pmap[itype]][self.pmap[jtype]]
r = math.sqrt(rsq)
delta = coeff[1]-r
if (r <= coeff[1]):
return delta*delta*coeff[0]
else:
return 0.0
class LJCutMelt(LAMMPSPairPotential):
def __init__(self):
super(LJCutMelt,self).__init__()