case STAGE_INSERT_ATOMS:
psize=sizeof(t_insert_atoms_params);
break;
+ case STAGE_INSERT_MIXED_ATOMS:
+ psize=sizeof(t_insert_mixed_atoms_params);
+ break;
case STAGE_CONTINUE:
psize=sizeof(t_continue_params);
break;
t_displace_atom_params dap;
t_insert_atoms_params iap;
+ t_insert_mixed_atoms_params imp;
t_continue_params cp;
t_anneal_params ap;
t_chaattr_params cap;
// reset
memset(&iap,0,sizeof(t_insert_atoms_params));
+ memset(&imp,0,sizeof(t_insert_mixed_atoms_params));
memset(&cp,0,sizeof(t_continue_params));
memset(&ap,0,sizeof(t_anneal_params));
memset(&cap,0,sizeof(t_chaattr_params));
mdrun->lattice=FCC;
if(!strncmp(word[1],"diamond",7))
mdrun->lattice=DIAMOND;
+ if(!strncmp(word[1],"none",4))
+ mdrun->lattice=NONE;
}
else if(!strncmp(word[0],"element1",8)) {
mdrun->element1=atoi(word[1]);
}
add_stage(mdrun,STAGE_INSERT_ATOMS,&iap);
}
+
+
+ // HERE WE GO ...
+
+ else if(!strncmp(word[1],"ins_m_atoms",11)) {
+ imp.element1=atoi(word[2]);
+ imp.element2=atoi(word[3]);
+ imp.amount1=atoi(word[4]);
+ imp.amount2=atoi(word[5]);
+ imp.brand1=atoi(word[6]);
+ imp.brand2=atoi(word[7]);
+ imp.cr=atof(word[8]);
+ /* do this later ...
+ for(i=0;i<strlen(word[8]);i++) {
+ switch(word[8][i]) {
+ case 'b':
+ imp.attr|=ATOM_ATTR_VB;
+ break;
+ case 'h':
+ imp.attr|=ATOM_ATTR_HB;
+ break;
+ case 'v':
+ imp.attr|=ATOM_ATTR_VA;
+ break;
+ case 'f':
+ imp.attr|=ATOM_ATTR_FP;
+ break;
+ case '1':
+ imp.attr|=ATOM_ATTR_1BP;
+ break;
+ case '2':
+ imp.attr|=ATOM_ATTR_2BP;
+ break;
+ case '3':
+ imp.attr|=ATOM_ATTR_3BP;
+ break;
+ default:
+ break;
+ }
+ }
+ */
+ imp.attr1=ATOM_ATTR_HB|ATOM_ATTR_VA|ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP;
+ imp.attr2=ATOM_ATTR_HB|ATOM_ATTR_VA|ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP;
+ add_stage(mdrun,STAGE_INSERT_MIXED_ATOMS,&imp);
+ }
+
+
+
+
+
else if(!strncmp(word[1],"continue",8)) {
cp.runs=atoi(word[2]);
add_stage(mdrun,STAGE_CONTINUE,&cp);
return 0;
}
+int insert_mixed_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
+
+ t_stage *stage;
+ t_insert_mixed_atoms_params *imp;
+ t_atom *atom;
+ double x,x0,y,y0,z,z0;
+ double dmin,d,c;
+ u8 retry;
+ t_3dvec r,v,dist;
+ int i;
+
+
+ stage=mdrun->stage.current->data;
+ imp=stage->params;
+
+ x=moldyn->dim.x;
+ x0=-x/2.0;
+ y=moldyn->dim.y;
+ y0=-y/2.0;
+ z=moldyn->dim.z;
+ z0=-z/2.0;
+
+ v.x=0.0;
+ v.y=0.0;
+ v.z=0.0;
+
+ c=imp->cr*imp->cr;
+
+ while(imp->amount1|imp->amount2) {
+ if(imp->amount1) {
+ retry=1;
+ while(retry) {
+ retry=0;
+ r.x=rand_get_double(&(moldyn->random))*x;
+ r.y=rand_get_double(&(moldyn->random))*y;
+ r.z=rand_get_double(&(moldyn->random))*z;
+ r.x+=x0;
+ r.y+=y0;
+ r.z+=z0;
+ dmin=1000.0; // for sure too high!
+ for(i=0;i<moldyn->count;i++) {
+ atom=&(moldyn->atom[i]);
+ v3_sub(&dist,&(atom->r),&r);
+ check_per_bound(moldyn,&dist);
+ d=v3_absolute_square(&dist);
+ if(d<c) {
+ retry=1;
+ break;
+ }
+ if(d<dmin)
+ dmin=d;
+
+ }
+ }
+ add_atom(moldyn,imp->element1,pse_mass[imp->element1],
+ imp->brand1,imp->attr1,&r,&v);
+ printf("%s (mixed) atom inserted (%d): %f %f %f\n",
+ ME,imp->amount1,r.x,r.y,r.z);
+ printf(" -> d2 = %f/%f\n",dmin,c);
+ imp->amount1-=1;
+ }
+ if(imp->amount2) {
+ retry=1;
+ while(retry) {
+ retry=0;
+ r.x=rand_get_double(&(moldyn->random))*x;
+ r.y=rand_get_double(&(moldyn->random))*y;
+ r.z=rand_get_double(&(moldyn->random))*z;
+ r.x+=x0;
+ r.y+=y0;
+ r.z+=z0;
+ dmin=1000.0; // for sure too high!
+ for(i=0;i<moldyn->count;i++) {
+ atom=&(moldyn->atom[i]);
+ v3_sub(&dist,&(atom->r),&r);
+ check_per_bound(moldyn,&dist);
+ d=v3_absolute_square(&dist);
+ if(d<c) {
+ retry=1;
+ break;
+ }
+ if(d<dmin)
+ dmin=d;
+
+ }
+ }
+ add_atom(moldyn,imp->element2,pse_mass[imp->element2],
+ imp->brand2,imp->attr2,&r,&v);
+ printf("%s (mixed) atom inserted (%d): %f %f %f\n",
+ ME,imp->amount2,r.x,r.y,r.z);
+ printf(" -> d2 = %f/%f\n",dmin,c);
+ imp->amount2-=1;
+ }
+ }
+
+ return 0;
+}
+
int chaatr(t_moldyn *moldyn,t_mdrun *mdrun) {
t_stage *stage;
u8 change_stage;
t_insert_atoms_params *iap;
+ t_insert_mixed_atoms_params *imp;
t_continue_params *cp;
t_anneal_params *ap;
insert_atoms(moldyn,mdrun);
iap->cnt_steps+=1;
break;
+
+
+
+ case STAGE_INSERT_MIXED_ATOMS:
+ stage_print(" -> insert mixed atoms\n\n");
+ imp=stage->params;
+ insert_mixed_atoms(moldyn,mdrun);
+ break;
+
+
+
case STAGE_CONTINUE:
stage_print(" -> continue\n\n");
if(stage->executed==TRUE) {
mdrun.m2,DEFAULT_ATOM_ATTR,1,mdrun.lx,
mdrun.ly,mdrun.lz,&o);
break;
+ case NONE:
+ break;
default:
printf("%s unknown lattice type: %02x\n",
ME,mdrun.lattice);