mirror of
https://github.com/ParticulateFlow/LPP.git
synced 2025-12-08 06:37:46 +00:00
python 3 compatibility for src/*.py files
move imports to top of files add from __future__ import commands module -> subprocesses module print statement -> print() function exec statement -> exec() function xrange -> range map() -> list(map()) StandardError -> Exception integer division: / -> // x.has_key(y) -> y in x sort(): use functools.cmp_to_key type(x) is y -> isinstance(x, y) raw_input -> input change variable names 'list' to avoid clashes with list class
This commit is contained in:
23
src/pair.py
23
src/pair.py
@ -8,6 +8,11 @@
|
||||
|
||||
# pair tool
|
||||
|
||||
# Imports and external programs
|
||||
|
||||
from __future__ import absolute_import
|
||||
from math import sqrt
|
||||
|
||||
oneline = "Compute LAMMPS pairwise energies"
|
||||
|
||||
docstr = """
|
||||
@ -41,10 +46,6 @@ e_vdwl,e_coul = p.single(rsq,itype,jtype,q1,q2,...) compute LJ/Coul energy
|
||||
|
||||
# Variables
|
||||
|
||||
# Imports and external programs
|
||||
|
||||
from math import sqrt
|
||||
|
||||
# Class definition
|
||||
|
||||
class pair:
|
||||
@ -68,7 +69,7 @@ class pair:
|
||||
self.init_func = self.init_lj_charmm_coul_charmm
|
||||
self.single_func = self.single_lj_charmm_coul_charmm
|
||||
else:
|
||||
raise StandardError, "this pair style not yet supported"
|
||||
raise Exception("this pair style not yet supported")
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# generic coeff method
|
||||
@ -99,10 +100,10 @@ class pair:
|
||||
|
||||
self.lj3 = []
|
||||
self.lj4 = []
|
||||
for i in xrange(ntypes):
|
||||
for i in range(ntypes):
|
||||
self.lj3.append(ntypes * [0])
|
||||
self.lj4.append(ntypes * [0])
|
||||
for j in xrange(ntypes):
|
||||
for j in range(ntypes):
|
||||
epsilon_ij = sqrt(epsilon[i]*epsilon[j])
|
||||
sigma_ij = sqrt(sigma[i]*sigma[j])
|
||||
self.lj3[i][j] = 4.0 * epsilon_ij * pow(sigma_ij,12.0);
|
||||
@ -143,10 +144,10 @@ class pair:
|
||||
|
||||
self.lj3 = []
|
||||
self.lj4 = []
|
||||
for i in xrange(ntypes):
|
||||
for i in range(ntypes):
|
||||
self.lj3.append(ntypes * [0])
|
||||
self.lj4.append(ntypes * [0])
|
||||
for j in xrange(ntypes):
|
||||
for j in range(ntypes):
|
||||
epsilon_ij = sqrt(epsilon[i]*epsilon[j])
|
||||
sigma_ij = sqrt(sigma[i]*sigma[j])
|
||||
self.lj3[i][j] = 4.0 * epsilon_ij * pow(sigma_ij,12.0);
|
||||
@ -197,10 +198,10 @@ class pair:
|
||||
|
||||
self.lj3 = []
|
||||
self.lj4 = []
|
||||
for i in xrange(ntypes):
|
||||
for i in range(ntypes):
|
||||
self.lj3.append(ntypes * [0])
|
||||
self.lj4.append(ntypes * [0])
|
||||
for j in xrange(ntypes):
|
||||
for j in range(ntypes):
|
||||
epsilon_ij = sqrt(epsilon[i]*epsilon[j])
|
||||
sigma_ij = 0.5 * (sigma[i] + sigma[j])
|
||||
self.lj3[i][j] = 4.0 * epsilon_ij * pow(sigma_ij,12.0);
|
||||
|
||||
Reference in New Issue
Block a user