mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-06-30 23:55:48 +00:00
Added lib 'stat_print.c'
This commit is contained in:
BIN
stat_new/coords
BIN
stat_new/coords
Binary file not shown.
@ -2,7 +2,8 @@
|
||||
*
|
||||
* Usage:
|
||||
* reading_coords (filename, type_interaction, labels, cell,
|
||||
* &number_of_molecules, &number_of_atoms, label_molecule, type_atoms, coords)
|
||||
* &number_of_molecules, &number_of_atoms, true_label_molecule, label_molecule,
|
||||
* type_atoms, coords)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -28,13 +29,15 @@ char conv (int fnumb, int dig_pos)
|
||||
|
||||
int reading_coords (char *filename, int type_inter, const int *label_atom,
|
||||
const float *cell, int *num_mol, int *num_atoms,
|
||||
int *label_mol, int *type_atoms, float *coords)
|
||||
int *true_label_mol, int *label_mol,
|
||||
int *type_atoms, float *coords)
|
||||
/* filename - name of file with coordinates
|
||||
* type_inter - type interaction (number of molecules for interaction)
|
||||
* label_atom - types of atom for interaction
|
||||
* cell - cell dimension
|
||||
* num_mol - number of molecules for writing coordinates
|
||||
* num_atoms - number of atoms for writing coordinates
|
||||
* true_label_mol - massive of true numbers of molecule for atoms
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* type_atoms - massive of atom types for atoms
|
||||
* coords - massive of coordinates
|
||||
@ -57,7 +60,7 @@ int reading_coords (char *filename, int type_inter, const int *label_atom,
|
||||
*num_mol = 0;
|
||||
|
||||
// Reading file
|
||||
inp = fopen (filename, "r+");
|
||||
inp = fopen (filename, "r");
|
||||
if (inp == NULL)
|
||||
return 1;
|
||||
|
||||
@ -77,9 +80,10 @@ int reading_coords (char *filename, int type_inter, const int *label_atom,
|
||||
if (ref_mol != atoi (&file_string[53]))
|
||||
{
|
||||
ref_mol = atoi (&file_string[53]);
|
||||
true_label_mol[*num_mol] = ref_mol;
|
||||
*num_mol = *num_mol + 1;
|
||||
}
|
||||
label_mol[*num_atoms] = num_mol - 1;
|
||||
label_mol[*num_atoms] = *num_mol - 1;
|
||||
type_atoms[*num_atoms] = j;
|
||||
|
||||
*num_atoms = *num_atoms + 1;
|
||||
@ -287,13 +291,6 @@ int reading_coords (char *filename, int type_inter, const int *label_atom,
|
||||
}
|
||||
}
|
||||
|
||||
// Reading number of molecules
|
||||
// *num_mol = 1;
|
||||
// ref_mol = label_mol[0];
|
||||
// for (i=0; i<*num_atoms; i++)
|
||||
// if (ref_mol != label_mol[i])
|
||||
// *num_mol = *num_mol + 1;
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
BIN
stat_new/stat
BIN
stat_new/stat
Binary file not shown.
109
stat_new/stat_print.c
Normal file
109
stat_new/stat_print.c
Normal file
@ -0,0 +1,109 @@
|
||||
/* Library for printing aglomerates
|
||||
*
|
||||
* Usage:
|
||||
* printing_agl (input_file, output_file, number_of_molecules,
|
||||
* true_label_molecules, num_of_molecules_in_aglomerates, aglomerates, statistic)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int printing_agl (char *input, char *output, const int *connect, int num_mol,
|
||||
const int *true_label_mol, const int *num_mol_agl,
|
||||
const int *agl, const int *stat)
|
||||
/* input - name of file with coordinates
|
||||
* output - name of output file
|
||||
* connect - connectivity graph for all molecules
|
||||
* num_mol - number of molecules
|
||||
* true_label_mol - massive of true numbers of molecule for atoms
|
||||
* num_mol_agl - massive of numbers of molecule in aglomerates
|
||||
* agl - massive of aglomerates
|
||||
* stat - massive of statistics
|
||||
*/
|
||||
{
|
||||
int i, iso, j, k, p, type, *label_matrix, **matrix;
|
||||
FILE *f_out;
|
||||
/* iso - isomorphic graph in database
|
||||
* type - number of cycle in aglomerates
|
||||
* label_matrix - massive of indexes of molecule
|
||||
* matrix - connectivity graph
|
||||
*/
|
||||
|
||||
f_out = fopen (output, "a");
|
||||
|
||||
// head
|
||||
fprintf (f_out, "FILE=%s\nSTATISTIC:\n| n | N |\n-----------------", input);
|
||||
for (i=0; i<num_mol; i++)
|
||||
if (stat[i] != 0)
|
||||
fprintf (f_out, " %7i %7i \n", i+1, stat[i]);
|
||||
fprintf (f_out, "-----------------\n");
|
||||
|
||||
// body
|
||||
for (i=0; i<num_mol; i++)
|
||||
if (num_mol_agl[i] > 0)
|
||||
{
|
||||
// creating connectivity graph
|
||||
matrix = (int **) malloc (num_mol_agl[i] * sizeof (int *));
|
||||
for (j=0; j<num_mol_agl[i]; j++)
|
||||
{
|
||||
matrix[i] = (int *) malloc (num_mol_agl[i] * sizeof (int));
|
||||
for (k=0; k<num_mol_agl[i]; k++)
|
||||
matrix[i][j] = 0;
|
||||
}
|
||||
label_matrix = (int *) malloc (num_mol * sizeof (int));
|
||||
for (j=0; j<num_mol_agl[i]; j++)
|
||||
label_matrix[agl[num_mol*i+j]] = j;
|
||||
for (j=0; j<num_mol; j++)
|
||||
for (k=0; k<num_mol; k++)
|
||||
if (connect[num_mol*j+k] == 1)
|
||||
{
|
||||
matrix[label_matrix[j]][label_matrix[k]] = 1;
|
||||
matrix[label_matrix[k]][label_matrix[j]] = 1;
|
||||
}
|
||||
// TODO: analyze of topology
|
||||
iso = 0;
|
||||
p = 0;
|
||||
for (j=0; j<num_mol_agl[i]; j++)
|
||||
for (k=0; k<num_mol_agl[i]; k++)
|
||||
p += matrix[i][j];
|
||||
if (p == (2*num_mol_agl[i]-2))
|
||||
type = 0;
|
||||
else
|
||||
type = (p - (2*num_mol_agl[i]-2)) / 2;
|
||||
|
||||
// printing class of aglomerate
|
||||
fprintf (f_out, " %7i=%1i=%-7i\n", num_mol_agl[i], type, iso);
|
||||
for (j=0; j<num_mol_agl[i]; j++)
|
||||
{
|
||||
fprintf (f_out, "%7i=", true_label_mol[agl[num_mol*i+j]]);
|
||||
for (k=0; k<num_mol_agl[i]; k++)
|
||||
{
|
||||
if (matrix[j][k] == 1)
|
||||
{
|
||||
if (k == 0)
|
||||
fprintf (f_out, "%7i", true_label_mol[agl[num_mol*i+k]]);
|
||||
else
|
||||
fprintf (f_out, ",%7i", true_label_mol[agl[num_mol*i+k]]);
|
||||
}
|
||||
}
|
||||
fprintf (f_out, "\n");
|
||||
}
|
||||
|
||||
// free memory
|
||||
for (j=0; j<num_mol_agl[i]; j++)
|
||||
free (matrix[j]);
|
||||
free (matrix);
|
||||
free (label_matrix);
|
||||
}
|
||||
|
||||
fclose (f_out);
|
||||
fprintf (f_out, "---------------------------------------------------\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -11,6 +11,9 @@
|
||||
|
||||
|
||||
float radii (const float *a, const float *b)
|
||||
/* a - [x, y, z] first point
|
||||
* b - [x, y, z] second point
|
||||
*/
|
||||
{
|
||||
return sqrt (pow((a[0]-b[0]), 2) + pow((a[1]-b[1]), 2) + pow((a[2]-b[2]), 2));
|
||||
}
|
||||
@ -19,9 +22,23 @@ float radii (const float *a, const float *b)
|
||||
int create_matrix (int num_mol, int num_atoms, const int *label_mol,
|
||||
const int *type_atoms, const float *coords, int num_of_inter,
|
||||
const float *crit, int *connect)
|
||||
/* num_mol - number of molecules
|
||||
* num_atoms - number of atoms
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* type_atoms - massive of atom types for atoms
|
||||
* coords - massive of coordinates
|
||||
* num_of_inter - number of different interactions
|
||||
* crit - massive of criteria
|
||||
* connect - connectivity graph for all molecules
|
||||
*/
|
||||
{
|
||||
float x[2][3];
|
||||
int cur_num_inter, i, j, k, l, num_inter, ***label_inter;
|
||||
/* x - temporary coordinates
|
||||
* cur_num_inter - current number of true interactions
|
||||
* num_inter - needed number of true interactions
|
||||
* label_inter - temporary massive of true interactions
|
||||
*/
|
||||
|
||||
label_inter = (int ***) malloc (num_mol * sizeof (int **));
|
||||
for (i=0; i<num_mol; i++)
|
||||
|
@ -1,28 +1,38 @@
|
||||
/* Library for processing connectivity matrix
|
||||
*
|
||||
* Usage:
|
||||
* proc_matrix (number_of_molecules, connect_matrix, max_size_of_aglomerates,
|
||||
* num_of_molecules_in_aglomerates, aglomerates, statistic)
|
||||
* proc_matrix (number_of_molecules, connect_matrix,
|
||||
* num_of_molecules_in_aglomerates, aglomerates, statistic, summary_statistic)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int proc_matrix (int num_mol, const int *connect, int max_size, int *num_mol_agl, int *agl, int *stat)
|
||||
int proc_matrix (int num_mol, const int *connect, int *num_mol_agl, int *agl,
|
||||
int *stat, int *stat_all)
|
||||
/* num_mol - number of molecules
|
||||
* connect - connectivity graph for all molecules
|
||||
* num_mol_agl - massive of numbers of molecule in aglomerates
|
||||
* agl - massive of aglomerates
|
||||
* stat - massive of statistics
|
||||
* stat_all - massive of summary statistics
|
||||
*/
|
||||
{
|
||||
int i, j, k, p, *bin;
|
||||
/* p - weight / graph index
|
||||
* bin - binary massive of labels
|
||||
*/
|
||||
|
||||
// definition and zeroing
|
||||
bin = (int *) malloc (num_mol * sizeof (int));
|
||||
for (i=0; i<num_mol; i++)
|
||||
bin[i] = 0;
|
||||
for (i=0; i<max_size; i++)
|
||||
{
|
||||
bin[i] = 0;
|
||||
stat[i] = 0;
|
||||
num_mol_agl[i] = 0;
|
||||
for (j=0; j<max_size; j++)
|
||||
agl[max_size*i+j] = 0;
|
||||
for (j=0; j<num_mol; j++)
|
||||
agl[num_mol*i+j] = 0;
|
||||
}
|
||||
|
||||
// select non-bonded molecules
|
||||
@ -43,15 +53,15 @@ int proc_matrix (int num_mol, const int *connect, int max_size, int *num_mol_agl
|
||||
for (i=0; i<num_mol; i++)
|
||||
if (bin[i] == 1)
|
||||
{
|
||||
agl[max_size*p+num_mol_agl[p]] = i;
|
||||
agl[num_mol*p+num_mol_agl[p]] = i;
|
||||
num_mol_agl[p]++;
|
||||
bin[i] = 0;
|
||||
|
||||
for (j=0; j<num_mol_agl[p]; j++)
|
||||
for (k=0; k<num_mol; k++)
|
||||
if ((connect[agl[max_size*p+j]*num_mol+k] == 1) && (bin[k] == 1))
|
||||
if ((connect[agl[num_mol*p+j]*num_mol+k] == 1) && (bin[k] == 1))
|
||||
{
|
||||
agl[max_size*p+num_mol_agl[p]] = k;
|
||||
agl[num_mol*p+num_mol_agl[p]] = k;
|
||||
num_mol_agl[p]++;
|
||||
bin[k] = 0;
|
||||
}
|
||||
@ -60,8 +70,11 @@ int proc_matrix (int num_mol, const int *connect, int max_size, int *num_mol_agl
|
||||
}
|
||||
|
||||
// filling statistic array
|
||||
for (i=0; i<max_size; i++)
|
||||
for (i=0; i<num_mol; i++)
|
||||
{
|
||||
stat[num_mol_agl[i]-1]++;
|
||||
stat_all[num_mol_agl[i]-1]++;
|
||||
}
|
||||
|
||||
free (bin);
|
||||
|
||||
|
Reference in New Issue
Block a user