From 96f0a82aa5ad030da3d432ab106ffd9416077ed1 Mon Sep 17 00:00:00 2001
From: Axel Kohlmeyer <akohlmey@gmail.com>
Date: Wed, 17 May 2017 07:48:15 -0400
Subject: [PATCH] simplify class names in pair style python examples. add SPC/E
 water example

---
 examples/python/in.pair_python_hybrid |  2 +-
 examples/python/in.pair_python_melt   |  2 +-
 examples/python/in.pair_python_spce   | 28 ++++++++++++++++++
 examples/python/potentials.py         | 41 ++++++++++++++++++++++++++-
 4 files changed, 70 insertions(+), 3 deletions(-)
 create mode 100644 examples/python/in.pair_python_spce

diff --git a/examples/python/in.pair_python_hybrid b/examples/python/in.pair_python_hybrid
index b917910a29..dcd1f1e35c 100644
--- a/examples/python/in.pair_python_hybrid
+++ b/examples/python/in.pair_python_hybrid
@@ -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
diff --git a/examples/python/in.pair_python_melt b/examples/python/in.pair_python_melt
index 2367ea0026..2349f080d4 100644
--- a/examples/python/in.pair_python_melt
+++ b/examples/python/in.pair_python_melt
@@ -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
diff --git a/examples/python/in.pair_python_spce b/examples/python/in.pair_python_spce
new file mode 100644
index 0000000000..d3765ebc33
--- /dev/null
+++ b/examples/python/in.pair_python_spce
@@ -0,0 +1,28 @@
+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
diff --git a/examples/python/potentials.py b/examples/python/potentials.py
index 2438a8ba46..dbce8cd445 100644
--- a/examples/python/potentials.py
+++ b/examples/python/potentials.py
@@ -1,6 +1,6 @@
 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))
-- 
GitLab