示例#1
0
            public Mode[] GetModes()
            {   // determine eigvals and eigvecs
                if (_modes != null)
                {
                    return(_modes.HClone <Mode>());
                }
                MatrixByArr hess = MatrixByArr.FromMatrixArray(this.hess);

                _modes = HBioinfo.GetModes(hess, cachebase + "Modes.data");
                return(_modes.HClone <Mode>());
            }
示例#2
0
            public Anisou[] GetAnisous()
            {
                if (_anisous != null)
                {
                    return(_anisous);
                }
                MatrixByArr hess = MatrixByArr.FromMatrixArray(this.hess);

                _anisous = Anisou.FromHessian(hess, masses, scale: 10000000, cachepath: cachebase + "Anisous.data");
                //_anisous = Bioinfo.GetAnisou(GetModes(), masses, scale: 10000000);
                return(_anisous);
            }
示例#3
0
        static void UpdateMassWeightedHess(Matrix hess, Vector mass)
        {
            if (HDebug.Selftest())
            //if(GetMassWeightedHess_selftest1)
            #region selftest
            {
                //HDebug.ToDo("replace examplt not to use blocked hessian matrix");
                //GetMassWeightedHess_selftest1 = false;
                MatrixByArr[,] _bhess = new MatrixByArr[2, 2];
                _bhess[0, 0]          = new double[3, 3] {
                    { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }
                };
                _bhess[0, 1] = _bhess[0, 0] + 10;
                _bhess[1, 0] = _bhess[0, 0] + 20;
                _bhess[1, 1] = _bhess[0, 0] + 30;
                Vector _mass = new double[2] {
                    2, 3
                };
                MatrixByArr _hess = MatrixByArr.FromMatrixArray(_bhess);

                Matrix _mwhess = GetMassWeightedHess(_hess, _mass);
                MatrixByArr[,] _mwbhess = GetMassWeightedHess(_bhess, _mass);

                HDebug.AssertTolerance(0.00000001, MatrixByArr.FromMatrixArray(_mwbhess) - _mwhess.ToArray());
            }
            #endregion

            HDebug.Exception(hess.ColSize == mass.Size);
            HDebug.Assert(hess.ColSize == hess.RowSize);
            HDebug.Assert(hess.ColSize % 3 == 0);

            Vector mass05 = mass.ToArray().HSqrt();

            // mass weighted hessian
            // MH = M^(-1/2) * H * M^(-1/2)
            // MH_ij = H_IJ * sqrt(M[i] * M[j])
            {
                // mass weighted block hessian
                for (int i = 0; i < hess.ColSize; i++)
                {
                    for (int j = 0; j < hess.RowSize; j++)
                    {
                        //if(i == j) continue;
                        hess[i, j] = hess[i, j] / (mass05[i] * mass05[j]);
                        //mbhess[i, i] -= mbhess[i, j];
                    }
                }
            }
        }
示例#4
0
文件: TNM.cs 项目: htna/explsolv
            public static MatrixByArr GetJ(Universe univ, Vector[] coords, List <RotableInfo> rotInfos, string option = null)
            {
                switch (option)
                {
                case "mine":
                {
                    MatrixByArr[,] J = TNM_mine.GetJ(univ, coords, rotInfos, fnInv3x3: null);
                    double tolerance = 0.00001;
                    HDebug.Assert(CheckEckartConditions(univ, coords, rotInfos, J, tolerance: tolerance));
                    //if(Debug.IsDebuggerAttachedWithProb(0.1))
                    //{
                    //    Matrix J0 = Matrix.FromBlockmatrix(J);
                    //    Matrix J1 = Matrix.FromBlockmatrix(GetJ(univ, coords, rotInfos, option:"paper", useNamedLock:false));
                    //    Debug.AssertTolerance(0.00000001, J0 - J1);
                    //}
                    return(MatrixByArr.FromMatrixArray(J));
                }

                case "paper":
                {
                    MatrixByArr[,] J = TNM_paper.GetJ(univ, coords, rotInfos);
                    HDebug.Assert(CheckEckartConditions(univ, coords, rotInfos, J, 0.0000001));
                    return(MatrixByArr.FromMatrixArray(J));
                }

                case "mineopt":
                {
                    MatrixByArr J = TNM_mineopt.GetJ(univ, coords, rotInfos);
                    if (HDebug.IsDebuggerAttached && univ.GetMolecules().Length == 1)
                    {
                        MatrixByArr J0 = TNM.GetJ(univ, coords, rotInfos, option: "paper");
                        MatrixByArr dJ = J - J0;
                        //double tolerance = dJ.ToArray().HAbs().HToArray1D().Mean();
                        //double maxAbsDH  = dJ.ToArray().HAbs().HMax();
                        //if(tolerance == 0)
                        //    tolerance = 0.000001;
                        HDebug.AssertTolerance(0.00000001, dJ);
                    }
                    return(J);
                }

                case null:
                    // my implementation has smaller error while checking Eckart conditions
                    goto case "mineopt";
                }
                return(null);
            }