case STAGE_THERMAL_INIT:
psize=0;
break;
+ case STAGE_CONSTRAINT_RELAXATION_TECHNIQUE:
+ psize=sizeof(t_constraint_relaxation_technique);
+ break;
default:
printf("%s unknown stage type: %02x\n",ME,type);
return -1;
t_set_timestep_params stsp;
t_fill_params fp;
t_del_atoms_params delp;
+ t_crt_params crtp;
/* open config file */
fd=open(mdrun->cfile,O_RDONLY);
memset(&stsp,0,sizeof(t_set_timestep_params));
memset(&fp,0,sizeof(t_fill_params));
memset(&delp,0,sizeof(t_del_atoms_params));
+ memset(&crtp,0,sizeof(t_crt_params));
// get command + args
wcnt=0;
stsp.tau=atof(word[2]);
add_stage(mdrun,STAGE_SET_TIMESTEP,&stsp);
}
+ else if(!strncmp(word[1],"crt",3)) {
+ crtp.type=atoi(word[2]);
+ crtp.steps=atoi(word[3]);
+ strncpy(crtp.file,word[4],127);
+ add_stage(mdrun,STAGE_CRT,&crtp);
+ }
else {
printf("%s unknown stage type: %s\n",
ME,word[1]);
return 0;
}
+int crt(t_moldyn *moldyn,t_mdrun *mdrun) {
+
+ t_stage *stage;
+ t_crt_params *crtp;
+
+ int fd;
+ char line[128];
+ char *wptr;
+ int acount;
+ int ret;
+ void *ptr;
+
+ extern u8 crt;
+ extern u8 *constraints;
+ extern double *trafo_angles;
+
+ t_atom *atom;
+ double dx,dy,dz;
+
+ stage=mdrun->stage.current->data;
+ crtp=stage->params;
+
+ acount=0;
+
+ /* initial stuff */
+
+ if(crtp->count==0) {
+ printf(" crt init\n",acount);
+ // read final positions, constraints and do the alloc
+ fd=open(crtp->file,O_RDONLY);
+ if(fd<0) {
+ perror("[mdrun] FATAL reading constraints file");
+ return fd;
+ }
+ while(1) {
+ ret=get_line(fd,line,128);
+ // check for end of file
+ if(ret<=0) {
+ printf(" -> read %d atom positions\n",acount);
+ crtp->acnt=acount;
+ break;
+ }
+ // ignore # lines and \n
+ if((line[0]=='#')|(ret==1))
+ continue;
+ // allocate new memory
+ ptr=realloc(crtp->r_fin,(acount+1)*sizeof(t_3dvec));
+ if(ptr==NULL) {
+ perror("[mdrun] FATAL realloc crt positions");
+ return -1;
+ }
+ crtp->r_fin=ptr;
+ ptr=realloc(constraints,(acount+1)*3*sizeof(u8));
+ if(ptr==NULL) {
+ perror("[mdrun] FATAL realloc crt constraints");
+ return -1;
+ }
+ constraints=ptr;
+ // ignore type
+ wptr=strtok(line," \t");
+ // read x y z
+ wptr=strtok(NULL," \t");
+ crtp->r_fin.x=atof(wptr);
+ wptr=strtok(NULL," \t");
+ crtp->r_fin.y=atof(wptr);
+ wptr=strtok(NULL," \t");
+ crtp->r_fin.z=atof(wptr);
+ // read constraints
+ wptr=strtok(NULL," \t");
+ constraints[acount]=atoi(wptr);
+ wptr=strtok(NULL," \t");
+ constraints[acount+1]=atoi(wptr);
+ wptr=strtok(NULL," \t");
+ constraints[acount+2]=atoi(wptr);
+ // done reading
+ acount+=1;
+ }
+ // allocate trafo angles
+ trafo_angle=malloc(acount*2*sizeof(double));
+ if(trafo_angle==NULL) {
+ perror("[mdrun] FATAL alloc trafo angles");
+ return -1;
+ }
+ // set crt mode
+ crt=crtp->type;
+ }
+
+ /* crt routines: calculate displacement + set individual constraints */
+
+ for(i=0;i<moldyn->count;i++) {
+ atom=moldyn->atom;
+ dx=atom[i].r.x-crtp->r_fin[i].x;
+ dy=atom[i].r.y-crtp->r_fin[i].y;
+ dz=atom[i].r.z-crtp->r_fin[i].z;
+ // HIER WEITER
+ }
+
+ return 0;
+}
+
#define stage_print(m) if(!(stage->executed)) \
printf("%s",m)
thermal_init(moldyn,TRUE);
change_stage=TRUE;
break;
+ case STAGE_CRT:
+ stage_print(" -> constraint relaxation")
+ stage_print(" technique\n\n");
+ crtp=stage->params;
+ if(crtp->count==crtp->steps) {
+ change_stage=TRUE;
+ break;
+ }
+ crt(moldyn,mdrun);
+ crtp->count+=1;
+ break;
default:
printf("%s unknwon stage type\n",ME);
break;