From 33aad9200025ac63713ec7b53f091b1fb6bba49a Mon Sep 17 00:00:00 2001 From: seto Date: Fri, 1 Nov 2024 18:16:49 +0900 Subject: [PATCH] update --- Crystallography/BetheMethod.cs | 6 +++--- ReciPro/ImageSimulator/FormImageSimulator.cs | 17 ++++++++++------- ReciPro/Version.cs | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Crystallography/BetheMethod.cs b/Crystallography/BetheMethod.cs index 3eb1bee4..e834174c 100644 --- a/Crystallography/BetheMethod.cs +++ b/Crystallography/BetheMethod.cs @@ -1399,7 +1399,7 @@ Complex Lenz(in PointD k, in PointD kq, in double defocus) { for (int x = 0; x < width; x++) { - var rVec = new PointD(-resolution * (x - cX), resolution * (y - cY)) + shift;//X座標はマイナス。 + var rVec = new PointD(resolution * (x - cX), -resolution * (y - cY)) + shift;//Y座標はマイナス。 for (int t = 0; t < Thicknesses.Length; t++) for (int d = 0; d < dLen; d++) { @@ -1571,7 +1571,7 @@ public void GetHRTEMImage(int BlochNum, double AccVol, Matrix3D rot, (double R, Parallel.For(0, divTotal, div => { int start = step * div, count = div == divTotal - 1 ? width * height - start : step; - var rVec = Enumerable.Range(start, count).SelectMany(n => new[] { -res * (n % width - cX) + shift.X, res * (n / width - cY) + shift.Y }).ToArray();//X座標はマイナス。 + var rVec = Enumerable.Range(start, count).SelectMany(n => new[] { res * (n % width - cX) + shift.X, -res * (n / width - cY) + shift.Y }).ToArray();//Y座標はマイナス。 var results = NativeWrapper.HRTEM_Solver(gPsi, gVec, gLenz, rVec, quasiMode); for (var i = 0; i < defLen; i++) Array.Copy(results, i * count, _images[t][i], start, count); @@ -1581,7 +1581,7 @@ public void GetHRTEMImage(int BlochNum, double AccVol, Matrix3D rot, (double R, { Parallel.For(0, width * height, n => { - PointD r = new(-(n % width - cX) * res + shift.X, (n / width - cY) * res + shift.Y), _vec = new(double.NaN, double.NaN);//X座標はマイナス。 + PointD r = new((n % width - cX) * res + shift.X, -(n / width - cY) * res + shift.Y), _vec = new(double.NaN, double.NaN);//Y座標はマイナス。 var sums = new Complex[defLen]; var exp = new Complex(0, 0); foreach (var (Psi, Vec, Lenz) in gList) diff --git a/ReciPro/ImageSimulator/FormImageSimulator.cs b/ReciPro/ImageSimulator/FormImageSimulator.cs index 3b7a3328..79f3878b 100644 --- a/ReciPro/ImageSimulator/FormImageSimulator.cs +++ b/ReciPro/ImageSimulator/FormImageSimulator.cs @@ -365,6 +365,7 @@ private void simulateSTEM(bool realtimeMode = false) { var x = (w - radius + 0.5) / (radius - 0.5) * sin; var y = -(h - radius + 0.5) / (radius - 0.5) * sin;//結晶の座標系は、X軸が右、Y軸が上、Z軸が手前なのでYを反転 + directions.Add(new Vector3DBase(x, y, -Sqrt(1 - x * x - y * y))); } @@ -476,6 +477,8 @@ private void stemCompleted(object sender, RunWorkerCompletedEventArgs e) { //SendImage(ThicknessArray.Length, DefocusArray.Length, FormMain.Crystal.Bethe.STEM_Image, ImageSize.Width, ImageSize.Height); GeneratePseudBitmap(); + + toolStripProgressBar.Value = toolStripProgressBar.Maximum; toolStripStatusLabel1.Text = $"Completed! Total ellapsed time: {(s1 + s2 + s3 + s4) / 1000.0:f1} sec."; toolStripStatusLabel1.Text += $" Stage 1: {s1 / 1000.0:f1} sec. Stage 2: {s2 / 1000.0:f1} sec. Stage 3: {s3 / 1000.0:f1} sec. Stage 4: {s4 / 1000.0:f1} sec."; @@ -537,9 +540,10 @@ private void simulatePotential(bool realtimeMode = false) Beams = FormMain.Crystal.Bethe.GetDifractedBeamAmpriltudes(BlochNum, AccVol, FormMain.Crystal.RotationMatrix, ThicknessArray[0]); var images = FormMain.Crystal.Bethe.GetPotentialImage(Beams, ImageSize, ImageResolution, radioButtonPotentialModeMagAndPhase.Checked); - //画像が上下左右反転しているみたいなので、処理 20230304 - for (int i = 0; i < images.Length; i++) - images[i] = [.. images[i].Reverse()]; + //画像が上下左右反転 (180度回転) しているみたいなので、処理 20230304 + //なぜかまた上下左右反転 (180度回転) しているみたいなので、削除 20241101 + //for (int i = 0; i < images.Length; i++) + // images[i] = [.. images[i].Reverse()]; var temp = sw1.ElapsedMilliseconds; @@ -677,6 +681,9 @@ public void GeneratePseudBitmap() for (int t = 0; t < tLen; t++) _images[t] = new double[dLen][]; + //20241101 生成した画像が180度回転していることが発覚したため、ここで修正 + + //作成したイメージをPseudoBitmapに変換 var pseudo = radioButtonHorizontalDefocus.Checked ? new PseudoBitmap[tLen, dLen] : new PseudoBitmap[dLen, tLen]; var mat = rot * FormMain.Crystal.MatrixReal; @@ -1150,7 +1157,6 @@ private void drawSymbols(Graphics g, Func conv, double zoom, Ima } - private enum formatEnum { Meta, PNG, TIFF } private enum actionEnum { Save, Copy } private void Save(formatEnum format, actionEnum action) @@ -1295,9 +1301,6 @@ private void FormImageSimulator_KeyDown(object sender, KeyEventArgs e) private void ToolStripMenuItemSavePNG_Click(object sender, EventArgs e) => Save(formatEnum.PNG, actionEnum.Save); private void ToolStripMenuItemSaveTIFF_Click(object sender, EventArgs e) => Save(formatEnum.TIFF, actionEnum.Save); private void ToolStripMenuItemSaveMetafile_Click(object sender, EventArgs e) => Save(formatEnum.Meta, actionEnum.Save); - - - private void ToolStripMenuItemCopyImage_Click(object sender, EventArgs e) => Save(formatEnum.PNG, actionEnum.Copy); private void ToolStripMenuItemCopyMetafile_Click(object sender, EventArgs e) => Save(formatEnum.Meta, actionEnum.Copy); #endregion 画像のコピー/保存 diff --git a/ReciPro/Version.cs b/ReciPro/Version.cs index 8d4ca8d6..8de13f00 100644 --- a/ReciPro/Version.cs +++ b/ReciPro/Version.cs @@ -7,6 +7,7 @@ internal static class Version public const string History = "History" + + "\r\n ver4.893(2024/11/01) Fixed bugs on the 'Diffraction Simulator' and 'HRTEM/STEM simulator' (thanks to lukmuk-san and Nakamura-san!)." + "\r\n ver4.892(2024/10/04) Added several 'Macro' functions." + "\r\n ver4.891(2024/09/06) Added the function to simulate electron trajectories based on the Monte Carlo method." + "\r\n ver4.890(2024/08/10) Improved 'Macro' functions." +