本文整理汇总了C++中DOMAINDECOMP函数的典型用法代码示例。如果您正苦于以下问题:C++ DOMAINDECOMP函数的具体用法?C++ DOMAINDECOMP怎么用?C++ DOMAINDECOMP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DOMAINDECOMP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pull_set_pbcatom
static void pull_set_pbcatom(t_commrec *cr, t_pull_group *pgrp,
t_mdatoms *md, rvec *x,
rvec x_pbc)
{
int a, m;
if (cr && PAR(cr))
{
if (DOMAINDECOMP(cr))
{
if (!ga2la_get_home(cr->dd->ga2la, pgrp->pbcatom, &a))
{
a = -1;
}
}
else
{
a = pgrp->pbcatom;
}
if (a >= 0 && a < md->homenr)
{
copy_rvec(x[a], x_pbc);
}
else
{
clear_rvec(x_pbc);
}
}
else
{
copy_rvec(x[pgrp->pbcatom], x_pbc);
}
}
示例2: make_local_shells
void make_local_shells(t_commrec *cr,t_mdatoms *md,
struct gmx_shellfc *shfc)
{
t_shell *shell;
int a0,a1,*ind,nshell,i;
gmx_domdec_t *dd=NULL;
if (PAR(cr)) {
if (DOMAINDECOMP(cr)) {
dd = cr->dd;
a0 = 0;
a1 = dd->nat_home;
} else {
pd_at_range(cr,&a0,&a1);
}
} else {
/* Single node: we need all shells, just copy the pointer */
shfc->nshell = shfc->nshell_gl;
shfc->shell = shfc->shell_gl;
return;
}
ind = shfc->shell_index_gl;
nshell = 0;
shell = shfc->shell;
for(i=a0; i<a1; i++) {
if (md->ptype[i] == eptShell) {
if (nshell+1 > shfc->shell_nalloc) {
shfc->shell_nalloc = over_alloc_dd(nshell+1);
srenew(shell,shfc->shell_nalloc);
}
if (dd) {
shell[nshell] = shfc->shell_gl[ind[dd->gatindex[i]]];
} else {
shell[nshell] = shfc->shell_gl[ind[i]];
}
/* With inter-cg shells we can no do shell prediction,
* so we do not need the nuclei numbers.
*/
if (!shfc->bInterCG) {
shell[nshell].nucl1 = i + shell[nshell].nucl1 - shell[nshell].shell;
if (shell[nshell].nnucl > 1)
shell[nshell].nucl2 = i + shell[nshell].nucl2 - shell[nshell].shell;
if (shell[nshell].nnucl > 2)
shell[nshell].nucl3 = i + shell[nshell].nucl3 - shell[nshell].shell;
}
shell[nshell].shell = i;
nshell++;
}
}
shfc->nshell = nshell;
shfc->shell = shell;
}
示例3: do_redist_pos_coeffs
void
do_redist_pos_coeffs(struct gmx_pme_t *pme, t_commrec *cr, int start, int homenr,
gmx_bool bFirst, rvec x[], real *data)
{
int d;
pme_atomcomm_t *atc;
atc = &pme->atc[0];
for (d = pme->ndecompdim - 1; d >= 0; d--)
{
int n_d;
rvec *x_d;
real *param_d;
if (d == pme->ndecompdim - 1)
{
n_d = homenr;
x_d = x + start;
param_d = data;
}
else
{
n_d = pme->atc[d + 1].n;
x_d = atc->x;
param_d = atc->coefficient;
}
atc = &pme->atc[d];
atc->npd = n_d;
if (atc->npd > atc->pd_nalloc)
{
atc->pd_nalloc = over_alloc_dd(atc->npd);
srenew(atc->pd, atc->pd_nalloc);
}
pme_calc_pidx_wrapper(n_d, pme->recipbox, x_d, atc);
where();
/* Redistribute x (only once) and qA/c6A or qB/c6B */
if (DOMAINDECOMP(cr))
{
dd_pmeredist_pos_coeffs(pme, n_d, bFirst, x_d, param_d, atc);
}
}
}
示例4: pull_potential
real pull_potential(int ePull,t_pull *pull, t_mdatoms *md, t_pbc *pbc,
t_commrec *cr, double t, real lambda,
rvec *x, rvec *f, tensor vir, real *dvdlambda)
{
real V,dVdl;
pull_calc_coms(cr,pull,md,pbc,t,x,NULL);
do_pull_pot(ePull,pull,pbc,t,lambda,
&V,pull->bVirial && MASTER(cr) ? vir : NULL,&dVdl);
/* Distribute forces over pulled groups */
apply_forces(pull, md, DOMAINDECOMP(cr) ? cr->dd->ga2la : NULL, f);
if (MASTER(cr)) {
*dvdlambda += dVdl;
}
return (MASTER(cr) ? V : 0.0);
}
示例5: pull_set_pbcatom
static void pull_set_pbcatom(t_commrec *cr, pull_group_work_t *pgrp,
rvec *x,
rvec x_pbc)
{
int a;
if (cr != NULL && DOMAINDECOMP(cr))
{
if (ga2la_get_home(cr->dd->ga2la, pgrp->params.pbcatom, &a))
{
copy_rvec(x[a], x_pbc);
}
else
{
clear_rvec(x_pbc);
}
}
else
{
copy_rvec(x[pgrp->params.pbcatom], x_pbc);
}
}
示例6: do_force_lowlevel
//.........这里部分代码省略.........
* but we do so anyhow for consistency of the returned coordinates.
*/
if (graph)
{
shift_self(graph, box, x);
if (TRICLINIC(box))
{
inc_nrnb(nrnb, eNR_SHIFTX, 2*graph->nnodes);
}
else
{
inc_nrnb(nrnb, eNR_SHIFTX, graph->nnodes);
}
}
/* Check whether we need to do bondeds or correct for exclusions */
if (fr->bMolPBC &&
((flags & GMX_FORCE_BONDED)
|| EEL_RF(fr->eeltype) || EEL_FULL(fr->eeltype)))
{
/* Since all atoms are in the rectangular or triclinic unit-cell,
* only single box vector shifts (2 in x) are required.
*/
set_pbc_dd(&pbc, fr->ePBC, cr->dd, TRUE, box);
}
debug_gmx();
if (flags & GMX_FORCE_BONDED)
{
GMX_MPE_LOG(ev_calc_bonds_start);
wallcycle_sub_start(wcycle, ewcsBONDED);
calc_bonds(fplog, cr->ms,
idef, x, hist, f, fr, &pbc, graph, enerd, nrnb, lambda, md, fcd,
DOMAINDECOMP(cr) ? cr->dd->gatindex : NULL, atype, born,
flags,
fr->bSepDVDL && do_per_step(step, ir->nstlog), step);
/* Check if we have to determine energy differences
* at foreign lambda's.
*/
if (fepvals->n_lambda > 0 && (flags & GMX_FORCE_DHDL) &&
idef->ilsort != ilsortNO_FE)
{
if (idef->ilsort != ilsortFE_SORTED)
{
gmx_incons("The bonded interactions are not sorted for free energy");
}
for (i = 0; i < enerd->n_lambda; i++)
{
reset_foreign_enerdata(enerd);
for (j = 0; j < efptNR; j++)
{
lam_i[j] = (i == 0 ? lambda[j] : fepvals->all_lambda[j][i-1]);
}
calc_bonds_lambda(fplog, idef, x, fr, &pbc, graph, &(enerd->foreign_grpp), enerd->foreign_term, nrnb, lam_i, md,
fcd, DOMAINDECOMP(cr) ? cr->dd->gatindex : NULL);
sum_epot(&ir->opts, &(enerd->foreign_grpp), enerd->foreign_term);
enerd->enerpart_lambda[i] += enerd->foreign_term[F_EPOT];
}
}
debug_gmx();
GMX_MPE_LOG(ev_calc_bonds_finish);
wallcycle_sub_stop(wcycle, ewcsBONDED);
}
where();
示例7: do_force_lowlevel
//.........这里部分代码省略.........
/* Here sometimes we would not need to shift with NBFonly,
* but we do so anyhow for consistency of the returned coordinates.
*/
if (graph)
{
shift_self(graph, box, x);
if (TRICLINIC(box))
{
inc_nrnb(nrnb, eNR_SHIFTX, 2*graph->nnodes);
}
else
{
inc_nrnb(nrnb, eNR_SHIFTX, graph->nnodes);
}
}
/* Check whether we need to do listed interactions or correct for exclusions */
if (fr->bMolPBC &&
((flags & GMX_FORCE_LISTED)
|| EEL_RF(fr->eeltype) || EEL_FULL(fr->eeltype) || EVDW_PME(fr->vdwtype)))
{
/* TODO There are no electrostatics methods that require this
transformation, when using the Verlet scheme, so update the
above conditional. */
/* Since all atoms are in the rectangular or triclinic unit-cell,
* only single box vector shifts (2 in x) are required.
*/
set_pbc_dd(&pbc, fr->ePBC, cr->dd, TRUE, box);
}
debug_gmx();
do_force_listed(wcycle, box, ir->fepvals, cr->ms,
idef, (const rvec *) x, hist, f, fr,
&pbc, graph, enerd, nrnb, lambda, md, fcd,
DOMAINDECOMP(cr) ? cr->dd->gatindex : NULL,
flags);
where();
*cycles_pme = 0;
clear_mat(fr->vir_el_recip);
clear_mat(fr->vir_lj_recip);
/* Do long-range electrostatics and/or LJ-PME, including related short-range
* corrections.
*/
if (EEL_FULL(fr->eeltype) || EVDW_PME(fr->vdwtype))
{
int status = 0;
real Vlr_q = 0, Vlr_lj = 0, Vcorr_q = 0, Vcorr_lj = 0;
real dvdl_long_range_q = 0, dvdl_long_range_lj = 0;
bSB = (ir->nwall == 2);
if (bSB)
{
copy_mat(box, boxs);
svmul(ir->wall_ewald_zfac, boxs[ZZ], boxs[ZZ]);
box_size[ZZ] *= ir->wall_ewald_zfac;
}
if (EEL_PME_EWALD(fr->eeltype) || EVDW_PME(fr->vdwtype))
{
real dvdl_long_range_correction_q = 0;
real dvdl_long_range_correction_lj = 0;
/* With the Verlet scheme exclusion forces are calculated
* in the non-bonded kernel.
*/
示例8: mdoutf_write_to_trajectory_files
void mdoutf_write_to_trajectory_files(FILE *fplog, t_commrec *cr,
gmx_mdoutf_t of,
int mdof_flags,
gmx_mtop_t *top_global,
gmx_int64_t step, double t,
t_state *state_local, t_state *state_global,
rvec *f_local, rvec *f_global)
{
rvec *local_v;
rvec *global_v;
/* MRS -- defining these variables is to manage the difference
* between half step and full step velocities, but there must be a better way . . . */
local_v = state_local->v;
global_v = state_global->v;
if (DOMAINDECOMP(cr))
{
if (mdof_flags & MDOF_CPT)
{
dd_collect_state(cr->dd, state_local, state_global);
}
else
{
if (mdof_flags & (MDOF_X | MDOF_X_COMPRESSED))
{
dd_collect_vec(cr->dd, state_local, state_local->x,
state_global->x);
}
if (mdof_flags & MDOF_V)
{
dd_collect_vec(cr->dd, state_local, local_v,
global_v);
}
}
if (mdof_flags & MDOF_F)
{
dd_collect_vec(cr->dd, state_local, f_local, f_global);
}
}
else
{
if (mdof_flags & MDOF_CPT)
{
/* All pointers in state_local are equal to state_global,
* but we need to copy the non-pointer entries.
*/
state_global->lambda = state_local->lambda;
state_global->veta = state_local->veta;
state_global->vol0 = state_local->vol0;
copy_mat(state_local->box, state_global->box);
copy_mat(state_local->boxv, state_global->boxv);
copy_mat(state_local->svir_prev, state_global->svir_prev);
copy_mat(state_local->fvir_prev, state_global->fvir_prev);
copy_mat(state_local->pres_prev, state_global->pres_prev);
}
}
if (MASTER(cr))
{
if (mdof_flags & MDOF_CPT)
{
fflush_tng(of->tng);
fflush_tng(of->tng_low_prec);
write_checkpoint(of->fn_cpt, of->bKeepAndNumCPT,
fplog, cr, of->eIntegrator, of->simulation_part,
of->bExpanded, of->elamstats, step, t, state_global);
}
if (mdof_flags & (MDOF_X | MDOF_V | MDOF_F))
{
if (of->fp_trn)
{
gmx_trr_write_frame(of->fp_trn, step, t, state_local->lambda[efptFEP],
state_local->box, top_global->natoms,
(mdof_flags & MDOF_X) ? state_global->x : NULL,
(mdof_flags & MDOF_V) ? global_v : NULL,
(mdof_flags & MDOF_F) ? f_global : NULL);
if (gmx_fio_flush(of->fp_trn) != 0)
{
gmx_file("Cannot write trajectory; maybe you are out of disk space?");
}
}
gmx_fwrite_tng(of->tng, FALSE, step, t, state_local->lambda[efptFEP],
state_local->box,
top_global->natoms,
(mdof_flags & MDOF_X) ? state_global->x : NULL,
(mdof_flags & MDOF_V) ? global_v : NULL,
(mdof_flags & MDOF_F) ? f_global : NULL);
}
if (mdof_flags & MDOF_X_COMPRESSED)
{
rvec *xxtc = NULL;
if (of->natoms_x_compressed == of->natoms_global)
{
/* We are writing the positions of all of the atoms to
the compressed output */
//.........这里部分代码省略.........
示例9: pme_loadbal_do
void pme_loadbal_do(pme_load_balancing_t *pme_lb,
t_commrec *cr,
FILE *fp_err,
FILE *fp_log,
t_inputrec *ir,
t_forcerec *fr,
t_state *state,
gmx_wallcycle_t wcycle,
gmx_int64_t step,
gmx_int64_t step_rel,
gmx_bool *bPrinting)
{
int n_prev;
double cycles_prev;
assert(pme_lb != NULL);
if (!pme_lb->bActive)
{
return;
}
n_prev = pme_lb->cycles_n;
cycles_prev = pme_lb->cycles_c;
wallcycle_get(wcycle, ewcSTEP, &pme_lb->cycles_n, &pme_lb->cycles_c);
if (pme_lb->cycles_n == 0)
{
/* Before the first step we haven't done any steps yet */
return;
}
/* Sanity check, we expect nstlist cycle counts */
if (pme_lb->cycles_n - n_prev != ir->nstlist)
{
/* We could return here, but it's safer to issue and error and quit */
gmx_incons("pme_loadbal_do called at an interval != nstlist");
}
/* PME grid + cut-off optimization with GPUs or PME ranks */
if (!pme_lb->bBalance && pme_lb->bSepPMERanks)
{
if (pme_lb->bTriggerOnDLB)
{
pme_lb->bBalance = dd_dlb_is_on(cr->dd);
}
/* We should ignore the first timing to avoid timing allocation
* overhead. And since the PME load balancing is called just
* before DD repartitioning, the ratio returned by dd_pme_f_ratio
* is not over the last nstlist steps, but the nstlist steps before
* that. So the first useful ratio is available at step_rel=3*nstlist.
*/
else if (step_rel >= 3*ir->nstlist)
{
if (DDMASTER(cr->dd))
{
/* If PME rank load is too high, start tuning */
pme_lb->bBalance =
(dd_pme_f_ratio(cr->dd) >= loadBalanceTriggerFactor);
}
dd_bcast(cr->dd, sizeof(gmx_bool), &pme_lb->bBalance);
}
pme_lb->bActive = (pme_lb->bBalance ||
step_rel <= pme_lb->step_rel_stop);
}
/* The location in the code of this balancing termination is strange.
* You would expect to have it after the call to pme_load_balance()
* below, since there pme_lb->stage is updated.
* But when terminating directly after deciding on and selecting the
* optimal setup, DLB will turn on right away if it was locked before.
* This might be due to PME reinitialization. So we check stage here
* to allow for another nstlist steps with DLB locked to stabilize
* the performance.
*/
if (pme_lb->bBalance && pme_lb->stage == pme_lb->nstage)
{
pme_lb->bBalance = FALSE;
if (DOMAINDECOMP(cr) && dd_dlb_is_locked(cr->dd))
{
/* Unlock the DLB=auto, DLB is allowed to activate */
dd_dlb_unlock(cr->dd);
md_print_warn(cr, fp_log, "NOTE: DLB can now turn on, when beneficial\n");
/* We don't deactivate the tuning yet, since we will balance again
* after DLB gets turned on, if it does within PMETune_period.
*/
continue_pme_loadbal(pme_lb, TRUE);
pme_lb->bTriggerOnDLB = TRUE;
pme_lb->step_rel_stop = step_rel + PMETunePeriod*ir->nstlist;
}
else
{
/* We're completely done with PME tuning */
pme_lb->bActive = FALSE;
}
if (DOMAINDECOMP(cr))
{
/* Set the cut-off limit to the final selected cut-off,
//.........这里部分代码省略.........
示例10: pull_calc_coms
/* calculates center of mass of selection index from all coordinates x */
void pull_calc_coms(t_commrec *cr,
struct pull_t *pull, t_mdatoms *md, t_pbc *pbc, double t,
rvec x[], rvec *xp)
{
int g;
real twopi_box = 0;
pull_comm_t *comm;
comm = &pull->comm;
if (comm->rbuf == NULL)
{
snew(comm->rbuf, pull->ngroup);
}
if (comm->dbuf == NULL)
{
snew(comm->dbuf, 3*pull->ngroup);
}
if (pull->bRefAt && pull->bSetPBCatoms)
{
pull_set_pbcatoms(cr, pull, x, comm->rbuf);
if (cr != NULL && DOMAINDECOMP(cr))
{
/* We can keep these PBC reference coordinates fixed for nstlist
* steps, since atoms won't jump over PBC.
* This avoids a global reduction at the next nstlist-1 steps.
* Note that the exact values of the pbc reference coordinates
* are irrelevant, as long all atoms in the group are within
* half a box distance of the reference coordinate.
*/
pull->bSetPBCatoms = FALSE;
}
}
if (pull->cosdim >= 0)
{
int m;
assert(pull->npbcdim <= DIM);
for (m = pull->cosdim+1; m < pull->npbcdim; m++)
{
if (pbc->box[m][pull->cosdim] != 0)
{
gmx_fatal(FARGS, "Can not do cosine weighting for trilinic dimensions");
}
}
twopi_box = 2.0*M_PI/pbc->box[pull->cosdim][pull->cosdim];
}
for (g = 0; g < pull->ngroup; g++)
{
pull_group_work_t *pgrp;
pgrp = &pull->group[g];
if (pgrp->bCalcCOM)
{
if (pgrp->epgrppbc != epgrppbcCOS)
{
dvec com, comp;
double wmass, wwmass;
rvec x_pbc = { 0, 0, 0 };
int i;
clear_dvec(com);
clear_dvec(comp);
wmass = 0;
wwmass = 0;
if (pgrp->epgrppbc == epgrppbcREFAT)
{
/* Set the pbc atom */
copy_rvec(comm->rbuf[g], x_pbc);
}
for (i = 0; i < pgrp->nat_loc; i++)
{
int ii, m;
real mass, wm;
ii = pgrp->ind_loc[i];
mass = md->massT[ii];
if (pgrp->weight_loc == NULL)
{
wm = mass;
wmass += wm;
}
else
{
real w;
w = pgrp->weight_loc[i];
wm = w*mass;
wmass += wm;
wwmass += wm*w;
}
//.........这里部分代码省略.........
示例11: make_cyl_refgrps
static void make_cyl_refgrps(t_commrec *cr, t_pull *pull, t_mdatoms *md,
t_pbc *pbc, double t, rvec *x, rvec *xp)
{
int c, i, ii, m, start, end;
rvec g_x, dx, dir;
double r0_2, sum_a, sum_ap, dr2, mass, weight, wmass, wwmass, inp;
t_pull_coord *pcrd;
t_pull_group *pref, *pgrp, *pdyna;
gmx_ga2la_t ga2la = NULL;
if (pull->dbuf_cyl == NULL)
{
snew(pull->dbuf_cyl, pull->ncoord*4);
}
if (cr && DOMAINDECOMP(cr))
{
ga2la = cr->dd->ga2la;
}
start = 0;
end = md->homenr;
r0_2 = dsqr(pull->cyl_r0);
/* loop over all groups to make a reference group for each*/
for (c = 0; c < pull->ncoord; c++)
{
pcrd = &pull->coord[c];
/* pref will be the same group for all pull coordinates */
pref = &pull->group[pcrd->group[0]];
pgrp = &pull->group[pcrd->group[1]];
pdyna = &pull->dyna[c];
copy_rvec(pcrd->vec, dir);
sum_a = 0;
sum_ap = 0;
wmass = 0;
wwmass = 0;
pdyna->nat_loc = 0;
for (m = 0; m < DIM; m++)
{
g_x[m] = pgrp->x[m] - pcrd->vec[m]*(pcrd->init + pcrd->rate*t);
}
/* loop over all atoms in the main ref group */
for (i = 0; i < pref->nat; i++)
{
ii = pref->ind[i];
if (ga2la)
{
if (!ga2la_get_home(ga2la, pref->ind[i], &ii))
{
ii = -1;
}
}
if (ii >= start && ii < end)
{
pbc_dx_aiuc(pbc, x[ii], g_x, dx);
inp = iprod(dir, dx);
dr2 = 0;
for (m = 0; m < DIM; m++)
{
dr2 += dsqr(dx[m] - inp*dir[m]);
}
if (dr2 < r0_2)
{
/* add to index, to sum of COM, to weight array */
if (pdyna->nat_loc >= pdyna->nalloc_loc)
{
pdyna->nalloc_loc = over_alloc_large(pdyna->nat_loc+1);
srenew(pdyna->ind_loc, pdyna->nalloc_loc);
srenew(pdyna->weight_loc, pdyna->nalloc_loc);
}
pdyna->ind_loc[pdyna->nat_loc] = ii;
mass = md->massT[ii];
weight = get_weight(sqrt(dr2), pull->cyl_r1, pull->cyl_r0);
pdyna->weight_loc[pdyna->nat_loc] = weight;
sum_a += mass*weight*inp;
if (xp)
{
pbc_dx_aiuc(pbc, xp[ii], g_x, dx);
inp = iprod(dir, dx);
sum_ap += mass*weight*inp;
}
wmass += mass*weight;
wwmass += mass*sqr(weight);
pdyna->nat_loc++;
}
}
}
pull->dbuf_cyl[c*4+0] = wmass;
pull->dbuf_cyl[c*4+1] = wwmass;
pull->dbuf_cyl[c*4+2] = sum_a;
pull->dbuf_cyl[c*4+3] = sum_ap;
}
if (cr && PAR(cr))
//.........这里部分代码省略.........
示例12: do_lincs
static void do_lincs(rvec *x,rvec *xp,matrix box,t_pbc *pbc,
struct gmx_lincsdata *lincsd,real *invmass,
t_commrec *cr,
real wangle,int *warn,
real invdt,rvec *v,
gmx_bool bCalcVir,tensor rmdr)
{
int b,i,j,k,n,iter;
real tmp0,tmp1,tmp2,im1,im2,mvb,rlen,len,len2,dlen2,wfac,lam;
rvec dx;
int ncons,*bla,*blnr,*blbnb;
rvec *r;
real *blc,*blmf,*bllen,*blcc,*rhs1,*rhs2,*sol,*lambda;
int *nlocat;
ncons = lincsd->nc;
bla = lincsd->bla;
r = lincsd->tmpv;
blnr = lincsd->blnr;
blbnb = lincsd->blbnb;
blc = lincsd->blc;
blmf = lincsd->blmf;
bllen = lincsd->bllen;
blcc = lincsd->tmpncc;
rhs1 = lincsd->tmp1;
rhs2 = lincsd->tmp2;
sol = lincsd->tmp3;
lambda = lincsd->lambda;
if (DOMAINDECOMP(cr) && cr->dd->constraints)
{
nlocat = dd_constraints_nlocalatoms(cr->dd);
}
else if (PARTDECOMP(cr))
{
nlocat = pd_constraints_nlocalatoms(cr->pd);
}
else
{
nlocat = NULL;
}
*warn = 0;
if (pbc)
{
/* Compute normalized i-j vectors */
for(b=0; b<ncons; b++)
{
pbc_dx_aiuc(pbc,x[bla[2*b]],x[bla[2*b+1]],dx);
unitv(dx,r[b]);
}
for(b=0; b<ncons; b++)
{
for(n=blnr[b]; n<blnr[b+1]; n++)
{
blcc[n] = blmf[n]*iprod(r[b],r[blbnb[n]]);
}
pbc_dx_aiuc(pbc,xp[bla[2*b]],xp[bla[2*b+1]],dx);
mvb = blc[b]*(iprod(r[b],dx) - bllen[b]);
rhs1[b] = mvb;
sol[b] = mvb;
}
}
else
{
/* Compute normalized i-j vectors */
for(b=0; b<ncons; b++)
{
i = bla[2*b];
j = bla[2*b+1];
tmp0 = x[i][0] - x[j][0];
tmp1 = x[i][1] - x[j][1];
tmp2 = x[i][2] - x[j][2];
rlen = gmx_invsqrt(tmp0*tmp0+tmp1*tmp1+tmp2*tmp2);
r[b][0] = rlen*tmp0;
r[b][1] = rlen*tmp1;
r[b][2] = rlen*tmp2;
} /* 16 ncons flops */
for(b=0; b<ncons; b++)
{
tmp0 = r[b][0];
tmp1 = r[b][1];
tmp2 = r[b][2];
len = bllen[b];
i = bla[2*b];
j = bla[2*b+1];
for(n=blnr[b]; n<blnr[b+1]; n++)
{
k = blbnb[n];
blcc[n] = blmf[n]*(tmp0*r[k][0] + tmp1*r[k][1] + tmp2*r[k][2]);
} /* 6 nr flops */
mvb = blc[b]*(tmp0*(xp[i][0] - xp[j][0]) +
tmp1*(xp[i][1] - xp[j][1]) +
tmp2*(xp[i][2] - xp[j][2]) - len);
rhs1[b] = mvb;
sol[b] = mvb;
/* 10 flops */
}
//.........这里部分代码省略.........
示例13: replica_exchange
gmx_bool replica_exchange(FILE *fplog,const t_commrec *cr,struct gmx_repl_ex *re,
t_state *state,real *ener,
t_state *state_local,
int step,real time)
{
gmx_multisim_t *ms;
int exchange=-1,shift;
gmx_bool bExchanged=FALSE;
ms = cr->ms;
if (MASTER(cr))
{
exchange = get_replica_exchange(fplog,ms,re,ener,det(state->box),
step,time);
bExchanged = (exchange >= 0);
}
if (PAR(cr))
{
#ifdef GMX_MPI
MPI_Bcast(&bExchanged,sizeof(gmx_bool),MPI_BYTE,MASTERRANK(cr),
cr->mpi_comm_mygroup);
#endif
}
if (bExchanged)
{
/* Exchange the states */
if (PAR(cr))
{
/* Collect the global state on the master node */
if (DOMAINDECOMP(cr))
{
dd_collect_state(cr->dd,state_local,state);
}
else
{
pd_collect_state(cr,state);
}
}
if (MASTER(cr))
{
/* Exchange the global states between the master nodes */
if (debug)
{
fprintf(debug,"Exchanging %d with %d\n",ms->sim,exchange);
}
exchange_state(ms,exchange,state);
if (re->type == ereTEMP)
{
scale_velocities(state,sqrt(re->q[ms->sim]/re->q[exchange]));
}
}
/* With domain decomposition the global state is distributed later */
if (!DOMAINDECOMP(cr))
{
/* Copy the global state to the local state data structure */
copy_state_nonatomdata(state,state_local);
if (PAR(cr))
{
bcast_state(cr,state,FALSE);
}
}
}
return bExchanged;
}
示例14: pull_calc_coms
/* calculates center of mass of selection index from all coordinates x */
void pull_calc_coms(t_commrec *cr,
t_pull *pull, t_mdatoms *md, t_pbc *pbc, double t,
rvec x[], rvec *xp)
{
int g, i, ii, m;
real mass, w, wm, twopi_box = 0;
double wmass, wwmass, invwmass;
dvec com, comp;
double cm, sm, cmp, smp, ccm, csm, ssm, csw, snw;
rvec *xx[2], x_pbc = {0, 0, 0}, dx;
t_pull_group *pgrp;
if (pull->rbuf == NULL)
{
snew(pull->rbuf, pull->ngroup);
}
if (pull->dbuf == NULL)
{
snew(pull->dbuf, 3*pull->ngroup);
}
if (pull->bRefAt && pull->bSetPBCatoms)
{
pull_set_pbcatoms(cr, pull, x, pull->rbuf);
if (cr != NULL && DOMAINDECOMP(cr))
{
/* We can keep these PBC reference coordinates fixed for nstlist
* steps, since atoms won't jump over PBC.
* This avoids a global reduction at the next nstlist-1 steps.
* Note that the exact values of the pbc reference coordinates
* are irrelevant, as long all atoms in the group are within
* half a box distance of the reference coordinate.
*/
pull->bSetPBCatoms = FALSE;
}
}
if (pull->cosdim >= 0)
{
for (m = pull->cosdim+1; m < pull->npbcdim; m++)
{
if (pbc->box[m][pull->cosdim] != 0)
{
gmx_fatal(FARGS, "Can not do cosine weighting for trilinic dimensions");
}
}
twopi_box = 2.0*M_PI/pbc->box[pull->cosdim][pull->cosdim];
}
for (g = 0; g < pull->ngroup; g++)
{
pgrp = &pull->group[g];
clear_dvec(com);
clear_dvec(comp);
wmass = 0;
wwmass = 0;
cm = 0;
sm = 0;
cmp = 0;
smp = 0;
ccm = 0;
csm = 0;
ssm = 0;
if (!(g == 0 && PULL_CYL(pull)))
{
if (pgrp->epgrppbc == epgrppbcREFAT)
{
/* Set the pbc atom */
copy_rvec(pull->rbuf[g], x_pbc);
}
w = 1;
for (i = 0; i < pgrp->nat_loc; i++)
{
ii = pgrp->ind_loc[i];
mass = md->massT[ii];
if (pgrp->epgrppbc != epgrppbcCOS)
{
if (pgrp->weight_loc)
{
w = pgrp->weight_loc[i];
}
wm = w*mass;
wmass += wm;
wwmass += wm*w;
if (pgrp->epgrppbc == epgrppbcNONE)
{
/* Plain COM: sum the coordinates */
for (m = 0; m < DIM; m++)
{
com[m] += wm*x[ii][m];
}
if (xp)
{
for (m = 0; m < DIM; m++)
{
comp[m] += wm*xp[ii][m];
}
}
//.........这里部分代码省略.........
示例15: do_force_lowlevel
//.........这里部分代码省略.........
/* Here sometimes we would not need to shift with NBFonly,
* but we do so anyhow for consistency of the returned coordinates.
*/
if (graph)
{
shift_self(graph,box,x);
if (TRICLINIC(box))
{
inc_nrnb(nrnb,eNR_SHIFTX,2*graph->nnodes);
}
else
{
inc_nrnb(nrnb,eNR_SHIFTX,graph->nnodes);
}
}
/* Check whether we need to do bondeds or correct for exclusions */
if (fr->bMolPBC &&
((flags & GMX_FORCE_BONDED)
|| EEL_RF(fr->eeltype) || EEL_FULL(fr->eeltype)))
{
/* Since all atoms are in the rectangular or triclinic unit-cell,
* only single box vector shifts (2 in x) are required.
*/
set_pbc_dd(&pbc,fr->ePBC,cr->dd,TRUE,box);
}
debug_gmx();
if (flags & GMX_FORCE_BONDED)
{
GMX_MPE_LOG(ev_calc_bonds_start);
calc_bonds(fplog,cr->ms,
idef,x,hist,f,fr,&pbc,graph,enerd,nrnb,lambda,md,fcd,
DOMAINDECOMP(cr) ? cr->dd->gatindex : NULL, atype, born,
fr->bSepDVDL && do_per_step(step,ir->nstlog),step);
/* Check if we have to determine energy differences
* at foreign lambda's.
*/
if (ir->n_flambda > 0 && (flags & GMX_FORCE_DHDL) &&
idef->ilsort != ilsortNO_FE)
{
if (idef->ilsort != ilsortFE_SORTED)
{
gmx_incons("The bonded interactions are not sorted for free energy");
}
init_enerdata(mtop->groups.grps[egcENER].nr,ir->n_flambda,&ed_lam);
for(i=0; i<enerd->n_lambda; i++)
{
lam_i = (i==0 ? lambda : ir->flambda[i-1]);
dvdl_dum = 0;
reset_enerdata(&ir->opts,fr,TRUE,&ed_lam,FALSE);
calc_bonds_lambda(fplog,
idef,x,fr,&pbc,graph,&ed_lam,nrnb,lam_i,md,
fcd,
DOMAINDECOMP(cr) ? cr->dd->gatindex : NULL);
sum_epot(&ir->opts,&ed_lam);
enerd->enerpart_lambda[i] += ed_lam.term[F_EPOT];
}
destroy_enerdata(&ed_lam);
}
debug_gmx();
GMX_MPE_LOG(ev_calc_bonds_finish);
}