本文整理汇总了C++中CMol::Restrain_All_Torsions方法的典型用法代码示例。如果您正苦于以下问题:C++ CMol::Restrain_All_Torsions方法的具体用法?C++ CMol::Restrain_All_Torsions怎么用?C++ CMol::Restrain_All_Torsions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMol
的用法示例。
在下文中一共展示了CMol::Restrain_All_Torsions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Geoometry_Optimization_With_Constraint
double Geoometry_Optimization_With_Constraint(CMol *pMol)
{
return (pMol->Cal_E(0));
nlopt_opt opt, opt_AugLag;
int Return_Opt, nAtom, nDim, i, iPos;
double E_min, x[MAX_NUM_ATOM*3];
Mol_ESP.Restrain_All_Torsions(1); // apply soft restraints on all soft dihedrals
nAtom = pMol->nAtom;
nDim = 3 * nAtom;
printf("\nMM before:\t");
for(i=0; i<n_Phi; i++) {
printf("%3d %3d %3d %3d %8.4lf\n", DihList[i][0], DihList[i][1], DihList[i][2], DihList[i][3],
Mol_ESP.Query_Dihedral(DihList[i][0], DihList[i][1], DihList[i][2], DihList[i][3], 0, NULL));
}
double AUG_LAG_ICM_TOL = 1.0E-17;
opt_AugLag = nlopt_create(NLOPT_LD_LBFGS_GEO, nDim);
nlopt_set_min_objective(opt_AugLag, func_Geo_Opt_Constraint, pMol);
// pMol->SavePdb("opt-free.pdb");
for(i=0; i<pMol->nBond_Fixed; i++) {
int ret=0;
pMol->Geo_Fix_r0[i].pMol = pMol;
ret =nlopt_add_equality_constraint(opt_AugLag, Geo_Constraint_Bond, &(pMol->Geo_Fix_r0[i]), 2.0E-6);
printf(" Fixing bond %d\n", i );
}
for(i=0; i<pMol->nAngle_Fixed; i++) {
int ret=0;
pMol->Geo_Fix_theta0[i].pMol = pMol;
ret=nlopt_add_equality_constraint(opt_AugLag, Geo_Constraint_Angle, &(pMol->Geo_Fix_theta0[i]), 2.0E-6);
printf(" Fixing angle %d\n", i );
}
for(i=0; i<pMol->nPhi_Fixed; i++) {
int ret=0;
pMol->Geo_Fix_phi0[i].pMol = pMol;
ret=nlopt_add_equality_constraint(opt_AugLag, Geo_Constraint_Dihedral, &(pMol->Geo_Fix_phi0[i]), 2.0E-6);
printf(" Fixing phi %d : %d\n", i, ret );
}
nlopt_set_xtol_rel(opt_AugLag, 2E-7);
// opt = nlopt_create(NLOPT_LD_LBFGS_GEO, nDim);
// opt = nlopt_create(NLOPT_LN_COBYLA, nDim);
// nlopt_set_min_objective(opt, func_Geo_Opt_Constraint, pMol);
// nlopt_set_xtol_rel(opt, 1E-7);
// nlopt_set_local_optimizer(opt_AugLag, opt);
// nlopt_destroy(opt);
for(i=0; i<nAtom; i++) {
iPos = 3*i;
x[iPos ] = pMol->x[i];
x[iPos+1] = pMol->y[i];
x[iPos+2] = pMol->z[i];
}
Iter_Opt_Constrained = 0;
Return_Opt = nlopt_optimize(opt_AugLag, x, &E_min);
if (Return_Opt < 0) {
printf("nlopt failed : %d\n", Return_Opt);
}
// else {
// printf("After constrained optimization, E = %12.6lf\n", E_min);
// }
nlopt_destroy(opt_AugLag);
printf("MM after:\t");
for(i=0; i<n_Phi; i++) {
printf("%3d %3d %3d %3d %8.4lf\n", DihList[i][0], DihList[i][1], DihList[i][2], DihList[i][3],
Mol_ESP.Query_Dihedral(DihList[i][0], DihList[i][1], DihList[i][2], DihList[i][3], 0, NULL));
}
Mol_ESP.Restrain_All_Torsions(0); // lift soft restraints on all soft dihedrals
return (pMol->Cal_E(0));
}