示例#1
0
文件: topsort.c 项目: hasagar/gromacs
static gmx_bool ip_q_pert(int ftype, const t_iatom *ia,
                          const t_iparams *ip, const real *qA, const real *qB)
{
    /* 1-4 interactions do not have the charges stored in the iparams list,
     * so we need a separate check for those.
     */
    return (ip_pert(ftype, ip+ia[0]) ||
            (ftype == F_LJ14 && (qA[ia[1]] != qB[ia[1]] ||
                                 qA[ia[2]] != qB[ia[2]])));
}
示例#2
0
文件: topsort.c 项目: hasagar/gromacs
gmx_bool gmx_mtop_bondeds_free_energy(const gmx_mtop_t *mtop)
{
    const gmx_ffparams_t *ffparams;
    int                   i, ftype;
    int                   mb;
    t_atom               *atom;
    t_ilist              *il;
    t_iatom              *ia;
    gmx_bool              bPert;

    ffparams = &mtop->ffparams;

    /* Loop over all the function types and compare the A/B parameters */
    bPert = FALSE;
    for (i = 0; i < ffparams->ntypes; i++)
    {
        ftype = ffparams->functype[i];
        if (interaction_function[ftype].flags & IF_BOND)
        {
            if (ip_pert(ftype, &ffparams->iparams[i]))
            {
                bPert = TRUE;
            }
        }
    }

    /* Check perturbed charges for 1-4 interactions */
    for (mb = 0; mb < mtop->nmolblock; mb++)
    {
        atom = mtop->moltype[mtop->molblock[mb].type].atoms.atom;
        il   = &mtop->moltype[mtop->molblock[mb].type].ilist[F_LJ14];
        ia   = il->iatoms;
        for (i = 0; i < il->nr; i += 3)
        {
            if (atom[ia[i+1]].q != atom[ia[i+1]].qB ||
                atom[ia[i+2]].q != atom[ia[i+2]].qB)
            {
                bPert = TRUE;
            }
        }
    }

    return (bPert ? ilsortFE_UNSORTED : ilsortNO_FE);
}
示例#3
0
bool gmx_mtop_bondeds_free_energy(gmx_mtop_t *mtop)
{
    gmx_ffparams_t *ffparams;
    int  i,ftype;
    bool bPert;

    ffparams = &mtop->ffparams;
    
    /* Loop over all the function types and compare the A/B parameters */
    bPert = FALSE;
    for(i=0; i<ffparams->ntypes; i++)
    {
        ftype = ffparams->functype[i];
        if (interaction_function[ftype].flags & IF_BOND)
        {
            if (ip_pert(ftype,&ffparams->iparams[i]))
            {
                bPert = TRUE;
            }
        }
    }

    return (bPert ? ilsortFE_UNSORTED : ilsortNO_FE);
}
示例#4
0
void gmx_sort_ilist_fe(t_idef *idef)
{
    int  ftype,nral,i,ic,ib,a;
    t_iparams *iparams;
    t_ilist *ilist;
    t_iatom *iatoms;
    bool bPert;
    t_iatom *iabuf;
    int  iabuf_nalloc;

    iabuf_nalloc = 0;
    iabuf        = NULL;
    
    iparams = idef->iparams;

    for(ftype=0; ftype<F_NRE; ftype++)
    {
        if (interaction_function[ftype].flags & IF_BOND)
        {
            ilist = &idef->il[ftype];
            iatoms = ilist->iatoms;
            nral  = NRAL(ftype);
            ic = 0;
            ib = 0;
            i  = 0;
            while (i < ilist->nr)
            {
                /* The first element of ia gives the type */
                if (ip_pert(ftype,&iparams[iatoms[i]]))
                {
                    /* Copy to the perturbed buffer */
                    if (ib + 1 + nral > iabuf_nalloc)
                    {
                        iabuf_nalloc = over_alloc_large(ib+1+nral);
                        srenew(iabuf,iabuf_nalloc);
                    }
                    for(a=0; a<1+nral; a++)
                    {
                        iabuf[ib++] = iatoms[i++];
                    }
                }
                else
                {
                    /* Copy in place */
                    for(a=0; a<1+nral; a++)
                    {
                        iatoms[ic++] = iatoms[i++];
                    }
                }
            }
            /* Now we now the number of non-perturbed interactions */
            ilist->nr_nonperturbed = ic;
            
            /* Copy the buffer with perturbed interactions to the ilist */
            for(a=0; a<ib; a++)
            {
                iatoms[ic++] = iabuf[a];
            }

            if (debug)
            {
                fprintf(debug,"%s non-pert %d pert %d\n",
                        interaction_function[ftype].longname,
                        ilist->nr_nonperturbed,
                        ilist->nr-ilist->nr_nonperturbed);
            }
        }
    }

    sfree(iabuf);

    idef->ilsort = ilsortFE_SORTED;
}