mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-06-28 06:41:42 +00:00
Added lib 'summary_stat.c'
This commit is contained in:
BIN
stat_new/stat
BIN
stat_new/stat
Binary file not shown.
@ -2,7 +2,8 @@
|
||||
*
|
||||
* Usage:
|
||||
* printing_agl (input_file, output_file, number_of_molecules,
|
||||
* true_label_molecules, num_of_molecules_in_aglomerates, aglomerates, statistic)
|
||||
* true_label_molecules, num_of_molecules_in_aglomerates, aglomerates,
|
||||
* statistic, type_of_aglomerate)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -11,7 +12,7 @@
|
||||
|
||||
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)
|
||||
const int *agl, const int *stat, int *type_agl)
|
||||
/* input - name of file with coordinates
|
||||
* output - name of output file
|
||||
* connect - connectivity graph for all molecules
|
||||
@ -20,6 +21,7 @@ int printing_agl (char *input, char *output, const int *connect, int num_mol,
|
||||
* num_mol_agl - massive of numbers of molecule in aglomerates
|
||||
* agl - massive of aglomerates
|
||||
* stat - massive of statistics
|
||||
* type_agl - massive of numbers of aglomerate types
|
||||
*/
|
||||
{
|
||||
int i, iso, j, k, p, type, *label_matrix, **matrix;
|
||||
@ -28,8 +30,12 @@ int printing_agl (char *input, char *output, const int *connect, int num_mol,
|
||||
* type - number of cycle in aglomerates
|
||||
* label_matrix - massive of indexes of molecule
|
||||
* matrix - connectivity graph
|
||||
* f_out - output file
|
||||
*/
|
||||
|
||||
type_agl[0] = 0;
|
||||
type_agl[1] = 0;
|
||||
|
||||
f_out = fopen (output, "a");
|
||||
|
||||
// head
|
||||
@ -68,9 +74,15 @@ int printing_agl (char *input, char *output, const int *connect, int num_mol,
|
||||
for (k=0; k<num_mol_agl[i]; k++)
|
||||
p += matrix[i][j];
|
||||
if (p == (2*num_mol_agl[i]-2))
|
||||
{
|
||||
type = 0;
|
||||
type_agl[0]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = (p - (2*num_mol_agl[i]-2)) / 2;
|
||||
type_agl[1]++;
|
||||
}
|
||||
|
||||
// printing class of aglomerate
|
||||
fprintf (f_out, " %7i=%1i=%-7i\n", num_mol_agl[i], type, iso);
|
||||
|
70
stat_new/summary_stat.c
Normal file
70
stat_new/summary_stat.c
Normal file
@ -0,0 +1,70 @@
|
||||
/* Library for summary statistic
|
||||
* Usage:
|
||||
* summary_statistic (filename, number_of_step, number_of_molecules,
|
||||
* type_of_aglomerate, summary_statistic)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int summary_statistic (char *filename, int step, int num_mol, const int *type_agl, const int *stat_all)
|
||||
/* filename - name of output file
|
||||
* step - number of steps
|
||||
* num_mol - number of molecules
|
||||
* type_agl - massive of numbers of aglomerate types
|
||||
* stat_all - massive of summary statistics
|
||||
*/
|
||||
{
|
||||
float conc, p, pn, type[2], x, y;
|
||||
int i, index;
|
||||
FILE *f_out;
|
||||
/* conc - concentrate of aglomerates
|
||||
* p - probability of aglomerates
|
||||
* pn - weight probability of aglomerates
|
||||
* f_out - output file
|
||||
*/
|
||||
|
||||
index = 0;
|
||||
for (i=0; i<num_mol; i++)
|
||||
if (stat_all[i] != 0)
|
||||
index = i;
|
||||
|
||||
// head
|
||||
f_out = fopen (filename, "a");
|
||||
fprintf (f_out, "SUMMARY STATISTIC:\n");
|
||||
fprintf (f_out, "| n | N | C | p | pn |\n------------------------------------------------\n");
|
||||
|
||||
for (i=0; i<index; i++)
|
||||
{
|
||||
// calculating concentrates
|
||||
x = stat_all[i];
|
||||
y = step;
|
||||
conc = x / y;
|
||||
|
||||
// calculating probabilityes
|
||||
x = (i + 1) * stat_all[i];
|
||||
y = step * num_mol;
|
||||
p = x / y;
|
||||
pn = (i + 1) * p;
|
||||
|
||||
fprintf (f_out, " %7i %7i %9.2f %9.5f %9.5f\n", i+1, stat_all[i], conc, p, pn);
|
||||
}
|
||||
|
||||
// types of aglomerates
|
||||
x = type_agl[0] + type_agl[1];
|
||||
type[0] = type_agl[0];
|
||||
type[1] = type_agl[1];
|
||||
fprintf (f_out, "------------------------------------------------\n");
|
||||
fprintf (f_out, "LINEAR=%7.5f\nCYCLE=%7.5f\n", type[0]/x, type[1]/x);
|
||||
|
||||
fclose (f_out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user