2 * init.c - create initial conditions
4 * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
8 #include "../math/math.h"
11 /* fcc lattice init */
12 int fcc_init(t_3dvec *dim,double lc,t_atom *atom,t_3dvec *origin) {
20 if(origin) v3_copy(&o,origin);
23 /* construct the basis */
26 if(i!=j) help[j]=0.5*lc;
29 v3_set(&basis[i],help);
36 /* fill up the room */
40 v3_copy(&(atom[count].r),&r);
43 v3_add(&n,&r,&basis[i]);
44 if((n.x<dim->x+o.x)&&(n.y<dim->y+o.y)&&(n.z<dim->z+o.z)) {
45 v3_copy(&(atom[count].r),&n);
56 /* coordinate transformation */
62 v3_sub(&(atom[i].r),&(atom[i].r),&n);
67 int diamond_init(t_3dvec *dim,double lc,t_atom *atom,t_3dvec *origin) {
72 count=fcc_init(dim,lc,atom,origin);
78 if(origin) v3_add(&o,&o,origin);
80 count+=fcc_init(dim,lc,&atom[count],&o);