Project

General

Profile

this.patch

Chris Neale, 02/28/2013 12:39 AM

View differences:

./gmx_trjconv.c 2011-08-02 13:13:00.000000000 -0400
385 385
    }
386 386
}
387 387

  
388
static void center_x_com(int ecenter,rvec x[],matrix box,int n,int nc,atom_id ci[],t_atom atom[])
389
{
390
    int i,m,ai;
391
    rvec com,box_center,dx;
392
    real mtot;
393

  
394
    mtot=0.0;
395
    com[0]=com[1]=com[2]=0.0;
396
    if (nc > 0) {
397
        for(i=0; i<nc; i++) {
398
            ai=ci[i];
399
            for(m=0; m<DIM; m++) {
400
                com[m]+=atom[ai].m*x[ai][m];
401
            }
402
            mtot+=atom[ai].m;
403
        }
404
        calc_box_center(ecenter,box,box_center);
405
        for(m=0; m<DIM; m++)
406
            dx[m] = box_center[m]-com[m]/mtot;
407

  
408
        for(i=0; i<n; i++)
409
            rvec_inc(x[i],dx);
410

  
411
//fprintf(stderr,"want %f %f %f but have %f %f %f\n",box_center[0],box_center[1],box_center[2],
412
    }
413
}
414

  
388 415
static void mk_filenm(char *base,const char *ext,int ndigit,int file_nr,
389 416
                      char out_file[])
390 417
{
......
1291 1318
                                        rvec_inc(fr.x[i],x_shift);
1292 1319
                            }
1293 1320

  
1294
                            if (bCenter)
1295
                                center_x(ecenter,fr.x,fr.box,natoms,ncent,cindex);
1321
                            if (bCenter){
1322
                                //center_x(ecenter,fr.x,fr.box,natoms,ncent,cindex);
1323
                                center_x_com(ecenter,fr.x,fr.box,natoms,ncent,cindex,atoms->atom);
1324
                            }
1296 1325
                        }
1297 1326

  
1298 1327
                        if (bPBCcomAtom) {