From 2c44b229eea203b6cf149e9b23378eaa364fe477 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sun, 1 Nov 2015 00:10:42 +0300 Subject: [PATCH] rewrite trajectory format to store coordinates --- mathmech/agl/src/add_main.c | 2 -- mathmech/agl/src/main.c | 10 +--------- mathmech/envir/src/add_main.c | 2 -- mathmech/envir/src/main.c | 11 ++--------- mathmech/mm/include/mathmech/print_trj.h | 3 ++- mathmech/mm/src/coords.c | 9 ++++++++- mathmech/mm/src/print_trj.c | 4 +++- mathmech/mm/src/read_gmx.c | 2 +- mathmech/mm/src/read_puma.c | 2 +- mathmech/radf/src/add_main.c | 2 -- mathmech/radf/src/main.c | 13 +++---------- mathmech/statgen/src/add_main.c | 2 -- mathmech/statgen/src/main.c | 11 ++--------- 13 files changed, 23 insertions(+), 50 deletions(-) diff --git a/mathmech/agl/src/add_main.c b/mathmech/agl/src/add_main.c index 6b0f8bf..455abd2 100644 --- a/mathmech/agl/src/add_main.c +++ b/mathmech/agl/src/add_main.c @@ -27,8 +27,6 @@ int error_checking (const char *aglinp, const system_info _system_info, const char *input, const char *output) { - if ((_system_info.cell[0] == 0.0) || (_system_info.cell[1] == 0.0) || (_system_info.cell[2] == 0.0)) - return 11; if (input[0] == '#') return 12; if (output[0] == '#') diff --git a/mathmech/agl/src/main.c b/mathmech/agl/src/main.c index 2423b7e..ea9db21 100644 --- a/mathmech/agl/src/main.c +++ b/mathmech/agl/src/main.c @@ -81,11 +81,10 @@ int main(int argc, char *argv[]) sprintf (tmp_str, "%s Evgeniy Alekseev aka arcanis\n", tmp_str); sprintf (tmp_str, "%s E-mail : esalexeev@gmail.com\n\n", tmp_str); sprintf (tmp_str, "%sUsage:\n", tmp_str); - sprintf (tmp_str, "%smm_agl -a AGL_INP -i INPUT -c X,Y,Z -o OUTPUT [ -l LOGFILE ] [ -q ] [ -h ]\n\n", tmp_str); + sprintf (tmp_str, "%smm_agl -a AGL_INP -i INPUT -o OUTPUT [ -l LOGFILE ] [ -q ] [ -h ]\n\n", tmp_str); sprintf (tmp_str, "%sParametrs:\n", tmp_str); sprintf (tmp_str, "%s -a - input file with agglomerates (in format statgen)\n", tmp_str); sprintf (tmp_str, "%s -i - input file with coordinates\n", tmp_str); - sprintf (tmp_str, "%s -c - cell size (float), A\n", tmp_str); sprintf (tmp_str, "%s -o - output file name\n", tmp_str); sprintf (tmp_str, "%s -l - log enable\n", tmp_str); sprintf (tmp_str, "%s -q - quiet enable\n", tmp_str); @@ -105,13 +104,6 @@ int main(int argc, char *argv[]) strcpy (input, argv[i+1]); i++; } - else if ((argv[i][0] == '-') && (argv[i][1] == 'c') && (argv[i][2] == '\0')) -// cell size - { - sscanf (argv[i+1], "%f,%f,%f", &_system_info.cell[0], &_system_info.cell[1], - &_system_info.cell[2]); - i++; - } else if ((argv[i][0] == '-') && (argv[i][1] == 'o') && (argv[i][2] == '\0')) // output file { diff --git a/mathmech/envir/src/add_main.c b/mathmech/envir/src/add_main.c index 74d56c3..4e8f1e3 100644 --- a/mathmech/envir/src/add_main.c +++ b/mathmech/envir/src/add_main.c @@ -27,8 +27,6 @@ int error_checking (const system_info _system_info, const char *input, const char *output) { - if ((_system_info.cell[0] == 0.0) || (_system_info.cell[1] == 0.0) || (_system_info.cell[2] == 0.0)) - return 11; if (input[0] == '#') return 12; if (output[0] == '#') diff --git a/mathmech/envir/src/main.c b/mathmech/envir/src/main.c index 7d239cd..f14576b 100644 --- a/mathmech/envir/src/main.c +++ b/mathmech/envir/src/main.c @@ -81,11 +81,10 @@ int main(int argc, char *argv[]) sprintf (tmp_str, "%s Evgeniy Alekseev aka arcanis\n", tmp_str); sprintf (tmp_str, "%s E-mail : esalexeev@gmail.com\n\n", tmp_str); sprintf (tmp_str, "%sUsage:\n", tmp_str); - sprintf (tmp_str, "%smm_envir -i INPUT -c X,Y,Z -o OUTPUT [ -n NUM_OF_MOLECULE ] [ -r RADIUS ]\n", tmp_str); - sprintf (tmp_str, "%s [ -l LOGFILE ] [ -q ] [ -h ]\n\n", tmp_str); + sprintf (tmp_str, "%smm_envir -i INPUT -o OUTPUT [ -n NUM_OF_MOLECULE ] [ -r RADIUS ]\n", tmp_str); + sprintf (tmp_str, "%s [ -l LOGFILE ] [ -q ] [ -h ]\n\n", tmp_str); sprintf (tmp_str, "%sParametrs:\n", tmp_str); sprintf (tmp_str, "%s -i - input file name\n", tmp_str); - sprintf (tmp_str, "%s -c - cell size (float), A\n", tmp_str); sprintf (tmp_str, "%s -o - output file name\n", tmp_str); sprintf (tmp_str, "%s -n - number of molecule for search (integer). Default is 1\n", tmp_str); sprintf (tmp_str, "%s -r - radius of environment (float). Default is 6.0\n", tmp_str); @@ -101,12 +100,6 @@ int main(int argc, char *argv[]) strcpy (input, argv[i+1]); i++; } - else if ((argv[i][0] == '-') && (argv[i][1] == 'c') && (argv[i][2] == '\0')) -// cell size - { - sscanf (argv[i+1], "%f,%f,%f", &_system_info.cell[0], &_system_info.cell[1], &_system_info.cell[2]); - i++; - } else if ((argv[i][0] == '-') && (argv[i][1] == 'o') && (argv[i][2] == '\0')) // output file { diff --git a/mathmech/mm/include/mathmech/print_trj.h b/mathmech/mm/include/mathmech/print_trj.h index 8d02727..9e47f4d 100644 --- a/mathmech/mm/include/mathmech/print_trj.h +++ b/mathmech/mm/include/mathmech/print_trj.h @@ -33,12 +33,13 @@ * @param ch_atom_types massive of char atom types * @param atom_types massive of atom types * @param coords massive of coordinates + * @param cell cell size * * @return 0 - exit without errors */ int printing_trj (const char *filename, const int atoms, const int num_types, const int *num_mol, const int *num_atoms, const char *ch_atom_types, const int *atom_types, - const float *coords); + const float *coords, const float *cell); #endif /* PRINT_TRJ_H */ diff --git a/mathmech/mm/src/coords.c b/mathmech/mm/src/coords.c index ac37758..30d08e9 100644 --- a/mathmech/mm/src/coords.c +++ b/mathmech/mm/src/coords.c @@ -29,7 +29,7 @@ int reading_coords (const int mode, const char *filename, const int type_inter, { char at_symb[32], file_string[256]; int atoms, cur_at_num, cur_at_type, cur_mol, i, j, tr_num_atoms, ref_mol, x, y; - float cur_coords[3], ref[3]; + float cur_coords[3], ref[3], cur_cell[3]; FILE *inp; /* cur_* temp variables @@ -132,6 +132,13 @@ int reading_coords (const int mode, const char *filename, const int type_inter, default: return 2; } } + // cell sizes + fgets (file_string, 256, inp); + sscanf (file_string, "%f,%f,%f", &cur_cell[0], &cur_cell[1], + &cur_cell[2]); + (*_system_info).cell[0] = cur_cell[0]; + (*_system_info).cell[1] = cur_cell[1]; + (*_system_info).cell[2] = cur_cell[2]; fclose (inp); ///
   translation 
diff --git a/mathmech/mm/src/print_trj.c b/mathmech/mm/src/print_trj.c index ecf8cb7..3c0e7e3 100644 --- a/mathmech/mm/src/print_trj.c +++ b/mathmech/mm/src/print_trj.c @@ -24,7 +24,7 @@ */ int printing_trj (const char *filename, const int atoms, const int num_types, const int *num_mol, const int *num_atoms, const char *ch_atom_types, const int *atom_types, - const float *coords) + const float *coords, const float *cell) { int cur_mol, cur_type[2], i, j, k, l; FILE *f_out; @@ -60,6 +60,8 @@ coords[3*i+1], coords[3*i+2], atom_types[cur_type[1]], cur_mol); cur_type[0] += num_atoms[j]; } } + + fprintf (f_out, "%lf,%lf,%lf\n", cell[0], cell[1], cell[2]); fclose (f_out); diff --git a/mathmech/mm/src/read_gmx.c b/mathmech/mm/src/read_gmx.c index 4e9d4fa..ed852b7 100644 --- a/mathmech/mm/src/read_gmx.c +++ b/mathmech/mm/src/read_gmx.c @@ -126,7 +126,7 @@ int rw_gmx (const char *input, const int step, const char *output, const int num // write to output printing_trj (filename, atoms, num_types, num_mol, num_atoms, ch_atom_types, - atom_types, coords); + atom_types, coords, cell); } fclose (f_inp); diff --git a/mathmech/mm/src/read_puma.c b/mathmech/mm/src/read_puma.c index b8c2634..691bdfd 100644 --- a/mathmech/mm/src/read_puma.c +++ b/mathmech/mm/src/read_puma.c @@ -78,7 +78,7 @@ int rw_puma (const char *input, const int step, const char *output, const int nu // write to output printing_trj (filename, atoms, num_types, num_mol, num_atoms, ch_atom_types, - atom_types, coords); + atom_types, coords, cell); } fclose (f_inp); diff --git a/mathmech/radf/src/add_main.c b/mathmech/radf/src/add_main.c index 7bb66c0..2e413dd 100644 --- a/mathmech/radf/src/add_main.c +++ b/mathmech/radf/src/add_main.c @@ -28,8 +28,6 @@ int error_checking (const char *input, const int num_needed_at, const int *needed_at, const char *output, const system_info _system_info) { - if ((_system_info.cell[0] == 0.0) || (_system_info.cell[1] == 0.0) || (_system_info.cell[2] == 0.0)) - return 11; if (input[0] == '#') return 12; if (output[0] == '#') diff --git a/mathmech/radf/src/main.c b/mathmech/radf/src/main.c index 5460e96..477deef 100644 --- a/mathmech/radf/src/main.c +++ b/mathmech/radf/src/main.c @@ -81,13 +81,12 @@ int main(int argc, char *argv[]) sprintf (tmp_str, "%s Evgeniy Alekseev aka arcanis\n", tmp_str); sprintf (tmp_str, "%s E-mail : esalexeev@gmail.com\n\n", tmp_str); sprintf (tmp_str, "%sUsage:\n", tmp_str); - sprintf (tmp_str, "%smm_radf -i INPUT -s FIRST,LAST -c X,Y,Z -at ... -o OUTPUT [ -r MIN,MAX ]\n", tmp_str); - sprintf (tmp_str, "%s [ -rs R_STEP ] [ -a MIN,MAX ] [ -as ANG_STEP ] [ -m ]\n", tmp_str); - sprintf (tmp_str, "%s [ -l LOGFILE ] [ -q ] [ -h ]\n\n", tmp_str); + sprintf (tmp_str, "%smm_radf -i INPUT -s FIRST,LAST -at ... -o OUTPUT [ -r MIN,MAX ] [ -rs R_STEP ]\n", tmp_str); + sprintf (tmp_str, "%s [ -a MIN,MAX ] [ -as ANG_STEP ] [ -m ]\n", tmp_str); + sprintf (tmp_str, "%s [ -l LOGFILE ] [ -q ] [ -h ]\n\n", tmp_str); sprintf (tmp_str, "%sParametrs:\n", tmp_str); sprintf (tmp_str, "%s -i - mask of input files\n", tmp_str); sprintf (tmp_str, "%s -s - trajectory steps (integer)\n", tmp_str); - sprintf (tmp_str, "%s -c - cell size (float), A\n", tmp_str); sprintf (tmp_str, "%s -at - atom types (integer). Format: 'AT1-AT2' or 'A1,A2,A3-B1,B2,B3'\n", tmp_str); sprintf (tmp_str, "%s (will enable RDF calculation for center mass automaticaly)\n", tmp_str); sprintf (tmp_str, "%s -o - output file name\n", tmp_str); @@ -123,12 +122,6 @@ int main(int argc, char *argv[]) } i++; } - else if ((argv[i][0] == '-') && (argv[i][1] == 'c') && (argv[i][2] == '\0')) -// cell size - { - sscanf (argv[i+1], "%f,%f,%f", &_system_info.cell[0], &_system_info.cell[1], &_system_info.cell[2]); - i++; - } else if ((argv[i][0] == '-') && (argv[i][1] == 'a') && (argv[i][2] == 't') && (argv[i][3] == '\0')) // atom types { diff --git a/mathmech/statgen/src/add_main.c b/mathmech/statgen/src/add_main.c index 62c6799..e36b5c1 100644 --- a/mathmech/statgen/src/add_main.c +++ b/mathmech/statgen/src/add_main.c @@ -30,8 +30,6 @@ int error_checking (const system_info _system_info, const char *input, const int { if ((type_inter == 0) || (type_inter > 4)) return 11; - if ((_system_info.cell[0] == 0.0) || (_system_info.cell[1] == 0.0) || (_system_info.cell[2] == 0.0)) - return 12; if ((_system_info.to == -1) || (_system_info.from == -1)) return 13; if (num_of_inter == 0) diff --git a/mathmech/statgen/src/main.c b/mathmech/statgen/src/main.c index 7543724..bba6653 100644 --- a/mathmech/statgen/src/main.c +++ b/mathmech/statgen/src/main.c @@ -107,12 +107,11 @@ int main (int argc, char *argv[]) sprintf (tmp_str, "%s Evgeniy Alekseev aka arcanis\n", tmp_str); sprintf (tmp_str, "%s E-mail : esalexeev@gmail.com\n\n", tmp_str); sprintf (tmp_str, "%sUsage:\n", tmp_str); - sprintf (tmp_str, "%smm_statgen -i INPUT -s FIRST,LAST -c X,Y,Z -a ... -r ... -o OUTPUT [ -g DEPTH ]\n", tmp_str); - sprintf (tmp_str, "%s [ -l LOGFILE ] [ -q ] [ -h ]\n\n", tmp_str); + sprintf (tmp_str, "%smm_statgen -i INPUT -s FIRST,LAST -a ... -r ... -o OUTPUT [ -g DEPTH ]\n", tmp_str); + sprintf (tmp_str, "%s [ -l LOGFILE ] [ -q ] [ -h ]\n\n", tmp_str); sprintf (tmp_str, "%sParametrs:\n", tmp_str); sprintf (tmp_str, "%s -i - mask of input files\n", tmp_str); sprintf (tmp_str, "%s -s - trajectory steps (integer)\n", tmp_str); - sprintf (tmp_str, "%s -c - cell size (float), A\n", tmp_str); sprintf (tmp_str, "%s -a - atom types (integer). Format: 'ATOM1' or 'ATOM1,ATOM2' or etc\n", tmp_str); sprintf (tmp_str, "%s -r - criteria (float), A. Format: '0-0:2.4,0-1:3.0' means 0-0\n", tmp_str); sprintf (tmp_str, "%s interaction (<2.4 A) and 0-1 (<3.0) are needed. This flag can be\n", tmp_str); @@ -144,12 +143,6 @@ int main (int argc, char *argv[]) } i++; } - else if ((argv[i][0] == '-') && (argv[i][1] == 'c') && (argv[i][2] == '\0')) -// cell size - { - sscanf (argv[i+1], "%f,%f,%f", &_system_info.cell[0], &_system_info.cell[1], &_system_info.cell[2]); - i++; - } else if ((argv[i][0] == '-') && (argv[i][1] == 'a') && (argv[i][2] == '\0')) // atom types {