#include "../moldyn.h"
/* fcc lattice init */
-int fcc_init(t_3dvec *dim,double lc,t_atom *atom,t_3dvec *origin) {
+int fcc_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin) {
int count;
int i,j;
t_3dvec o,r,n;
t_3dvec basis[3];
double help[3];
+ double x,y,z;
+
+ x=a*lc;
+ y=b*lc;
+ z=c*lc;
if(origin) v3_copy(&o,origin);
else v3_zero(&o);
count=0;
/* fill up the room */
- while(r.x<dim->x) {
- while(r.y<dim->y) {
- while(r.z<dim->z) {
+ while(r.x<x) {
+ r.y=.0;
+ while(r.y<y) {
+ r.z=.0;
+ while(r.z<z) {
v3_copy(&(atom[count].r),&r);
count+=1;
for(i=0;i<3;i++) {
v3_add(&n,&r,&basis[i]);
- if((n.x<dim->x+o.x)&&(n.y<dim->y+o.y)&&(n.z<dim->z+o.z)) {
+ if((n.x<x+o.x)&&(n.y<y+o.y)&&(n.z<z+o.z)) {
v3_copy(&(atom[count].r),&n);
count+=1;
}
}
/* coordinate transformation */
- help[0]=dim->x/2.0;
- help[1]=dim->y/2.0;
- help[2]=dim->z/2.0;
+ help[0]=x/2.0;
+ help[1]=y/2.0;
+ help[2]=z/2.0;
v3_set(&n,help);
for(i=0;i<count;i++)
v3_sub(&(atom[i].r),&(atom[i].r),&n);
return count;
}
-int diamond_init(t_3dvec *dim,double lc,t_atom *atom,t_3dvec *origin) {
+int diamond_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin) {
int count;
t_3dvec o;
- count=fcc_init(dim,lc,atom,origin);
+ count=fcc_init(a,b,c,lc,atom,origin);
o.x=0.25*lc;
o.y=0.25*lc;
if(origin) v3_add(&o,&o,origin);
- count+=fcc_init(dim,lc,&atom[count],&o);
-
+ count+=fcc_init(a,b,c,lc,&atom[count],&o);
return count;
}
/* function prototypes */
-int fcc_init(t_3dvec *dim,double lc,t_atom *atom,t_3dvec *origin);
-int diamond_init(t_3dvec *dim,double lc,t_atom *atom,t_3dvec *origin);
+int fcc_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin);
+int diamond_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin);
#endif
int create_lattice(unsigned char type,int element,double mass,double lc,
- t_3dvec *dim,t_atom **atom) {
+ int a,int b,int c,t_atom **atom) {
int count;
int ret;
t_3dvec origin;
- count=((dim->x/lc)*(dim->y/lc)*(dim->z/lc));
+ count=a*b*c;
if(type==FCC) count*=4;
if(type==DIAMOND) count*=8;
switch(type) {
case FCC:
- ret=fcc_init(dim,lc,*atom,&origin);
+ ret=fcc_init(a,b,c,lc,*atom,&origin);
break;
case DIAMOND:
- ret=diamond_init(dim,lc,*atom,&origin);
+ ret=diamond_init(a,b,c,lc,*atom,&origin);
break;
default:
ret=-1;
/* function prototypes */
int create_lattice(unsigned char type,int element,double mass,double lc,
- t_3dvec *dim,t_atom **atom);
+ int a,int b,int c,t_atom **atom);
#endif
int main(int argc,char **argv) {
t_atom *si;
- t_3dvec dim;
+ int a,b,c;
char fb[32]="saves/fcc_test";
int count;
- dim.x=LEN_X;
- dim.y=LEN_Y;
- dim.z=LEN_Z;
+ a=LEN_X;
+ b=LEN_Y;
+ c=LEN_Z;
visual_init(&vis,fb);
/* init */
printf("placing silicon atoms\n");
- count=create_lattice(FCC,Si,M_SI,LC_SI,&dim,&si);
+ count=create_lattice(FCC,Si,M_SI,LC_SI,a,b,c,&si);
visual_atoms(&vis,0.0,si,count);
#ifndef POSIC_H
#define POSIC_H
-#define LEN_X 50
-#define LX (1.0*LEN_X/2)
-#define LEN_Y 50
-#define LY (1.0*LEN_Y/2)
-#define LEN_Z 50
-#define LZ (1.0*LEN_Z/2)
-
#define RUNS 15000
#define TAU 0.001
-#define R_CUTOFF 20
-#define R2_CUTOFF (R_CUTOFF*R_CUTOFF)
-
#define SI_M 1
#define SI_LC 5.43105
#define LJ_SIGMA SI_LC
#define LJ_SIGMA_06 (LJ_SIGMA_02*LJ_SIGMA_02*LJ_SIGMA_02)
#define LJ_SIGMA_12 (LJ_SIGMA_06*LJ_SIGMA_06)
+#define LEN_X 2
+#define LEN_Y 2
+#define LEN_Z 2
+
+#define R_CUTOFF 20
+#define R2_CUTOFF (R_CUTOFF*R_CUTOFF)
+
#define AMOUNT_SI ((LEN_X/SI_LC)*(LEN_Y/SI_LC)*(LEN_Z/SI_LC)*2)
#endif
memset(file,0,128+8);
sprintf(file,"%s.scr",v->fb);
- v->fd=open(file,O_WRONLY);
+ v->fd=open(file,O_WRONLY|O_CREAT|O_TRUNC);
if(v->fd<0) {
perror("open visual fd");
return -1;
};
sprintf(file,"%s-%.15f.xyz",v->fb,time);
- fd=open(file,O_WRONLY);
+ fd=open(file,O_WRONLY|O_CREAT|O_TRUNC);
if(fd<0) {
perror("open visual save file fd");
return -1;
dprintf(v->fd,"zap\n");
/* write the actual data file */
- dprintf(fd,"Atoms at time %.15f\n",time);
dprintf(fd,"%d\n",n);
+ dprintf(fd,"atoms at time %.15f\n",time);
for(i=0;i<n;i++)
dprintf(fd,"%s %f %f %f\n",pse[atom[i].element],
atom[i].r.x,atom[i].r.y,atom[i].r.z);