mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-07-10 04:15:53 +00:00
Beta version
This commit is contained in:
@ -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)
|
OBJECTS=$(SOURCES:.c=.o)
|
||||||
EXECUTABLE=statgen
|
EXECUTABLE=statgen
|
||||||
|
|
||||||
$(STATGEN): $(SOURCES) $(EXECUTABLE)
|
$(PROJECT): $(SOURCES) $(EXECUTABLE)
|
||||||
|
|
||||||
$(EXECUTABLE): $(OBJECTS)
|
$(EXECUTABLE): $(OBJECTS)
|
||||||
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
|
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
|
||||||
|
@ -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
|
// 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+0] = not_tr_coords[3*i+0] + cell[0];
|
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] + cell[2];
|
||||||
|
|
||||||
label_mol[tr_num_atoms] = label_mol[i];
|
label_mol[tr_num_atoms] = label_mol[i];
|
||||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||||
|
@ -4,6 +4,18 @@
|
|||||||
#include <string.h>
|
#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 error_checking (const float *cell, int from, const char *input,
|
||||||
int num_of_inter, const char *output, int to, int type_inter)
|
int num_of_inter, const char *output, int to, int type_inter)
|
||||||
{
|
{
|
||||||
@ -276,10 +288,10 @@ int main (int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
fscanf (f_inp, "%i", &num_atoms);
|
fscanf (f_inp, "%i", &num_atoms);
|
||||||
fclose (f_inp);
|
fclose (f_inp);
|
||||||
coords = (float *) malloc (3 * num_atoms * sizeof (float));
|
coords = (float *) malloc (3 * 8 * num_atoms * sizeof (float));
|
||||||
label_mol = (int *) malloc (num_atoms * sizeof (int));
|
label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||||
true_label_mol = (int *) malloc (num_atoms * sizeof (int));
|
true_label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||||
type_atoms = (int *) malloc (num_atoms * sizeof (int));
|
type_atoms = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||||
|
|
||||||
// head
|
// head
|
||||||
printing_head (output, log, quiet, input, from, to, cell, type_inter, label_atom,
|
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));
|
agl = (int *) malloc (num_mol * num_mol * sizeof (int));
|
||||||
connect = (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));
|
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 = (int *) malloc (num_mol * sizeof (int));
|
||||||
stat_all = (int *) malloc (num_mol * sizeof (int));
|
stat_all = (int *) malloc (num_mol * sizeof (int));
|
||||||
}
|
}
|
||||||
|
|
||||||
// analyze
|
for (j=0; j<num_mol; j++)
|
||||||
if (error == 0)
|
|
||||||
{
|
{
|
||||||
error = create_matrix (num_mol, num_atoms, label_mol, type_atoms, coords,
|
num_mol_agl[j] = j;
|
||||||
num_of_inter, crit, connect);
|
printf ("%i - %i\n", j, num_mol_agl[j]);
|
||||||
if (error == 0)
|
}
|
||||||
{
|
|
||||||
error = proc_matrix (num_mol, connect, num_mol_agl, agl, stat, stat_all);
|
// analyze
|
||||||
if (error == 0)
|
error = 1;
|
||||||
printing_agl (filename, output, connect, num_mol, true_label_mol,
|
error = create_matrix (num_mol, num_atoms, label_mol, type_atoms, coords,
|
||||||
num_mol_agl, agl, stat, type_agl);
|
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 memory
|
||||||
free (agl);
|
free (agl);
|
||||||
@ -332,7 +351,8 @@ int main (int argc, char *argv[])
|
|||||||
free (coords);
|
free (coords);
|
||||||
free (crit);
|
free (crit);
|
||||||
free (label_mol);
|
free (label_mol);
|
||||||
free (num_mol_agl);
|
// memory crash here
|
||||||
|
free(num_mol_agl);
|
||||||
// free (stat);
|
// free (stat);
|
||||||
// free (stat_all);
|
// free (stat_all);
|
||||||
free (true_label_mol);
|
free (true_label_mol);
|
||||||
|
3376
stat_new/oct-clb.001
Executable file
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
105726
stat_new/oct-clb_4.55.dat
Executable file
File diff suppressed because it is too large
Load Diff
@ -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 *));
|
matrix = (int **) malloc (num_mol_agl[i] * sizeof (int *));
|
||||||
for (j=0; j<num_mol_agl[i]; j++)
|
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++)
|
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));
|
label_matrix = (int *) malloc (num_mol * sizeof (int));
|
||||||
for (j=0; j<num_mol_agl[i]; j++)
|
for (j=0; j<num_mol_agl[i]; j++)
|
||||||
label_matrix[agl[num_mol*i+j]] = j;
|
label_matrix[agl[num_mol*i+j]] = j;
|
||||||
for (j=0; j<num_mol; j++)
|
for (j=0; j<num_mol_agl[i]; j++)
|
||||||
for (k=0; k<num_mol; k++)
|
for (k=j+1; k<num_mol_agl[i]; k++)
|
||||||
if (connect[num_mol*j+k] == 1)
|
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[agl[num_mol*i+j]]][label_matrix[agl[num_mol*i+k]]] = 1;
|
||||||
matrix[label_matrix[k]][label_matrix[j]] = 1;
|
matrix[label_matrix[agl[num_mol*i+k]]][label_matrix[agl[num_mol*i+j]]] = 1;
|
||||||
}
|
}
|
||||||
// TODO: analyze of topology
|
// TODO: analyze of topology
|
||||||
iso = 0;
|
iso = 0;
|
||||||
p = 0;
|
p = 0;
|
||||||
for (j=0; j<num_mol_agl[i]; j++)
|
for (j=0; j<num_mol_agl[i]; j++)
|
||||||
for (k=0; k<num_mol_agl[i]; k++)
|
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))
|
if (p == (2*num_mol_agl[i]-2))
|
||||||
{
|
{
|
||||||
type = 0;
|
type = 0;
|
||||||
@ -82,19 +82,14 @@ int printing_agl (char *input, char *output, const int *connect, int num_mol,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// printing class of aglomerate
|
// 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++)
|
for (j=0; j<num_mol_agl[i]; j++)
|
||||||
{
|
{
|
||||||
fprintf (f_out, "%7i=", true_label_mol[agl[num_mol*i+j]]);
|
fprintf (f_out, "%7i=", true_label_mol[agl[num_mol*i+j]]);
|
||||||
for (k=0; k<num_mol_agl[i]; k++)
|
for (k=0; k<num_mol_agl[i]; k++)
|
||||||
{
|
{
|
||||||
if (matrix[j][k] == 1)
|
if (matrix[j][k] == 1)
|
||||||
{
|
fprintf (f_out, "%i,", true_label_mol[agl[num_mol*i+k]]);
|
||||||
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");
|
fprintf (f_out, "\n");
|
||||||
}
|
}
|
||||||
@ -106,7 +101,7 @@ int printing_agl (char *input, char *output, const int *connect, int num_mol,
|
|||||||
free (label_matrix);
|
free (label_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (f_out);
|
|
||||||
fprintf (f_out, "---------------------------------------------------\n");
|
fprintf (f_out, "---------------------------------------------------\n");
|
||||||
|
fclose (f_out);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -10,15 +10,6 @@
|
|||||||
#include <stdlib.h>
|
#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,
|
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 int *type_atoms, const float *coords, int num_of_inter,
|
||||||
const float *crit, int *connect)
|
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
|
* connect - connectivity graph for all molecules
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
float x[2][3];
|
float r;
|
||||||
int cur_num_inter, i, j, k, l, num_inter, ***label_inter;
|
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
|
* cur_num_inter - current number of true interactions
|
||||||
* num_inter - needed number of true interactions
|
* num_inter - needed number of true interactions
|
||||||
* label_inter - temporary massive 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 atoms from different molecules
|
||||||
if (label_mol[i] != label_mol[j])
|
if (label_mol[i] != label_mol[j])
|
||||||
{
|
{
|
||||||
for (k=0; k<3; k++)
|
r = sqrt (pow ((coords[3*i+0]-coords[3*j+0]), 2) +
|
||||||
{
|
pow ((coords[3*i+1]-coords[3*j+1]), 2) +
|
||||||
x[0][k] = coords[3*i+k];
|
pow ((coords[3*i+2]-coords[3*j+2]), 2));
|
||||||
x[1][k] = coords[3*j+k];
|
|
||||||
}
|
|
||||||
for (k=0; k<num_of_inter; k++)
|
for (k=0; k<num_of_inter; k++)
|
||||||
if (crit[16*k+4*type_atoms[i]+type_atoms[j]] != 0.0)
|
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[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[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++;
|
num_inter++;
|
||||||
|
|
||||||
for (i=0; i<num_mol; i++)
|
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;
|
cur_num_inter = 0;
|
||||||
for (l=0; l<16; l++)
|
for (l=0; l<16; l++)
|
||||||
|
@ -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));
|
bin = (int *) malloc (num_mol * sizeof (int));
|
||||||
for (i=0; i<num_mol; i++)
|
for (i=0; i<num_mol; i++)
|
||||||
{
|
{
|
||||||
bin[i] = 0;
|
bin[i] = 1;
|
||||||
stat[i] = 0;
|
stat[i] = 0;
|
||||||
num_mol_agl[i] = 0;
|
num_mol_agl[i] = 0;
|
||||||
for (j=0; j<num_mol; j++)
|
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;
|
bin[i] = 0;
|
||||||
stat[0]++;
|
stat[0]++;
|
||||||
|
stat_all[0]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
stat_new/statgen
Executable file
BIN
stat_new/statgen
Executable file
Binary file not shown.
@ -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, "SUMMARY STATISTIC:\n");
|
||||||
fprintf (f_out, "| n | N | C | p | pn |\n------------------------------------------------\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
|
// calculating concentrates
|
||||||
x = stat_all[i];
|
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;
|
p = x / y;
|
||||||
pn = (i + 1) * p;
|
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
|
// types of aglomerates
|
||||||
|
Reference in New Issue
Block a user