Beta version

This commit is contained in:
arcan1s
2013-07-17 23:25:22 +04:00
parent 709c4564c6
commit 41c6657090
10 changed files with 109169 additions and 60 deletions

View File

@ -7,7 +7,7 @@ SOURCES=main.c coords.c int2str.c stat_print.c stat_select.c stat_sort.c summary
OBJECTS=$(SOURCES:.c=.o)
EXECUTABLE=statgen
$(STATGEN): $(SOURCES) $(EXECUTABLE)
$(PROJECT): $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@

View File

@ -194,8 +194,8 @@ int reading_coords (char *filename, int type_inter, const int *label_atom,
// if x and y >= 0.0 A and z < 0.0 A
{
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] + cell[2];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];

View File

@ -4,6 +4,18 @@
#include <string.h>
// prototypes
char conv (int, int);
int create_matrix (int, int, const int *, const int *, const float *, int,
const float *, int *);
int printing_agl (char *, char *, const int *, int, const int *, const int *,
const int *, const int *, int *);
int proc_matrix (int, const int *, int *, int *, int *, int *);
int reading_coords (char *, int, const int *, const float *, int *, int *,
int *, int *, int *, float *);
int summary_statistic (char *, int, int, const int *, const int *);
int error_checking (const float *cell, int from, const char *input,
int num_of_inter, const char *output, int to, int type_inter)
{
@ -276,10 +288,10 @@ int main (int argc, char *argv[])
return 1;
fscanf (f_inp, "%i", &num_atoms);
fclose (f_inp);
coords = (float *) malloc (3 * num_atoms * sizeof (float));
label_mol = (int *) malloc (num_atoms * sizeof (int));
true_label_mol = (int *) malloc (num_atoms * sizeof (int));
type_atoms = (int *) malloc (num_atoms * sizeof (int));
coords = (float *) malloc (3 * 8 * num_atoms * sizeof (float));
label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
true_label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
type_atoms = (int *) malloc (8 * num_atoms * sizeof (int));
// head
printing_head (output, log, quiet, input, from, to, cell, type_inter, label_atom,
@ -302,29 +314,36 @@ int main (int argc, char *argv[])
agl = (int *) malloc (num_mol * num_mol * sizeof (int));
connect = (int *) malloc (num_mol * num_mol * sizeof (int));
num_mol_agl = (int *) malloc (num_mol * sizeof (int));
if (num_mol_agl != NULL)
printf ("error\n");
stat = (int *) malloc (num_mol * sizeof (int));
stat_all = (int *) malloc (num_mol * sizeof (int));
}
// analyze
if (error == 0)
for (j=0; j<num_mol; j++)
{
error = create_matrix (num_mol, num_atoms, label_mol, type_atoms, coords,
num_of_inter, crit, connect);
if (error == 0)
{
error = proc_matrix (num_mol, connect, num_mol_agl, agl, stat, stat_all);
if (error == 0)
printing_agl (filename, output, connect, num_mol, true_label_mol,
num_mol_agl, agl, stat, type_agl);
}
num_mol_agl[j] = j;
printf ("%i - %i\n", j, num_mol_agl[j]);
}
// analyze
error = 1;
error = create_matrix (num_mol, num_atoms, label_mol, type_atoms, coords,
num_of_inter, crit, connect);
if (error == 0)
{
error = 1;
error = proc_matrix (num_mol, connect, num_mol_agl, agl, stat, stat_all);
if (error == 0)
printing_agl (filename, output, connect, num_mol, true_label_mol,
num_mol_agl, agl, stat, type_agl);
}
// tail
summary_statistic (output, step, num_mol, type_agl, stat_all);
}
num_mol_agl[num_mol-1] = num_mol;
printf ("%i - %i\n", num_mol-1, num_mol_agl[num_mol]);
// tail
summary_statistic (output, step, num_mol, type_agl, stat_all);
printf ("%i - %i\n", num_mol-1, num_mol_agl[num_mol]);
// free memory
free (agl);
@ -332,7 +351,8 @@ int main (int argc, char *argv[])
free (coords);
free (crit);
free (label_mol);
free (num_mol_agl);
// memory crash here
free(num_mol_agl);
// free (stat);
// free (stat_all);
free (true_label_mol);

3376
stat_new/oct-clb.001 Executable file

File diff suppressed because it is too large Load Diff

105726
stat_new/oct-clb_4.55.dat Executable file

File diff suppressed because it is too large Load Diff

View File

@ -50,26 +50,26 @@ int printing_agl (char *input, char *output, const int *connect, int num_mol,
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));
matrix[j] = (int *) malloc (num_mol_agl[i] * sizeof (int));
for (k=0; k<num_mol_agl[i]; k++)
matrix[i][j] = 0;
matrix[j][k] = 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)
for (j=0; j<num_mol_agl[i]; j++)
for (k=j+1; k<num_mol_agl[i]; k++)
if (connect[num_mol*agl[num_mol*i+j]+agl[num_mol*i+k]] == 1)
{
matrix[label_matrix[j]][label_matrix[k]] = 1;
matrix[label_matrix[k]][label_matrix[j]] = 1;
matrix[label_matrix[agl[num_mol*i+j]]][label_matrix[agl[num_mol*i+k]]] = 1;
matrix[label_matrix[agl[num_mol*i+k]]][label_matrix[agl[num_mol*i+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];
p += matrix[j][k];
if (p == (2*num_mol_agl[i]-2))
{
type = 0;
@ -82,19 +82,14 @@ int printing_agl (char *input, char *output, const int *connect, int num_mol,
}
// printing class of aglomerate
fprintf (f_out, " %7i=%1i=%-7i\n", num_mol_agl[i], type, iso);
fprintf (f_out, "AGL=%i=%i=%i\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, "%i,", true_label_mol[agl[num_mol*i+k]]);
}
fprintf (f_out, "\n");
}
@ -106,7 +101,7 @@ int printing_agl (char *input, char *output, const int *connect, int num_mol,
free (label_matrix);
}
fclose (f_out);
fprintf (f_out, "---------------------------------------------------\n");
fclose (f_out);
return 0;
}

View File

@ -10,15 +10,6 @@
#include <stdlib.h>
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));
}
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)
@ -32,9 +23,9 @@ int create_matrix (int num_mol, int num_atoms, const int *label_mol,
* connect - connectivity graph for all molecules
*/
{
float x[2][3];
float r;
int cur_num_inter, i, j, k, l, num_inter, ***label_inter;
/* x - temporary coordinates
/* r - radius
* cur_num_inter - current number of true interactions
* num_inter - needed number of true interactions
* label_inter - temporary massive of true interactions
@ -58,17 +49,17 @@ int create_matrix (int num_mol, int num_atoms, const int *label_mol,
// if atoms from different molecules
if (label_mol[i] != label_mol[j])
{
for (k=0; k<3; k++)
{
x[0][k] = coords[3*i+k];
x[1][k] = coords[3*j+k];
}
r = sqrt (pow ((coords[3*i+0]-coords[3*j+0]), 2) +
pow ((coords[3*i+1]-coords[3*j+1]), 2) +
pow ((coords[3*i+2]-coords[3*j+2]), 2));
for (k=0; k<num_of_inter; k++)
if (crit[16*k+4*type_atoms[i]+type_atoms[j]] != 0.0)
if (radii (x[0], x[1]) <= crit[16*k+4*type_atoms[i]+type_atoms[j]])
if (r < crit[16*k+4*type_atoms[i]+type_atoms[j]])
{
label_inter[label_mol[i]][label_mol[j]][4*type_atoms[i]+type_atoms[j]] = 1;
label_inter[label_mol[i]][label_mol[j]][4*type_atoms[j]+type_atoms[i]] = 1;
label_inter[label_mol[j]][label_mol[i]][4*type_atoms[i]+type_atoms[j]] = 1;
label_inter[label_mol[j]][label_mol[i]][4*type_atoms[j]+type_atoms[i]] = 1;
}
}
@ -86,7 +77,7 @@ int create_matrix (int num_mol, int num_atoms, const int *label_mol,
num_inter++;
for (i=0; i<num_mol; i++)
for (j=0; j<num_mol; j++)
for (j=i+1; j<num_mol; j++)
{
cur_num_inter = 0;
for (l=0; l<16; l++)

View File

@ -28,7 +28,7 @@ int proc_matrix (int num_mol, const int *connect, int *num_mol_agl, int *agl,
bin = (int *) malloc (num_mol * sizeof (int));
for (i=0; i<num_mol; i++)
{
bin[i] = 0;
bin[i] = 1;
stat[i] = 0;
num_mol_agl[i] = 0;
for (j=0; j<num_mol; j++)
@ -45,6 +45,7 @@ int proc_matrix (int num_mol, const int *connect, int *num_mol_agl, int *agl,
{
bin[i] = 0;
stat[0]++;
stat_all[0]++;
}
}

BIN
stat_new/statgen Executable file

Binary file not shown.

View File

@ -35,7 +35,7 @@ int summary_statistic (char *filename, int step, int num_mol, const int *type_ag
fprintf (f_out, "SUMMARY STATISTIC:\n");
fprintf (f_out, "| n | N | C | p | pn |\n------------------------------------------------\n");
for (i=0; i<index; i++)
for (i=0; i<index+1; i++)
{
// calculating concentrates
x = stat_all[i];
@ -48,7 +48,7 @@ int summary_statistic (char *filename, int step, int num_mol, const int *type_ag
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);
fprintf (f_out, " %7i %7i %9.2f %9.5f %10.5f\n", i+1, stat_all[i], conc, p, pn);
}
// types of aglomerates