DEPS += potentials/tersoff.o potentials/albe.o
ALL = mdrun sic fluctuation_calc postproc pair_correlation_calc diffusion_calc
-ALL += bond_analyze search_bonds
+ALL += bond_analyze search_bonds visual_atoms
all: $(ALL)
search_bonds: $(DEPS)
+visual_atoms: $(DEPS)
+
.PHONY:clean
clean:
rm -vf $(ALL) *.o */*.o
/* main molecular dynamics api */
#include "moldyn.h"
-/* elements */
-#include "pse.h"
-
/* list api */
#include "list/list.h"
#include "potentials/tersoff.h"
#endif
-
-/*
- * global variables, pse and atom colors (only needed here)
- */
-
-static char *pse_name[]={
- "*",
- "H",
- "He",
- "Li",
- "Be",
- "B",
- "C",
- "N",
- "O",
- "F",
- "Ne",
- "Na",
- "Mg",
- "Al",
- "Si",
- "P",
- "S",
- "Cl",
- "Ar",
-};
-
-static char *pse_col[]={
- "*",
- "White",
- "He",
- "Li",
- "Be",
- "B",
- "Gray",
- "N",
- "Blue",
- "F",
- "Ne",
- "Na",
- "Mg",
- "Al",
- "Yellow",
- "P",
- "S",
- "Cl",
- "Ar",
-};
-
-/*
-static double pse_mass[]={
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- M_C,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- M_SI,
- 0,
- 0,
- 0,
- 0,
-};
-
-static double pse_lc[]={
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- LC_C,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- LC_SI,
- 0,
- 0,
- 0,
- 0,
-};
-*/
-
/*
* the moldyn functions
*/
#define DIAMOND 0x04
#define ZINCBLENDE 0x08
+/*
+ * more includes
+ */
+
+#include "pse.h"
+
/*
*
* function prototypes
0,
};
+static char *pse_name[]={
+ "*",
+ "H",
+ "He",
+ "Li",
+ "Be",
+ "B",
+ "C",
+ "N",
+ "O",
+ "F",
+ "Ne",
+ "Na",
+ "Mg",
+ "Al",
+ "Si",
+ "P",
+ "S",
+ "Cl",
+ "Ar",
+};
+
+static char *pse_col[]={
+ "*",
+ "White",
+ "He",
+ "Li",
+ "Be",
+ "B",
+ "Gray",
+ "N",
+ "Blue",
+ "F",
+ "Ne",
+ "Na",
+ "Mg",
+ "Al",
+ "Yellow",
+ "P",
+ "S",
+ "Cl",
+ "Ar",
+};
+
#include "moldyn.h"
#include "potentials/albe.h"
+typedef struct s_data {
+ double pm,len;
+ u8 type;
+} t_data;
+
int usage(char *prog) {
printf("\nusage:\n");
return -1;
}
+int process(t_moldyn *moldyn,t_atom *ai,t_atom *aj,void *ptr,u8 bc) {
+
+ t_3dvec dist;
+ double d;
+ t_data *data;
+
+ data=ptr;
+
+ if(aj<ai)
+ return 0;
+
+ switch(data->type) {
+ case 'a':
+ if(ai->brand!=0)
+ return 0;
+ if(aj->brand!=0)
+ return 0;
+
+ break;
+ case 'b':
+ if(ai->brand!=1)
+ return 0;
+ if(aj->brand!=1)
+ return 0;
+ break;
+ default:
+ if(ai->brand==aj->brand)
+ return 0;
+ break;
+ }
+
+ v3_sub(&dist,&(ai->r),&(aj->r));
+ check_per_bound(moldyn,&dist);
+ d=v3_norm(&dist);
+
+ if((d<=data->len+data->pm)&(d>=data->len-data->pm))
+ printf(" # atoms %d/%d %d/%d - %f\n",
+ ai->tag,ai->brand,
+ aj->tag,aj->brand,d);
+
+ return 0;
+}
+
int main(int argc,char **argv) {
t_moldyn moldyn;
- t_atom *itom,*jtom;
- int i,j;
int ret;
- t_list n[27];
- t_list *this;
- t_linkcell *lc;
- t_3dvec dist;
- double d,bondlen,bondpm;
+ t_data data;
if(argc!=5) {
usage(argv[0]);
return -1;
}
- bondlen=atof(argv[3]);
- bondpm=atof(argv[4]);
+ data.type=argv[2][0];
+ data.len=atof(argv[3]);
+ data.pm=atof(argv[4]);
memset(&moldyn,0,sizeof(t_moldyn));
}
/* link cell init */
- moldyn.cutoff=bondlen+bondpm;
+ moldyn.cutoff=data.len+data.pm;
link_cell_init(&moldyn,VERBOSE);
- lc=&(moldyn.lc);
- /* analyzing ... */
- for(i=0;i<moldyn.count;i++) {
- itom=&(moldyn.atom[i]);
- link_cell_neighbour_index(&moldyn,
- (itom->r.x+moldyn.dim.x/2)/lc->x,
- (itom->r.y+moldyn.dim.y/2)/lc->y,
- (itom->r.z+moldyn.dim.z/2)/lc->z,
- n);
- for(j=0;j<27;j++) {
- this=&(n[j]);
- list_reset_f(this);
-
- if(this->start==NULL)
- continue;
-
- do {
-
- jtom=this->current->data;
-
- if(jtom<itom)
- continue;
-
- switch(argv[2][0]) {
- case 'a':
- if(itom->brand!=0)
- continue;
- if(jtom->brand!=0)
- continue;
- break;
- case 'b':
- if(itom->brand!=1)
- continue;
- if(jtom->brand!=1)
- continue;
- break;
- default:
- if(itom->brand==jtom->brand)
- continue;
- break;
- }
-
- v3_sub(&dist,&(itom->r),&(jtom->r));
- check_per_bound(&moldyn,&dist);
- d=v3_norm(&dist);
-
- if((d<=bondlen+bondpm)&(d>=bondlen-bondpm)) {
-
- printf(" # atoms %d/%d %d/%d - %f\n",
- itom->tag,itom->brand,
- jtom->tag,jtom->brand,d);
-
- }
-
- } while(list_next_f(this)!=L_NO_NEXT_ELEMENT);
- }
- }
+ process_2b_bonds(&moldyn,&data,process);
+ /* analyzing ... */
link_cell_shutdown(&moldyn);
moldyn_free_save_file(&moldyn);
--- /dev/null
+/*
+ * code visualize atoms
+ *
+ * author: frank.zirkelbach@physik.uni-augsburg.de
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+//#include <stdlib.h>
+//#include <unistd.h>
+//#include <string.h>
+//#include <sys/types.h>
+//#include <sys/stat.h>
+//#include <fcntl.h>
+
+#include "moldyn.h"
+
+int usage(char *prog) {
+
+ printf("\nusage:\n");
+ printf(" %s <file> <centre atom> <radius> [marked atom]\n\n",prog);
+
+ return -1;
+}
+
+int main(int argc,char **argv) {
+
+ t_moldyn moldyn;
+ t_atom *itom,*jtom;
+ int j;
+ int ret;
+ t_list n[27];
+ t_list *this;
+ t_linkcell *lc;
+ t_3dvec dist;
+ double d,radius;
+ int ma,ca;
+
+ if(argc<4) {
+ usage(argv[0]);
+ return -1;
+ }
+
+ ca=atoi(argv[2]);
+ radius=atof(argv[3]);
+
+ ma=-1;
+ if(argc==5)
+ ma=atoi(argv[4]);
+
+ memset(&moldyn,0,sizeof(t_moldyn));
+
+ printf("[visual atoms] reading save file ...\n");
+ ret=moldyn_read_save_file(&moldyn,argv[1]);
+ if(ret) {
+ printf("[visual atoms] exit!\n");
+ return ret;
+ }
+
+ /* link cell init */
+ moldyn.cutoff=radius;
+ link_cell_init(&moldyn,VERBOSE);
+ lc=&(moldyn.lc);
+
+ /* serach atoms */
+ itom=&(moldyn.atom[ca]);
+ link_cell_neighbour_index(&moldyn,
+ (itom->r.x+moldyn.dim.x/2)/lc->x,
+ (itom->r.y+moldyn.dim.y/2)/lc->y,
+ (itom->r.z+moldyn.dim.z/2)/lc->z,
+ n);
+
+
+ printf("%s %f %f %f %s %f\n",
+ pse_name[itom->element],itom->r.x,itom->r.y,itom->r.z,
+ "Green",itom->ekin);
+
+ for(j=0;j<27;j++) {
+ this=&(n[j]);
+ list_reset_f(this);
+
+ if(this->start==NULL)
+ continue;
+
+ do {
+
+ jtom=this->current->data;
+
+ if(jtom==itom)
+ continue;
+
+ v3_sub(&dist,&(itom->r),&(jtom->r));
+ check_per_bound(&moldyn,&dist);
+ d=v3_norm(&dist);
+
+ if(d<=radius) {
+ printf("%s %f %f %f %s %f\n",
+ pse_name[jtom->element],
+ jtom->r.x,jtom->r.y,jtom->r.z,
+ (jtom->tag==ma)?"Red":pse_col[jtom->element],
+ jtom->ekin);
+ }
+
+ } while(list_next_f(this)!=L_NO_NEXT_ELEMENT);
+ }
+
+ link_cell_shutdown(&moldyn);
+
+ moldyn_free_save_file(&moldyn);
+
+ return 0;
+}