From 028c7bc939b1f07da58ea4c9284e95f83c0a7da8 Mon Sep 17 00:00:00 2001 From: "Kurt A. O'Hearn" <ohearnku@cse.msu.edu> Date: Fri, 1 Jul 2016 09:44:34 -0400 Subject: [PATCH] Add more tools. Update water benchmark. --- data/benchmarks/water/water_6540.pdb | 2 +- tools/geo2lmp_reax.awk | 38 ++++++++++ tools/lmp2pdb.awk | 106 +++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 tools/geo2lmp_reax.awk create mode 100644 tools/lmp2pdb.awk diff --git a/data/benchmarks/water/water_6540.pdb b/data/benchmarks/water/water_6540.pdb index 660883aa..4c09dc51 100644 --- a/data/benchmarks/water/water_6540.pdb +++ b/data/benchmarks/water/water_6540.pdb @@ -1,4 +1,4 @@ -CRYST1 40.299 40.299 40.299 90.00 90.00 90.00 0 +CRYST1 40.299 40.299 40.299 90.00 90.00 90.00 0 ATOM 1 O REX 1 5.690 12.751 11.651 1.00 0.00 0 O ATOM 2 H REX 1 4.760 12.681 11.281 1.00 0.00 0 H ATOM 3 H REX 1 5.800 13.641 12.091 1.00 0.00 0 H diff --git a/tools/geo2lmp_reax.awk b/tools/geo2lmp_reax.awk new file mode 100644 index 00000000..9a5823f2 --- /dev/null +++ b/tools/geo2lmp_reax.awk @@ -0,0 +1,38 @@ +BEGIN{ + comment = "water strong scaling test"; + ntypes = 2; + masses[1] = 1.0080; + masses[2] = 15.990; + types["H"] = 1; + types["O"] = 2; + box[0] = box[1] = box[2] = 0; +} +{ + if( $1 == "BOXGEO" ) { + box[0] = $2; + box[1] = $3; + box[2] = $4; + } + else if( NF == 1 ) { + natoms = $1; + # print the header + print "#", comment, "\n"; + + print natoms, "atoms"; + print ntypes, "atom types\n"; + + print "0", box[0], "xlo", "xhi"; + print "0", box[1], "ylo", "yhi"; + print "0", box[2], "zlo", "zhi\n"; + + print "Masses\n"; + for( i = 1; i <= ntypes; ++i ) + print i, masses[i]; + + print "\nAtoms\n"; + } + else{ + # print the atom info + print $1, types[$2], "0", $4, $5, $6; + } +} \ No newline at end of file diff --git a/tools/lmp2pdb.awk b/tools/lmp2pdb.awk new file mode 100644 index 00000000..482bd502 --- /dev/null +++ b/tools/lmp2pdb.awk @@ -0,0 +1,106 @@ +BEGIN{ + box_flag = 0; + natoms = -1; + ntypes = -1; + atom_style = "charge"; +} +{ + # num atoms + if( $2 == "atoms" ) + natoms = $1; + # num atom types + else if( $2 == "atom" && $3 == "types" ) + ntypes = $1; + # box geometry + else if( $3 == "xlo" && $4 == "xhi" ) { + box[0] = $2 - $1; + ++box_flag; + } + else if( $3 == "ylo" && $4 == "yhi" ) { + box[1] = $2 - $1; + ++box_flag; + } + else if( $3 == "zlo" && $4 == "zhi" ) { + box[2] = $2 - $1; + ++box_flag; + } + # atom masses + else if( $1 == "Masses" ) { + if( ntypes <= 0 ) { + printf( "number of atom types can not be %d!\n", ntypes ); + exit; + } + + getline; # skip the empty line + for( i = 0; i < ntypes; ++i ) { + getline; + if( NF != 2 ) { # expect one integer, one float + printf( "unexpected mass line format: %s!\n", $0 ); + exit; + } + + # record the atom type + if( $2 == 12.0000 ) + types[$1] = "C"; + else if( $2 == 1.0080 ) + types[$1] = "H"; + else if( $2 == 15.9990 ) + types[$1] = "O"; + else if( $2 == 14.0000 ) + types[$1] = "N"; + else { + printf( "unknown atom type!\n" ); + exit; + } + } + } + # atom info + else if( $1 == "Atoms" ) { + if( natoms <= 0 ) { + printf( "number of atoms can not be %d!\n", natoms ); + exit; + } + + getline; # skip the empty line + for( i = 0; i < natoms; ++i ) { + getline; + if( NF != 6 ) { # expect 3 ints, 3 floats + printf( "unexpected atom line format: %s!\n", $0 ); + exit; + } + + atoms[i,"serial"] = $1; + atoms[i,"type"] = types[$2]; + atoms[i,"q"] = $3; + atoms[i,"x"] = $4; + atoms[i,"y"] = $5; + atoms[i,"z"] = $6; + } + } + else if( $1 == "#" ) + 1; # skip the comment + else if( NF == 0 ) + 1; # skip the empty line + else { + printf( "unexpected line: %s\n", $0 ); + exit; + } +} +END{ + if( box_flag != 3 ) { + printf( "incorrect box geometry!\n" ); + exit; + } + + printf( "%6s%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f%11s%4d\n", + "CRYST1", box[0], box[1], box[2], 90, 90, 90, "P", 1 ); + + for( i = 0; i < natoms; ++i ) { + printf( "%-6s%5d%5s%c%3s %c%4d%c %8.3f%8.3f%8.3f%6.2f%6.2f "\ + "%-4s%2s%2s\n", "ATOM", atoms[i,"serial"], atoms[i,"type"], " ", + "REX", " ", 1, " ", atoms[i,"x"], atoms[i,"y"], atoms[i,"z"], + 1.0, 0.0, "0", atoms[i,"type"], " " ); + } + + printf( "END\n" ); +} \ No newline at end of file -- GitLab