Release mm_trj-1.0.1

This commit is contained in:
arcan1s
2013-08-05 06:07:59 +04:00
parent 8861dbd7d6
commit 38bb73d4f1
7 changed files with 155 additions and 71 deletions

View File

@ -3,22 +3,16 @@ Version : 1.0.1
License : GPL License : GPL
Usage: Usage:
mm_radf -i INPUT -s FIRST,LAST -c X,Y,Z -a ... -o OUTPUT [ -r MIN,MAX ] [ -rs R_STEP ] mm_trj -i INPUT_TRJ -t INPUT_TYPE -s NUMBER -a INPUT_ATOMS -o OUTPUT [ -tt TOTAL_TYPES ]
[ -a MIN,MAX ] [ -as ANG_STEP ] [ -m ] [ -l LOGFILE ] [ -q ] [ -h ] [ -l LOGFILE ] [ -q ] [ -h ]
Parametrs: Parametrs:
-i - mask of input files -i - input file name
-s - trajectory steps (integer) -t - type of trajectory. Supported formats: gmx, puma
-c - cell size (float), A -s - number of trajectory steps (integer)
-a - atom types (integer). Format: 'ATOM1-ATOM2' or 'A1,A2,A3-B1,B2,B3' -a - input file with atom types. See file format in manual
(will enable RDF calculation for center mass automaticaly) -o - mask of output files
-o - output file name -tt - number of different atom types. Default is 1024
-r - minimal and maximal radii for analyze (float), A. Default is '2.0,15.0'
-rs - radius step for analyze (float), A. Default is '0.2'
-a - minimal and maximal angles for analyze (float), deg. Default is '0.0,90.0'
-as - angle step for analyze (float), deg. This option will enable RADF
calculation automaticaly
-m - matrix output enable
-l - log enable -l - log enable
-q - quiet enable -q - quiet enable
-h - show this help and exit -h - show this help and exit

View File

@ -24,21 +24,15 @@
* @section How-To-Use How to use * @section How-To-Use How to use
* Usage: * Usage:
* <pre> * <pre>
* mm_radf -i INPUT -s FIRST,LAST -c X,Y,Z -a ... -o OUTPUT [ -r MIN,MAX ] [ -rs R_STEP ] * mm_trj -i INPUT_TRJ -t INPUT_TYPE -s NUMBER -a INPUT_ATOMS -o OUTPUT [ -tt TOTAL_TYPES ]
* [ -a MIN,MAX ] [ -as ANG_STEP ] [ -m ] [ -l LOGFILE ] [ -q ] [ -h ] * [ -l LOGFILE ] [ -q ] [ -h ]
* Parametrs: * Parametrs:
* -i - mask of input files * -i - input file name
* -s - trajectory steps (integer) * -t - type of trajectory. Supported formats: gmx, puma
* -c - cell size (float), A * -s - number of trajectory steps (integer)
* -a - atom types (integer). Format: 'ATOM1-ATOM2' or 'A1,A2,A3-B1,B2,B3' * -a - input file with atom types. See file format in manual
* (will enable RDF calculation for center mass automaticaly) * -o - mask of output files
* -o - output file name * -tt - number of different atom types. Default is 1024
* -r - minimal and maximal radii for analyze (float), A. Default is '2.0,15.0'
* -rs - radius step for analyze (float), A. Default is '0.2'
* -a - minimal and maximal angles for analyze (float), deg. Default is '0.0,90.0'
* -as - angle step for analyze (float), deg. This option will enable RADF
* calculation automaticaly
* -m - matrix output enable
* -l - log enable * -l - log enable
* -q - quiet enable * -q - quiet enable
* -h - show this help and exit * -h - show this help and exit
@ -269,6 +263,7 @@ int main(int argc, char *argv[])
error = 1; error = 1;
error = reading_atoms (input_at, &num_types, num_mol, num_atoms, ch_atom_types, error = reading_atoms (input_at, &num_types, num_mol, num_atoms, ch_atom_types,
atom_types, total_types); atom_types, total_types);
if (error == 0) if (error == 0)
{ {
sprintf (tmp_str, "%6cLog: %i;\n%6cQuiet: %i;\n%6cInput file: %s;\n%6cTrajectory type: %i;\n\ sprintf (tmp_str, "%6cLog: %i;\n%6cQuiet: %i;\n%6cInput file: %s;\n%6cTrajectory type: %i;\n\

Binary file not shown.

View File

@ -2,11 +2,37 @@
* @file * @file
*/ */
#include <math.h>
#include <stdio.h> #include <stdio.h>
#include "print_trj.h" #include "print_trj.h"
/**
* @fn translate_coords
*/
int translate_coords (const float coords, const float cell, float *trans)
/**
* @brief funtion that translates coordinate
* @code
*
* @endcode
*
* @param coords coordinate
* @param cell cell size
* @param trans massive of translated coordinates
*
* @return 0 - exit without errors
*/
{
trans[0] = coords;
trans[1] = coords - cell;
trans[2] = coords + cell;
return 0;
}
/** /**
* @fn rw_gmx * @fn rw_gmx
*/ */
@ -34,5 +60,95 @@ int rw_gmx (const char *input, const int step, const char *output, const int num
* @return 0 - exit without errors * @return 0 - exit without errors
*/ */
{ {
char filename[256], tmp_str[256];
float cell[3], trans[3], r_min;
int atoms, i, j, k, l, m, n;
FILE *f_inp;
/* filename output file name
* cell cell size
* trans translated coordinates
* r_min minimal radius
* atom number of atoms
* f_inp input file
*/
f_inp = fopen (input, "r");
if (f_inp == NULL)
return 1;
for (i=0; i<step; i++)
{
// initial variables
sprintf (filename, "%s.%03i", output, i+1);
fgets (tmp_str, 256, f_inp);
fgets (tmp_str, 256, f_inp);
sscanf (tmp_str, " natoms=%i%s", &atoms, tmp_str);
fgets (tmp_str, 256, f_inp);
fgets (tmp_str, 256, f_inp);
sscanf (tmp_str, " box[ 0]={%f%s", &cell[0], tmp_str);
fgets (tmp_str, 256, f_inp);
sscanf (tmp_str, " box[ 1]={%f,%f%s", &cell[1], &cell[1], tmp_str);
fgets (tmp_str, 256, f_inp);
sscanf (tmp_str, " box[ 2]={%f,%f,%f%s", &cell[2], &cell[2], &cell[2], tmp_str);
fgets (tmp_str, 256, f_inp);
for (j=0; j<3; j++)
cell[j] = 10 * cell[j];
// coordinates
for (j=0; j<atoms; j++)
{
fgets (tmp_str, 256, f_inp);
sscanf (tmp_str, " x[%i]={%f,%f,%f%s", &k, &coords[3*j+0], &coords[3*j+1],
&coords[3*j+2], tmp_str);
for (k=0; k<3; k++)
coords[3*j+k] = 10 * coords[3*j+k];
}
// velocities
fgets (tmp_str, 256, f_inp);
for (j=0; j<atoms; j++)
fgets (tmp_str, 256, f_inp);
// processing coordinates
j = 0;
while (j < atoms)
for (k=0; k<num_types; k++)
for (l=0; l<num_mol[k]; l++)
{
for (m=1; m<num_atoms[k]; m++)
for (n=0; n<3; n++)
{
r_min = fabs (coords[3*(j+m)+n] - coords[3*j+n]);
translate_coords (coords[3*(j+m)+n], cell[n], trans);
if (fabs (trans[1] - coords[3*j+n]) < r_min)
coords[3*(j+m)+n] = trans[1];
if (fabs (trans[2] - coords[3*j+n]) < r_min)
coords[3*(j+m)+n] = trans[2];
}
j += num_atoms[k];
}
j = 0;
while (j < atoms)
for (k=0; k<num_types; k++)
for (l=0; l<num_mol[k]; l++)
{
for (m=0; m<3; m++)
{
while (coords[3*j+m] > cell[m]/2)
for (n=j; n<j+num_atoms[k]; n++)
coords[3*n+m] -= cell[m];
while (coords[3*j+m] < -cell[m]/2)
for (n=j; n<j+num_atoms[k]; n++)
coords[3*n+m] += cell[m];
}
j += num_atoms[k];
}
// write to output
printing_trj (filename, atoms, num_types, num_mol, num_atoms, ch_atom_types,
atom_types, coords);
}
fclose (f_inp);
return 0; return 0;
} }

View File

@ -5,10 +5,14 @@
#ifndef READ_GMX_H #ifndef READ_GMX_H
#define READ_GMX_H #define READ_GMX_H
/**
* @fn translate_coords
*/
/** /**
* @fn rw_gmx * @fn rw_gmx
*/ */
int translate_coords (const float, const float, float *);
int rw_gmx (const char *, const int, const char *, const int, const int *, int rw_gmx (const char *, const int, const char *, const int, const int *,
const int *, const char *, const int *, float *); const int *, const char *, const int *, float *);

View File

@ -39,6 +39,12 @@ int rw_puma (const char *input, const int step, const char *output, const int nu
int atoms, i, j, k, l, m, n; int atoms, i, j, k, l, m, n;
FILE *f_inp; FILE *f_inp;
/* filename output file name
* cell cell size
* atom number of atoms
* f_inp input file
*/
f_inp = fopen (input, "r"); f_inp = fopen (input, "r");
if (f_inp == NULL) if (f_inp == NULL)
return 1; return 1;
@ -51,7 +57,7 @@ int rw_puma (const char *input, const int step, const char *output, const int nu
sscanf (tmp_str, "%s%s%i%s", tmp_str, tmp_str, &atoms, tmp_str); sscanf (tmp_str, "%s%s%i%s", tmp_str, tmp_str, &atoms, tmp_str);
fgets (tmp_str, 256, f_inp); fgets (tmp_str, 256, f_inp);
sscanf (tmp_str, "%f%f%f", &cell[0], &cell[1], &cell[2]); sscanf (tmp_str, "%f%f%f", &cell[0], &cell[1], &cell[2]);
// coordinates
for (j=0; j<atoms; j++) for (j=0; j<atoms; j++)
{ {
fgets (tmp_str, 256, f_inp); fgets (tmp_str, 256, f_inp);
@ -76,6 +82,7 @@ int rw_puma (const char *input, const int step, const char *output, const int nu
} }
j += num_atoms[k]; j += num_atoms[k];
} }
// write to output // write to output
printing_trj (filename, atoms, num_types, num_mol, num_atoms, ch_atom_types, printing_trj (filename, atoms, num_types, num_mol, num_atoms, ch_atom_types,
atom_types, coords); atom_types, coords);

View File

@ -1,32 +0,0 @@
NUMTYPES=2
NUMMOL=3
NUMAT=12
CL=5
CA=2
CA=2
CA=2
CA=2
CA=2
CA=2
HC=3
HC=3
HC=3
HC=3
HC=3
NUMMOL=97
NUMAT=15
CL=1
CT=4
CA=2
CA=2
CA=2
CA=2
CA=2
CA=2
HC=3
HC=3
HC=3
HC=3
HC=3
HC=3
HC=3