create_lattice(&moldyn,FCC,mdrun.lc,mdrun.fill_element,
mdrun.m1,DEFAULT_ATOM_ATTR,
mdrun.fill_brand,mdrun.lx,
- mdrun.ly,mdrun.lz,NULL);
+ mdrun.ly,mdrun.lz,NULL,0,NULL);
break;
case DIAMOND:
create_lattice(&moldyn,DIAMOND,mdrun.lc,
mdrun.fill_element,
mdrun.m1,DEFAULT_ATOM_ATTR,
mdrun.fill_brand,mdrun.lx,
- mdrun.ly,mdrun.lz,NULL);
+ mdrun.ly,mdrun.lz,NULL,0,NULL);
break;
case ZINCBLENDE:
o.x=0.5*0.25*mdrun.lc; o.y=o.x; o.z=o.x;
create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element1,
mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx,
- mdrun.ly,mdrun.lz,&o);
+ mdrun.ly,mdrun.lz,&o,0,NULL);
o.x+=0.25*mdrun.lc; o.y=o.x; o.z=o.x;
create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element2,
mdrun.m2,DEFAULT_ATOM_ATTR,1,mdrun.lx,
- mdrun.ly,mdrun.lz,&o);
+ mdrun.ly,mdrun.lz,&o,0,NULL);
break;
case NONE:
set_nn_dist(&moldyn,mdrun.nnd);
*/
int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass,
- u8 attr,u8 brand,int a,int b,int c,t_3dvec *origin) {
+ u8 attr,u8 brand,int a,int b,int c,t_3dvec *origin,
+ u8 p_type,t_part_vals *p_vals) {
int new,count;
int ret;
switch(type) {
case CUBIC:
set_nn_dist(moldyn,lc);
- ret=cubic_init(a,b,c,lc,atom,&orig);
+ ret=cubic_init(a,b,c,lc,atom,&orig,p_type,p_vals);
strcpy(name,"cubic");
break;
case FCC:
if(!origin)
v3_scale(&orig,&orig,0.5);
set_nn_dist(moldyn,0.5*sqrt(2.0)*lc);
- ret=fcc_init(a,b,c,lc,atom,&orig);
+ ret=fcc_init(a,b,c,lc,atom,&orig,p_type,p_vals);
strcpy(name,"fcc");
break;
case DIAMOND:
if(!origin)
v3_scale(&orig,&orig,0.25);
set_nn_dist(moldyn,0.25*sqrt(3.0)*lc);
- ret=diamond_init(a,b,c,lc,atom,&orig);
+ ret=diamond_init(a,b,c,lc,atom,&orig,p_type,p_vals);
strcpy(name,"diamond");
break;
default:
}
/* cubic init */
-int cubic_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin) {
+int cubic_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin,
+ u8 p_type,t_part_vals *p_vals) {
int count;
t_3dvec r;
int i,j,k;
t_3dvec o;
+ t_3dvec dist;
count=0;
if(origin)
else
v3_zero(&o);
+ /* shift partition values */
+ if(p_type) {
+ p_vals->p.x+=(a*lc)/2.0;
+ p_vals->p.y+=(b*lc)/2.0;
+ p_vals->p.z+=(c*lc)/2.0;
+ }
+
r.x=o.x;
for(i=0;i<a;i++) {
r.y=o.y;
for(j=0;j<b;j++) {
r.z=o.z;
for(k=0;k<c;k++) {
+ switch(p_type) {
+ case PART_INSIDE_R:
+ v3_sub(&dist,&r,&(p_vals->p));
+ if(v3_absolute_square(&dist)<(p_vals->r*p_vals->r)) {
v3_copy(&(atom[count].r),&r);
count+=1;
+ }
+ break;
+ case PART_OUTSIDE_R:
+ v3_sub(&dist,&r,&(p_vals->p));
+ if(v3_absolute_square(&dist)>=(p_vals->r*p_vals->r)) {
+ v3_copy(&(atom[count].r),&r);
+ count+=1;
+ }
+ break;
+ default:
+ v3_copy(&(atom[count].r),&r);
+ count+=1;
+ break;
+ }
r.z+=lc;
}
r.y+=lc;
}
/* fcc lattice init */
-int fcc_init(int a,int b,int c,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,
+ u8 p_type,t_part_vals *p_vals) {
int count;
int i,j,k,l;
t_3dvec o,r,n;
t_3dvec basis[3];
+ t_3dvec dist;
count=0;
if(origin)
basis[2].y=0.5*lc;
basis[2].z=0.5*lc;
+ /* shift partition values */
+ if(p_type) {
+ p_vals->p.x+=(a*lc)/2.0;
+ p_vals->p.y+=(b*lc)/2.0;
+ p_vals->p.z+=(c*lc)/2.0;
+ }
+
/* fill up the room */
r.x=o.x;
for(i=0;i<a;i++) {
r.z=o.z;
for(k=0;k<c;k++) {
/* first atom */
+ switch(p_type) {
+ case PART_INSIDE_R:
+ v3_sub(&dist,&r,&(p_vals->p));
+ if(v3_absolute_square(&dist)<(p_vals->r*p_vals->r)) {
v3_copy(&(atom[count].r),&r);
count+=1;
- r.z+=lc;
+ }
+ break;
+ case PART_OUTSIDE_R:
+ v3_sub(&dist,&r,&(p_vals->p));
+ if(v3_absolute_square(&dist)>=(p_vals->r*p_vals->r)) {
+ v3_copy(&(atom[count].r),&r);
+ count+=1;
+ }
+ break;
+ default:
+ v3_copy(&(atom[count].r),&r);
+ count+=1;
+ break;
+ }
/* the three face centered atoms */
for(l=0;l<3;l++) {
v3_add(&n,&r,&basis[l]);
+ switch(p_type) {
+ case PART_INSIDE_R:
+ v3_sub(&dist,&n,&(p_vals->p));
+ if(v3_absolute_square(&dist)<(p_vals->r*p_vals->r)) {
+ v3_copy(&(atom[count].r),&r);
+ count+=1;
+ }
+ break;
+ case PART_OUTSIDE_R:
+ v3_sub(&dist,&n,&(p_vals->p));
+ if(v3_absolute_square(&dist)>=(p_vals->r*p_vals->r)) {
+ v3_copy(&(atom[count].r),&r);
+ count+=1;
+ }
+ break;
+ default:
v3_copy(&(atom[count].r),&n);
count+=1;
+ break;
+ }
}
+ r.z+=lc;
}
r.y+=lc;
}
return count;
}
-int diamond_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,
+ u8 p_type,t_part_vals *p_vals) {
int count;
t_3dvec o;
- count=fcc_init(a,b,c,lc,atom,origin);
+ count=fcc_init(a,b,c,lc,atom,origin,p_type,p_vals);
o.x=0.25*lc;
o.y=0.25*lc;
if(origin) v3_add(&o,&o,origin);
- count+=fcc_init(a,b,c,lc,&atom[count],&o);
+ count+=fcc_init(a,b,c,lc,&atom[count],&o,p_type,p_vals);
return count;
}
int fd;
} t_vb;
+typedef struct s_part_vals {
+ double r;
+ t_3dvec p;
+ t_3dvec d;
+} t_part_vals;
+
+#define PART_INSIDE_R 1
+#define PART_OUTSIDE_R 2
+
/*
*
* defines
int moldyn_log_shutdown(t_moldyn *moldyn);
int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass,
- u8 attr,u8 brand,int a,int b,int c,t_3dvec *origin);
+ u8 attr,u8 brand,int a,int b,int c,t_3dvec *origin,
+ u8 p_type,t_part_vals *p_vals);
int add_atom(t_moldyn *moldyn,int element,double mass,u8 brand,u8 attr,
t_3dvec *r,t_3dvec *v);
int del_atom(t_moldyn *moldyn,int tag);
-int cubic_init(int a,int b,int c,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);
+int cubic_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin,
+ u8 p_type,t_part_vals *p_vals);
+int fcc_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin,
+ u8 p_type,t_part_vals *p_vals);
+int diamond_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin,
+ u8 p_type,t_part_vals *p_vals);
int destroy_atoms(t_moldyn *moldyn);
int thermal_init(t_moldyn *moldyn,u8 equi_init);
#ifdef INIT_SI
create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
- 0,LCNTX,LCNTY,LCNTZ,NULL);
+ 0,LCNTX,LCNTY,LCNTZ,NULL,0,NULL);
#endif
#ifdef INIT_C
create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_AT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