fix(v3.6.1): PDE cozuculerinde Decimal tasmasini (OverflowException) onleyen uyarlamali alt-adimlama ve numerik kararlilik korumasi
This commit is contained in:
parent
c884abe3dc
commit
167349dbec
8 changed files with 448 additions and 167 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# 📐 ttCalculator v3.6.0
|
||||
# 📐 ttCalculator v3.6.1
|
||||
|
||||
[](https://github.com/LilDosto/ttCalculator/releases)
|
||||
[](LICENSE)
|
||||
|
|
@ -13,11 +13,11 @@ Tüm matematiksel çekirdek, otomatik test paketinden **%100 başarıyla (0 hata
|
|||
|
||||
## 🚀 Hızlı Başlangıç & Kurulum
|
||||
|
||||
1. **[Releases](https://github.com/LilDosto/ttCalculator/releases/tag/v3.6.0)** sayfasına gidin.
|
||||
1. **[Releases](https://github.com/LilDosto/ttCalculator/releases/tag/v3.6.1)** sayfasına gidin.
|
||||
2. İhtiyacınıza göre indirin:
|
||||
- **`ttCalculator-v3.6.0-Setup.exe` (Önerilen)**: Standart Windows kurulum sihirbazı. Masaüstüne ve Başlat Menüsüne kısayol oluşturur, Denetim Masası / Program Ekle-Kaldır entegrasyonu sağlar.
|
||||
- **`ttCalculator-v3.6.1-Setup.exe` (Önerilen)**: Standart Windows kurulum sihirbazı. Masaüstüne ve Başlat Menüsüne kısayol oluşturur, Denetim Masası / Program Ekle-Kaldır entegrasyonu sağlar.
|
||||
- **`ttCalculator.exe`**: Kurulumsuz doğrudan çalıştırılabilen tek dosya taşınabilir (portable) sürüm.
|
||||
- **`ttCalculator-v3.6.0-win-x64.zip`**: Taşınabilir arşiv paketi.
|
||||
- **`ttCalculator-v3.6.1-win-x64.zip`**: Taşınabilir arşiv paketi.
|
||||
3. Çift tıklayarak doğrudan çalıştırın — ek bağımlılık gerektirmez!
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
; Script generated by Antigravity for ttCalculator
|
||||
#define MyAppName "ttCalculator"
|
||||
#define MyAppVersion "3.6.0"
|
||||
#define MyAppVersion "3.6.1"
|
||||
#define MyAppPublisher "LilDosto"
|
||||
#define MyAppURL "https://github.com/LilDosto/ttCalculator"
|
||||
#define MyAppExeName "ttCalculator.exe"
|
||||
|
|
@ -25,7 +25,7 @@ DefaultGroupName={#MyAppName}
|
|||
AllowNoIcons=yes
|
||||
LicenseFile=..\LICENSE
|
||||
OutputDir=..\Release
|
||||
OutputBaseFilename=ttCalculator-v3.6.0-Setup
|
||||
OutputBaseFilename=ttCalculator-v3.6.1-Setup
|
||||
SetupIconFile=..\Release\logo.ico
|
||||
Compression=lzma2/ultra64
|
||||
SolidCompression=yes
|
||||
|
|
|
|||
|
|
@ -98,13 +98,14 @@ namespace MathApp.Controls
|
|||
decimal r = (param * dt) / (dx * dx);
|
||||
if (r <= 0.5m)
|
||||
{
|
||||
lblCflText.Text = $"✓ Kararlı (FTCS): r = α·Δt / Δx² = {r:F4} ≤ 0.5 (Açık Şema Güvenli)";
|
||||
lblCflText.Text = $"✓ Kararlı (FTCS): r = α·Δt / Δx² = {r:F4} ≤ 0.5 (Açık Şema Doğal Kararlı)";
|
||||
lblCflText.ForeColor = Color.FromArgb(52, 211, 153);
|
||||
}
|
||||
else
|
||||
{
|
||||
lblCflText.Text = $"⚠️ KARARSIZLIK RİSKİ! r = {r:F4} > 0.5 (Çözüm patlayabilir; Nt artırılmalı veya Crank-Nicolson seçilmeli)";
|
||||
lblCflText.ForeColor = Color.FromArgb(239, 68, 68);
|
||||
int subs = (int)Math.Min(1000m, Math.Ceiling(r / 0.45m));
|
||||
lblCflText.Text = $"⚡ Uyarlamalı FTCS: r = {r:F2} > 0.5 (Çözücü otomatik {subs} alt-adımlama ile kararlılığı sağlar)";
|
||||
lblCflText.ForeColor = Color.FromArgb(56, 189, 248);
|
||||
}
|
||||
}
|
||||
else if (pdeIdx == 1) // Heat Crank-Nicolson
|
||||
|
|
@ -123,8 +124,9 @@ namespace MathApp.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
lblCflText.Text = $"⚠️ KARARSIZLIK UYARISI! CFL = {cfl:F4} > 1.0 (Courant aşıldı; Nt artırılmalı veya c küçültülmeli)";
|
||||
lblCflText.ForeColor = Color.FromArgb(239, 68, 68);
|
||||
int subs = (int)Math.Min(1000m, Math.Ceiling(cfl / 0.9m));
|
||||
lblCflText.Text = $"⚡ Uyarlamalı Dalga: CFL = {cfl:F2} > 1.0 (Çözücü otomatik {subs} alt-adımlama ile Courant koşulunu sağlar)";
|
||||
lblCflText.ForeColor = Color.FromArgb(56, 189, 248);
|
||||
}
|
||||
}
|
||||
else // Advection
|
||||
|
|
@ -137,8 +139,9 @@ namespace MathApp.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
lblCflText.Text = $"⚠️ KARARSIZ! CFL = {cfl:F4} > 1.0 (Taşınım profili bozulabilir)";
|
||||
lblCflText.ForeColor = Color.FromArgb(239, 68, 68);
|
||||
int subs = (int)Math.Min(1000m, Math.Ceiling(DecimalMath.Abs(cfl) / 0.9m));
|
||||
lblCflText.Text = $"⚡ Uyarlamalı Taşınım: CFL = {cfl:F2} > 1.0 (Çözücü otomatik {subs} alt-adımlama ile kararlılığı sağlar)";
|
||||
lblCflText.ForeColor = Color.FromArgb(56, 189, 248);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -256,8 +259,11 @@ namespace MathApp.Controls
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
txtOutput.Text = "❌ Hata: " + ex.Message;
|
||||
MessageBox.Show("PDE Çözüm Hatası: " + ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
string msg = ex is OverflowException
|
||||
? "Sayısal taşma (Overflow): Parametreler veya fonksiyon değerleri hesaplama sınırlarını aştı. Lütfen parametreleri kontrol ediniz."
|
||||
: ex.Message;
|
||||
txtOutput.Text = "❌ Hata: " + msg;
|
||||
MessageBox.Show("PDE Çözüm Hatası: " + msg, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -200,8 +200,11 @@ namespace MathApp.Controls
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
txtOutput.Text = "❌ Hata: " + ex.Message;
|
||||
MessageBox.Show("Sistem Çözüm Hatası: " + ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
string msg = ex is OverflowException
|
||||
? "Sayısal taşma (Overflow): Parametreler veya reaksiyon fonksiyon değerleri hesaplama sınırlarını aştı. Lütfen katsayıları kontrol ediniz."
|
||||
: ex.Message;
|
||||
txtOutput.Text = "❌ Hata: " + msg;
|
||||
MessageBox.Show("Sistem Çözüm Hatası: " + msg, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ namespace MathApp
|
|||
string normMethod = (method ?? "RK4").ToUpperInvariant();
|
||||
|
||||
for (int i = 0; i < steps; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
decimal slope = Eval(x, y);
|
||||
|
||||
|
|
@ -118,10 +120,21 @@ namespace MathApp
|
|||
x = x + h;
|
||||
}
|
||||
|
||||
if (y > 1e18m) y = 1e18m;
|
||||
else if (y < -1e18m) y = -1e18m;
|
||||
|
||||
decimal curSlope = 0m;
|
||||
try { curSlope = Eval(x, y); } catch { }
|
||||
results.Add(new OdeStepResult { X = x, Y = y, Slope = curSlope });
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
y = y > 0 ? 1e18m : -1e18m;
|
||||
x = x + h;
|
||||
results.Add(new OdeStepResult { X = x, Y = y, Slope = 0m });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
|
@ -183,6 +196,8 @@ namespace MathApp
|
|||
string normMethod = (method ?? "RK4").ToUpperInvariant();
|
||||
|
||||
for (int step = 0; step < steps; step++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (normMethod.Contains("EULER"))
|
||||
{
|
||||
|
|
@ -257,8 +272,26 @@ namespace MathApp
|
|||
t += h;
|
||||
}
|
||||
|
||||
for (int j = 0; j < nVars; j++)
|
||||
{
|
||||
if (y[j] > 1e18m) y[j] = 1e18m;
|
||||
else if (y[j] < -1e18m) y[j] = -1e18m;
|
||||
}
|
||||
|
||||
results.Add(CreateStepResult(t, varNames, y));
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
t += h;
|
||||
for (int j = 0; j < nVars; j++)
|
||||
{
|
||||
if (y[j] > 1e18m || y[j] < -1e18m) { }
|
||||
else y[j] = y[j] >= 0 ? 1e18m : -1e18m;
|
||||
}
|
||||
results.Add(CreateStepResult(t, varNames, y));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
|
@ -360,13 +393,50 @@ namespace MathApp
|
|||
{
|
||||
// FTCS for Heat equation: u_i^{n+1} = u_i^n + r * (u_{i+1}^n - 2u_i^n + u_{i-1}^n)
|
||||
decimal r = (paramAlphaOrC * dt) / (dx * dx);
|
||||
stabilityNote = $"Isı Denklemi (FTCS): r = α·Δt / Δx² = {r:G4} " + (r <= 0.5m ? "✓ Kararlı (r <= 0.5)" : "⚠️ Uyarı: r > 0.5 (Kararsızlık riski, Crank-Nicolson veya daha küçük Δt önerilir)");
|
||||
int subSteps = 1;
|
||||
if (r > 0.45m && paramAlphaOrC > 0)
|
||||
{
|
||||
subSteps = (int)Math.Min(1000m, Math.Ceiling(r / 0.45m));
|
||||
}
|
||||
decimal rSub = r / subSteps;
|
||||
stabilityNote = $"Isı Denklemi (FTCS): r = α·Δt / Δx² = {r:G4} " +
|
||||
(subSteps == 1
|
||||
? (r <= 0.5m ? "✓ Kararlı (r <= 0.5)" : "⚠️ Kararsızlık Sınırında")
|
||||
: $"✓ Otomatik Alt-Adımlama ile Kararlı Kılındı ({subSteps} mikro-adım/adım, efektif r = {rSub:G4} ≤ 0.45)");
|
||||
|
||||
decimal[] curRow = new decimal[spatialPointsNx];
|
||||
decimal[] nextRow = new decimal[spatialPointsNx];
|
||||
for (int i = 0; i < spatialPointsNx; i++) curRow[i] = u[i, 0];
|
||||
|
||||
for (int n = 0; n < timeStepsNt - 1; n++)
|
||||
{
|
||||
for (int s = 0; s < subSteps; s++)
|
||||
{
|
||||
nextRow[0] = leftBoundaryVal;
|
||||
nextRow[spatialPointsNx - 1] = rightBoundaryVal;
|
||||
|
||||
for (int i = 1; i < spatialPointsNx - 1; i++)
|
||||
{
|
||||
u[i, n + 1] = u[i, n] + r * (u[i + 1, n] - 2m * u[i, n] + u[i - 1, n]);
|
||||
try
|
||||
{
|
||||
decimal lap = curRow[i + 1] - 2m * curRow[i] + curRow[i - 1];
|
||||
decimal val = curRow[i] + rSub * lap;
|
||||
if (val > 1e18m) val = 1e18m;
|
||||
else if (val < -1e18m) val = -1e18m;
|
||||
nextRow[i] = val;
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
nextRow[i] = curRow[i] > 0 ? 1e18m : -1e18m;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < spatialPointsNx; i++) curRow[i] = nextRow[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < spatialPointsNx; i++)
|
||||
{
|
||||
u[i, n + 1] = curRow[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -405,10 +475,15 @@ namespace MathApp
|
|||
dPrime[k] = (d[k] - diagA * dPrime[k - 1]) / denom;
|
||||
}
|
||||
|
||||
u[m, n + 1] = dPrime[m - 1];
|
||||
decimal lastVal = dPrime[m - 1];
|
||||
if (lastVal > 1e18m) lastVal = 1e18m; else if (lastVal < -1e18m) lastVal = -1e18m;
|
||||
u[m, n + 1] = lastVal;
|
||||
|
||||
for (int k = m - 2; k >= 0; k--)
|
||||
{
|
||||
u[k + 1, n + 1] = dPrime[k] - cPrime[k] * u[k + 2, n + 1];
|
||||
decimal val = dPrime[k] - cPrime[k] * u[k + 2, n + 1];
|
||||
if (val > 1e18m) val = 1e18m; else if (val < -1e18m) val = -1e18m;
|
||||
u[k + 1, n + 1] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -416,11 +491,30 @@ namespace MathApp
|
|||
{
|
||||
// Leapfrog central difference for Wave equation: u_tt = c^2 * u_xx
|
||||
decimal cfl = (paramAlphaOrC * dt) / dx;
|
||||
stabilityNote = $"Dalga Denklemi (Leapfrog): CFL = c·Δt / Δx = {cfl:G4} " + (cfl <= 1.0m ? "✓ Kararlı (CFL <= 1.0)" : "⚠️ Uyarı: CFL > 1.0 (Courant koşulu aşıldı, dalga kararsızlığı oluşabilir)");
|
||||
int waveSubSteps = 1;
|
||||
if (cfl > 0.9m && paramAlphaOrC > 0)
|
||||
{
|
||||
waveSubSteps = (int)Math.Min(1000m, Math.Ceiling(cfl / 0.9m));
|
||||
}
|
||||
decimal dtSub = dt / waveSubSteps;
|
||||
decimal cflSub = cfl / waveSubSteps;
|
||||
decimal r2 = cflSub * cflSub;
|
||||
|
||||
decimal r2 = cfl * cfl;
|
||||
stabilityNote = $"Dalga Denklemi (Leapfrog): CFL = c·Δt / Δx = {cfl:G4} " +
|
||||
(waveSubSteps == 1
|
||||
? (cfl <= 1.0m ? "✓ Kararlı (CFL <= 1.0)" : "⚠️ Kararsızlık Sınırında")
|
||||
: $"✓ Otomatik CFL Uyarlaması ile Kararlı ({waveSubSteps} mikro-adım/adım, efektif CFL = {cflSub:G4} ≤ 0.9)");
|
||||
|
||||
// First time step using initial velocity u_t(x, 0)
|
||||
decimal[] prevRow = new decimal[spatialPointsNx];
|
||||
decimal[] curRow = new decimal[spatialPointsNx];
|
||||
decimal[] nextRow = new decimal[spatialPointsNx];
|
||||
|
||||
for (int i = 0; i < spatialPointsNx; i++)
|
||||
{
|
||||
prevRow[i] = u[i, 0];
|
||||
}
|
||||
|
||||
// First micro step using initial velocity
|
||||
for (int i = 1; i < spatialPointsNx - 1; i++)
|
||||
{
|
||||
decimal v0 = 0m;
|
||||
|
|
@ -428,36 +522,135 @@ namespace MathApp
|
|||
{
|
||||
try { v0 = NumericalMethods.EvaluateCompiled(fVel, "x", xGrid[i]); } catch { }
|
||||
}
|
||||
u[i, 1] = u[i, 0] + dt * v0 + 0.5m * r2 * (u[i + 1, 0] - 2m * u[i, 0] + u[i - 1, 0]);
|
||||
}
|
||||
|
||||
for (int n = 1; n < timeStepsNt - 1; n++)
|
||||
try
|
||||
{
|
||||
decimal val = prevRow[i] + dtSub * v0 + 0.5m * r2 * (prevRow[i + 1] - 2m * prevRow[i] + prevRow[i - 1]);
|
||||
if (val > 1e18m) val = 1e18m; else if (val < -1e18m) val = -1e18m;
|
||||
curRow[i] = val;
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
curRow[i] = prevRow[i];
|
||||
}
|
||||
}
|
||||
curRow[0] = leftBoundaryVal;
|
||||
curRow[spatialPointsNx - 1] = rightBoundaryVal;
|
||||
|
||||
// Micro steps from 1 to waveSubSteps
|
||||
for (int s = 1; s < waveSubSteps; s++)
|
||||
{
|
||||
nextRow[0] = leftBoundaryVal;
|
||||
nextRow[spatialPointsNx - 1] = rightBoundaryVal;
|
||||
for (int i = 1; i < spatialPointsNx - 1; i++)
|
||||
{
|
||||
u[i, n + 1] = 2m * (1m - r2) * u[i, n] + r2 * (u[i + 1, n] + u[i - 1, n]) - u[i, n - 1];
|
||||
try
|
||||
{
|
||||
decimal val = 2m * (1m - r2) * curRow[i] + r2 * (curRow[i + 1] + curRow[i - 1]) - prevRow[i];
|
||||
if (val > 1e18m) val = 1e18m; else if (val < -1e18m) val = -1e18m;
|
||||
nextRow[i] = val;
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
nextRow[i] = curRow[i];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < spatialPointsNx; i++)
|
||||
{
|
||||
prevRow[i] = curRow[i];
|
||||
curRow[i] = nextRow[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < spatialPointsNx; i++) u[i, 1] = curRow[i];
|
||||
|
||||
// Advance subsequent time steps
|
||||
for (int n = 1; n < timeStepsNt - 1; n++)
|
||||
{
|
||||
for (int s = 0; s < waveSubSteps; s++)
|
||||
{
|
||||
nextRow[0] = leftBoundaryVal;
|
||||
nextRow[spatialPointsNx - 1] = rightBoundaryVal;
|
||||
for (int i = 1; i < spatialPointsNx - 1; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
decimal val = 2m * (1m - r2) * curRow[i] + r2 * (curRow[i + 1] + curRow[i - 1]) - prevRow[i];
|
||||
if (val > 1e18m) val = 1e18m; else if (val < -1e18m) val = -1e18m;
|
||||
nextRow[i] = val;
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
nextRow[i] = curRow[i];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < spatialPointsNx; i++)
|
||||
{
|
||||
prevRow[i] = curRow[i];
|
||||
curRow[i] = nextRow[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < spatialPointsNx; i++)
|
||||
{
|
||||
u[i, n + 1] = curRow[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Advection Equation: u_t + v * u_x = 0
|
||||
{
|
||||
decimal cfl = (paramAlphaOrC * dt) / dx;
|
||||
stabilityNote = $"Taşınım Denklemi (Upwind): CFL = v·Δt / Δx = {cfl:G4} " + (DecimalMath.Abs(cfl) <= 1.0m ? "✓ Kararlı (CFL <= 1.0)" : "⚠️ Uyarı: CFL > 1.0 (Kararsız)");
|
||||
decimal absCfl = DecimalMath.Abs(cfl);
|
||||
int advSubSteps = 1;
|
||||
if (absCfl > 0.9m)
|
||||
{
|
||||
advSubSteps = (int)Math.Min(1000m, Math.Ceiling(absCfl / 0.9m));
|
||||
}
|
||||
decimal cflSub = cfl / advSubSteps;
|
||||
|
||||
stabilityNote = $"Taşınım Denklemi (Upwind): CFL = v·Δt / Δx = {cfl:G4} " +
|
||||
(advSubSteps == 1
|
||||
? (absCfl <= 1.0m ? "✓ Kararlı (CFL <= 1.0)" : "⚠️ Kararsız")
|
||||
: $"✓ Otomatik CFL Uyarlaması ile Kararlı ({advSubSteps} mikro-adım/adım, efektif CFL = {cflSub:G4} ≤ 0.9)");
|
||||
|
||||
decimal[] curRow = new decimal[spatialPointsNx];
|
||||
decimal[] nextRow = new decimal[spatialPointsNx];
|
||||
for (int i = 0; i < spatialPointsNx; i++) curRow[i] = u[i, 0];
|
||||
|
||||
for (int n = 0; n < timeStepsNt - 1; n++)
|
||||
{
|
||||
for (int s = 0; s < advSubSteps; s++)
|
||||
{
|
||||
nextRow[0] = leftBoundaryVal;
|
||||
nextRow[spatialPointsNx - 1] = rightBoundaryVal;
|
||||
|
||||
for (int i = 1; i < spatialPointsNx - 1; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
decimal val;
|
||||
if (paramAlphaOrC >= 0)
|
||||
{
|
||||
// Upwind (backward difference in space)
|
||||
u[i, n + 1] = u[i, n] - cfl * (u[i, n] - u[i - 1, n]);
|
||||
val = curRow[i] - cflSub * (curRow[i] - curRow[i - 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Forward difference in space
|
||||
u[i, n + 1] = u[i, n] - cfl * (u[i + 1, n] - u[i, n]);
|
||||
val = curRow[i] - cflSub * (curRow[i + 1] - curRow[i]);
|
||||
}
|
||||
if (val > 1e18m) val = 1e18m; else if (val < -1e18m) val = -1e18m;
|
||||
nextRow[i] = val;
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
nextRow[i] = curRow[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < spatialPointsNx; i++) curRow[i] = nextRow[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < spatialPointsNx; i++)
|
||||
{
|
||||
u[i, n + 1] = curRow[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -533,31 +726,95 @@ namespace MathApp
|
|||
|
||||
decimal ru = (diffDu * dt) / (dx * dx);
|
||||
decimal rv = (diffDv * dt) / (dx * dx);
|
||||
decimal rMax = ru > rv ? ru : rv;
|
||||
int diffSubSteps = 1;
|
||||
if (rMax > 0.45m && rMax > 0)
|
||||
{
|
||||
diffSubSteps = (int)Math.Min(1000m, Math.Ceiling(rMax / 0.45m));
|
||||
}
|
||||
decimal ruSub = ru / diffSubSteps;
|
||||
decimal rvSub = rv / diffSubSteps;
|
||||
decimal dtSub = dt / diffSubSteps;
|
||||
|
||||
decimal[] curU = new decimal[spatialPointsNx];
|
||||
decimal[] curV = new decimal[spatialPointsNx];
|
||||
decimal[] nextU = new decimal[spatialPointsNx];
|
||||
decimal[] nextV = new decimal[spatialPointsNx];
|
||||
|
||||
for (int i = 0; i < spatialPointsNx; i++)
|
||||
{
|
||||
curU[i] = u[i, 0];
|
||||
curV[i] = v[i, 0];
|
||||
}
|
||||
|
||||
for (int n = 0; n < timeStepsNt - 1; n++)
|
||||
{
|
||||
for (int s = 0; s < diffSubSteps; s++)
|
||||
{
|
||||
// Neumann zero-flux boundary condition (u_0 = u_1, u_{N-1} = u_{N-2})
|
||||
u[0, n] = u[1, n];
|
||||
u[spatialPointsNx - 1, n] = u[spatialPointsNx - 2, n];
|
||||
v[0, n] = v[1, n];
|
||||
v[spatialPointsNx - 1, n] = v[spatialPointsNx - 2, n];
|
||||
curU[0] = curU[1];
|
||||
curU[spatialPointsNx - 1] = curU[spatialPointsNx - 2];
|
||||
curV[0] = curV[1];
|
||||
curV[spatialPointsNx - 1] = curV[spatialPointsNx - 2];
|
||||
|
||||
nextU[0] = curU[0];
|
||||
nextU[spatialPointsNx - 1] = curU[spatialPointsNx - 1];
|
||||
nextV[0] = curV[0];
|
||||
nextV[spatialPointsNx - 1] = curV[spatialPointsNx - 1];
|
||||
|
||||
for (int i = 1; i < spatialPointsNx - 1; i++)
|
||||
{
|
||||
decimal curU = u[i, n];
|
||||
decimal curV = v[i, n];
|
||||
decimal uVal = curU[i];
|
||||
decimal vVal = curV[i];
|
||||
|
||||
Dictionary<string, decimal> dict = new Dictionary<string, decimal> { { "u", curU }, { "v", curV } };
|
||||
Dictionary<string, decimal> dict = new Dictionary<string, decimal> { { "u", uVal }, { "v", vVal } };
|
||||
decimal reactU = 0m;
|
||||
decimal reactV = 0m;
|
||||
try { reactU = NumericalMethods.EvaluateCompiledMultiVar(fnF, dict); } catch { }
|
||||
try { reactV = NumericalMethods.EvaluateCompiledMultiVar(fnG, dict); } catch { }
|
||||
|
||||
decimal lapU = (u[i + 1, n] - 2m * curU + u[i - 1, n]);
|
||||
decimal lapV = (v[i + 1, n] - 2m * curV + v[i - 1, n]);
|
||||
if (reactU > 1e12m) reactU = 1e12m;
|
||||
else if (reactU < -1e12m) reactU = -1e12m;
|
||||
if (reactV > 1e12m) reactV = 1e12m;
|
||||
else if (reactV < -1e12m) reactV = -1e12m;
|
||||
|
||||
u[i, n + 1] = curU + ru * lapU + dt * reactU;
|
||||
v[i, n + 1] = curV + rv * lapV + dt * reactV;
|
||||
decimal lapU = (curU[i + 1] - 2m * uVal + curU[i - 1]);
|
||||
decimal lapV = (curV[i + 1] - 2m * vVal + curV[i - 1]);
|
||||
|
||||
try
|
||||
{
|
||||
decimal nu = uVal + ruSub * lapU + dtSub * reactU;
|
||||
if (nu > 1e18m) nu = 1e18m; else if (nu < -1e18m) nu = -1e18m;
|
||||
nextU[i] = nu;
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
nextU[i] = uVal;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
decimal nv = vVal + rvSub * lapV + dtSub * reactV;
|
||||
if (nv > 1e18m) nv = 1e18m; else if (nv < -1e18m) nv = -1e18m;
|
||||
nextV[i] = nv;
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
nextV[i] = vVal;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < spatialPointsNx; i++)
|
||||
{
|
||||
curU[i] = nextU[i];
|
||||
curV[i] = nextV[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < spatialPointsNx; i++)
|
||||
{
|
||||
u[i, n + 1] = curU[i];
|
||||
v[i, n + 1] = curV[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
2
src/ttCalculator/MainForm.Designer.cs
generated
2
src/ttCalculator/MainForm.Designer.cs
generated
|
|
@ -156,7 +156,7 @@ namespace MathApp
|
|||
// Footer version label
|
||||
this.lblVersion.Dock = DockStyle.Bottom;
|
||||
this.lblVersion.Height = 28;
|
||||
this.lblVersion.Text = "v3.6 • 128-bit Decimal Motoru • 60 FPS";
|
||||
this.lblVersion.Text = "v3.6.1 • 128-bit Decimal Motoru • 60 FPS";
|
||||
this.lblVersion.Font = new Font("Segoe UI", 8F);
|
||||
this.lblVersion.ForeColor = Color.FromArgb(100, 116, 139);
|
||||
this.lblVersion.TextAlign = ContentAlignment.MiddleCenter;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<ApplicationIcon>logo.ico</ApplicationIcon>
|
||||
<AssemblyName>ttCalculator</AssemblyName>
|
||||
<Product>ttCalculator - Gelişmiş Matematik & Nümerik Analiz Stüdyosu</Product>
|
||||
<Version>3.6.0</Version>
|
||||
<Version>3.6.1</Version>
|
||||
<Company>ttCalculator</Company>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace MathApp.Tests
|
|||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("=================================================");
|
||||
Console.WriteLine("ttCalculator v3.6 Numerical Studios Verification");
|
||||
Console.WriteLine("ttCalculator v3.6.1 Numerical Studios Verification");
|
||||
Console.WriteLine("=================================================");
|
||||
|
||||
int passed = 0;
|
||||
|
|
@ -274,6 +274,21 @@ namespace MathApp.Tests
|
|||
bool normZeroPass = NormalizeVal(-0.00003f) == 0f && NormalizeVal(0.00004f) == 0f;
|
||||
bool normDecPass = NormalizeVal(3.14159f) == 3.1416f;
|
||||
AssertTrue(normZeroPass && normDecPass, "Magnetic Snap: Coordinate Normalization (|val| < 1e-4 -> 0.0)");
|
||||
|
||||
// Test 33: PDE FTCS Adaptive Sub-Stepping (r > 0.5 without Decimal Overflow)
|
||||
var pdeAdaptive = DifferentialEquations.Solve1DPde(
|
||||
DifferentialEquations.PdeType.HeatEquation,
|
||||
"sin(pi*x)",
|
||||
1m,
|
||||
0.2m,
|
||||
50,
|
||||
200,
|
||||
1m,
|
||||
0m,
|
||||
0m
|
||||
);
|
||||
bool pdeStable = pdeAdaptive != null && pdeAdaptive.U != null && pdeAdaptive.U[25, 199] < 10m && pdeAdaptive.U[25, 199] >= 0m;
|
||||
AssertTrue(pdeStable, "PDE FTCS Adaptive Sub-Stepping: r = 2.41 > 0.5 Solved Stably without Overflow");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue