Ejemplo n.º 1
0
        /// <summary>
        /// get symmetry matrix for a specific symmetry operation string
        /// may need translation
        /// linear search
        /// </summary>
        /// <param name="symOpMatrices"></param>
        /// <param name="symOpString"></param>
        /// <returns></returns>
        public SymOpMatrix GetSymmetryMatrixFromSymmetryString(SymOpMatrix[] symOpMatrices, string symOpString)
        {
            int    index1    = symOpString.IndexOf("_");
            int    index2    = symOpString.LastIndexOf("_");
            string symOpNum  = "";
            string symString = "";

            if (index1 == index2)
            {
                symOpNum  = symOpString.Substring(0, index1);
                symString = symOpString.Substring(index1 + 1, symOpString.Length - index1 - 1);
            }
            else
            {
                symOpNum  = symOpString.Substring(index1 + 1, index2 - index1 - 1);
                symString = symOpString.Substring(index2 + 1, symOpString.Length - index2 - 1);
            }
            SymOpMatrix convertedSymOpMatrix = null;

            foreach (SymOpMatrix symOpMatrix in symOpMatrices)
            {
                if (symOpMatrix.symmetryOpNum == symOpNum)
                {
                    convertedSymOpMatrix = (SymOpMatrix)symOpMatrix.Clone();
                    break;
                }
            }
            if (convertedSymOpMatrix != null)
            {
                if (symString.Length == 3)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (symString[i] == '5')
                        {
                            continue;
                        }
                        convertedSymOpMatrix.Add(i, 3, convertedSymOpMatrix.Value(i, 3) + (double)(Convert.ToInt32(symString[i].ToString()) - 5));
                    }
                }

                /* should deal with a symmetry string with translate vectors > 5
                 * format of this type of symmetry string: 1_+10-1+6
                 * translate vector (+5, -6, +1)
                 */
                else if (symString.Length > 3)
                {
                    string[] vectStrings = SeparateSymmetryString(symString);
                    convertedSymOpMatrix.Add(0, 3, convertedSymOpMatrix.Value(0, 3) +
                                             (double)(Convert.ToInt32(vectStrings[0]) - 5));
                    convertedSymOpMatrix.Add(1, 3, convertedSymOpMatrix.Value(1, 3) +
                                             (double)(Convert.ToInt32(vectStrings[1]) - 5));
                    convertedSymOpMatrix.Add(2, 3, convertedSymOpMatrix.Value(2, 3) +
                                             (double)(Convert.ToInt32(vectStrings[2]) - 5));
                }
            }
            return(convertedSymOpMatrix);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// get matrix from a symmetry operation string
 /// </summary>
 /// <param name="symOpStr"></param>
 /// <param name="symOpMatrix"></param>
 public void SetSymOpMatrix(string fullSymOpStr, /*string symOpString,*/ ref SymOpMatrix symOpMatrix)
 {
     double[]  indexValues = new double [3];
     string [] symOpRows   = fullSymOpStr.ToUpper().Split(',');
     for (int dimNo = 0; dimNo < 3; dimNo++)
     {
         string symOpRow = symOpRows[dimNo];
         symOpMatrix.Add(dimNo, 0, GetDimIndex(symOpRow, "X"));
         symOpMatrix.Add(dimNo, 1, GetDimIndex(symOpRow, "Y"));
         symOpMatrix.Add(dimNo, 2, GetDimIndex(symOpRow, "Z"));
         //int transVector = Convert.ToInt32 (symOpString[dimNo].ToString ()) - 5;
         //symOpMatrix.Add (dimNo, 3, GetVectorValue(symOpRow) - transVector);
         symOpMatrix.Add(dimNo, 3, GetVectorValue(symOpRow));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// the symmetry operator string
 /// </summary>
 /// <param name="infoNode"></param>
 /// <returns></returns>
 public SymOpMatrix GetOrigCoordSymOpMatrix()
 {
     SymOpMatrix symOpMatrix = new SymOpMatrix();
     List<double> itemList = new List<double> ();
     itemList.Add(1.0);
     itemList.Add(0.0);
     itemList.Add(0.0);
     itemList.Add(0.0);
     symOpMatrix.Add(0, itemList.ToArray ());
     itemList.Clear();
     itemList.Add(0.0);
     itemList.Add(1.0);
     itemList.Add(0.0);
     itemList.Add(0.0);
     symOpMatrix.Add(1, itemList.ToArray ());
     itemList.Clear();
     itemList.Add(0.0);
     itemList.Add(0.0);
     itemList.Add(1.0);
     itemList.Add(0.0);
     symOpMatrix.Add(2, itemList.ToArray ());
     return symOpMatrix;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// the symmetry operator string
 /// </summary>
 /// <param name="infoNode"></param>
 /// <returns></returns>
 public SymOpMatrix GetCoordSymOpMatrix(string matrixString)
 {
     string[] fields = matrixString.Split(',');
     SymOpMatrix symOpMatrix = new SymOpMatrix();
     List<double> itemList = new List<double> ();
     itemList.Add(Convert.ToDouble(fields[0]));
     itemList.Add(Convert.ToDouble(fields[1]));
     itemList.Add(Convert.ToDouble(fields[2]));
     itemList.Add(Convert.ToDouble(fields[3]));
     symOpMatrix.Add(0, itemList.ToArray ());
     itemList.Clear();
     itemList.Add(Convert.ToDouble(fields[4]));
     itemList.Add(Convert.ToDouble(fields[5]));
     itemList.Add(Convert.ToDouble(fields[6]));
     itemList.Add(Convert.ToDouble(fields[7]));
     symOpMatrix.Add(1, itemList.ToArray ());
     itemList.Clear();
     itemList.Add(Convert.ToDouble(fields[8]));
     itemList.Add(Convert.ToDouble(fields[9]));
     itemList.Add(Convert.ToDouble(fields[10]));
     itemList.Add(Convert.ToDouble(fields[11]));
     symOpMatrix.Add(2, itemList.ToArray ());
     return symOpMatrix;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// the symmetry matrix from matrix string
        /// s00, s01, s02, v0, s10, s11, s12, v1, s20, s21, s22, v2
        /// </summary>
        /// <param name="matrixString"></param>
        /// <returns></returns>
        private SymOpMatrix GetSymMatrixFromMatrixString(string matrixString)
        {
            string[]    fields      = matrixString.Split(',');
            SymOpMatrix symOpMatrix = new SymOpMatrix();
            int         numOfCol    = 4;
            int         colNum      = -1;
            int         rowNum      = -1;

            for (int i = 0; i < fields.Length; i++)
            {
                colNum++;
                if (i % numOfCol == 0)
                {
                    rowNum++;
                    colNum = 0;
                }
                symOpMatrix.Add(rowNum, colNum, Convert.ToDouble(fields[i]));
            }
            return(symOpMatrix);
        }