Commit 43efe9e4 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

adding Pair::single() support to python pair style and examples

with the single function, python pair styles can be massively
sped up and made compatible to accelerators, as one can translate
the analytic force and energy functions through LAMMPS into suitable
tables and then simply use the on-the-fly tables for production runs
parent 45becfb2
Loading
Loading
Loading
Loading
+9029 −0

File added.

Preview size limit exceeded, changes collapsed.

+45 −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

pair_modify     table 0

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

# create combined lj/coul table for all atom types
# generate tabulated potential from python variant
pair_write      1 1 2000 rsq 0.1 12 spce.table OW-OW -0.8472 -0.8472
pair_write      1 2 2000 rsq 0.1 12 spce.table OW-HW -0.8472  0.4236
pair_write      2 2 2000 rsq 0.1 12 spce.table HW-HW  0.4236  0.4236

# switch to tabulated potential
pair_style      table linear 2000 pppm
pair_coeff      1 1 spce.table OW-OW
pair_coeff      1 2 spce.table OW-HW
pair_coeff      2 2 spce.table HW-HW

thermo 10
run 100

shell rm spce.table
+32 −0
Original line number Diff line number Diff line
# 3d Lennard-Jones melt

units		lj
atom_style	atomic

lattice		fcc 0.8442
region		box block 0 10 0 10 0 10
create_box	1 box
create_atoms	1 box
mass		* 1.0

velocity	all create 3.0 87287

pair_style	python 2.5
pair_coeff	* * potentials.LJCutMelt lj

# generate tabulated potential from python variant
pair_write      1 1 10000 rsq 0.01 2.5 lj_1_1.table LJ

pair_style      table linear 10000
pair_coeff      1 1 lj_1_1.table LJ

neighbor	0.3 bin
neigh_modify	every 20 delay 0 check no

fix		1 all nve

thermo		50
run		250

shell rm lj_1_1.table
+178 −0
Original line number Diff line number Diff line
LAMMPS (4 May 2017)
  using 1 OpenMP thread(s) per MPI task
units		real
atom_style	full

read_data	data.spce
  orthogonal box = (0.02645 0.02645 0.02641) to (35.5328 35.5328 35.4736)
  1 by 1 by 1 MPI processor grid
  reading atoms ...
  4500 atoms
  scanning bonds ...
  2 = max bonds/atom
  scanning angles ...
  1 = max angles/atom
  reading bonds ...
  3000 bonds
  reading angles ...
  1500 angles
  2 = max # of 1-2 neighbors
  1 = max # of 1-3 neighbors
  1 = max # of 1-4 neighbors
  2 = max # of special neighbors

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

pair_modify     table 0

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
  2 = max # of 1-2 neighbors
  1 = max # of 1-3 neighbors
  2 = max # of special neighbors

neighbor        2.0 bin

fix		1 all shake 0.0001 20 0 b 1 a 1
  0 = # of size 2 clusters
  0 = # of size 3 clusters
  0 = # of size 4 clusters
  1500 = # of frozen angles
fix		2 all nvt temp 300.0 300.0 100.0

# create combined lj/coul table for all atom types
# generate tabulated potential from python variant
pair_write      1 1 2000 rsq 0.1 12 spce.table OW-OW -0.8472 -0.8472
PPPM initialization ...
WARNING: Using polynomial approximation for long-range coulomb (../kspace.cpp:321)
  G vector (1/distance) = 0.279652
  grid = 40 40 40
  stencil order = 5
  estimated absolute RMS force accuracy = 0.000394206
  estimated relative force accuracy = 1.18714e-06
  using double precision FFTs
  3d grid and FFT values/proc = 103823 64000
Neighbor list info ...
  update every 1 steps, delay 10 steps, check yes
  max neighbors/atom: 2000, page size: 100000
  master list distance cutoff = 14
  ghost atom cutoff = 14
  binsize = 7, bins = 6 6 6
  2 neighbor lists, perpetual/occasional/extra = 2 0 0
  (1) pair python, perpetual, skip from (2)
      attributes: half, newton on
      pair build: skip
      stencil: none
      bin: none
  (2) pair coul/long, perpetual
      attributes: half, newton on
      pair build: half/bin/newton
      stencil: half/bin/3d/newton
      bin: standard
pair_write      1 2 2000 rsq 0.1 12 spce.table OW-HW -0.8472  0.4236
PPPM initialization ...
WARNING: Using polynomial approximation for long-range coulomb (../kspace.cpp:321)
  G vector (1/distance) = 0.279652
  grid = 40 40 40
  stencil order = 5
  estimated absolute RMS force accuracy = 0.000394206
  estimated relative force accuracy = 1.18714e-06
  using double precision FFTs
  3d grid and FFT values/proc = 103823 64000
pair_write      2 2 2000 rsq 0.1 12 spce.table HW-HW  0.4236  0.4236
PPPM initialization ...
WARNING: Using polynomial approximation for long-range coulomb (../kspace.cpp:321)
  G vector (1/distance) = 0.279652
  grid = 40 40 40
  stencil order = 5
  estimated absolute RMS force accuracy = 0.000394206
  estimated relative force accuracy = 1.18714e-06
  using double precision FFTs
  3d grid and FFT values/proc = 103823 64000

# switch to tabulated potential
pair_style      table linear 2000 pppm
pair_coeff      1 1 spce.table OW-OW
pair_coeff      1 2 spce.table OW-HW
pair_coeff      2 2 spce.table HW-HW

thermo 10
run 100
PPPM initialization ...
WARNING: Using 12-bit tables for long-range coulomb (../kspace.cpp:321)
  G vector (1/distance) = 0.279652
  grid = 40 40 40
  stencil order = 5
  estimated absolute RMS force accuracy = 0.000394674
  estimated relative force accuracy = 1.18855e-06
  using double precision FFTs
  3d grid and FFT values/proc = 103823 64000
Neighbor list info ...
  update every 1 steps, delay 10 steps, check yes
  max neighbors/atom: 2000, page size: 100000
  master list distance cutoff = 14
  ghost atom cutoff = 14
  binsize = 7, bins = 6 6 6
  1 neighbor lists, perpetual/occasional/extra = 1 0 0
  (1) pair table, perpetual
      attributes: half, newton on
      pair build: half/bin/newton
      stencil: half/bin/3d/newton
      bin: standard
Per MPI rank memory allocation (min/avg/max) = 35.26 | 35.26 | 35.26 Mbytes
Step Temp E_pair E_mol TotEng Press 
       0            0   -100272.97            0   -100272.97   -1282.0708 
      10    120.61568   -101350.63            0   -100272.39   -4077.5051 
      20    136.11379   -101465.43            0   -100248.65   -5136.5677 
      30    137.01602    -101455.3            0   -100230.46   -5347.8311 
      40      153.424   -101582.46            0   -100210.93   -5223.1676 
      50    167.73654   -101686.24            0   -100186.77   -4468.6687 
      60    163.11642   -101618.16            0   -100159.99   -3291.7815 
      70    169.64512   -101647.89            0   -100131.35    -2611.638 
      80     182.9979   -101737.01            0   -100101.11   -2390.6293 
      90    191.33873   -101778.71            0   -100068.24    -2239.386 
     100     194.7458   -101775.84            0   -100034.92   -1951.9128 
Loop time of 7.60221 on 1 procs for 100 steps with 4500 atoms

Performance: 1.137 ns/day, 21.117 hours/ns, 13.154 timesteps/s
99.7% CPU use with 1 MPI tasks x 1 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 5.7401     | 5.7401     | 5.7401     |   0.0 | 75.51
Bond    | 0.00017881 | 0.00017881 | 0.00017881 |   0.0 |  0.00
Kspace  | 1.5387     | 1.5387     | 1.5387     |   0.0 | 20.24
Neigh   | 0.2299     | 0.2299     | 0.2299     |   0.0 |  3.02
Comm    | 0.024311   | 0.024311   | 0.024311   |   0.0 |  0.32
Output  | 0.00057936 | 0.00057936 | 0.00057936 |   0.0 |  0.01
Modify  | 0.063158   | 0.063158   | 0.063158   |   0.0 |  0.83
Other   |            | 0.005243   |            |       |  0.07

Nlocal:    4500 ave 4500 max 4500 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost:    21216 ave 21216 max 21216 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs:    2.60177e+06 ave 2.60177e+06 max 2.60177e+06 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 2601766
Ave neighs/atom = 578.17
Ave special neighs/atom = 2
Neighbor list builds = 3
Dangerous builds = 0

shell rm spce.table

Total wall time: 0:00:07
+178 −0
Original line number Diff line number Diff line
LAMMPS (4 May 2017)
  using 1 OpenMP thread(s) per MPI task
units		real
atom_style	full

read_data	data.spce
  orthogonal box = (0.02645 0.02645 0.02641) to (35.5328 35.5328 35.4736)
  2 by 2 by 1 MPI processor grid
  reading atoms ...
  4500 atoms
  scanning bonds ...
  2 = max bonds/atom
  scanning angles ...
  1 = max angles/atom
  reading bonds ...
  3000 bonds
  reading angles ...
  1500 angles
  2 = max # of 1-2 neighbors
  1 = max # of 1-3 neighbors
  1 = max # of 1-4 neighbors
  2 = max # of special neighbors

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

pair_modify     table 0

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
  2 = max # of 1-2 neighbors
  1 = max # of 1-3 neighbors
  2 = max # of special neighbors

neighbor        2.0 bin

fix		1 all shake 0.0001 20 0 b 1 a 1
  0 = # of size 2 clusters
  0 = # of size 3 clusters
  0 = # of size 4 clusters
  1500 = # of frozen angles
fix		2 all nvt temp 300.0 300.0 100.0

# create combined lj/coul table for all atom types
# generate tabulated potential from python variant
pair_write      1 1 2000 rsq 0.1 12 spce.table OW-OW -0.8472 -0.8472
PPPM initialization ...
WARNING: Using polynomial approximation for long-range coulomb (../kspace.cpp:321)
  G vector (1/distance) = 0.279652
  grid = 40 40 40
  stencil order = 5
  estimated absolute RMS force accuracy = 0.000394206
  estimated relative force accuracy = 1.18714e-06
  using double precision FFTs
  3d grid and FFT values/proc = 34263 16000
Neighbor list info ...
  update every 1 steps, delay 10 steps, check yes
  max neighbors/atom: 2000, page size: 100000
  master list distance cutoff = 14
  ghost atom cutoff = 14
  binsize = 7, bins = 6 6 6
  2 neighbor lists, perpetual/occasional/extra = 2 0 0
  (1) pair python, perpetual, skip from (2)
      attributes: half, newton on
      pair build: skip
      stencil: none
      bin: none
  (2) pair coul/long, perpetual
      attributes: half, newton on
      pair build: half/bin/newton
      stencil: half/bin/3d/newton
      bin: standard
pair_write      1 2 2000 rsq 0.1 12 spce.table OW-HW -0.8472  0.4236
PPPM initialization ...
WARNING: Using polynomial approximation for long-range coulomb (../kspace.cpp:321)
  G vector (1/distance) = 0.279652
  grid = 40 40 40
  stencil order = 5
  estimated absolute RMS force accuracy = 0.000394206
  estimated relative force accuracy = 1.18714e-06
  using double precision FFTs
  3d grid and FFT values/proc = 34263 16000
pair_write      2 2 2000 rsq 0.1 12 spce.table HW-HW  0.4236  0.4236
PPPM initialization ...
WARNING: Using polynomial approximation for long-range coulomb (../kspace.cpp:321)
  G vector (1/distance) = 0.279652
  grid = 40 40 40
  stencil order = 5
  estimated absolute RMS force accuracy = 0.000394206
  estimated relative force accuracy = 1.18714e-06
  using double precision FFTs
  3d grid and FFT values/proc = 34263 16000

# switch to tabulated potential
pair_style      table linear 2000 pppm
pair_coeff      1 1 spce.table OW-OW
pair_coeff      1 2 spce.table OW-HW
pair_coeff      2 2 spce.table HW-HW

thermo 10
run 100
PPPM initialization ...
WARNING: Using 12-bit tables for long-range coulomb (../kspace.cpp:321)
  G vector (1/distance) = 0.279652
  grid = 40 40 40
  stencil order = 5
  estimated absolute RMS force accuracy = 0.000394674
  estimated relative force accuracy = 1.18855e-06
  using double precision FFTs
  3d grid and FFT values/proc = 34263 16000
Neighbor list info ...
  update every 1 steps, delay 10 steps, check yes
  max neighbors/atom: 2000, page size: 100000
  master list distance cutoff = 14
  ghost atom cutoff = 14
  binsize = 7, bins = 6 6 6
  1 neighbor lists, perpetual/occasional/extra = 1 0 0
  (1) pair table, perpetual
      attributes: half, newton on
      pair build: half/bin/newton
      stencil: half/bin/3d/newton
      bin: standard
Per MPI rank memory allocation (min/avg/max) = 13.05 | 13.05 | 13.05 Mbytes
Step Temp E_pair E_mol TotEng Press 
       0            0   -100272.97            0   -100272.97   -1282.0708 
      10    120.61568   -101350.63            0   -100272.39   -4077.5051 
      20    136.11379   -101465.43            0   -100248.65   -5136.5677 
      30    137.01602    -101455.3            0   -100230.46   -5347.8311 
      40      153.424   -101582.46            0   -100210.93   -5223.1676 
      50    167.73654   -101686.24            0   -100186.77   -4468.6687 
      60    163.11642   -101618.16            0   -100159.99   -3291.7815 
      70    169.64512   -101647.89            0   -100131.35    -2611.638 
      80     182.9979   -101737.01            0   -100101.11   -2390.6293 
      90    191.33873   -101778.71            0   -100068.24    -2239.386 
     100     194.7458   -101775.84            0   -100034.92   -1951.9128 
Loop time of 2.38392 on 4 procs for 100 steps with 4500 atoms

Performance: 3.624 ns/day, 6.622 hours/ns, 41.948 timesteps/s
99.1% CPU use with 4 MPI tasks x 1 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 1.4377     | 1.5465     | 1.6848     |   7.3 | 64.87
Bond    | 0.00010276 | 0.00012648 | 0.0001452  |   0.0 |  0.01
Kspace  | 0.53311    | 0.66842    | 0.77484    |  10.9 | 28.04
Neigh   | 0.066      | 0.066074   | 0.066101   |   0.0 |  2.77
Comm    | 0.045355   | 0.048344   | 0.050747   |   1.0 |  2.03
Output  | 0.00042391 | 0.00044996 | 0.00052667 |   0.0 |  0.02
Modify  | 0.049891   | 0.050191   | 0.050336   |   0.1 |  2.11
Other   |            | 0.003771   |            |       |  0.16

Nlocal:    1125 ave 1154 max 1092 min
Histogram: 1 0 0 0 1 0 0 1 0 1
Nghost:    12256.2 ave 12296 max 12213 min
Histogram: 1 0 1 0 0 0 0 0 1 1
Neighs:    650442 ave 678824 max 626375 min
Histogram: 1 0 0 0 2 0 0 0 0 1

Total # of neighbors = 2601766
Ave neighs/atom = 578.17
Ave special neighs/atom = 2
Neighbor list builds = 3
Dangerous builds = 0

shell rm spce.table

Total wall time: 0:00:02
Loading