Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
seto77 committed Jan 13, 2024
1 parent 7a820a6 commit 608307f
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 60 deletions.
4 changes: 2 additions & 2 deletions CSManager/CSManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Binary file modified CSManager/doc/CSManager(en).pdf
Binary file not shown.
Binary file modified CSManager/doc/CSManager(ja).pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion Crystallography.Controls/Crystal/AtomControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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] :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ private void SaveDatabaseWorker_DoWork(object sender, DoWorkEventArgs e)

//最後まで来ている時で、かつ閾値以下の容量で、かつこれまで一度も分割もしていない場合
if (i + division >= total && byteList.Count <= thresholdBytes && filecounter == 0)
fs.Write(byteList.ToArray(), 0, byteList.Count);//最初のファイルに書き込んで終了
fs.Write([.. byteList], 0, byteList.Count);//最初のファイルに書き込んで終了

//最後まで来ている時か、閾値以上の容量の場合
else if (i + division >= total || byteList.Count > thresholdBytes)
{
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();

Expand Down
4 changes: 2 additions & 2 deletions Crystallography.Controls/Crystallography.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions Crystallography/Atom/AtomStatic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Crystallography/Atom/AtomStaticSub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static readonly (double X, double Y)[][][] MassAbsorptionCoefficient =
#region
[
[
System.Array.Empty<(double X, double Y)>()
[]
],

[
Expand Down
4 changes: 2 additions & 2 deletions Crystallography/Atom/Atoms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions Crystallography/Crystal/BondsAndPolyhedra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public partial class Bonds

[XmlIgnore]
//[MemoryPackIgnore]
public List<int[]> pairID = new();
public List<int[]> pairID = [];

#endregion

Expand Down Expand Up @@ -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()
Expand Down
58 changes: 29 additions & 29 deletions Crystallography/Crystal/ConvertCrystalData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()
};
Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand Down Expand Up @@ -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>();
Expand Down Expand Up @@ -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[]>;
Expand Down Expand Up @@ -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));
}
}

Expand All @@ -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,
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions Crystallography/Crystallography.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
30 changes: 15 additions & 15 deletions Crystallography/Mathematics/Geometriy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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++)
Expand All @@ -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);

Expand Down Expand Up @@ -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]);
}
}

Expand Down Expand Up @@ -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++)
{
Expand All @@ -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>
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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]);
}
Expand Down

0 comments on commit 608307f

Please sign in to comment.