Skip to content

Commit

Permalink
updated dump2data.py. fixed a bug reading triclinic boundary conditio…
Browse files Browse the repository at this point in the history
…ns from PDB files that affects some versions of awk. Corrected the README file for the EFF example.
  • Loading branch information
jewettaij committed Jul 26, 2020
1 parent e172205 commit 5ddf0f5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This example using the electron Force Field (eFF) was created by
Andres Jaramillo-Botero and distributed with LAMMPS in the
"examples/USERS/eff/CH4" subdirectory.
"examples/USER/eff/CH4" subdirectory.
The files from that example were converted into moltemplate format using
"ltemplify.py" and then edited by hand (to rename the atom types,
and replace all of the "pair_coeff ..." commands with "pair_coeff * *")
Expand Down
30 changes: 17 additions & 13 deletions moltemplate/dump2data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#g_program_name = 'dump2data.py'
g_program_name = __file__.split('/')[-1]
g_date_str = '2020-3-22'
g_version_str = '0.57.0'
g_date_str = '2020-7-26'
g_version_str = '0.58.0'

import sys
from collections import defaultdict
Expand Down Expand Up @@ -99,7 +99,7 @@ def __init__(self):
'dipole': ['atom-ID', 'atom-type', 'q', 'x', 'y', 'z', 'mux', 'muy', 'muz'],
'dpd': ['atom-ID', 'atom-type', 'theta', 'x', 'y', 'z'],
'electron': ['atom-ID', 'atom-type', 'q', 'spin', 'eradius', 'x', 'y', 'z'],
'ellipsoid': ['atom-ID', 'atom-type', 'x', 'y', 'z', 'quatw', 'quati', 'quatj', 'quatk'],
'ellipsoid': ['atom-ID', 'atom-type', 'ellipsoidflag', 'density', 'x', 'y', 'z'],
'full': ['atom-ID', 'molecule-ID', 'atom-type', 'q', 'x', 'y', 'z'],
'line': ['atom-ID', 'molecule-ID', 'atom-type', 'lineflag', 'density', 'x', 'y', 'z'],
'meso': ['atom-ID', 'atom-type', 'rho', 'e', 'cv', 'x', 'y', 'z'],
Expand Down Expand Up @@ -725,7 +725,7 @@ def WriteFrameToData(out_file,
tokens[1] = xz_str
tokens[2] = yz_str
line = ' '.join(tokens)
if (line in set(['Masses', 'Velocities', 'Atoms','Ellipsoids',
if (line in set(['Masses', 'Velocities', 'Atoms', 'Ellipsoids',
'Bond Coeffs', 'Angle Coeffs',
'Dihedral Coeffs', 'Improper Coeffs',
'Bonds', 'Angles', 'Dihedrals', 'Impropers'])):
Expand Down Expand Up @@ -1162,7 +1162,7 @@ def main():
if (i_ix != -1) and (not x_already_unwrapped):
ix = int(tokens[i_ix])
if (misc_settings.center_frame or
(misc_settings.output_format != 'data')):
(misc_settings.output_format != 'data')):
#sys.stderr.write('atomid='+str(atomid)+', ix = '+str(ix)+', avec='+str(avec)+'\n')
x += ix * avec[0]
y += ix * avec[1]
Expand All @@ -1175,7 +1175,7 @@ def main():
if (i_iy != -1) and (not y_already_unwrapped):
iy = int(tokens[i_iy])
if (misc_settings.center_frame or
(misc_settings.output_format != 'data')):
(misc_settings.output_format != 'data')):
#sys.stderr.write('atomid='+str(atomid)+', iy = '+str(iy)+', bvec='+str(bvec)+'\n')
x += iy * bvec[0]
y += iy * bvec[1]
Expand All @@ -1188,7 +1188,7 @@ def main():
if (i_iz != -1) and (not z_already_unwrapped):
iz = int(tokens[i_iz])
if (misc_settings.center_frame or
(misc_settings.output_format != 'data')):
(misc_settings.output_format != 'data')):
#sys.stderr.write('atomid='+str(atomid)+', iz = '+str(iz)+', cvec='+str(cvec)+'\n')
x += iz * cvec[0]
y += iz * cvec[1]
Expand Down Expand Up @@ -1240,18 +1240,22 @@ def main():
name_vz = dump_column_names[i_vz]
i_vx_data = 0
I_data = -1
# This code is ugly and inneficient.
# This code is dreadful and inneficient.
# I never want to touch this code again. (Hope it
# works)
while i_vx_data < len(data_settings.column_names):
if name_vx == data_settings.column_names[i_vx_data]:
I_data = 0
while I_data < len(data_settings.ii_vects):
if ii_vects[I] == data_settings.ii_vects[I_data]:
if (dump_column_names[ii_vects[I][0]] ==
data_settings.column_names[data_settings.ii_vects[I_data][0]]):
# (This checks the first component, ([0]) I should also
# check [1] and [2], but the code is slow enough already.
# THIS IS TERRIBLE CODE.
break
I_data += 1

if (0 < I_data) and (I_data < len(data_settings.ii_vects)):
if (0 <= I_data) and (I_data < len(data_settings.ii_vects)):
break

i_vx_data += 1
Expand Down Expand Up @@ -1310,10 +1314,10 @@ def main():

write_this_frame = True
if (misc_settings.tstart and
(int(frame_timestep_str) < misc_settings.tstart)):
(int(frame_timestep_str) < misc_settings.tstart)):
write_this_frame = False
if (misc_settings.tstop and
(int(frame_timestep_str) > misc_settings.tstop)):
(int(frame_timestep_str) > misc_settings.tstop)):
write_this_frame = False
read_last_frame = True

Expand All @@ -1334,7 +1338,7 @@ def main():
else:
assert(misc_settings.timestep_str)
if (int(frame_timestep_str) >=
int(misc_settings.timestep_str)):
int(misc_settings.timestep_str)):
write_this_frame = True
read_last_frame = True

Expand Down
11 changes: 5 additions & 6 deletions moltemplate/scripts/moltemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# Copyright (c) 2013

G_PROGRAM_NAME="moltemplate.sh"
G_VERSION="2.18.2"
G_DATE="2020-7-25"
G_VERSION="2.18.3"
G_DATE="2020-7-26"

echo "${G_PROGRAM_NAME} v${G_VERSION} ${G_DATE}" >&2
echo "" >&2
Expand Down Expand Up @@ -606,10 +606,9 @@ while [ "$i" -lt "$ARGC" ]; do
BOXSIZE_XY=`awk -v PI="$PI" -v BOXSIZE_B="$BOXSIZE_B" -v GAMMA="$GAMMA" 'BEGIN{print BOXSIZE_B*cos(GAMMA*PI/180.0)}'`
BOXSIZE_XZ=`awk -v PI="$PI" -v BOXSIZE_C="$BOXSIZE_C" -v BETA="$BETA" 'BEGIN{print BOXSIZE_C*cos(BETA*PI/180.0)}'`
BOXSIZE_YZ=`awk -v PI="$PI" -v BOXSIZE_C="$BOXSIZE_C" -v ALPHA="$ALPHA" -v BETA="$BETA" -v GAMMA="$GAMMA" 'BEGIN{ca=cos(ALPHA*PI/180.0); cb=cos(BETA*PI/180.0); cg=cos(GAMMA*PI/180.0); sg=sin(GAMMA*PI/180.0); print BOXSIZE_C*(ca-(cg*cb))/sg}'`
BOXSIZE_Z=`awk -v PI="$PI" -v BOXSIZE_C="$BOXSIZE_C" -v ALPHA="$ALPHA" -v BETA="$BETA" -v GAMMA="$GAMMA" 'BEGIN{ca=cos(ALPHA*PI/180.0); cb=cos(BETA*PI/180.0); cg=cos(GAMMA*PI/180.0); sg=sin(GAMMA*PI/180.0); print BOXSIZE_C*sqrt(1.+2*ca*cb*cg-ca**2-cb**2-cg**2)/sg}'`
#BOXSIZE_Z=`awk -v BOXSIZE_C="$BOXSIZE_C" -v BOXSIZE_XZ="$BOXSIZE_XZ" -v BOXSIZE_YZ="$BOXSIZE_YZ" 'BEGIN{print sqrt((BOXSIZE_C**2)-((BOXSIZE_XZ**2)+(BOXSIZE_YZ**2)))}'`
# The two expressions for "BOXSIZE_Z" should be algebraically equivalent, but I
# might have made a mistake. Thanks, Otello for fixing this code. -A 2020-7-25.
BOXSIZE_Z=`awk -v PI="$PI" -v BOXSIZE_C="$BOXSIZE_C" -v ALPHA="$ALPHA" -v BETA="$BETA" -v GAMMA="$GAMMA" 'BEGIN{ca=cos(ALPHA*PI/180.0); cb=cos(BETA*PI/180.0); cg=cos(GAMMA*PI/180.0); sg=sin(GAMMA*PI/180.0); print BOXSIZE_C*sqrt(1.0+2*ca*cb*cg-ca*ca-cb*cb-cg*cg)/sg}'`
#BOXSIZE_Z=`awk -v BOXSIZE_C="$BOXSIZE_C" -v BOXSIZE_XZ="$BOXSIZE_XZ" -v BOXSIZE_YZ="$BOXSIZE_YZ" 'BEGIN{print sqrt((BOXSIZE_C*BOXSIZE_C)-((BOXSIZE_XZ*BOXSIZE_XZ)+(BOXSIZE_YZ*BOXSIZE_YZ)))}'`
# Note: The two expressions for "BOXSIZE_Z" are algebraically equivalent.
else
BOXSIZE_X=$BOXSIZE_A
BOXSIZE_Y=$BOXSIZE_B
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

url='https://github.com/jewettaij/moltemplate',

download_url='https://github.com/jewettaij/moltemplate/archive/v2.18.2.zip',
download_url='https://github.com/jewettaij/moltemplate/archive/v2.18.3.zip',

version='2.18.2',
version='2.18.3',

keywords=['simulation', 'LAMMPS', 'molecule editor', 'molecule builder',
'ESPResSo'],
Expand Down

0 comments on commit 5ddf0f5

Please sign in to comment.