From fe84cdc3fc897581636aff89b6f4fd12db1d2718 Mon Sep 17 00:00:00 2001 From: hackbard Date: Thu, 20 May 2010 16:54:35 +0200 Subject: [PATCH] introduced crt type 2 (initial diplacement vector for constraints) + write out crt save files --- mdrun.c | 28 +++++++++++++++++++++++++--- moldyn.c | 3 --- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/mdrun.c b/mdrun.c index 3266dd3..bb1cd21 100644 --- a/mdrun.c +++ b/mdrun.c @@ -1286,6 +1286,7 @@ int crt(t_moldyn *moldyn,t_mdrun *mdrun) { // done reading acount+=1; } + close(fd); // allocate trafo angles trafo_angle=malloc(acount*2*sizeof(double)); if(trafo_angle==NULL) { @@ -1296,18 +1297,39 @@ int crt(t_moldyn *moldyn,t_mdrun *mdrun) { crtt=crtp->type; } + /* write a save file s-crt_xofy.save */ + snprintf(line,128,"%s/s-crt_%03dof%03d.save", + moldyn->vlsdir,crtp->count,crtp->steps); + fd=open(line,O_WRONLY|O_TRUNC|O_CREAT,S_IRUSR|S_IWUSR); + if(fd<0) perror("[mdrun] crt save fd open"); + else { + write(fd,moldyn,sizeof(t_moldyn)); + write(fd,moldyn->atom, + moldyn->count*sizeof(t_atom)); + } + close(fd); + + /* output energy */ + printf(" crt energy: %d - %f\n\n", + crtp->count,(moldyn->ekin+moldyn->energy)/EV); + /* crt routines: calculate displacement + set individual constraints */ printf(" crt step %d of %d in total\n\n",crtp->count+1,crtp->steps); + if((crtp->type==1)|(crtp->count==0)) + printf(" crt angle update\n\n"); + for(i=0;icount;i++) { // calc displacements atom=moldyn->atom; v3_sub(&disp,&(crtp->r_fin[i]),&(atom[i].r)); // angles - trafo_angle[2*i]=atan2(disp.x,disp.y); - trafo_angle[2*i+1]=-atan2(disp.z, - sqrt(disp.x*disp.x+disp.y*disp.y)); + if((crtp->type==1)|(crtp->count==0)) { + trafo_angle[2*i]=atan2(disp.x,disp.y); + trafo_angle[2*i+1]=-atan2(disp.z, + sqrt(disp.x*disp.x+disp.y*disp.y)); + } // move atoms frac=1.0/(crtp->steps-crtp->count); v3_scale(&disp,&disp,frac); diff --git a/moldyn.c b/moldyn.c index a6f5c45..d715c52 100644 --- a/moldyn.c +++ b/moldyn.c @@ -83,9 +83,6 @@ int moldyn_init(t_moldyn *moldyn,int argc,char **argv) { pthread_mutex_init(&emutex,NULL); #endif - if(crtt) - printf("USING CRT\n"); - return 0; } -- 2.20.1