예제 #1
0
        private static bool IsDataSetValid(
            QQDataSet dataSet,
            int n,
            int l,
            ColorState colorState,
            List <PotentialType> potentialTypes,
            double minTemperature,
            double maxTemperature
            )
        {
            bool isValid = (dataSet.N == n) &&
                           (dataSet.L == l) &&
                           (dataSet.ColorState == colorState) &&
                           potentialTypes.Contains(dataSet.PotentialType) &&
                           (dataSet.Temperature >= minTemperature) &&
                           (dataSet.Temperature <= maxTemperature);

            return(isValid);
        }
예제 #2
0
 public static string MakeDataLine(
     QQDataSet dataSet
     )
 {
     return(string.Format(
                " " + ColumnFormat,
                dataSet.N.ToString(),
                dataSet.L.ToString(),
                dataSet.ColorState.ToString(),
                dataSet.PotentialType.ToString(),
                dataSet.Temperature.ToString("G6"),
                dataSet.DebyeMass.ToString("G6"),
                dataSet.DisplacementRMS.ToString("G6"),
                dataSet.SoftScale.ToString("G6"),
                dataSet.UltraSoftScale.ToString("G6"),
                dataSet.BoundMass.ToString("G6"),
                dataSet.Energy.ToString("G6"),
                dataSet.GammaDamp.ToString("G6"),
                dataSet.GammaDiss.ToString("G6"),
                dataSet.GammaTot.ToString("G6")));
 }
예제 #3
0
        public static void Write(
            string pathFile,
            QQDataSet dataSet
            )
        {
            // read whole data file
            List <string> allLines  = new List <string>(File.ReadAllLines(pathFile));
            int           lineIndex = FindLineIndex(allLines, dataSet.N, dataSet.L, dataSet.ColorState,
                                                    dataSet.PotentialType, dataSet.Temperature, out bool lineFound);

            if (lineFound)
            {
                allLines[lineIndex] = MakeDataLine(dataSet);
            }
            else
            {
                allLines.Insert(lineIndex, MakeDataLine(dataSet));
            }

            File.WriteAllLines(pathFile, allLines);
        }
예제 #4
0
        // Extract a list of values from the QQ-data file with specified N, L, color state and
        // potential type within a given temperature region.
        // If no values are found an empty list is returned.
        private static List <QQDataSet> GetDataSets(
            string pathFile,
            int n,
            int l,
            ColorState colorState,
            List <PotentialType> potentialTypes,
            double minTemperature,
            double maxTemperature
            )
        {
            List <QQDataSet> dataSetList = new List <QQDataSet>();

            // read whole data file
            List <string> allLines = new List <string>(File.ReadAllLines(pathFile));

            // go through the data file and find the wanted data
            foreach (string currentLine in allLines)
            {
                // skip commentary
                if (IsCommentaryLine(currentLine))
                {
                    continue;
                }

                QQDataSet dataSet = ExtractDataSet(currentLine);

                if (!IsDataSetValid(dataSet, n, l, colorState, potentialTypes, minTemperature, maxTemperature))
                {
                    continue;
                }

                // add the data to the list and check the next line
                dataSetList.Add(dataSet);
            }

            return(dataSetList);
        }