Exemple #1
0
        public static PFSM GetHessFSM(IList <Vector> coords, Matrix pwspring, Matrix pwforce, ILinAlg la)
        {
            HDebug.ToDo("check!!");
            int size = coords.Count;

            Matrix khess = Hess.GetHessAnm(coords, pwspring.ToArray());
            Matrix invkhess;
            {
                var HH = la.ToILMat(khess);
                HDebug.Assert(false); // try to use eig, instead of pinv
                var invHH = la.PInv(HH);
                HH.Dispose();
                //var VVDD = la.EigSymm(HH);
                invkhess = invHH.ToArray();
                invHH.Dispose();
            }

            Matrix npwforce = Hess.GetHessFSM_GetEqlibForc(coords, khess, invkhess, pwforce);
            Matrix pwdist   = coords.Pwdist();

            Matrix anm = Hess.GetHessAnm(coords, double.PositiveInfinity);

            MatrixBySparseMatrix fhess = MatrixBySparseMatrix.Zeros(size * 3, size * 3, 3);

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    int[] idxi = new int[] { i *3 + 0, i *3 + 1, i *3 + 2 };
                    int[] idxj = new int[] { j *3 + 0, j *3 + 1, j *3 + 2 };

                    // ANM_ij
                    MatrixByArr fhess_ij = anm.SubMatrix(idxi, idxj).ToArray();
                    // ANM_ij - GNM_ij = ANM_ij - I_33
                    fhess_ij[0, 0] += 1;
                    fhess_ij[1, 1] += 1;
                    fhess_ij[2, 2] += 1;
                    // fij/rij * (ANM_ij - GNM_ij)
                    fhess_ij *= (npwforce[i, j] / pwdist[i, j]);

                    fhess.SetBlock(i, j, fhess_ij);
                    fhess.SetBlock(i, i, fhess.GetBlock(i, i) - fhess_ij);
                }
            }

            return(new PFSM
            {
                KHess = khess,
                FHess = fhess,
            });
        }
Exemple #2
0
 HessMatrixSparse(MatrixBySparseMatrix hess)
 {
     this.hess = hess;
 }
Exemple #3
0
 //////////////////////////////////////////////////////////////////////////////////////////////////
 // HessMatrix
 HessMatrixSparse(int colsize, int rowsize)
 {
     HDebug.Assert(colsize % 3 == 0);
     HDebug.Assert(rowsize % 3 == 0);
     this.hess = new MatrixBySparseMatrix(colsize, rowsize, 3);
 }