return 0;
}
-del_stages(t_mdrun *mdrun) {
+int del_stages(t_mdrun *mdrun) {
t_list *sl;
t_stage *stage;
- sl=mdrun->stage;
+ sl=&(mdrun->stage);
list_reset_f(sl);
return 0;
}
-add_stage(t_mdrun *mdrun,u8 type,void *params) {
+int add_stage(t_mdrun *mdrun,u8 type,void *params) {
int psize;
psize=sizeof(t_chsattr_params);
break;
default:
-
+ printf("%s unknown stage type: %02x\n",ME,type);
+ return -1;
}
stage=malloc(sizeof(t_stage));
memcpy(stage->params,params,psize);
- list_add_immediate_f(mdrun->stage,stage);
+ list_add_immediate_f(&(mdrun->stage),stage);
return 0;
}
if((line[0]=='#')|(ret==1))
continue;
+ // reset
+ memset(&iap,0,sizeof(t_insert_atoms_params));
+ memset(&cp,0,sizeof(t_continue_params));
+ memset(&ap,0,sizeof(t_anneal_params));
+ memset(&cap,0,sizeof(t_chaattr_params));
+ memset(&csp,0,sizeof(t_chsattr_params));
+
// get command + args
wcnt=0;
while(1) {
else if(!strncmp(word[0],"aattr",5)) {
// for aatrib line we need a special stage
// containing one schedule of 0 loops ...
- if(!strncmp(word[1],"all",3)) {
- cap.type=
-
-
- HIER WEITER
+ for(i=0;i<strlen(word[1]);i++) {
+ switch(word[1][i]) {
+ case 't':
+ cap.type|=CHAATTR_TOTALV;
+ break;
+ case 'r':
+ cap.type|=CHAATTR_REGION;
+ break;
+ case 'e':
+ cap.type|=CHAATTR_ELEMENT;
+ break;
+ default:
+ break;
+ }
+ }
+ i=1;
+ if(cap.type&CHAATTR_REGION) {
+ cap.x0=atof(word[1]);
+ cap.y0=atof(word[2]);
+ cap.z0=atof(word[3]);
+ cap.x1=atof(word[4]);
+ cap.y1=atof(word[5]);
+ cap.z1=atof(word[6]);
+ i+=6;
}
- for(i=0;i<strlen(wptr)) {
+ if(cap.type&CHAATTR_ELEMENT) {
+ cap.element=atoi(word[i]);
+ i+=1;
+ }
+ wptr=word[i];
+ for(i=0;i<strlen(wptr);i++) {
switch(word[2][i]) {
case 'b':
cap.attr|=ATOM_ATTR_VB;
}
add_stage(mdrun,STAGE_CHAATTR,&cap);
}
- else if(!strncmp(word[0],"ectrl",5)) {
- mdrun->p_tau=atof(word[1]);
- mdrun->t_tau=atof(word[2]);
+ else if(!strncmp(word[0],"sattr",5)) {
+ // for satrib line we need a special stage
+ // containing one schedule of 0 loops ...
+ for(i=1;i<wcnt;i++) {
+ if(!strncmp(word[i],"pctrl",5)) {
+ csp.ptau=atof(word[++i]);
+ }
+ if(!strncmp(word[i],"tctrl",5)) {
+ csp.ttau=atof(word[++i]);
+ }
+ if(!strncmp(word[i],"prelax",6)) {
+ csp.dp=atof(word[++i]);
+ }
+ if(!strncmp(word[i],"trelax",6)) {
+ csp.dt=atof(word[++i]);
+ }
+ if(!strncmp(word[i],"rsteps",6)) {
+ csp.rsteps=atoi(word[++i]);
+ }
+ if(!strncmp(word[i],"avgrst",6)) {
+ csp.avgrst=atoi(word[++i]);
+ }
+ }
+ add_stage(mdrun,STAGE_CHSATTR,&csp);
}
else if(!strncmp(word[0],"prerun",6))
mdrun->prerun=atoi(word[1]);
mdrun->visualize=atoi(word[1]);
else if(!strncmp(word[0],"stage",5)) {
// for every stage line, add a stage
- printf("%s stage: %s\n",ME,word[1]);
+ if(!strncmp(word[1],"ins_atoms",9)) {
+ iap.ins_steps=atoi(word[2]);
+ iap.ins_atoms=atoi(word[3]);
+ iap.element=atoi(word[4]);
+ iap.element=atoi(word[4]);
+ iap.brand=atoi(word[5]);
+ for(i=0;i<strlen(word[6]);i++) {
+ switch(word[6][i]) {
+ case 'b':
+ iap.attr|=ATOM_ATTR_VB;
+ break;
+ case 'h':
+ iap.attr|=ATOM_ATTR_HB;
+ break;
+ case 'v':
+ iap.attr|=ATOM_ATTR_VA;
+ break;
+ case 'f':
+ iap.attr|=ATOM_ATTR_FP;
+ break;
+ case '1':
+ iap.attr|=ATOM_ATTR_1BP;
+ break;
+ case '2':
+ iap.attr|=ATOM_ATTR_2BP;
+ break;
+ case '3':
+ iap.attr|=ATOM_ATTR_3BP;
+ break;
+ default:
+ break;
+ }
+ }
+ // only rand mode by now
+ if(word[8][0]=='t')
+ iap.type=INS_TOTAL;
+ else {
+ iap.type=INS_REGION;
+ iap.x0=atof(word[8]);
+ iap.y0=atof(word[9]);
+ iap.z0=atof(word[10]);
+ iap.x1=atof(word[11]);
+ iap.y1=atof(word[12]);
+ iap.z1=atof(word[13]);
+ }
+ add_stage(mdrun,STAGE_INSERT_ATOMS,&iap);
+ }
+ else if(!strncmp(word[1],"continue",8)) {
+ cp.runs=atoi(word[2]);
+ add_stage(mdrun,STAGE_CONTINUE,&cp);
+ }
+ else if(!strncmp(word[1],"anneal",6)) {
+ ap.count=0;
+ ap.runs=atoi(word[2]);
+ ap.dt=atof(word[3]);
+ add_stage(mdrun,STAGE_ANNEAL,&ap);
+ }
+ else {
+ printf("%s unknown stage type: %s\n",
+ ME,word[1]);
+ return -1;
+ }
}
else {
- printf("%s unknown command %s, skipped!\n",ME,word[0]);
+ printf("%s unknown keyword '%s', skipped!\n",
+ ME,word[0]);
continue;
}
}
int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
- insert_atoms_params *iap;
+ t_insert_atoms_params *iap;
t_stage *stage;
t_atom *atom;
t_3dvec r,v,dist;
double x0,y0,z0;
u8 cr_check,run;
- stage=mdrun->stage->current->data;
+ stage=mdrun->stage.current->data;
iap=stage->params;
cr_check=FALSE;
cr_check=TRUE;
break;
default:
- printf("%s unknown insertion mode\n");
+ printf("%s unknown insertion mode: %02x\n",
+ ME,iap->type);
return -1;
}
return 0;
}
-int chaatrib(t_moldyn *moldyn,t_mdrun *mdrun) {
+int chaatr(t_moldyn *moldyn,t_mdrun *mdrun) {
t_stage *stage;
t_chaattr_params *cap;
t_atom *atom;
- u8 assigne;
+ int i;
- stage=mdrun->stage->current->data;
+ stage=mdrun->stage.current->data;
cap=stage->params;
for(i=0;i<moldyn->count;i++) {
t_stage *stage;
t_chsattr_params *csp;
- stage=mdrun->stage->current->data;
+ stage=mdrun->stage.current->data;
csp=stage->params;
- switch(csp->type) {
- case CHSATTR_PCTRL:
- set_p_scale(moldyn,csp->ctrl_type,csp->tau);
- break;
- case CHSATTR_TCTRL:
- set_t_scale(moldyn,csp->ctrl_type,csp->tau);
- break;
- case CHSATTR_PRELAX:
- mdrun->sattr&=(^(SATTR_PRELAX));
- if(csp->ctrl==TRUE)
- mdrun->sattr|=SATTR_PRELAX;
- break;
- case CHSATTR_TRELAX:
- mdrun->sattr&=(^(SATTR_TRELAX));
- if(csp->ctrl==TRUE)
- mdrun->sattr|=SATTR_TRELAX;
- break;
- case CHSATTR_AVGRST:
- mdrun->sattr&=(^(SATTR_AVGRST));
- if(csp->ctrl==TRUE)
- mdrun->sattr|=SATTR_AVGRST;
- break;
- default:
- printf("%s unknown system attribute change\n",ME);
- return -1;
+ if(csp->type&CHSATTR_PCTRL) {
+ if(csp->ptau>0)
+ set_p_scale(moldyn,P_SCALE_BERENDSEN,csp->ptau);
+ else
+ set_p_scale(moldyn,P_SCALE_BERENDSEN,csp->ptau);
+ }
+ if(csp->type&CHSATTR_TCTRL) {
+ if(csp->ttau>0)
+ set_t_scale(moldyn,T_SCALE_BERENDSEN,csp->ttau);
+ else
+ set_t_scale(moldyn,T_SCALE_BERENDSEN,csp->ttau);
+ }
+ if(csp->type&CHSATTR_PRELAX) {
+ if(csp->dp<0)
+ mdrun->sattr&=(~(SATTR_PRELAX));
+ else
+ mdrun->sattr|=SATTR_PRELAX;
+ mdrun->dp=csp->dp;
+ }
+ if(csp->type&CHSATTR_TRELAX) {
+ if(csp->dt<0)
+ mdrun->sattr&=(~(SATTR_TRELAX));
+ else
+ mdrun->sattr|=SATTR_TRELAX;
+ mdrun->dt=csp->dt;
+ }
+ if(csp->type&CHSATTR_AVGRST) {
+ if(csp->avgrst)
+ mdrun->sattr|=CHSATTR_AVGRST;
+ else
+ mdrun->sattr&=(~(CHSATTR_AVGRST));
+ }
+ if(csp->type&CHSATTR_RSTEPS) {
+ mdrun->relax_steps=csp->rsteps;
}
return 0;
}
-int mdrun_hook(t_moldyn *moldyn,void *ptr) {
+int mdrun_hook(void *ptr1,void *ptr2) {
+ t_moldyn *moldyn;
t_mdrun *mdrun;
t_stage *stage;
t_list *sl;
t_continue_params *cp;
t_anneal_params *ap;
- mdrun=ptr;
- sl=mdrun->stage;
+ moldyn=ptr1;
+ mdrun=ptr2;
+
+ sl=&(mdrun->stage);
change_stage=FALSE;
return 0;
/* get stage description */
- stage=mdrun->sl->current->data;
+ stage=sl->current->data;
/* default steps and tau values */
steps=mdrun->relax_steps;
tau=mdrun->timestep;
/* check whether relaxation steps are necessary */
- if(!((check_pressure==FALSE)|(check_temperature==FALSE))) {
+ if(!((check_pressure(moldyn,mdrun)==FALSE)|\
+ (check_temperature(moldyn,mdrun)==FALSE))) {
/* stage specific stuff */
switch(stage->type) {
ap->count+=1;
break;
case STAGE_CHAATTR:
- chaatrib(moldyn,mdrun);
+ chaatr(moldyn,mdrun);
change_stage=TRUE;
break;
case STAGE_CHSATTR:
- chsatrib(moldyn,mdrun);
+ chsattr(moldyn,mdrun);
change_stage=TRUE;
break;
default:
mdrun.ly,mdrun.lz,&o);
o.x+=0.25*mdrun.lc; o.y=o.x; o.z=o.x;
create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element2,
- mdrun.m2,0,0,mdrun.lx,
+ mdrun.m2,0,1,mdrun.lx,
mdrun.ly,mdrun.lz,&o);
break;
default:
moldyn_set_log(&moldyn,CREATE_REPORT,0);
set_avg_skip(&moldyn,mdrun.avgskip);
- /* pt scaling */
- if(mdrun.p_tau!=0)
- set_p_scale(&moldyn,P_SCALE_BERENDSEN,mdrun.p_tau);
- if(mdrun.t_tau!=0)
- set_t_scale(&moldyn,T_SCALE_BERENDSEN,mdrun.t_tau);
-
/* prepare the hook function */
moldyn_set_schedule_hook(&moldyn,&mdrun_hook,&mdrun);