Example #1
0
File: TNM.cs Project: 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);
            }