public static HessMatrix GetHessApproxAnm(Vector[] coords, HessMatrix hess, string option, ILinAlg ila) { int nresi = coords.Length; HDebug.Assert(nresi * 3 == hess.ColSize); HDebug.Assert(nresi * 3 == hess.RowSize); double[,] Kij = new double[nresi, nresi]; for (int c = 0; c < nresi; c++) { for (int r = c + 1; r < nresi; r++) { HessMatrix anmCR = Hess.GetHessAnm(coords.HSelectByIndex(new int[] { c, r })); //Matrix anmCR = anm.SubMatrix(new int[] { 0, 1, 2 }, new int[] { 3, 4, 5 }); int[] idxs = new int[] { c *3 + 0, c *3 + 1, c *3 + 2, r *3 + 0, r *3 + 1, r *3 + 2 }; HessMatrix hessCR = new HessMatrixDense { hess = hess.SubMatrix(idxs, idxs) }; hessCR = Hess.CorrectHessDiag(hessCR); Vector vecHessCR = hessCR.GetColVectorList().ToVector(); Vector vecAnmCR = anmCR.GetColVectorList().ToVector(); double Kcr; switch (option) { case "match magnitude": Kcr = vecHessCR.Dist / vecAnmCR.Dist; break; case "least-mean square": Kcr = LinAlg.VtV(vecAnmCR, vecHessCR) / LinAlg.VtV(vecAnmCR, vecAnmCR); break; default: throw new NotImplementedException(); } if (Kcr < 0) { HDebug.Assert(false); } HDebug.Assert(Kcr >= 0); double mag2cahessCR = vecAnmCR.Dist; double mag2caAnmCR = vecHessCR.Dist; double mag2caAnmCRx = (Kcr * anmCR).GetColVectorList().ToVector().Dist; Kij[c, r] = Kij[r, c] = Kcr; } } //return Kij; return(Hess.GetHessAnm(coords, Kij)); throw new NotImplementedException(); }
public static HessMatrix GetHess(Universe univ) { Vector[] coords = univ.GetCoords(); HessMatrix hessian_spr = HessMatrixSparse.ZerosSparse(univ.size * 3, univ.size * 3); Universe.Nonbondeds_v1 nonbondeds = new Universe.Nonbondeds_v1(univ.atoms, univ.size, 12); nonbondeds.UpdateNonbondeds(coords, 0); hessian_spr = STeM.GetHessBond(coords, univ.bonds, null, hessian: hessian_spr); HDebug.Verify(Hess.CheckHessDiag(hessian_spr, 0.000001, "non-computable exception while generating STeM hess_spr with bond")); hessian_spr = STeM.GetHessAngle(coords, univ.angles, true, null, null, hessian: hessian_spr); HDebug.Verify(Hess.CheckHessDiag(hessian_spr, 0.000001, "non-computable exception while generating STeM hess_spr with angle")); hessian_spr = STeM.GetHessImproper(coords, univ.impropers, null, hessian: hessian_spr); HDebug.Verify(Hess.CheckHessDiag(hessian_spr, 0.000001, "non-computable exception while generating STeM hess_spr with improper")); hessian_spr = STeM.GetHessDihedral(coords, univ.dihedrals, null, null, hessian: hessian_spr); HDebug.Verify(Hess.CheckHessDiag(hessian_spr, 0.000001, "non-computable exception while generating STeM hess_spr with dihedral")); hessian_spr = STeM.GetHessVdw(coords, univ.nonbonded14s.GetEnumerable(), null, null, hessian: hessian_spr); HDebug.Verify(Hess.CheckHessDiag(hessian_spr, 0.000001, "non-computable exception while generating STeM hess_spr with vdw14")); hessian_spr = STeM.GetHessElec(coords, univ.nonbonded14s.GetEnumerable(), hessian: hessian_spr); HDebug.Verify(Hess.CheckHessDiag(hessian_spr, 0.000001, "non-computable exception while generating STeM hess_spr with elec14")); hessian_spr = STeM.GetHessVdw(coords, nonbondeds.GetEnumerable(), null, null, hessian: hessian_spr); HDebug.Verify(Hess.CheckHessDiag(hessian_spr, 0.000001, "non-computable exception while generating STeM hess_spr with vdw")); hessian_spr = STeM.GetHessElec(coords, nonbondeds.GetEnumerable(), hessian: hessian_spr); HDebug.Verify(Hess.CheckHessDiag(hessian_spr, 0.000001, "non-computable exception while generating STeM hess_spr with elec")); //hessian_spr = GetHessSprElec(coords, nonbondeds , hessian: hessian_spr); Debug.Verify(Hess.CheckHessDiag(hessian_spr)); //hessian_spr = GetHessSprVdw(coords, nonbondeds , hessian: hessian_spr); Debug.Verify(Hess.CheckHessDiag(hessian_spr)); hessian_spr = Hess.CorrectHessDiag(hessian_spr); HDebug.Verify(Hess.CheckHessDiag(hessian_spr, 0.000001, "non-computable exception while generating STeM hess_spr")); return(hessian_spr); }
public HessMatrix CorrectHessDiag() { return(Hess.CorrectHessDiag(this)); }