real do_opt_pppm(FILE *log, bool bVerbose, t_inputrec *ir, int natoms, rvec x[], rvec f[], real charge[], rvec box, real phi[], t_commrec *cr, t_nrnb *nrnb, rvec beta, t_fftgrid *grid, bool bOld) { real ***ghat; int nx,ny,nz; real ener; ener = 0.0; fprintf(log,"Generating Ghat function\n"); nx = ir->nkx; ny = ir->nky; nz = ir->nkz; ghat = mk_rgrid(nx,ny,nz); mk_ghat(NULL,nx,ny,nz,ghat,box,ir->rcoulomb_switch,ir->rcoulomb,TRUE,bOld); /* pr_scalar_gk("generghat.xvg",nx,ny,nz,box,ghat); */ /* Now start the actual PPPM procedure. * First step: spreading the charges over the grid. */ /* Make the grid empty */ clear_fftgrid(grid); spread_q(log,bVerbose,0,natoms,x,charge,box,grid,nrnb); /* Second step: solving the poisson equation in Fourier space */ solve_pppm(log,cr,grid,ghat,box,bVerbose,nrnb); /* Third and last step: gather the forces, energies and potential * from the grid. */ ener=gather_f(log,bVerbose,0,natoms,x,f,charge,box,phi,grid,beta,nrnb); free_rgrid(ghat,nx,ny); return ener; }
int gmx_pppm_do(FILE *log, gmx_pme_t pme, gmx_bool bVerbose, rvec x[], rvec f[], real charge[], rvec box, real phi[], t_commrec *cr, int start, int nr, t_nrnb *nrnb, int pme_order, real *energy) { #ifdef DISABLE_PPPM gmx_fatal(FARGS,"PPPM temporarily disabled while working on 2DPME\n"); return -1; #else /* Make the grid empty */ clear_fftgrid(grid); /* First step: spreading the charges over the grid. */ spread_q(log,bVerbose,start,nr,x,charge,box,grid,nrnb); /* In the parallel code we have to sum the grids from neighbouring nodes */ if (PAR(cr)) gmx_sum_qgrid(pme,cr,grid,GMX_SUM_QGRID_FORWARD); /* Second step: solving the poisson equation in Fourier space */ solve_pppm(log,cr,grid,ghat,box,bVerbose,nrnb); /* In the parallel code we have to sum once again... */ if (PAR(cr)) gmx_sum_qgrid(pme,cr,grid,GMX_SUM_QGRID_BACKWARD); /* Third and last step: gather the forces, energies and potential * from the grid. */ *energy = gather_f(log,bVerbose,start,nr,x,f,charge,box, phi,grid,beta,nrnb); return 0; #endif }
real do_pppm(FILE *log, bool bVerbose, rvec x[], rvec f[], real charge[], rvec box, real phi[], t_commrec *cr, t_nsborder *nsb, t_nrnb *nrnb) { real ener; int start,nr; start = START(nsb); nr = HOMENR(nsb); /* Make the grid empty */ clear_fftgrid(grid); /* First step: spreading the charges over the grid. */ spread_q(log,bVerbose,start,nr,x,charge,box,grid,nrnb); /* In the parallel code we have to sum the grids from neighbouring nodes */ if (PAR(cr)) sum_qgrid(cr,nsb,grid,TRUE); /* Second step: solving the poisson equation in Fourier space */ solve_pppm(log,cr,grid,ghat,box,bVerbose,nrnb); /* In the parallel code we have to sum once again... */ if (PAR(cr)) sum_qgrid(cr,nsb,grid,FALSE); /* Third and last step: gather the forces, energies and potential * from the grid. */ ener=gather_f(log,bVerbose,start,nr,x,f,charge,box,phi,grid,beta,nrnb); return ener; }