Commit 96f0a82a authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

simplify class names in pair style python examples. add SPC/E water example

parent 7caf6cf4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ mass * 1.0
velocity	all create 3.0 87287

pair_style	hybrid lj/cut 2.5 python 2.5
pair_coeff	* * python potentials.LAMMPSLJCutPotential lj NULL
pair_coeff	* * python potentials.LJCutMelt lj NULL
pair_coeff      * 2 lj/cut 1.0 1.0

neighbor	0.3 bin
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ mass * 1.0
velocity	all create 3.0 87287

pair_style	python 2.5
pair_coeff	* * potentials.LAMMPSLJCutPotential lj
pair_coeff	* * potentials.LJCutMelt lj

neighbor	0.3 bin
neigh_modify	every 20 delay 0 check no
+28 −0
Original line number Diff line number Diff line
units		real	
atom_style	full

read_data	data.spce

pair_style	hybrid/overlay python 12.0 coul/long 12.0
kspace_style	pppm 1.0e-6

pair_coeff	* * coul/long
pair_coeff	* * python potentials.LJCutSPCE OW NULL

bond_style	harmonic
angle_style	harmonic
dihedral_style	none
improper_style	none

bond_coeff	1 1000.00 1.000
angle_coeff	1 100.0 109.47

special_bonds   lj/coul 0.0 0.0 1.0

neighbor        2.0 bin

fix		1 all shake 0.0001 20 0 b 1 a 1
fix		2 all nvt temp 300.0 300.0 100.0

thermo 10
run 100
+40 −1
Original line number Diff line number Diff line
from __future__ import print_function

class LAMMPSLJCutPotential(object):
class LJCutMelt(object):

    def __init__(self):
        self.pmap=dict()
@@ -32,3 +32,42 @@ class LAMMPSLJCutPotential(object):
        lj3 = coeff[4]
        lj4 = coeff[5]
        return (r6inv * (lj3*r6inv - lj4))

class LJCutSPCE(object):

    def __init__(self):
        self.pmap=dict()
        # SPCE oxygen in real units
        eps=0.15535
        sig=3.166

        # set coeffs: eps, sig, 48*eps*sig**12, 24*eps*sig**6,
        #                        4*eps*sig**12,  4*eps*sig**6
        self.coeff = {'OW'  : {'OW'  : (1.0,1.0,
                                48.0*eps*sig**12,24.0*eps*sig**6,
                                 4.0*eps*sig**12, 4.0*eps*sig**6),
                               'NULL': (0.0,1.0, 0.0, 0.0,0.0,0.0)},
                      'NULL': {'OW'  : (0.0,1.0, 0.0, 0.0,0.0,0.0),
                               'NULL': (0.0,1.0, 0.0, 0.0,0.0,0.0)}}

    def map_coeff(self,name,type):
        if name in self.coeff:
           self.pmap[type] = name
        else:
           raise Exception("cannot match atom type %s" % name)

    def compute_force(self,rsq,itype,jtype):
        coeff = self.coeff[self.pmap[itype]][self.pmap[jtype]]
        r2inv  = 1.0/rsq
        r6inv  = r2inv*r2inv*r2inv
        lj1 = coeff[2]
        lj2 = coeff[3]
        return (r6inv * (lj1*r6inv - lj2))

    def compute_energy(self,rsq,itype,jtype):
        coeff = self.coeff[self.pmap[itype]][self.pmap[jtype]]
        r2inv  = 1.0/rsq
        r6inv  = r2inv*r2inv*r2inv
        lj3 = coeff[4]
        lj4 = coeff[5]
        return (r6inv * (lj3*r6inv - lj4))