diff --git a/CSManager/CSManager.csproj b/CSManager/CSManager.csproj index 738331a..9607616 100644 --- a/CSManager/CSManager.csproj +++ b/CSManager/CSManager.csproj @@ -4,8 +4,8 @@ <OutputType>WinExe</OutputType> <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework> <UseWindowsForms>true</UseWindowsForms> - <AssemblyVersion>2024.1.13.0858</AssemblyVersion> - <FileVersion>2024.1.13.0858</FileVersion> + <AssemblyVersion>2024.1.13.0911</AssemblyVersion> + <FileVersion>2024.1.13.0911</FileVersion> <ApplicationIcon>App.ico</ApplicationIcon> <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion> </PropertyGroup> diff --git a/CSManager/doc/CSManager(en).pdf b/CSManager/doc/CSManager(en).pdf index 7bbe1b9..b312f46 100644 Binary files a/CSManager/doc/CSManager(en).pdf and b/CSManager/doc/CSManager(en).pdf differ diff --git a/CSManager/doc/CSManager(ja).pdf b/CSManager/doc/CSManager(ja).pdf index 7bbe1b9..c8a177a 100644 Binary files a/CSManager/doc/CSManager(ja).pdf and b/CSManager/doc/CSManager(ja).pdf differ diff --git a/Crystallography.Controls/Crystal/AtomControl.cs b/Crystallography.Controls/Crystal/AtomControl.cs index f364235..c0c27e5 100644 --- a/Crystallography.Controls/Crystal/AtomControl.cs +++ b/Crystallography.Controls/Crystal/AtomControl.cs @@ -589,7 +589,7 @@ private Atoms GetFromInterface() double[] aniso = UseTypeU ? [Aniso11 / 100, Aniso22 / 100, Aniso33 / 100, Aniso12 / 100, Aniso23 / 100, Aniso13 / 100] : - new[] { Aniso11, Aniso22, Aniso33, Aniso12, Aniso23, Aniso13 }; + [Aniso11, Aniso22, Aniso33, Aniso12, Aniso23, Aniso13]; double[] anisoErr = UseTypeU ? [Aniso11Err / 100, Aniso22Err / 100, Aniso33Err / 100, Aniso12Err / 100, Aniso23Err / 100, Aniso13Err / 100] : diff --git a/Crystallography.Controls/CrystalDatabase/CrystalDatabaseControl.cs b/Crystallography.Controls/CrystalDatabase/CrystalDatabaseControl.cs index 95a3892..f1e8720 100644 --- a/Crystallography.Controls/CrystalDatabase/CrystalDatabaseControl.cs +++ b/Crystallography.Controls/CrystalDatabase/CrystalDatabaseControl.cs @@ -231,7 +231,7 @@ private void SaveDatabaseWorker_DoWork(object sender, DoWorkEventArgs e) //譛蠕後∪縺ァ譚・縺ヲ縺�k譎ゅ〒縲√°縺、髢セ蛟、莉・荳九�螳ケ驥上〒縲√°縺、縺薙l縺セ縺ァ荳蠎ヲ繧ょ�蜑イ繧ゅ@縺ヲ縺�↑縺��エ蜷� if (i + division >= total && byteList.Count <= thresholdBytes && filecounter == 0) - fs.Write(byteList.ToArray(), 0, byteList.Count);//譛蛻昴�繝輔ぃ繧、繝ォ縺ォ譖ク縺崎セシ繧薙〒邨ゆコ� + fs.Write([.. byteList], 0, byteList.Count);//譛蛻昴�繝輔ぃ繧、繝ォ縺ォ譖ク縺崎セシ繧薙〒邨ゆコ� //譛蠕後∪縺ァ譚・縺ヲ縺�k譎ゅ°縲�明蛟、莉・荳翫�螳ケ驥上�蝣エ蜷� else if (i + division >= total || byteList.Count > thresholdBytes) @@ -239,7 +239,7 @@ private void SaveDatabaseWorker_DoWork(object sender, DoWorkEventArgs e) if (filecounter == 0) Directory.CreateDirectory(fn.Remove(fn.Length - 5, 5)); using (var fs1 = new FileStream(header + filecounter.ToString("000"), FileMode.Create, FileAccess.Write)) - fs1.Write(byteList.ToArray(), 0, byteList.Count); + fs1.Write([.. byteList], 0, byteList.Count); fileSize.Add(byteList.Count); byteList.Clear(); diff --git a/Crystallography.Controls/Crystallography.Controls.csproj b/Crystallography.Controls/Crystallography.Controls.csproj index 3d79f82..0462024 100644 --- a/Crystallography.Controls/Crystallography.Controls.csproj +++ b/Crystallography.Controls/Crystallography.Controls.csproj @@ -4,8 +4,8 @@ <OutputType>Library</OutputType> <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework> <UseWindowsForms>true</UseWindowsForms> - <AssemblyVersion>2024.1.13.0858</AssemblyVersion> - <FileVersion>2024.1.13.0858</FileVersion> + <AssemblyVersion>2024.1.13.0914</AssemblyVersion> + <FileVersion>2024.1.13.0914</FileVersion> <ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode> <ApplicationUseCompatibleTextRendering>true</ApplicationUseCompatibleTextRendering> <ApplicationVisualStyles>true</ApplicationVisualStyles> diff --git a/Crystallography/Atom/AtomStatic.cs b/Crystallography/Atom/AtomStatic.cs index 4e263e4..8acc4d6 100644 --- a/Crystallography/Atom/AtomStatic.cs +++ b/Crystallography/Atom/AtomStatic.cs @@ -7242,7 +7242,7 @@ public static double MassAbsorption(double energy, int z) if (energy == coef[i].X) { if (massAbsorption[z] == null) - massAbsorption[z] = new Dictionary<double, double>(); + massAbsorption[z] = []; lock (lockObjForMassAbsorption) massAbsorption[z].Add(energy, coef[i].Y); return coef[i].Y; @@ -7439,7 +7439,7 @@ public static void ReadChantlerData(string[] fileNames) absorp.Add(new PointD(Convert.ToDouble(str[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0]), Convert.ToDouble(str[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]))); //sbAbsorption.AppendLine("new PointD(" + str[i].Replace(" ", ",") + ")" + (i == str.Count - 2 ? "" : ",")); absorp.Sort(); - var pf = new List<Profile> { new Profile() }; + var pf = new List<Profile> { new() }; for (int j = 0; j < absorp.Count; j++) { if (double.IsPositiveInfinity(absorp[j].Y) && pf[^1].Pt.Count != 0) diff --git a/Crystallography/Atom/AtomStaticSub.cs b/Crystallography/Atom/AtomStaticSub.cs index 4194f18..cab25c4 100644 --- a/Crystallography/Atom/AtomStaticSub.cs +++ b/Crystallography/Atom/AtomStaticSub.cs @@ -11,7 +11,7 @@ public static readonly (double X, double Y)[][][] MassAbsorptionCoefficient = #region [ [ - System.Array.Empty<(double X, double Y)>() + [] ], [ diff --git a/Crystallography/Atom/Atoms.cs b/Crystallography/Atom/Atoms.cs index edfbff0..bcedd86 100644 --- a/Crystallography/Atom/Atoms.cs +++ b/Crystallography/Atom/Atoms.cs @@ -44,7 +44,7 @@ public override int GetHashCode() public int ID; [XmlIgnore] - public Vector3D[] Atom = Array.Empty<Vector3D>(); + public Vector3D[] Atom = []; public double X, Y, Z; public double X_err, Y_err, Z_err; @@ -197,7 +197,7 @@ public Atoms(string label, int atomicNumber, int subXray, int subElectron, doubl SubNumberXray = subXray; SubNumberElectron = subElectron; - Isotope = isotope ?? Array.Empty<double>(); + Isotope = isotope ?? []; AtomicNumber = atomicNumber; ElementName = AtomicNumber.ToString() + ": " + AtomStatic.AtomicName(atomicNumber); } diff --git a/Crystallography/Crystal/BondsAndPolyhedra.cs b/Crystallography/Crystal/BondsAndPolyhedra.cs index 98a83a6..dd3b9ca 100644 --- a/Crystallography/Crystal/BondsAndPolyhedra.cs +++ b/Crystallography/Crystal/BondsAndPolyhedra.cs @@ -42,7 +42,7 @@ public partial class Bonds [XmlIgnore] //[MemoryPackIgnore] - public List<int[]> pairID = new(); + public List<int[]> pairID = []; #endregion @@ -164,7 +164,7 @@ public static Bonds[] GetVestaBonds(IEnumerable<string> elementNames) VestaCations.ForEach(cation => bonds.Remove(bonds.Find(b => b.Element1 == cation && b.Element2 == cation))); } - return bonds.ToArray(); + return [.. bonds]; } static Bonds() diff --git a/Crystallography/Crystal/ConvertCrystalData.cs b/Crystallography/Crystal/ConvertCrystalData.cs index 6b06a7b..8cdf0fb 100644 --- a/Crystallography/Crystal/ConvertCrystalData.cs +++ b/Crystallography/Crystal/ConvertCrystalData.cs @@ -442,9 +442,9 @@ private static Crystal2 ConvertFromAmc(string[] str) if (xShift != 0 || yShift != 0 || zShift != 0) { - x = (x.ToDouble() + xShift).ToString("f8").TrimEnd(new[] { '0' }); - y = (y.ToDouble() + yShift).ToString("f8").TrimEnd(new[] { '0' }); - z = (z.ToDouble() + zShift).ToString("f8").TrimEnd(new[] { '0' }); + x = (x.ToDouble() + xShift).ToString("f8").TrimEnd(['0']); + y = (y.ToDouble() + yShift).ToString("f8").TrimEnd(['0']); + z = (z.ToDouble() + zShift).ToString("f8").TrimEnd(['0']); } var occ = "1"; @@ -495,14 +495,14 @@ private static Crystal2 ConvertFromAmc(string[] str) } else if (atomicNumber == -1)//"OH"のときの対処 { - atoms.Add(new Atoms2(label, 1, 0, 0, new[] { x, y, z }, occ, IsIso, IsUtypeUsed, iso, aniso)); - atoms.Add(new Atoms2(label, 8, 0, 0, new[] { x, y, z }, occ, IsIso, IsUtypeUsed, iso, aniso)); + atoms.Add(new Atoms2(label, 1, 0, 0, [x, y, z], occ, IsIso, IsUtypeUsed, iso, aniso)); + atoms.Add(new Atoms2(label, 8, 0, 0, [x, y, z], occ, IsIso, IsUtypeUsed, iso, aniso)); } else if (atomicNumber == -2)//"Wat"水のときの対処 { - atoms.Add(new Atoms2(label, 1, 0, 0, new[] { x, y, z }, occ, IsIso, IsUtypeUsed, iso, aniso)); - atoms.Add(new Atoms2(label, 1, 0, 0, new[] { x, y, z }, occ, IsIso, IsUtypeUsed, iso, aniso)); - atoms.Add(new Atoms2(label, 8, 0, 0, new[] { x, y, z }, occ, IsIso, IsUtypeUsed, iso, aniso)); + atoms.Add(new Atoms2(label, 1, 0, 0, [x, y, z], occ, IsIso, IsUtypeUsed, iso, aniso)); + atoms.Add(new Atoms2(label, 1, 0, 0, [x, y, z], occ, IsIso, IsUtypeUsed, iso, aniso)); + atoms.Add(new Atoms2(label, 8, 0, 0, [x, y, z], occ, IsIso, IsUtypeUsed, iso, aniso)); } } crystal.name = Name; @@ -716,7 +716,7 @@ private static Crystal2 CellParamForAmc(string str) return new Crystal2 { - CellTexts = new[] { s[0], s[1], s[2], s[3], s[4], s[5] }, + CellTexts = [s[0], s[1], s[2], s[3], s[4], s[5]], sym = (short)symmetrySeriesNumber, argb = Color.FromArgb(r.Next(255), r.Next(255), r.Next(255)).ToArgb() }; @@ -782,10 +782,10 @@ private static double ConvertToDouble(string str, bool IsHex) #endregion #region CIFファイルの読み込み - static readonly Random r = new Random(); + static readonly Random r = new(); - static readonly string[] ignoreWords1 = new[] { "_shelx_hkl_", "_shelx_fab_", "_shelx_res_" }; - static readonly string[] ignoreWords2 = new[] { "_refln", "_geom", "_platon" }; + static readonly string[] ignoreWords1 = ["_shelx_hkl_", "_shelx_fab_", "_shelx_res_"]; + static readonly string[] ignoreWords2 = ["_refln", "_geom", "_platon"]; private static Crystal2 ConvertFromCIF(string fileName) { var sb = new StringBuilder(); @@ -799,7 +799,7 @@ private static Crystal2 ConvertFromCIF(string fileName) if (strTemp.Contains('\r')) strTemp = strTemp.Replace("\r", "\n"); - stringList = strTemp.Split('\n', true).ToList(); + stringList = [.. strTemp.Split('\n', true)]; } foreach (var word in ignoreWords1) @@ -980,12 +980,12 @@ private static Crystal2 ConvertFromCIF(List<string> str) //ここまででCIF_Groupクラスのリストが完成 //格子定数は、CIFファイル中に何回も記載されている場合があるため、リストにする。 - List<(int index, string value)> aList = new(), bList = new(), cList = new(), alphaList = new(), betaList = new(), gammaList = new(); + List<(int index, string value)> aList = [], bList = [], cList = [], alphaList = [], betaList = [], gammaList = []; string name = "", sectionTitle = "", journalNameFull = "", journalCodenASTM = ""; string volume = "", year = "", pageFirst = "", pageLast = "", issue = ""; var journal = new StringBuilder(); - List<string> spaceGroupNameHM = new(), spaceGroupNameHall = new(); + List<string> spaceGroupNameHM = [], spaceGroupNameHall = []; string chemical_formula_sum = "", chemical_formula_structural = ""; var symmetry_Int_Tables_number = -1; var author = new List<string>(); @@ -1098,7 +1098,7 @@ Func<double, double, double, V3> func(string sExpr) { try { - sExpr = sExpr.Replace(" ", "").Replace(",+", ",").TrimStart(new[] { '+' }); + sExpr = sExpr.Replace(" ", "").Replace(",+", ",").TrimStart(['+']); sExpr = "new [] {" + sExpr.Replace("/", ".0/").Replace(".0.0", ".0") + "}";//分子に小数点を加える var f = DynamicExpressionParser.ParseLambda(prms, typeof(double[]), sExpr).Compile() as Func<double, double, double, double[]>; @@ -1252,16 +1252,16 @@ Func<double, double, double, V3> func(string sExpr) if (iso.Length == 0) iso = "0"; - var aniso = isU ? //11, 22, 33, 12, 23, 31の順番 - new[] { u11, u22, u33, u12, u23, u13 } : - new[] { b11, b22, b33, b12, b23, b13 }; + string[] aniso = isU ? //11, 22, 33, 12, 23, 31の順番 + [u11, u22, u33, u12, u23, u13] : + [b11, b22, b33, b12, b23, b13]; if (atomicNumber > 0) - atoms.Add(new Atoms2(atomLabel, atomicNumber, 0, 0, new[] { x, y, z }, occ, isIso, isU, iso, aniso)); + atoms.Add(new Atoms2(atomLabel, atomicNumber, 0, 0, [x, y, z], occ, isIso, isU, iso, aniso)); else if (atomicNumber == -1)//"OH"のときの対処 { - atoms.Add(new Atoms2(atomLabel, 1, 0, 0, new[] { x, y, z }, occ, isIso, isU, iso, aniso)); - atoms.Add(new Atoms2(atomLabel, 8, 0, 0, new[] { x, y, z }, occ, isIso, isU, iso, aniso)); + atoms.Add(new Atoms2(atomLabel, 1, 0, 0, [x, y, z], occ, isIso, isU, iso, aniso)); + atoms.Add(new Atoms2(atomLabel, 8, 0, 0, [x, y, z], occ, isIso, isU, iso, aniso)); } } @@ -1278,7 +1278,7 @@ Func<double, double, double, V3> func(string sExpr) return new Crystal2 { - CellTexts = new[] { a, b, c, alpha, beta, gamma }, + CellTexts = [a, b, c, alpha, beta, gamma], sym = (short)sgnum, name = name, atoms = atoms, @@ -1690,12 +1690,12 @@ public static string ConvertToCIF(Crystal crystal) sb.AppendLine("loop_"); sb.AppendLine("_symmetry_equiv_pos_as_xyz"); bool[][] flag = Array.Empty<bool[]>(); - if (sym.LatticeTypeStr == "P") flag = new[] { new[] { false, false, false } }; - else if (sym.LatticeTypeStr == "A") flag = new[] { new[] { false, false, false }, new[] { false, true, true } }; - else if (sym.LatticeTypeStr == "B") flag = new[] { new[] { false, false, false }, new[] { true, false, true } }; - else if (sym.LatticeTypeStr == "C") flag = new[] { new[] { false, false, false }, new[] { true, true, false } }; - else if (sym.LatticeTypeStr == "I") flag = new[] { new[] { false, false, false }, new[] { true, true, true } }; - else if (sym.LatticeTypeStr == "F") flag = new[] { new[] { false, false, false }, new[] { false, true, true }, new[] { true, false, true }, new[] { true, true, false } }; + if (sym.LatticeTypeStr == "P") flag = [[false, false, false]]; + else if (sym.LatticeTypeStr == "A") flag = [[false, false, false], [false, true, true]]; + else if (sym.LatticeTypeStr == "B") flag = [[false, false, false], [true, false, true]]; + else if (sym.LatticeTypeStr == "C") flag = [[false, false, false], [true, true, false]]; + else if (sym.LatticeTypeStr == "I") flag = [[false, false, false], [true, true, true]]; + else if (sym.LatticeTypeStr == "F") flag = [[false, false, false], [false, true, true], [true, false, true], [true, true, false]]; foreach (string wp in SymmetryStatic.WyckoffPositions[crystal.SymmetrySeriesNumber][0].PositionStr) { diff --git a/Crystallography/Crystallography.csproj b/Crystallography/Crystallography.csproj index 6a5286e..6e3cfa8 100644 --- a/Crystallography/Crystallography.csproj +++ b/Crystallography/Crystallography.csproj @@ -4,8 +4,8 @@ <OutputType>Library</OutputType> <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework> <UseWindowsForms>true</UseWindowsForms> - <AssemblyVersion>2024.1.13.0858</AssemblyVersion> - <FileVersion>2024.1.13.0858</FileVersion> + <AssemblyVersion>2024.1.13.0914</AssemblyVersion> + <FileVersion>2024.1.13.0914</FileVersion> <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion> </PropertyGroup> diff --git a/Crystallography/Mathematics/Geometriy.cs b/Crystallography/Mathematics/Geometriy.cs index 25c14c0..df4378a 100644 --- a/Crystallography/Mathematics/Geometriy.cs +++ b/Crystallography/Mathematics/Geometriy.cs @@ -90,7 +90,7 @@ public static double[] GetParameterOfCurveOfSecondaryDegree(PointD[] point) double d = C[3]; double e = C[4]; - return new double[] { a, b, c, d, e }; + return [a, b, c, d, e]; } /// <summary> @@ -170,8 +170,8 @@ public static void GetTiltAndOffset(PointD[] EllipseCenter, double[] Radius, dou ref double tau, ref double tauDev, ref double phi, ref double phiDev) { //任意の二点を選んでoffset, tau, phiを計算する - List<double> offsetXList = new(), offsetYList = new(); - List<double> tauList = new(), phiList = new(); + List<double> offsetXList = [], offsetYList = []; + List<double> tauList = [], phiList = []; for (int i = 0; i < EllipseCenter.Length; i++) for (int j = i + 1; j < EllipseCenter.Length; j++) @@ -189,15 +189,15 @@ public static void GetTiltAndOffset(PointD[] EllipseCenter, double[] Radius, dou tauList.Add(tauTemp); phiList.Add(phiTemp); } - offsetDev = new PointD(Statistics.Deviation(offsetXList.ToArray()), Statistics.Deviation(offsetYList.ToArray())); - tauDev = Statistics.Deviation(tauList.ToArray()); + offsetDev = new PointD(Statistics.Deviation([.. offsetXList]), Statistics.Deviation([.. offsetYList])); + tauDev = Statistics.Deviation([.. tauList]); double phiDev1, phiDev2; - phiDev1 = Statistics.Deviation(phiList.ToArray()); + phiDev1 = Statistics.Deviation([.. phiList]); for (int i = 0; i < phiList.Count; i++) if (phiList[i] < 0) phiList[i] += Math.PI; - phiDev2 = Statistics.Deviation(phiList.ToArray()); + phiDev2 = Statistics.Deviation([.. phiList]); phiDev = Math.Min(phiDev1, phiDev2); @@ -461,13 +461,13 @@ public static void GetPixelShape(EllipseParameter[] ellipse, ref double PixX, re } PixX = tempPixX.Average(); - PixXDev = Statistics.Deviation(tempPixX.ToArray()); + PixXDev = Statistics.Deviation([.. tempPixX]); PixY = tempPixY.Average(); - PixYDev = Statistics.Deviation(tempPixY.ToArray()); + PixYDev = Statistics.Deviation([.. tempPixY]); if (distortion) { Ksi = tempKsi.Average(); - KsiDev = Statistics.Deviation(tempKsi.ToArray()); + KsiDev = Statistics.Deviation([.. tempKsi]); } } @@ -599,7 +599,7 @@ public static (double X, double Y)[] GetPolygonDividedByLine((double X, double Y //すべてが範囲外ならnullを返す if (flag2) - return Array.Empty<(double X, double Y)>(); + return []; for (int i = 0; i < ptAlpha.Count; i++) { @@ -618,7 +618,7 @@ public static (double X, double Y)[] GetPolygonDividedByLine((double X, double Y if (ptAlpha[i].Flag) ptBeta.Add((ptAlpha[i].X, ptAlpha[i].Y)); - return ptBeta.ToArray(); + return [.. ptBeta]; } /// <summary> @@ -774,9 +774,9 @@ public static PointD[][] GetPointsWithinRectangle(IEnumerable<PointD> sourcePoin pt.RemoveRange(last, pt.Count - last); if (pt.Max(p => p.Y) <= area.UpperY && pt.Min(pt => pt.Y) >= area.Y) - return new[] { pt.ToArray() }; + return [[.. pt]]; else if (pt.Max(p => p.Y) <= area.Y || pt.Min(pt => pt.Y) >= area.UpperY) - return new[] { Array.Empty<PointD>() }; + return [[]]; else { for (int i = 0; i < pt.Count - 1; i++) @@ -1213,7 +1213,7 @@ public static List<List<PointD>> ConicSection(in double alpha, in double phi, in { if (flags[j]) { - result.Add(new List<PointD>()); + result.Add([]); for (; j < pts.Count && flags[j]; j++) result[^1].Add(pts[j]); }