Matrix_0 1.0.20
dotnet add package Matrix_0 --version 1.0.20
NuGet\Install-Package Matrix_0 -Version 1.0.20
<PackageReference Include="Matrix_0" Version="1.0.20" />
<PackageVersion Include="Matrix_0" Version="1.0.20" />
<PackageReference Include="Matrix_0" />
paket add Matrix_0 --version 1.0.20
#r "nuget: Matrix_0, 1.0.20"
#:package Matrix_0@1.0.20
#addin nuget:?package=Matrix_0&version=1.0.20
#tool nuget:?package=Matrix_0&version=1.0.20





開啟Visual Studio 2026,執行應用程式專案
在最上層輸入 using Matrix_0; 則會於底部產生紅色折線。
再從功能表 ==> 工具 > NuGet 套件管理員 > 套件管理器主控台,開啟主控台視窗。
輸入 : PM >
dotnet package add Matrix_0@1.0.20或是輸入 : PM >
dotnet package add Matrix_0 --version 1.0.20



則底部的紅色折線會消失,表示已成功加入精銳矩陣類別庫(Matrix_0)。
再輸入C#程式碼,啟動但不偵錯(Ctrl + F5)。則可看到『數值』輸出結果。
另可將輸出的數據,繪製成『視覺化的圖表』
(1)使用Excel繪製、(2)使用Python的Matplotlib套件繪製、(3)使用ChatGPT繪製響應圖。


















/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 微分方程式 : 5y''''(t) + 3y''(t) + 6y + 12 = f(t) = Bf * u(t) *
* 設定 y(t) = B0 * u(t) , B0 = [100 50] u(t) = [ Sin(0.5t) Cos(0.5) ]t *
* @ t = 5 , yg(5) = [y'''(5) y''(5) y'(5) y(5)] = [3 -2 -5 1]t *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
using Matrix_0;
// 已知 (m = 1, r = 4),系統矩陣為 (mxr)X(mxr) 方形矩陣
// 由微分方程式求得系統矩陣 A
double[,] A = {{0, -0.6, 0, -1.2}, {1, 0, 0, 0},
{0, 1, 0, 0}, {0, 0, 1, 0 } };
// @ t0 = 5 秒之量測數據
double[,] yStart = { { 3 }, { -2 }, { -5 }, { 1 } };
// 先求特別解 yp (@ t0 = 5 秒)
ReMatrix yp = (new Particular(5)).Getyp;
// Console.WriteLine(" Particular Solution :\n{0}\n", new PR(yp));
// 求得系統之特徵矩陣 D,模態矩陣 Q,和(@ t0 = 5 秒)響應矩陣 Mat ,
EIG eig = new EIG(A);
CxMatrix D = eig.CxMatrixD; // 特徵矩陣 D
CxMatrix Q = eig.CxMatrixQ; // 模態矩陣 Q
CxHexp Hexp = new CxHexp(D, Q, 5); // @ t0 = 5 秒
CxMatrix Mat = Hexp.GetCxMatrix; // 響應矩陣
Console.WriteLine("\n 響應矩陣 Mat : \n{0}\n", new PR(Mat));
// 係數向量 d
// yStart = Mat * d + yp ==> d = ~Mat * (yStart - yp)
CxMatrix d = ~Mat * ((ReMatrix)yStart - yp);
Console.WriteLine(" 係數向量(複數) d : \n{0}", new PR(d));
// 建構 y0dot, y1dot, y2dot, y3dot 等儲存庫
double step = 0.25;
int iRow = (int)(11 / step + 1);
int iCol = 1 + 1; // m + 1 = 2
ReMatrix y0dot = new ReMatrix(iRow, iCol);
ReMatrix y1dot = new ReMatrix(iRow, iCol);
ReMatrix y2dot = new ReMatrix(iRow, iCol);
ReMatrix y3dot = new ReMatrix(iRow, iCol);
// 時間軸由 t = 0 至 t = 11秒, 輸出計算結果 :
for (int i = 0; i != iRow; i++)
{
double t = step * i;
Hexp = new CxHexp(D, Q, t);
Mat = Hexp.GetCxMatrix;
// Homogeneous Solution (@ t0 = t)
ReMatrix yh = (ReMatrix)(Mat * d);
// Particular Solution (@ t0 = t)
yp = (new Particular(t)).Getyp;
// General Solution (@ t0 = t)
ReMatrix yg = yh + yp;
y3dot.Matrix[i, 0] = y2dot.Matrix[i, 0] =
y1dot.Matrix[i, 0] = y0dot.Matrix[i, 0] = t;
y3dot.Matrix[i, 1] = yg.Matrix[0, 0];
y2dot.Matrix[i, 1] = yg.Matrix[1, 0];
y1dot.Matrix[i, 1] = yg.Matrix[2, 0];
y0dot.Matrix[i, 1] = yg.Matrix[3, 0];
}
// 可用於Excel視覺化列印
Console.WriteLine("\n y3dot :\n{0}", new PR(y3dot));
Console.WriteLine("\n y2dot :\n{0}", new PR(y2dot));
Console.WriteLine("\n y1dot :\n{0}", new PR(y1dot));
Console.WriteLine("\n y0dot :\n{0}", new PR(y0dot));
// 可用於matplotlib.pyplot視覺化列印
Console.WriteLine("\n 時間序列\n{0}\n", new PR4(y3dot, 0));
Console.WriteLine("\n y3dot \n{0}\n", new PR4(y3dot, 1));
Console.WriteLine("\n y2dot \n{0}\n", new PR4(y2dot, 1));
Console.WriteLine("\n y1dot \n{0}\n", new PR4(y1dot, 1));
Console.WriteLine("\n y0dot \n{0}\n", new PR4(y0dot, 1));
// 特別解類別
public class Particular
{
// Field 和 Property
private double[,] B0 = { { 100, 50 } };
private ReMatrix ypVector { get; init; } = default!;
private double t;
// Constructor
public Particular(double tPart)
{
t = tPart;
double temp0 = Math.Sin(0.5 * t);
double temp1 = Math.Cos(0.5 * t);
double[,] constValue = { { 2 } };
// yDot0
ReMatrix uDot0 = new ReMatrix(2, 1);
uDot0.Matrix[0, 0] = temp0;
uDot0.Matrix[1, 0] = temp1;
ReMatrix yDot0 = (ReMatrix)B0 * uDot0 - constValue;
// yDot1
temp0 = 0.5 * Math.Cos(0.5 * t);
temp1 = -0.5 * Math.Sin(0.5 * t);
ReMatrix uDot1 = new ReMatrix(2, 1);
uDot1.Matrix[0, 0] = temp0;
uDot1.Matrix[1, 0] = temp1;
ReMatrix yDot1 = (ReMatrix)B0 * uDot1;
// yDot2
temp0 = -0.25 * Math.Sin(0.5 * t);
temp1 = -0.25 * Math.Cos(0.5 * t);
ReMatrix uDot2 = new ReMatrix(2, 1);
uDot2.Matrix[0, 0] = temp0;
uDot2.Matrix[1, 0] = temp1;
ReMatrix yDot2 = (ReMatrix)B0 * uDot2;
// yDot3
temp0 = -0.125 * Math.Cos(0.5 * t);
temp1 = 0.125 * Math.Sin(0.5 * t);
ReMatrix uDot3 = new ReMatrix(2, 1);
uDot3.Matrix[0, 0] = temp0;
uDot3.Matrix[1, 0] = temp1;
ReMatrix yDot3 = (ReMatrix)B0 * uDot3;
// ypVector = yDot3 | yDot2 | yDot1 | yDot0
ypVector = yDot3 | yDot2 | yDot1 | yDot0;
}
// Property Getyp
public ReMatrix Getyp
{
get
{
return ypVector;
}
}
}
/* 輸出結果 :
響應矩陣 Mat :
-0.01165 - 0.01961i, -0.01165 + 0.01961i, -6.38373 - 10.74937i,
-6.38373 + 10.74937i
-0.00825 + 0.02017i, -0.00825 - 0.02017i, -11.87175 - 1.32074i,
-11.87175 + 1.32074i
0.02013 - 0.00532i, 0.02013 + 0.00532i, -7.84171 + 8.29208i,
-7.84171 - 8.29208i
-0.01565 - 0.01228i, -0.01565 + 0.01228i, 1.80837 + 10.75323i,
1.80837 - 10.75323i
係數向量(複數) d :
749.59832 + 89.66384i
749.59832 - 89.66385i
-0.83606 - 0.34820i
-0.83606 + 0.34820i
y3dot :
0.00000 787.16919
0.25000 639.42296
0.50000 494.03486
0.75000 358.98833
1.00000 239.51794
1.25000 138.54594
1.50000 57.13492
1.75000 -5.07440
2.00000 -49.46223
2.25000 -78.07905
2.50000 -93.35255
2.75000 -97.85369
3.00000 -94.11972
3.25000 -84.52890
3.50000 -71.22011
3.75000 -56.04920
4.00000 -40.57409
4.25000 -26.06046
4.50000 -13.50065
4.75000 -3.63930
5.00000 3.00000
5.25000 6.09123
5.50000 5.48920
5.75000 1.22150
6.00000 -6.50980
6.25000 -17.31695
6.50000 -30.60710
6.75000 -45.55730
7.00000 -61.08741
7.25000 -75.83602
7.50000 -88.14495
7.75000 -96.05949
8.00000 -97.35185
8.25000 -89.57606
8.50000 -70.16240
8.75000 -36.55928
9.00000 13.57119
9.25000 82.09938
9.50000 170.11515
9.75000 277.55880
10.00000 402.80529
10.25000 542.21774
10.50000 689.69522
10.75000 836.24883
11.00000 969.65126
y2dot :
0.00000 -401.16591
0.25000 -222.78785
0.50000 -81.24920
0.75000 25.09903
1.00000 99.54941
1.25000 146.40469
1.50000 170.45639
1.75000 176.57512
2.00000 169.40616
2.25000 153.15928
2.50000 131.47896
2.75000 107.38059
3.00000 83.23791
3.25000 60.80812
3.50000 41.28250
3.75000 25.35241
4.00000 13.28244
4.25000 4.98448
4.50000 0.08870
4.75000 -1.99133
5.00000 -2.00000
5.25000 -0.78750
5.50000 0.73737
5.75000 1.65115
6.00000 1.05897
6.25000 -1.86064
6.50000 -7.80706
6.75000 -17.30324
7.00000 -30.63482
7.25000 -47.78266
7.50000 -68.35036
7.75000 -91.48970
8.00000 -115.82887
8.25000 -139.41031
8.50000 -159.64705
8.75000 -173.30848
9.00000 -176.54813
9.25000 -164.98759
9.50000 -133.87129
9.75000 -78.30669
10.00000 6.39726
10.25000 124.28331
10.50000 278.18626
10.75000 469.06297
11.00000 695.22442
y1dot :
0.00000 -234.31835
0.25000 -311.54210
0.50000 -348.78881
0.75000 -355.10376
1.00000 -338.90022
1.25000 -307.62997
1.50000 -267.59835
1.75000 -223.89553
2.00000 -180.41686
2.25000 -139.94735
2.50000 -104.28825
2.75000 -74.40758
3.00000 -50.59992
3.25000 -32.64431
3.50000 -19.95246
3.75000 -11.70224
4.00000 -6.95360
4.25000 -4.74591
4.50000 -4.17724
4.75000 -4.46648
5.00000 -5.00000
5.25000 -5.36455
5.50000 -5.36768
5.75000 -5.04687
6.00000 -4.66780
6.25000 -4.71168
6.50000 -5.85085
6.75000 -8.91168
7.00000 -14.82293
7.25000 -24.54816
7.50000 -39.00050
7.75000 -58.93909
8.00000 -84.84697
8.25000 -116.79214
8.50000 -154.27520
8.75000 -196.06945
9.00000 -240.06246
9.25000 -283.11124
9.50000 -320.92702
9.75000 -348.00901
10.00000 -357.65032
10.25000 -342.04188
10.50000 -292.50208
10.75000 -199.86028
11.00000 -55.02052
y0dot :
0.00000 729.93040
0.25000 660.76877
0.50000 577.49042
0.75000 488.95029
1.00000 401.81245
1.25000 320.75261
1.50000 248.72426
1.75000 187.25609
2.00000 136.75478
2.25000 96.79421
2.50000 66.37795
2.75000 44.16670
3.00000 28.66666
3.25000 18.37806
3.50000 11.90522
3.75000 8.03138
4.00000 5.76225
4.25000 4.34299
4.50000 3.25304
4.75000 2.18334
5.00000 1.00000
5.25000 -0.30197
5.50000 -1.65152
5.75000 -2.95818
6.00000 -4.16951
6.25000 -5.32680
6.50000 -6.61620
6.75000 -8.41209
7.00000 -11.30949
7.25000 -16.14153
7.50000 -23.97793
7.75000 -36.09975
8.00000 -53.94608
8.25000 -79.02793
8.50000 -112.80568
8.75000 -156.52727
9.00000 -211.02650
9.25000 -276.48300
9.50000 -352.14940
9.75000 -436.05537
10.00000 -524.70355
10.25000 -612.77876
10.50000 -692.89818
10.75000 -755.43769
11.00000 -788.47607
時間序列
0.0000, 0.2500, 0.5000, 0.7500, 1.0000,
1.2500, 1.5000, 1.7500, 2.0000, 2.2500,
2.5000, 2.7500, 3.0000, 3.2500, 3.5000,
3.7500, 4.0000, 4.2500, 4.5000, 4.7500,
5.0000, 5.2500, 5.5000, 5.7500, 6.0000,
6.2500, 6.5000, 6.7500, 7.0000, 7.2500,
7.5000, 7.7500, 8.0000, 8.2500, 8.5000,
8.7500, 9.0000, 9.2500, 9.5000, 9.7500,
10.0000, 10.2500, 10.5000, 10.7500, 11.0000,
y3dot
787.1692, 639.4230, 494.0349, 358.9883, 239.5179,
138.5459, 57.1349, -5.0744, -49.4622, -78.0791,
-93.3526, -97.8537, -94.1197, -84.5289, -71.2201,
-56.0492, -40.5741, -26.0605, -13.5007, -3.6393,
3.0000, 6.0912, 5.4892, 1.2215, -6.5098,
-17.3169, -30.6071, -45.5573, -61.0874, -75.8360,
-88.1449, -96.0595, -97.3519, -89.5761, -70.1624,
-36.5593, 13.5712, 82.0994, 170.1151, 277.5588,
402.8053, 542.2177, 689.6952, 836.2488, 969.6513,
y2dot
-401.1659, -222.7878, -81.2492, 25.0990, 99.5494,
146.4047, 170.4564, 176.5751, 169.4062, 153.1593,
131.4790, 107.3806, 83.2379, 60.8081, 41.2825,
25.3524, 13.2824, 4.9845, 0.0887, -1.9913,
-2.0000, -0.7875, 0.7374, 1.6511, 1.0590,
-1.8606, -7.8071, -17.3032, -30.6348, -47.7827,
-68.3504, -91.4897, -115.8289, -139.4103, -159.6470,
-173.3085, -176.5481, -164.9876, -133.8713, -78.3067,
6.3973, 124.2833, 278.1863, 469.0630, 695.2244,
y1dot
-234.3184, -311.5421, -348.7888, -355.1038, -338.9002,
-307.6300, -267.5984, -223.8955, -180.4169, -139.9474,
-104.2882, -74.4076, -50.5999, -32.6443, -19.9525,
-11.7022, -6.9536, -4.7459, -4.1772, -4.4665,
-5.0000, -5.3646, -5.3677, -5.0469, -4.6678,
-4.7117, -5.8508, -8.9117, -14.8229, -24.5482,
-39.0005, -58.9391, -84.8470, -116.7921, -154.2752,
-196.0695, -240.0625, -283.1112, -320.9270, -348.0090,
-357.6503, -342.0419, -292.5021, -199.8603, -55.0205,
y0dot
729.9304, 660.7688, 577.4904, 488.9503, 401.8125,
320.7526, 248.7243, 187.2561, 136.7548, 96.7942,
66.3780, 44.1667, 28.6667, 18.3781, 11.9052,
8.0314, 5.7622, 4.3430, 3.2530, 2.1833,
1.0000, -0.3020, -1.6515, -2.9582, -4.1695,
-5.3268, -6.6162, -8.4121, -11.3095, -16.1415,
-23.9779, -36.0998, -53.9461, -79.0279, -112.8057,
-156.5273, -211.0265, -276.4830, -352.1494, -436.0554,
-524.7036, -612.7788, -692.8982, -755.4377, -788.4761,
*/

### 微分方程式 :
### 5 * y''''(t) + 3 * y''(t) + 6 * y +12 = f(t) = Bf * u(t)
import numpy as np
import matplotlib.pyplot as plt
t = [
0.0000, 0.2500, 0.5000, 0.7500, 1.0000,
1.2500, 1.5000, 1.7500, 2.0000, 2.2500,
2.5000, 2.7500, 3.0000, 3.2500, 3.5000,
3.7500, 4.0000, 4.2500, 4.5000, 4.7500,
5.0000, 5.2500, 5.5000, 5.7500, 6.0000,
6.2500, 6.5000, 6.7500, 7.0000, 7.2500,
7.5000, 7.7500, 8.0000, 8.2500, 8.5000,
8.7500, 9.0000, 9.2500, 9.5000, 9.7500,
10.0000, 10.2500, 10.5000, 10.7500, 11.0000,
]
y3dot = [
787.1692, 639.4230, 494.0349, 358.9883, 239.5179,
138.5459, 57.1349, -5.0744, -49.4622, -78.0791,
-93.3526, -97.8537, -94.1197, -84.5289, -71.2201,
-56.0492, -40.5741, -26.0605, -13.5007, -3.6393,
3.0000, 6.0912, 5.4892, 1.2215, -6.5098,
-17.3169, -30.6071, -45.5573, -61.0874, -75.8360,
-88.1449, -96.0595, -97.3519, -89.5761, -70.1624,
-36.5593, 13.5712, 82.0994, 170.1151, 277.5588,
402.8053, 542.2177, 689.6952, 836.2488, 969.6513,
]
y2dot = [
-401.1659, -222.7878, -81.2492, 25.0990, 99.5494,
146.4047, 170.4564, 176.5751, 169.4062, 153.1593,
131.4790, 107.3806, 83.2379, 60.8081, 41.2825,
25.3524, 13.2824, 4.9845, 0.0887, -1.9913,
-2.0000, -0.7875, 0.7374, 1.6511, 1.0590,
-1.8606, -7.8071, -17.3032, -30.6348, -47.7827,
-68.3504, -91.4897, -115.8289, -139.4103, -159.6470,
-173.3085, -176.5481, -164.9876, -133.8713, -78.3067,
6.3973, 124.2833, 278.1863, 469.0630, 695.2244,
]
y1dot = [
-234.3184, -311.5421, -348.7888, -355.1038, -338.9002,
-307.6300, -267.5984, -223.8955, -180.4169, -139.9474,
-104.2882, -74.4076, -50.5999, -32.6443, -19.9525,
-11.7022, -6.9536, -4.7459, -4.1772, -4.4665,
-5.0000, -5.3646, -5.3677, -5.0469, -4.6678,
-4.7117, -5.8508, -8.9117, -14.8229, -24.5482,
-39.0005, -58.9391, -84.8470, -116.7921, -154.2752,
-196.0695, -240.0625, -283.1112, -320.9270, -348.0090,
-357.6503, -342.0419, -292.5021, -199.8603, -55.0205,
]
y0dot = [
729.9304, 660.7688, 577.4904, 488.9503, 401.8125,
320.7526, 248.7243, 187.2561, 136.7548, 96.7942,
66.3780, 44.1667, 28.6667, 18.3781, 11.9052,
8.0314, 5.7622, 4.3430, 3.2530, 2.1833,
1.0000, -0.3020, -1.6515, -2.9582, -4.1695,
-5.3268, -6.6162, -8.4121, -11.3095, -16.1415,
-23.9779, -36.0998, -53.9461, -79.0279, -112.8057,
-156.5273, -211.0265, -276.4830, -352.1494, -436.0554,
-524.7036, -612.7788, -692.8982, -755.4377, -788.4761,
]
plt.figure(figsize=(8, 4))
plt.subplots_adjust(left=0.2, bottom=0.2, right=0.9, top=0.9)
plt.plot(t, y3dot, 'm-', label = r'$y3$', lw = 2, ms = 6)
plt.plot(t, y2dot, 'b-', label = r'$y2$', lw = 2, ms = 6)
plt.plot(t, y1dot, 'g-', label = r'$y1$', lw = 2, ms = 6)
plt.plot(t, y0dot, 'r-', label = r'$y0$', lw = 2, ms = 6)
plt.xlabel(r'$X-Axis(Time(s))$', fontsize = 16)
plt.ylabel(r'$y3$', fontsize = 16)
plt.ylabel(r'$y2$', fontsize = 16)
plt.ylabel(r'$y1$', fontsize = 16)
plt.ylabel(r'$Y-Axis$', fontsize = 16)
plt.title(r'$y3-y2-y1-y0-And-Time$', fontsize = 20)
plt.legend(fontsize = 10)
plt.grid(axis='both', color='0.8')
plt.savefig('Diff_Equation.png', dpi = 200)
plt.show()









// .NET 10, Project Name : App_6J_2。
// J.L. Humar, "Dynamics of Structures",第502-504頁。
// 參考 https://myyeh2.com/myyeh2/App_6J 並加入特別解。
using Matrix_0;
// 已知微分方程式 (m = 2, r = 2)
double[,] M = { { 2, 0 }, { 0, 1 } };
double[,] C = { { 0.4, -0.05 }, { -0.05, 0.2 } };
double[,] K = { { 3, -1 }, { -1, 1 } };
// @t=0時,第0點和第1點,速度和位移之初始值。
double[,] yStart = { { 3 }, { -1 }, { 0 }, { -3 } };
ReMatrix y0 = new ReMatrix(yStart);
// 系統矩陣 A 為 (mxr)x(mxr) 方形矩陣
ReMatrix A = (new SysMatrix2(M, C, K)).GetMatrix;
// 系統之特徵矩陣 D 、模特矩陣 Q
EIG eig = new EIG(A);
CxMatrix D = eig.CxMatrixD;
CxMatrix Q = eig.CxMatrixQ;
// 響應矩陣 Mat (@t=0 秒)
CxMatrix Mat = (new CxHexp(D, Q, 0)).GetCxMatrix;
Console.WriteLine("\n 響應矩陣 Mat : \n{0}\n", new PR(Mat));
// 特別解 yp
ReMatrix yp = (new PS(0)).Getyp;
//Console.WriteLine(" * yp : *\n{0}\n ", new PR(yp));
// 係數向量 d :
// yStart = Mat * d + yp ==> d = ~Mat * (yStart - yp)
CxMatrix d = ~Mat * (yStart - yp);
Console.WriteLine(" 係數向量(複數) d : \n{0}", new PR(d));
// 列印系統與狀態參數。
Console.Write("\n****{0,5}系{0,5}統{0,5}與{0,5}" +
"狀{0,5}態{0,5}參{0,5}數{0,5}****\n", "");
Console.Write("\n***{0,5}特徵矩陣D{0,5}***\n{1}\n", "", new PR(D));
Console.Write("\n***{0,5}模態矩陣Q{0,5}***\n{1}\n", "", new PR(Q));
Console.Write("\n***{0,5}係數向量d{0,5}***\n{1}\n", "", new PR(d));
// 建構 yDot0、yDot1、yDot2 等儲存矩陣
double step = 1.0;
int iRow = (int)(50 / step + 1);
int iCol = 2 + 1; // m + 1
ReMatrix yDot0 = new ReMatrix(iRow, iCol);
ReMatrix yDot1 = new ReMatrix(iRow, iCol);
ReMatrix yDot2 = new ReMatrix(iRow, iCol);
for (int i = 0; i != iRow; i++)
{
double t = step * i;
// HS(Homogeneous Solution)
Mat = (new CxHexp(D, Q, t)).GetCxMatrix;
ReMatrix yh = (ReMatrix)(Mat * d);
// GS(General Solution) = HS + PS(Particular Solution)
yDot1.Matrix[i, 0] = yDot0.Matrix[i, 0] = yDot2.Matrix[i, 0] = t;
ReMatrix Part = (new PS(i)).Getyp;
yDot1.Matrix[i, 1] = yh.Matrix[0, 0] + Part.Matrix[0, 0];
yDot1.Matrix[i, 2] = yh.Matrix[1, 0] + Part.Matrix[1, 0];
yDot0.Matrix[i, 1] = yh.Matrix[2, 0] + Part.Matrix[2, 0];
yDot0.Matrix[i, 2] = yh.Matrix[3, 0] + Part.Matrix[3, 0];
ReMatrix y2Dot = A * yh;
Part = (new PS(i)).Getyp2;
yDot2.Matrix[i, 1] = y2Dot.Matrix[0, 0] + Part.Matrix[0, 0];
yDot2.Matrix[i, 2] = y2Dot.Matrix[1, 0] + Part.Matrix[1, 0];
}
// 列印標題。
Console.Write("\n****{0,10}狀{0,5}態{0,5}響{0,5}應{0,10}****\n", "");
// 列印空間節點之狀態響應(變位,速度,和加速)。
Console.Write("\n{0,5}***位移反應量***{0,5}\n{0,8}時間(秒)" +
"{0,8}第0點位移{0,8}第1點位移\n\n{1}", "", new PR(yDot0));
Console.Write("\n{0,5}***速度反應量***{0,5}\n{0,8}時間(秒)" +
"{0,8}第0點速度{0,8}第1點速度\n\n{1}", "", new PR(yDot1));
Console.Write("\n***{0,5}加速度反應量{0,5}***\n{0,8}時間(秒)" +
"{0,8}第0點加速度{0,7}第1點加速度\n\n{1}", "", new PR(yDot2));
// 列印時間、節點變位、速度、和加速度等序列。
Console.Write("\n時間序列\n{0}\n", new PR4(yDot0, 0));
Console.Write("\n第0點變位序列\n{0}\n", new PR4(yDot0, 1));
Console.Write("\n第1點變位序列\n{0}\n", new PR4(yDot0, 2));
Console.Write("\n第0點速度序列\n{0}\n", new PR4(yDot1, 1));
Console.Write("\n第1點速度序列\n{0}\n", new PR4(yDot1, 2));
Console.Write("\n第0點加速度序列\n{0}\n", new PR4(yDot2, 1));
Console.Write("\n第1點加速度序列\n{0}\n", new PR4(yDot2, 2));
Console.Write("\n\n");
// 特別解類別 [m=2, p=3, B是(mxp)矩陣、U是(px1)矩陣、Const是(mx1)矩陣]
public class PS
{
// Field 和 Property
private double t;
private double[,] K = { { 3, -1 }, { -1, 1 } };
private double[,] B = { { 4, 1, -1 }, { 0, -3, 1 } };
private double[,] Const = { { 0 }, { -2 } };
private ReMatrix ypVector { get; init; } = default!;
private ReMatrix ypVector2 { get; init; } = default!;
// Constructor
public PS(double tPart)
{
t = tPart;
ReMatrix Val = ~(ReMatrix)K * Const;
ReMatrix U = new ReMatrix(3, 1);
// yDot0
double temp0 = Math.Sin(0.5 * t);
double temp1 = Math.Cos(0.5 * t);
double temp2 = Math.Exp(-1 * t);
U.Matrix[0, 0] = temp0;
U.Matrix[1, 0] = temp1;
U.Matrix[2, 0] = temp2;
ReMatrix yp0 = B * U + Val;
// yDot1
temp0 = 0.5 * Math.Cos(0.5 * t);
temp1 = -0.5 * Math.Sin(0.5 * t);
temp2 = -1.0 * Math.Exp(-1 * t);
U.Matrix[0, 0] = temp0;
U.Matrix[1, 0] = temp1;
U.Matrix[2, 0] = temp2;
ReMatrix yp1 = B * U;
// yDot2
temp0 = -0.5 * 0.5 * Math.Sin(0.5 * t);
temp1 = -0.5 * 0.5 * Math.Cos(0.5 * t);
temp2 = Math.Exp(-1 * t);
U.Matrix[0, 0] = temp0;
U.Matrix[1, 0] = temp1;
U.Matrix[2, 0] = temp2;
ReMatrix yp2 = B * U;
// ypVector = yp1 | yp0
ypVector = yp1 | yp0;
// ypVector2 = yp2 | yp1
ypVector2 = yp2 | yp1;
}
// Property Getyp
public ReMatrix Getyp
{
get { return ypVector; }
}
public ReMatrix Getyp2
{
get { return ypVector2; }
}
} // End of class PS (Particular Solution)
/* 輸出結果 :
響應矩陣 Mat :
0.57745 + 0.00000i, 0.57745 + 0.00000i, 0.25800 + 0.00000i,
0.25800 + 0.00000i
-0.57707 - 0.01365i, -0.57707 + 0.01365i, 0.51648 - 0.00609i,
0.51648 + 0.00609i
-0.03369 - 0.40695i, -0.03369 + 0.40695i, -0.04300 - 0.36231i,
-0.04300 + 0.36231i
0.02405 + 0.40748i, 0.02405 - 0.40748i, -0.09463 - 0.72428i,
-0.09463 + 0.72428i
係數向量(複數) d :
0.00484 + 0.00006i
0.00484 - 0.00006i
-0.01084 + 1.37914i
-0.01084 - 1.37914i
**** 系 統 與 狀 態 參 數 ****
*** 特徵矩陣D ***
-0.11666 + 1.40933i, 0.00000 + 0.00000i, 0.00000 + 0.00000i,
0.00000 + 0.00000i
0.00000 + 0.00000i, -0.11666 - 1.40933i, 0.00000 + 0.00000i,
0.00000 + 0.00000i
0.00000 + 0.00000i, 0.00000 + 0.00000i, -0.08334 + 0.70221i,
0.00000 + 0.00000i
0.00000 + 0.00000i, 0.00000 + 0.00000i, 0.00000 + 0.00000i,
-0.08334 - 0.70221i
*** 模態矩陣Q ***
0.57745 + 0.00000i, 0.57745 + 0.00000i, 0.25800 + 0.00000i,
0.25800 + 0.00000i
-0.57707 - 0.01365i, -0.57707 + 0.01365i, 0.51648 - 0.00609i,
0.51648 + 0.00609i
-0.03369 - 0.40695i, -0.03369 + 0.40695i, -0.04300 - 0.36231i,
-0.04300 + 0.36231i
0.02405 + 0.40748i, 0.02405 - 0.40748i, -0.09463 - 0.72428i,
-0.09463 + 0.72428i
*** 係數向量d ***
0.00484 + 0.00006i
0.00484 - 0.00006i
-0.01084 + 1.37914i
-0.01084 - 1.37914i
**** 狀 態 響 應 ****
***位移反應量***
時間(秒) 第0點位移 第1點位移
0.00000 0.00000 -3.00000
1.00000 2.19921 -3.71793
2.00000 3.00472 -4.00160
3.00000 2.68499 -3.79092
4.00000 1.54962 -3.02854
5.00000 -0.05385 -1.87903
6.00000 -1.77566 -0.74040
7.00000 -3.28908 -0.09804
8.00000 -4.31387 -0.30738
9.00000 -4.64690 -1.41938
10.00000 -4.19712 -3.13798
11.00000 -3.01759 -4.92564
12.00000 -1.32349 -6.20232
13.00000 0.52370 -6.55244
14.00000 2.08266 -5.86448
15.00000 2.94296 -4.35890
16.00000 2.84591 -2.50081
17.00000 1.77180 -0.83624
18.00000 -0.03820 0.18228
19.00000 -2.13484 0.31942
20.00000 -3.97674 -0.40166
21.00000 -5.07832 -1.73696
22.00000 -5.14569 -3.31208
23.00000 -4.15819 -4.73134
24.00000 -2.37180 -5.67370
25.00000 -0.24688 -5.95468
26.00000 1.67593 -5.54778
27.00000 2.91616 -4.57251
28.00000 3.17381 -3.25974
29.00000 2.39954 -1.90336
30.00000 0.79919 -0.80354
31.00000 -1.22444 -0.20779
32.00000 -3.17439 -0.25822
33.00000 -4.58028 -0.95584
34.00000 -5.10887 -2.15194
35.00000 -4.64030 -3.57333
36.00000 -3.29355 -4.88072
37.00000 -1.39628 -5.74969
38.00000 0.59370 -5.95413
39.00000 2.19680 -5.42893
40.00000 3.02552 -4.29271
41.00000 2.87745 -2.82238
42.00000 1.78535 -1.38461
43.00000 0.01138 -0.34196
44.00000 -2.01459 0.04118
45.00000 -3.79840 -0.33282
46.00000 -4.90215 -1.37004
47.00000 -5.05238 -2.81008
48.00000 -4.20869 -4.29327
49.00000 -2.57541 -5.45193
50.00000 -0.55229 -6.00199
***速度反應量***
時間(秒) 第0點速度 第1點速度
0.00000 3.00000 -1.00000
1.00000 1.45725 -0.49210
2.00000 0.19614 -0.05744
3.00000 -0.78359 0.49190
4.00000 -1.42856 1.00552
5.00000 -1.71971 1.22452
6.00000 -1.66908 0.96792
7.00000 -1.31052 0.25441
8.00000 -0.70460 -0.68234
9.00000 0.05426 -1.49042
10.00000 0.83681 -1.85364
11.00000 1.48618 -1.62137
12.00000 1.84066 -0.86030
13.00000 1.77824 0.17912
14.00000 1.26915 1.15850
15.00000 0.40679 1.77224
16.00000 -0.60456 1.84987
17.00000 -1.50256 1.40170
18.00000 -2.04055 0.59544
19.00000 -2.05992 -0.31661
20.00000 -1.54058 -1.08329
21.00000 -0.61218 -1.52300
22.00000 0.48094 -1.55965
23.00000 1.45014 -1.22431
24.00000 2.04375 -0.62933
25.00000 2.11356 0.07157
26.00000 1.64990 0.72171
27.00000 0.77934 1.18953
28.00000 -0.27233 1.38606
29.00000 -1.24089 1.27567
30.00000 -1.89090 0.88181
31.00000 -2.07145 0.28540
32.00000 -1.74815 -0.38658
33.00000 -1.00678 -0.98346
34.00000 -0.02999 -1.36222
35.00000 0.94679 -1.42260
36.00000 1.69074 -1.13666
37.00000 2.02563 -0.56251
38.00000 1.87242 0.16487
39.00000 1.26759 0.86532
40.00000 0.35525 1.35978
41.00000 -0.64584 1.51815
42.00000 -1.49360 1.29533
43.00000 -1.98091 0.74471
44.00000 -1.98658 0.00487
45.00000 -1.50618 -0.73677
46.00000 -0.65456 -1.29311
47.00000 0.36105 -1.52545
48.00000 1.29142 -1.37806
49.00000 1.90683 -0.89071
50.00000 2.05445 -0.18701
*** 加速度反應量 ***
時間(秒) 第0點加速度 第1點加速度
0.00000 -1.75000 0.75000
1.00000 -1.38681 0.39830
2.00000 -1.13050 0.49737
3.00000 -0.81895 0.57251
4.00000 -0.46808 0.40842
5.00000 -0.11641 -0.00274
6.00000 0.21215 -0.50763
7.00000 0.49502 -0.87869
8.00000 0.70111 -0.93337
9.00000 0.79496 -0.62780
10.00000 0.74364 -0.07268
11.00000 0.52738 0.52549
12.00000 0.16030 0.95322
13.00000 -0.29068 1.06710
14.00000 -0.71172 0.83891
15.00000 -0.97801 0.35937
16.00000 -0.99969 -0.20195
17.00000 -0.75395 -0.66513
18.00000 -0.29470 -0.90384
19.00000 0.25952 -0.87722
20.00000 0.75694 -0.62528
21.00000 1.05791 -0.24145
22.00000 1.07881 0.16251
23.00000 0.81650 0.48873
24.00000 0.34543 0.67495
25.00000 -0.20737 0.70027
26.00000 -0.69821 0.57781
27.00000 -1.00422 0.34284
28.00000 -1.05392 0.04418
29.00000 -0.84300 -0.26102
30.00000 -0.43132 -0.51303
31.00000 0.07601 -0.65825
32.00000 0.55588 -0.66006
33.00000 0.89566 -0.50925
34.00000 1.01772 -0.23105
35.00000 0.89611 0.11519
36.00000 0.56172 0.44685
37.00000 0.09457 0.67840
38.00000 -0.39478 0.74552
39.00000 -0.79030 0.62471
40.00000 -0.99704 0.34190
41.00000 -0.96378 -0.03291
42.00000 -0.69634 -0.40360
43.00000 -0.25755 -0.67392
44.00000 0.24699 -0.77367
45.00000 0.69421 -0.67760
46.00000 0.97362 -0.41137
47.00000 1.01500 -0.04381
48.00000 0.80646 0.33176
49.00000 0.39823 0.62177
50.00000 -0.10940 0.75569
時間序列
0.0000, 1.0000, 2.0000, 3.0000, 4.0000,
5.0000, 6.0000, 7.0000, 8.0000, 9.0000,
10.0000, 11.0000, 12.0000, 13.0000, 14.0000,
15.0000, 16.0000, 17.0000, 18.0000, 19.0000,
20.0000, 21.0000, 22.0000, 23.0000, 24.0000,
25.0000, 26.0000, 27.0000, 28.0000, 29.0000,
30.0000, 31.0000, 32.0000, 33.0000, 34.0000,
35.0000, 36.0000, 37.0000, 38.0000, 39.0000,
40.0000, 41.0000, 42.0000, 43.0000, 44.0000,
45.0000, 46.0000, 47.0000, 48.0000, 49.0000,
50.0000,
第0點變位序列
0.0000, 2.1992, 3.0047, 2.6850, 1.5496,
-0.0539, -1.7757, -3.2891, -4.3139, -4.6469,
-4.1971, -3.0176, -1.3235, 0.5237, 2.0827,
2.9430, 2.8459, 1.7718, -0.0382, -2.1348,
-3.9767, -5.0783, -5.1457, -4.1582, -2.3718,
-0.2469, 1.6759, 2.9162, 3.1738, 2.3995,
0.7992, -1.2244, -3.1744, -4.5803, -5.1089,
-4.6403, -3.2935, -1.3963, 0.5937, 2.1968,
3.0255, 2.8774, 1.7854, 0.0114, -2.0146,
-3.7984, -4.9022, -5.0524, -4.2087, -2.5754,
-0.5523,
第1點變位序列
-3.0000, -3.7179, -4.0016, -3.7909, -3.0285,
-1.8790, -0.7404, -0.0980, -0.3074, -1.4194,
-3.1380, -4.9256, -6.2023, -6.5524, -5.8645,
-4.3589, -2.5008, -0.8362, 0.1823, 0.3194,
-0.4017, -1.7370, -3.3121, -4.7313, -5.6737,
-5.9547, -5.5478, -4.5725, -3.2597, -1.9034,
-0.8035, -0.2078, -0.2582, -0.9558, -2.1519,
-3.5733, -4.8807, -5.7497, -5.9541, -5.4289,
-4.2927, -2.8224, -1.3846, -0.3420, 0.0412,
-0.3328, -1.3700, -2.8101, -4.2933, -5.4519,
-6.0020,
第0點速度序列
3.0000, 1.4572, 0.1961, -0.7836, -1.4286,
-1.7197, -1.6691, -1.3105, -0.7046, 0.0543,
0.8368, 1.4862, 1.8407, 1.7782, 1.2691,
0.4068, -0.6046, -1.5026, -2.0405, -2.0599,
-1.5406, -0.6122, 0.4809, 1.4501, 2.0438,
2.1136, 1.6499, 0.7793, -0.2723, -1.2409,
-1.8909, -2.0714, -1.7482, -1.0068, -0.0300,
0.9468, 1.6907, 2.0256, 1.8724, 1.2676,
0.3552, -0.6458, -1.4936, -1.9809, -1.9866,
-1.5062, -0.6546, 0.3610, 1.2914, 1.9068,
2.0545,
第1點速度序列
-1.0000, -0.4921, -0.0574, 0.4919, 1.0055,
1.2245, 0.9679, 0.2544, -0.6823, -1.4904,
-1.8536, -1.6214, -0.8603, 0.1791, 1.1585,
1.7722, 1.8499, 1.4017, 0.5954, -0.3166,
-1.0833, -1.5230, -1.5596, -1.2243, -0.6293,
0.0716, 0.7217, 1.1895, 1.3861, 1.2757,
0.8818, 0.2854, -0.3866, -0.9835, -1.3622,
-1.4226, -1.1367, -0.5625, 0.1649, 0.8653,
1.3598, 1.5182, 1.2953, 0.7447, 0.0049,
-0.7368, -1.2931, -1.5255, -1.3781, -0.8907,
-0.1870,
第0點加速度序列
-1.7500, -1.3868, -1.1305, -0.8190, -0.4681,
-0.1164, 0.2121, 0.4950, 0.7011, 0.7950,
0.7436, 0.5274, 0.1603, -0.2907, -0.7117,
-0.9780, -0.9997, -0.7540, -0.2947, 0.2595,
0.7569, 1.0579, 1.0788, 0.8165, 0.3454,
-0.2074, -0.6982, -1.0042, -1.0539, -0.8430,
-0.4313, 0.0760, 0.5559, 0.8957, 1.0177,
0.8961, 0.5617, 0.0946, -0.3948, -0.7903,
-0.9970, -0.9638, -0.6963, -0.2576, 0.2470,
0.6942, 0.9736, 1.0150, 0.8065, 0.3982,
-0.1094,
第1點加速度序列
0.7500, 0.3983, 0.4974, 0.5725, 0.4084,
-0.0027, -0.5076, -0.8787, -0.9334, -0.6278,
-0.0727, 0.5255, 0.9532, 1.0671, 0.8389,
0.3594, -0.2019, -0.6651, -0.9038, -0.8772,
-0.6253, -0.2414, 0.1625, 0.4887, 0.6749,
0.7003, 0.5778, 0.3428, 0.0442, -0.2610,
-0.5130, -0.6583, -0.6601, -0.5092, -0.2311,
0.1152, 0.4469, 0.6784, 0.7455, 0.6247,
0.3419, -0.0329, -0.4036, -0.6739, -0.7737,
-0.6776, -0.4114, -0.0438, 0.3318, 0.6218,
0.7557,
*/





/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 二階矩陣微分方程式 : *
* M * y''(t) + C * y'(t) + K * y = Bf * U(t) *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
using Matrix_0;
// 已知微分方程式 (m = 3, r = 2)
double[,] M = { { 300, -80, 0 }, { -100, 350, -60 },
{ 0, -40, 320 } };
double[,] C = { {10, -8, 0}, {-8, 20, -10}, {0, -10, 12} };
double[,] K = { { 600, -600, 0 }, { -600, 1800, -1200 },
{ 0, -1200, 1500 } };
// @t=0時,第0點和第1點,速度和位移之初始值。
double[,] yStart = { { -25 }, { 19 }, { -15 }, { -20 },
{ 12 }, { -4 } };
// 系統矩陣 A 為 (mxr)x(mxr) 方形矩陣
ReMatrix A = (new SysMatrix2(M, C, K)).GetMatrix;
// 系統之特徵矩陣 D 、模特矩陣 Q
EIG eig = new EIG(A);
CxMatrix D = eig.CxMatrixD;
CxMatrix Q = eig.CxMatrixQ;
// 列印系統與狀態參數。
Console.Write("\n****{0,5}系{0,5}統{0,5}與{0,5}" +
"狀{0,5}態{0,5}參{0,5}數{0,5}****\n", "");
Console.WriteLine("\n*** 系統矩陣 A: ***\n{0}\n", new PR(A));
Console.Write("\n***{0,5}特徵矩陣D{0,5}***\n{1}\n", "",
new PR(D));
Console.Write("\n***{0,5}模態矩陣Q{0,5}***\n{1}\n", "",
new PR(Q));
// 響應矩陣 Mat (@t=0 秒)
CxMatrix Mat = (new CxHexp(D, Q, 0)).GetCxMatrix;
Console.WriteLine("\n 響應矩陣 Mat : \n{0}\n", new PR(Mat));
// 係數向量 d :
ReMatrix yp = (new PS(0)).Getyp;
// Console.WriteLine(" * yp : *\n{0}\n ", new PR(yp));
// yStart = Mat * d + yp ==> d = ~Mat * (yStart - yp)
CxMatrix d = ~Mat * (yStart - yp);
Console.WriteLine(" 係數向量(複數) d : \n{0}", new PR(d));
// 建構 yDot0、yDot1、yDot2 等儲存矩陣
double step = 0.5;
int iRow = (int)(40 / step + 1);
int iCol = 3 + 1; // m + 1
ReMatrix yDot0 = new ReMatrix(iRow, iCol);
ReMatrix yDot1 = new ReMatrix(iRow, iCol);
ReMatrix yDot2 = new ReMatrix(iRow, iCol);
for (int i = 0; i != iRow; i++)
{
double t = step * i;
// HS(Homogeneous Solution)
Mat = (new CxHexp(D, Q, t)).GetCxMatrix;
ReMatrix yh = (ReMatrix)(Mat * d);
// GS(General Solution) = HS + PS(Particular Solution)
ReMatrix Part = (new PS(i)).Getyp;
// 儲存矩陣 yDot1
yDot1.Matrix[i, 0] = t;
yDot1.Matrix[i, 1] = yh.Matrix[0, 0] + Part.Matrix[0, 0];
yDot1.Matrix[i, 2] = yh.Matrix[1, 0] + Part.Matrix[1, 0];
yDot1.Matrix[i, 3] = yh.Matrix[2, 0] = Part.Matrix[2, 0];
// 儲存矩陣 yDot0
yDot0.Matrix[i, 0] = t;
yDot0.Matrix[i, 1] = yh.Matrix[3, 0] + Part.Matrix[3, 0];
yDot0.Matrix[i, 2] = yh.Matrix[4, 0] + Part.Matrix[4, 0];
yDot0.Matrix[i, 3] = yh.Matrix[5, 0] + Part.Matrix[5, 0];
// 儲存矩陣 yDot2
ReMatrix y2Dot = A * yh;
Part = (new PS(i)).Getyp2;
yDot2.Matrix[i, 0] = t;
yDot2.Matrix[i, 1] = y2Dot.Matrix[0, 0] + Part.Matrix[0, 0];
yDot2.Matrix[i, 2] = y2Dot.Matrix[1, 0] + Part.Matrix[1, 0];
yDot2.Matrix[i, 3] = y2Dot.Matrix[2, 0] + Part.Matrix[2, 0];
}
// 列印標題。
Console.Write("\n****{0,10}狀{0,5}態{0,5}響{0,5}應{0,10}****\n", "");
// 列印空間節點之狀態響應(變位,速度,和加速)。
Console.Write("\n{0,5}***位移反應量***{0,5}\n{0,8}時間(秒)" +
"{0,8}第0點位移{0,8}第1點位移{0, 8}第2點位移\n\n{1}", "",
new PR(yDot0));
Console.Write("\n{0,5}***速度反應量***{0,5}\n{0,8}時間(秒)" +
"{0,8}第0點速度{0,8}第1點速度{0,8}第2點位移\n\n{1}", "",
new PR(yDot1));
Console.Write("\n***{0,5}加速度反應量{0,5}***\n{0,8}時間(秒)" +
"{0,6}第0點加速度{0,6}第1點加速度{0,6}第2點加速度\n\n{1}",
"", new PR(yDot2));
// 列印時間、節點變位、速度、和加速度等序列。
Console.Write("\n時間序列\n{0}\n", new PR4(yDot0, 0));
Console.Write("\n第0點變位序列\n{0}\n", new PR4(yDot0, 1));
Console.Write("\n第1點變位序列\n{0}\n", new PR4(yDot0, 2));
Console.Write("\n第2點變位序列\n{0}\n", new PR4(yDot0, 3));
Console.Write("\n第0點速度序列\n{0}\n", new PR4(yDot1, 1));
Console.Write("\n第1點速度序列\n{0}\n", new PR4(yDot1, 2));
Console.Write("\n第2點速度序列\n{0}\n", new PR4(yDot1, 3));
Console.Write("\n第0點加速度序列\n{0}\n", new PR4(yDot2, 1));
Console.Write("\n第1點加速度序列\n{0}\n", new PR4(yDot2, 2));
Console.Write("\n第2點加速度序列\n{0}\n", new PR4(yDot2, 3));
Console.Write("\n\n");
// 特別解類別[m=3,p=3,B是(mxp)矩陣、U是(px1)矩陣、Const是(mx1)矩陣]
public class PS
{
// Field 和 Property
private double t;
private double[,] K = { {600, -600, 0},
{-600, 1800, -1200}, {0, -1200, 1500} };
private double[,] B =
{ { 4, 1, -1 }, { 0, -3, 1}, {2.5, -3, 7.5} };
private double[,] Const = { { 10 }, { -2 }, { 6 } };
private ReMatrix ypVector { get; init; } = default!;
private ReMatrix ypVector2 { get; init; } = default!;
// Constructor
public PS(double tPart)
{
t = tPart;
ReMatrix Val = ~(ReMatrix)K * Const;
ReMatrix U = new ReMatrix(3, 1);
// yDot0
double temp0 = Math.Exp(-1.2 * t);
double temp1 = Math.Sin(1.3 * t);
double temp2 = Math.Cos(1.3 * t);
U.Matrix[0, 0] = temp0;
U.Matrix[1, 0] = temp1;
U.Matrix[2, 0] = temp2;
ReMatrix yp0 = B * U + Val;
// yDot1
temp0 = -1.2 * Math.Exp(-1.2 * t);
temp1 = 1.3 * Math.Cos(1.3 * t);
temp2 = -1.3 * Math.Sin(1.3 * t);
U.Matrix[0, 0] = temp0;
U.Matrix[1, 0] = temp1;
U.Matrix[2, 0] = temp2;
ReMatrix yp1 = B * U;
// yDot2
temp0 = 1.2 * 1.2 * Math.Exp(-1.2 * t);
temp1 = -1.3 * 1.3 * Math.Sin(1.3 * t);
temp2 = -1.3 * 1.3 * Math.Cos(1.3 * t);
U.Matrix[0, 0] = temp0;
U.Matrix[1, 0] = temp1;
U.Matrix[2, 0] = temp2;
ReMatrix yp2 = B * U;
// ypVector = yp1 | yp0
ypVector = yp1 | yp0;
// ypVector2 = yp2 | yp1
ypVector2 = yp2 | yp1;
}
// Property Getyp
public ReMatrix Getyp
{
get { return ypVector; }
}
public ReMatrix Getyp2
{
get { return ypVector2; }
}
} // End of class PS (Particular Solution)
**** 系 統 與 狀 態 參 數 ****
*** 系統矩陣 A: ***
-0.02939 0.01361 0.00654 -1.66227 0.83905 0.77573
0.01478 -0.04894 0.02454 1.26649 -4.35356 2.90897
0.00185 0.02513 -0.03443 0.15831 3.20580 -4.32388
1.00000 0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 1.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 1.00000 0.00000 0.00000 0.00000
*** 特徵矩陣D ***
-0.03375 + 2.71923i, 0.00000 + 0.00000i, 0.00000 + 0.00000i,
0.00000 + 0.00000i, 0.00000 + 0.00000i, 0.00000 + 0.00000i
0.00000 + 0.00000i, -0.03375 - 2.71923i, 0.00000 + 0.00000i,
0.00000 + 0.00000i, 0.00000 + 0.00000i, 0.00000 + 0.00000i
0.00000 + 0.00000i, 0.00000 + 0.00000i, -0.01790 + 1.60283i,
0.00000 + 0.00000i, 0.00000 + 0.00000i, 0.00000 + 0.00000i
0.00000 + 0.00000i, 0.00000 + 0.00000i, 0.00000 + 0.00000i,
-0.01790 - 1.60283i, 0.00000 + 0.00000i, 0.00000 + 0.00000i
0.00000 + 0.00000i, 0.00000 + 0.00000i, 0.00000 + 0.00000i,
0.00000 + 0.00000i, -0.00474 + 0.61229i, 0.00000 + 0.00000i
0.00000 + 0.00000i, 0.00000 + 0.00000i, 0.00000 + 0.00000i,
0.00000 + 0.00000i, 0.00000 + 0.00000i, -0.00474 - 0.61229i
*** 模態矩陣Q ***
0.00437 + 0.00000i, 0.00437 + 0.00000i, 0.65481 + 0.00000i,
0.65481 + 0.00000i, 0.34652 + 0.00000i, 0.34652 + 0.00000i
-0.50120 + 0.41297i, -0.50120 - 0.41297i, -0.28352 + 0.00395i,
-0.28352 - 0.00395i, 0.29638 + 0.00036i, 0.29638 - 0.00036i
0.51940 - 0.43514i, 0.51940 + 0.43514i, -0.45898 + 0.00124i,
-0.45898 - 0.00124i, 0.25449 + 0.00056i, 0.25449 - 0.00056i
-0.00002 - 0.00161i, -0.00002 + 0.00161i, -0.00456 - 0.40848i,
-0.00456 + 0.40848i, -0.00438 - 0.56591i, -0.00438 + 0.56591i
0.15413 + 0.18240i, 0.15413 - 0.18240i, 0.00444 + 0.17684i,
0.00444 - 0.17684i, -0.00316 - 0.48403i, -0.00316 + 0.48403i
-0.16237 - 0.18900i, -0.16237 + 0.18900i, 0.00397 + 0.28631i,
0.00397 - 0.28631i, -0.00230 - 0.41563i, -0.00230 + 0.41563i
響應矩陣 Mat :
0.00437 + 0.00000i, 0.00437 + 0.00000i, 0.65481 + 0.00000i,
0.65481 + 0.00000i, 0.34652 + 0.00000i, 0.34652 + 0.00000i
-0.50120 + 0.41297i, -0.50120 - 0.41297i, -0.28352 + 0.00395i,
-0.28352 - 0.00395i, 0.29638 + 0.00036i, 0.29638 - 0.00036i
0.51940 - 0.43514i, 0.51940 + 0.43514i, -0.45898 + 0.00124i,
-0.45898 - 0.00124i, 0.25449 + 0.00056i, 0.25449 - 0.00056i
-0.00002 - 0.00161i, -0.00002 + 0.00161i, -0.00456 - 0.40848i,
-0.00456 + 0.40848i, -0.00438 - 0.56591i, -0.00438 + 0.56591i
0.15413 + 0.18240i, 0.15413 - 0.18240i, 0.00444 + 0.17684i,
0.00444 - 0.17684i, -0.00316 - 0.48403i, -0.00316 + 0.48403i
-0.16237 - 0.18900i, -0.16237 + 0.18900i, 0.00397 + 0.28631i,
0.00397 - 0.28631i, -0.00230 - 0.41563i, -0.00230 + 0.41563i
係數向量(複數) d :
9.03114 - 32.22721i
9.03114 + 32.22721i
-14.02517 - 15.47681i
-14.02517 + 15.47681i
-4.63359 - 9.26871i
-4.63359 + 9.26871i
**** 狀 態 響 應 ****
***位移反應量***
時間(秒) 第0點位移 第1點位移 第2點位移
0.00000 -20.00000 12.00000 -4.00000
0.50000 -26.45344 4.25494 -6.62025
...
39.00000 -2.42566 2.98207 4.91105
39.50000 -8.14921 3.39641 -6.41272
40.00000 -10.76151 -0.29212 -4.44322
***速度反應量***
時間(秒) 第0點速度 第1點速度 第2點位移
0.00000 -25.00000 19.00000 -6.90000
0.50000 1.08417 -38.46005 -11.34152
...
39.00000 -15.96993 7.39078 -9.96384
39.50000 -8.90063 -4.38978 -5.86027
40.00000 0.03280 -14.62160 6.82860
*** 加速度反應量 ***
時間(秒) 第0點加速度 第1點加速度 第2點加速度
0.00000 44.98557 -121.03410 83.87511
0.50000 47.87004 -78.78406 47.69997
...
39.50000 19.32874 -34.12889 29.26985
40.00000 18.70022 -7.05833 -0.43115
時間序列
0.0000, 0.5000, 1.0000, 1.5000, 2.0000,
2.5000, 3.0000, 3.5000, 4.0000, 4.5000,
...
35.0000, 35.5000, 36.0000, 36.5000, 37.0000,
37.5000, 38.0000, 38.5000, 39.0000, 39.5000,
40.0000,
第0點變位序列
-20.0000, -26.4534, -20.6436, -8.8185, 2.9597,
9.7797, 8.5171, 0.1925, -8.5892, -9.4037,
...
2.9246, -1.3936, -0.5099, 6.5090, 14.7326,
17.8287, 13.7730, 5.6208, -2.4257, -8.1492,
-10.7615,
第1點變位序列
12.0000, 4.2549, -17.5882, -21.3742, -5.1508,
3.1526, -7.4186, -13.3144, 4.1640, 26.1126,
...
8.8112, 11.0524, 9.2441, 8.1940, 7.9021,
5.6011, 2.1154, 1.1492, 2.9821, 3.3964,
-0.2921,
第2點速度序列
-4.0000, -6.6203, 2.0789, 1.9694, -13.3603,
-24.0612, -13.1478, 8.4557, 18.4169, 13.2564,
...
-6.1752, 12.7476, 25.1907, 14.3200, -5.5206,
-9.0524, 4.6729, 13.3006, 4.9110, -6.4127,
-4.4432,
第0點速度序列
-25.0000, 1.0842, 20.6985, 27.4064, 20.6128,
4.5727, -12.2618, -19.2483, -10.1569, 9.9657,
...
-9.4234, -3.0798, 8.4319, 15.7475, 12.2632,
0.1360, -12.2482, -17.9857, -15.9699, -8.9006,
0.0328,
第1點速度序列
19.0000, -38.4600, -36.4248, 15.5002, 34.9776,
-1.4114, -25.6981, 8.0139, 47.8831, 26.3688,
...
7.5808, -4.0483, -1.5757, 3.4836, -2.2181,
-10.9404, -7.4099, 4.7803, 7.3908, -4.3898,
-14.6216,
第2點速度序列
-6.9000, -11.3415, -1.9564, 9.4549, 6.7618,
-5.9135, -9.9485, 0.5842, 10.2589, 4.9037,
...
2.8447, 10.5010, 2.7734, -9.0173, -7.5976,
4.9526, 10.2472, 0.5296, -9.9638, -5.8603,
6.8286,
第0點加速度序列
44.9856, 47.8700, 29.1398, -0.5676, -26.9384,
-37.7442, -26.0802, 3.5352, 32.7456, 40.0116,
...
5.1930, 19.4946, 19.7755, 4.4862, -15.5907,
-26.0837, -20.9004, -5.4044, 10.3846, 19.3287,
18.7002,
第1點加速度序列
-121.0341, -78.7841, 72.6006, 100.7241, -21.9637,
-89.1694, 4.0801, 99.1047, 32.9928, -99.2982,
...
-35.1221, -5.1498, 18.6046, -0.6793, -25.5241,
-9.4170, 25.7594, 24.1412, -14.7542, -34.1289,
-7.0583,
第2點加速度序列
83.8751, 47.7000, -81.7599, -91.2111, 49.0112,
132.6737, 36.6113, -94.4630, -77.5314, 35.1078,
...
38.9667, -28.0186, -67.0267, -19.8551, 47.0027,
42.6198, -16.0319, -38.2451, 0.5197, 29.2699,
-0.4311,
以下的程式碼完全和上述的相同,僅將已知的資料放在
KD類別中。方便從主程式碼中,引入已知的資料(
KDKnown Data)中。





/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 二階矩陣微分方程式 : *
* M * y''(t) + C * y'(t) + K * y + Const = Bf * U(t) *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
using Matrix_0;
// 由微分方程式和已知的資料(參見 KD 靜態類別),
// 計算系統矩陣 A 為 (mxr)x(mxr) 方形矩陣。
ReMatrix A = (new SysMatrix2(KD.M, KD.C, KD.K)).GetMatrix;
// 計算系統之特徵矩陣 D 、模特矩陣 Q
EIG eig = new EIG(A);
CxMatrix D = eig.CxMatrixD;
CxMatrix Q = eig.CxMatrixQ;
// 列印系統與狀態參數。
Console.Write("\n****{0,5}系{0,5}統{0,5}與{0,5}" +
"狀{0,5}態{0,5}參{0,5}數{0,5}****\n", "");
Console.WriteLine("\n*** 系統矩陣 A: ***\n{0}\n", new PR(A));
Console.Write("\n***{0,5}特徵矩陣D{0,5}***\n{1}\n", "",
new PR(D));
Console.Write("\n***{0,5}模態矩陣Q{0,5}***\n{1}\n", "",
new PR(Q));
// 計算響應矩陣 Mat (@t=0 秒)
CxMatrix Mat = (new CxHexp(D, Q, 0)).GetCxMatrix;
Console.WriteLine("\n 響應矩陣 Mat : \n{0}\n", new PR(Mat));
// 計算係數向量 d : (利用 PS 類別,求取特別解 yp)
ReMatrix yp = (new PS(0)).Getyp;
// yStart = Mat * d + yp ==> d = ~Mat * (yStart - yp)
CxMatrix d = ~Mat * (KD.yStart - yp);
Console.WriteLine(" 係數向量(複數) d : \n{0}", new PR(d));
// 建構 yDot0、yDot1、yDot2 等儲存矩陣
double step = 0.5;
int iRow = (int)(40 / step + 1);
int iCol = 3 + 1; // m + 1
ReMatrix yDot0 = new ReMatrix(iRow, iCol);
ReMatrix yDot1 = new ReMatrix(iRow, iCol);
ReMatrix yDot2 = new ReMatrix(iRow, iCol);
for (int i = 0; i != iRow; i++)
{
double t = step * i;
// HS(Homogeneous Solution)
Mat = (new CxHexp(D, Q, t)).GetCxMatrix;
ReMatrix yh = (ReMatrix)(Mat * d);
// GS(General Solution) = HS + PS(Particular Solution)
ReMatrix Part = (new PS(i)).Getyp;
// 儲存矩陣 yDot1
yDot1.Matrix[i, 0] = t;
yDot1.Matrix[i, 1] = yh.Matrix[0, 0] + Part.Matrix[0, 0];
yDot1.Matrix[i, 2] = yh.Matrix[1, 0] + Part.Matrix[1, 0];
yDot1.Matrix[i, 3] = yh.Matrix[2, 0] = Part.Matrix[2, 0];
// 儲存矩陣 yDot0
yDot0.Matrix[i, 0] = t;
yDot0.Matrix[i, 1] = yh.Matrix[3, 0] + Part.Matrix[3, 0];
yDot0.Matrix[i, 2] = yh.Matrix[4, 0] + Part.Matrix[4, 0];
yDot0.Matrix[i, 3] = yh.Matrix[5, 0] + Part.Matrix[5, 0];
// 儲存矩陣 yDot2
ReMatrix y2Dot = A * yh;
Part = (new PS(i)).Getyp2;
yDot2.Matrix[i, 0] = t;
yDot2.Matrix[i, 1] = y2Dot.Matrix[0, 0] + Part.Matrix[0, 0];
yDot2.Matrix[i, 2] = y2Dot.Matrix[1, 0] + Part.Matrix[1, 0];
yDot2.Matrix[i, 3] = y2Dot.Matrix[2, 0] + Part.Matrix[2, 0];
}
// 列印標題。
Console.Write("\n****{0,10}狀{0,5}態{0,5}響{0,5}應{0,10}****\n", "");
// 列印空間節點之狀態響應(變位,速度,和加速)。
Console.Write("\n{0,5}***位移反應量***{0,5}\n{0,8}時間(秒)" +
"{0,8}第0點位移{0,8}第1點位移{0, 8}第2點位移\n\n{1}", "",
new PR(yDot0));
Console.Write("\n{0,5}***速度反應量***{0,5}\n{0,8}時間(秒)" +
"{0,8}第0點速度{0,8}第1點速度{0,8}第2點位移\n\n{1}", "",
new PR(yDot1));
Console.Write("\n***{0,5}加速度反應量{0,5}***\n{0,8}時間(秒)" +
"{0,6}第0點加速度{0,6}第1點加速度{0,6}第2點加速度\n\n{1}",
"", new PR(yDot2));
// 列印時間、節點變位、速度、和加速度等序列。
Console.Write("\n時間序列\n{0}\n", new PR4(yDot0, 0));
Console.Write("\n第0點變位序列\n{0}\n", new PR4(yDot0, 1));
Console.Write("\n第1點變位序列\n{0}\n", new PR4(yDot0, 2));
Console.Write("\n第2點速度序列\n{0}\n", new PR4(yDot0, 3));
Console.Write("\n第0點速度序列\n{0}\n", new PR4(yDot1, 1));
Console.Write("\n第1點速度序列\n{0}\n", new PR4(yDot1, 2));
Console.Write("\n第2點速度序列\n{0}\n", new PR4(yDot1, 3));
Console.Write("\n第0點加速度序列\n{0}\n", new PR4(yDot2, 1));
Console.Write("\n第1點加速度序列\n{0}\n", new PR4(yDot2, 2));
Console.Write("\n第2點加速度序列\n{0}\n", new PR4(yDot2, 3));
Console.Write("\n\n");
// public static class KD (Known Data,即 KD 類別)
public static class KD
{
public static int m = 3; // 空間維度的自由度為 3
public static int r = 2; // 狀態維度的自由度為 2
public static int p = 3; // PS 基本作用力個數
public static double[,] M = {{300, -80, 0},
{-100, 350, -60 }, {0, -40, 320 } };
public static double[,] C = {{10, -8, 0},
{-8, 20, -10 }, {0, -10, 12} };
public static double[,] K = {{600, -600, 0},
{-600, 1800, -1200}, {0, -1200, 1500} };
public static double[,] yStart = {{-25}, {19},
{-15}, {-20}, {12}, {-4}}; // 初始值
public static double[,] B = {{4, 1, -1},
{0, -3, 1}, {2.5, -3, 7.5} };
public static double[,] Const = {{10}, {-2}, {6} };
}
// 特別解類別[m=3,p=3,B是(mxp)矩陣、U是(px1)矩陣、Const是(mx1)矩陣]
public class PS
{
// Field 和 Property
private double t;
private ReMatrix ypVector { get; init; } = default!;
private ReMatrix ypVector2 { get; init; } = default!;
// Constructor
public PS(double tPart)
{
t = tPart;
ReMatrix Val = ~(ReMatrix)KD.K * KD.Const;
ReMatrix U = new ReMatrix(3, 1);
// yDot0
double temp0 = Math.Exp(-1.2 * t);
double temp1 = Math.Sin(1.3 * t);
double temp2 = Math.Cos(1.3 * t);
U.Matrix[0, 0] = temp0;
U.Matrix[1, 0] = temp1;
U.Matrix[2, 0] = temp2;
ReMatrix yp0 = KD.B * U + Val;
// yDot1
temp0 = -1.2 * Math.Exp(-1.2 * t);
temp1 = 1.3 * Math.Cos(1.3 * t);
temp2 = -1.3 * Math.Sin(1.3 * t);
U.Matrix[0, 0] = temp0;
U.Matrix[1, 0] = temp1;
U.Matrix[2, 0] = temp2;
ReMatrix yp1 = KD.B * U;
// yDot2
temp0 = 1.2 * 1.2 * Math.Exp(-1.2 * t);
temp1 = -1.3 * 1.3 * Math.Sin(1.3 * t);
temp2 = -1.3 * 1.3 * Math.Cos(1.3 * t);
U.Matrix[0, 0] = temp0;
U.Matrix[1, 0] = temp1;
U.Matrix[2, 0] = temp2;
ReMatrix yp2 = KD.B * U;
// ypVector = yp1 | yp0
ypVector = yp1 | yp0;
// ypVector2 = yp2 | yp1
ypVector2 = yp2 | yp1;
}
// Property Getyp
public ReMatrix Getyp
{
get { return ypVector; }
}
public ReMatrix Getyp2
{
get { return ypVector2; }
}
} // End of class PS (Particular Solution)

常微分與偏微分方程式求解器(Solver)
若是偏微分方程式,應轉為常微分方程式的方式再求解。(即空間偏微分轉為有限離散的空間節點)
空間維度(m個自由度),狀態維度(r個階度),時間維度(僅有一個連續的時間自由度t),三個維度互為垂直,彼此無關。
系統共有 m X (r + 1)個數據,即m個空間『space』節點和(r+1)個狀態『states』,但系統矩陣是 (m X r) X (m X r) 的正方形矩陣。以二階矩陣微分方程式為例,先將常微分方程式轉化為系統矩陣A,則 ReMatrix A = ( (-1.0 * ~M * C ) & (-1.0 * ~M * K) ) | (Id & Zero) 。其中 『* ~ | &』均為矩陣的運算子,Id 和 Zero 是 Identity 和 Zero 矩陣,請參見相關的png圖片和程式碼。
上述的二階系統矩陣 A 亦可為: SysMatrix2 SMatrix = new SysMatrix2(M, C, K); ReMatrix A = SMatrix.GetMatrix;
常微分方程式求解分析,共有三個維度(Dimensions):空間(Space)維度、狀態(State)維度、和時間(Time)維度,三個維度之間彼此無關,以
數學模型、軟體模型而言,是互為垂直。若空間維度有m個自由度(DOF:Degree Of Freedom,m >= 1,至少1個節點),若狀態維度有r+1個自由度(或Order階度 r >= 0,即0個階度表示僅有靜態的位移),但時間維度僅有一個連續的時間自由度(t)。複數的實數部分表示振幅,虛數部分表示頻率。唯有使用『複數』的計算,才有可能求得實數的數值精確解,但為何須要由實數的範圍(Scope)轉化為複數的範圍?其理由是,當我們要求解矩陣的特徵值、或是多項式的根,這些都是複數,我們就會體會到,為何必須由『實數轉化為複數』了。接下來的計算,都必須完全使用『複數的計算』,從古至今好像我們就被卡住了,複數就變得非常神秘。訊號與系統課程所提供多種求解法(譬如捲積計算)、自動控制課程所提到的知識、結構動力學之計算等等,個人之淺見,這些課程理論的闡述多於實際的數值求解,動態系統的數值求解,基本上就是『微分方程式』的求解,只要學生、工程師、科學家若能致力於建構精準的矩陣微分方程式,剩下的數值求解就直接使用求解器(Solver)來處理。
由系統矩陣 ReMatrix A,使用類別庫 EIG(或EIG2、EIG3) ,可求得複數特徵矩陣 CxMatrix D和複數模態矩陣 CxMatrix Q,由響應矩陣 CxMatrix CxHexp(D, Q, t)和係數向量 CxMatrix d。微分方程式的齊次解就是CxHexp(D,Q,t) * d ,其中 d 就是已知時間 t 的初始值,或是不同時間 t 的邊界值求得。
特別解使用未定係數方法求得,參見以上的特別解說明。一般解是齊次解加上特別解,但如果沒有外力時,則一般解即是齊次解。
A * Q = Q * D ==> A = Q * D * ~Q 。但一般純數學的書籍都寫成 A = QDQ^-1,這種寫法並不符合程式撰寫的規則。其中 『* 和 ~』 是矩陣相乘和求逆的運算子。
陣列(Array)的範圍包含(>=)矩陣(Matrix),譬如double[][] Array 是陣列(鋸齒型)的寫法,矩陣(Matrix)的範圍包含向量,譬如double[,] Matrix = {{1,2,3},{4,5,-6},{-4,8,9}} 是矩陣,為長方(或正方)的形態,double[,] Vector = {{-6},{9},{0},{-3}} 是向量的寫法,其行(欄位,Column)是1,即 4 X 1 的矩陣是向量。
由求解器(Solver)求得的數據,包含響應和頻率,再使用Excel、Matplotlib、或ChatGPT等等,繪製視覺化的圖表。
線性微分方程分為,線性非時變系統(Linear Time-invariant System)、和線性時變系統(Linear Time-Varying System)。線性時變系統的實例參見如下【App_48】和【App_49】,其餘均為線性非時變系統。
https://github.com/myyeh2/App_48
https://github.com/myyeh2/App_49
CSharp 程式碼如下(1)
將C#的矩陣,轉為精銳求解器的矩陣,再將其列印出來。
// App06 專案
using Matrix_0;
// 先建構C#陣列。
double[,] Are = { { 3, 4, 5 }, {0, -5, -4}, {-9, 8, 7} };
double[,] Aim = { {7, 4, 8}, {4, 8, 9}, {5, -8, -7} };
// 再建構 精銳矩陣。
// 由精銳矩陣,便可使用12種矩陣運算子和各種類別庫。
// 參見程式碼 https://myyeh2.github.io
// 實數矩陣B
ReMatrix B = new ReMatrix(Are);
// 複數矩陣C
CxMatrix C = new CxMatrix(Are, Aim);
// 列印矩陣。
Console.WriteLine("矩陣 B:\n{0}", new PR(B));
Console.WriteLine("矩陣 C:\n{0}", new PR(C));
/* 輸出結果如下:
矩陣 B:
3.00000 4.00000 5.00000
0.00000 -5.00000 -4.00000
-9.00000 8.00000 7.00000
矩陣 C:
3.00000 + 7.00000i, 4.00000 + 4.00000i, 5.00000 + 8.00000i
0.00000 + 4.00000i, -5.00000 + 8.00000i, -4.00000 + 9.00000i
-9.00000 + 5.00000i, 8.00000 - 8.00000i, 7.00000 - 7.00000i
*/
CSharp 程式碼如下(2)
複數矩陣如何表示,求複數矩陣的逆矩陣,並將其列印出來。
系統矩陣 A 是 (4 X 4) 的複數矩陣,求該複數矩陣的逆矩陣 B。
矩陣的逆矩陣,其運算子是『~』,即 B = ~A
兩矩陣相乘,其運算子是『*』,即 D = A * ~A (即 D = A * B )
矩陣 D 是複數,再將轉為實數矩陣 C = (ReMatrix)(A * ~A)
若無法轉為實數矩陣,則產生錯誤
using Matrix_0;
double[,] A_real = { {5, -6, 9, 6}, {-4, 7, 9, 0},
{3, 5, -6, -1}, {4, -9, 8, 9} };
double[,] A_image = { {-6, -4, 9, 3}, {6, -4, 5, 9},
{4, 7, 8, 9}, {4, -4, 5, 6} };
CxMatrix A = new CxMatrix(A_real, A_image);
// 列印複數複數矩陣 A
Console.WriteLine("複數矩陣 A:\n{0}", new PR(A));
// A 矩陣的逆矩陣是 B,並列印矩陣 B。
CxMatrix B = ~A;
Console.WriteLine("複數矩陣 B:\n{0}", new PR(B));
// C = A * B 再轉為實數矩陣,即矩陣 C是 Identity Matrix。
ReMatrix C = (ReMatrix)(A * B);
// 列印實數矩陣 C。
Console.WriteLine("實數矩陣 C:\n{0}", new PR(C));
/* 輸出結果如下 :
複數矩陣 A:
5.00000 - 6.00000i, -6.00000 - 4.00000i,
9.00000 + 9.00000i, 6.00000 + 3.00000i
-4.00000 + 6.00000i, 7.00000 - 4.00000i,
9.00000 + 5.00000i, 0.00000 + 9.00000i
3.00000 + 4.00000i, 5.00000 + 7.00000i,
-6.00000 + 8.00000i, -1.00000 + 9.00000i
4.00000 + 4.00000i, -9.00000 - 4.00000i,
8.00000 + 5.00000i, 9.00000 + 6.00000i
複數矩陣 B:
0.09343 + 0.10319i, 0.05986 - 0.05474i,
0.00583 + 0.06387i, -0.08570 - 0.10139i
-0.01536 + 0.00599i, 0.02238 - 0.01110i,
0.01390 - 0.04433i, -0.04732 - 0.00853i
0.05349 + 0.04023i, 0.09868 + 0.00357i,
-0.03655 + 0.04555i, -0.03115 - 0.08095i
-0.09786 - 0.08846i, -0.10405 + 0.00794i,
0.03991 - 0.11592i, 0.09593 + 0.07890i
實數矩陣 C:
1.00000 0.00000 0.00000 0.00000
0.00000 1.00000 0.00000 0.00000
0.00000 0.00000 1.00000 0.00000
0.00000 0.00000 0.00000 1.00000
*/
齊次解,並將輸出結果列出來。
CSharp 程式碼如下(3)
// .NET 8, Project Name : App_6J。
// J.L. Humar, "Dynamics of Structures",第502-504頁。
using Matrix_0;
// CSharp 矩陣。
double[,] M_cs = { { 2, 0 }, { 0, 1 } };
double[,] C_cs = { { 0.4, -0.05 }, { -0.05, 0.2 } };
double[,] K_cs = { { 3, -1 }, { -1, 1 } };
// 轉為精銳矩陣。
ReMatrix M = new ReMatrix(M_cs);
ReMatrix C = new ReMatrix(C_cs);
ReMatrix K = new ReMatrix(K_cs);
// Iden 和 Zero 矩陣。
ReMatrix Id = (new Iden(2, 2)).GetMatrix;
ReMatrix Zero = (new Zero(2, 2)).GetMatrix;
// 系統矩陣 A = ((-Mi * C) & (-Mi * K)) | (Id & Zero);
// 或 A = ((-Mi * C) | Id)) & ((-Mi * K) | Zero);
ReMatrix A = ((-1.0 * ~M * C) & (-1.0 * ~M * K)) | (Id & Zero);
// t=0時,第0點和第1點,速度和位移之初始值。
double[,] y0Start = { { 0 }, { 0 }, { 1 }, { 2 } };
ReMatrix y0 = new ReMatrix(y0Start);
// 由EIG類別,求得特徵矩陣D、特徵向量V、模態矩陣Q。
EIG eig = new EIG(A);
CxMatrix D = eig.CxMatrixD;
CxMatrix V = eig.CxVector;
CxMatrix Q = eig.CxMatrixQ;
// 由CxHexp類別,得到MatTemp物件和係數向量d。
CxHexp Hexp = new CxHexp(D, Q, 0);
CxMatrix MatTemp = Hexp.GetCxMatrix;
CxMatrix d = ~MatTemp * y0;
// 列印系統與狀態參數。
Console.Write("\n****{0,5}系{0,5}統{0,5}與{0,5}狀{0,5}態{0,5}參{0,5}數{0,5}****\n", "");
Console.Write("\n***{0,5}特徵值V{0,5}***\n{1}\n", "", new PR(V));
Console.Write("\n***{0,5}特徵向量矩陣Q{0,5}***\n{1}\n", "", new PR(Q));
Console.Write("\n***{0,5}係數向量d{0,5}***\n{1}\n", "", new PR(d));
double step = 0.5;
int iRow = (int)(50 / step + 1);
int iCol = M.Col + 1;
ReMatrix Disp = new ReMatrix(iRow, iCol);
ReMatrix Vel = new ReMatrix(iRow, iCol);
ReMatrix Acc = new ReMatrix(iRow, iCol);
for (int i = 0; i != iRow; i++)
{
double t = step * i;
Hexp = new CxHexp(D, Q, t);
MatTemp = Hexp.GetCxMatrix;
ReMatrix yh_Re = (ReMatrix)(MatTemp * d);
ReMatrix yhDot_Re = A * yh_Re;
Acc.Matrix[i, 0] = t;
Acc.Matrix[i, 1] = yhDot_Re.Matrix[0, 0];
Acc.Matrix[i, 2] = yhDot_Re.Matrix[1, 0];
Vel.Matrix[i, 0] = t;
Vel.Matrix[i, 1] = yh_Re.Matrix[0, 0];
Vel.Matrix[i, 2] = yh_Re.Matrix[1, 0];
Disp.Matrix[i, 0] = t;
Disp.Matrix[i, 1] = yh_Re.Matrix[2, 0];
Disp.Matrix[i, 2] = yh_Re.Matrix[3, 0];
}
// 列印標題。
Console.Write("\n****{0,10}狀{0,5}態{0,5}響{0,5}應{0,10}****\n", "");
// 列印空間節點之狀態響應(變位,速度,和加速)。
Console.Write("\n{0,5}***位移反應量***{0,5}\n{0,8}時間(秒)" +
"{0,8}第0點位移{0,8}第1點位移\n\n{1}", "", new PR(Disp));
Console.Write("\n{0,5}***速度反應量***{0,5}\n{0,8}時間(秒)" +
"{0,8}第0點速度{0,8}第1點速度\n\n{1}", "", new PR(Vel));
Console.Write("\n***{0,5}加速度反應量{0,5}***\n{0,8}時間(秒)" +
"{0,8}第0點加速度{0,7}第1點加速度\n\n{1}", "", new PR(Acc));
// 列印時間、節點變位、速度、和加速度等序列。
Console.Write("\n時間序列\n{0}\n", new PR4(Disp, 0));
Console.Write("\n第0點變位序列\n{0}\n", new PR4(Disp, 1));
Console.Write("\n第1點變位序列\n{0}\n", new PR4(Disp, 2));
Console.Write("\n第0點速度序列\n{0}\n", new PR4(Vel, 1));
Console.Write("\n第1點速度序列\n{0}\n", new PR4(Vel, 2));
Console.Write("\n第0點加速度序列\n{0}\n", new PR4(Acc, 1));
Console.Write("\n第1點加速度序列\n{0}\n", new PR4(Acc, 2));
Console.Write("\n\n");
/*
**** 系 統 與 狀 態 參 數 ****
*** 特徵值V ***
-0.11666 + 1.40933i
-0.11666 - 1.40933i
-0.08334 + 0.70221i
-0.08334 - 0.70221i
*** 特徵向量矩陣Q ***
0.57745 + 0.00000i, 0.57745 + 0.00000i,
0.25800 + 0.00000i, 0.25800 + 0.00000i
-0.57707 - 0.01365i, -0.57707 + 0.01365i,
0.51648 - 0.00609i, 0.51648 + 0.00609i
-0.03369 - 0.40695i, -0.03369 + 0.40695i,
-0.04300 - 0.36231i, -0.04300 + 0.36231i
0.02405 + 0.40748i, 0.02405 - 0.40748i,
-0.09463 - 0.72428i, -0.09463 + 0.72428i
*** 係數向量d ***
0.00484 + 0.00006i
0.00484 - 0.00006i
-0.01084 + 1.37914i
-0.01084 - 1.37914i
**** 狀 態 響 應 ****
***位移反應量***
時間(秒) 第0點位移 第1點位移
0.00000 1.00000 2.00000
0.50000 0.93967 1.87981
1.00000 0.77181 1.54694
1.50000 0.52458 1.05825
2.00000 0.23388 0.48398
2.50000 -0.06169 -0.10150
3.00000 -0.32593 -0.62850
3.50000 -0.52952 -1.03960
4.00000 -0.65311 -1.29530
4.50000 -0.68877 -1.37729
5.00000 -0.63986 -1.28919
5.50000 -0.51942 -1.05458
6.00000 -0.34767 -0.71285
6.50000 -0.14893 -0.31328
7.00000 0.05142 0.09168
7.50000 0.22989 0.45312
8.00000 0.36732 0.73135
8.50000 0.45067 0.90002
9.00000 0.47413 0.94810
9.50000 0.43939 0.87986
10.00000 0.35495 0.71296
10.50000 0.23471 0.47520
11.00000 0.09592 0.20036
11.50000 -0.04325 -0.07622
12.00000 -0.16599 -0.32181
12.50000 -0.25890 -0.50987
13.00000 -0.31336 -0.62267
13.50000 -0.32611 -0.65268
14.00000 -0.29918 -0.60277
14.50000 -0.23909 -0.48509
15.00000 -0.15568 -0.31900
15.50000 -0.06063 -0.12814
16.00000 0.03398 0.06269
16.50000 0.11710 0.23071
17.00000 0.17986 0.35772
17.50000 0.21642 0.43194
18.00000 0.22445 0.44888
18.50000 0.20516 0.41122
19.00000 0.16294 0.32789
19.50000 0.10460 0.21245
20.00000 0.03842 0.08112
20.50000 -0.02705 -0.04933
21.00000 -0.08400 -0.16356
21.50000 -0.12632 -0.24936
22.00000 -0.15015 -0.29880
22.50000 -0.15422 -0.30886
23.00000 -0.13968 -0.28142
23.50000 -0.10980 -0.22269
24.00000 -0.06937 -0.14214
24.50000 -0.02398 -0.05110
25.00000 0.02061 0.03872
25.50000 0.05924 0.11672
26.00000 0.08782 0.17456
26.50000 0.10374 0.20699
27.00000 0.10610 0.21225
27.50000 0.09565 0.19191
28.00000 0.07464 0.15047
28.50000 0.04640 0.09452
29.00000 0.01488 0.03187
29.50000 -0.01588 -0.02957
30.00000 -0.04228 -0.08260
30.50000 -0.06150 -0.12164
31.00000 -0.07185 -0.14314
31.50000 -0.07284 -0.14595
32.00000 -0.06511 -0.13119
32.50000 -0.05031 -0.10201
33.00000 -0.03074 -0.06303
33.50000 -0.00911 -0.01966
34.00000 0.01188 0.02256
34.50000 0.02980 0.05872
35.00000 0.04277 0.08499
35.50000 0.04964 0.09905
36.00000 0.05008 0.10023
36.50000 0.04453 0.08942
37.00000 0.03412 0.06888
37.50000 0.02048 0.04183
38.00000 0.00548 0.01198
38.50000 -0.00896 -0.01691
39.00000 -0.02117 -0.04149
39.50000 -0.02988 -0.05919
40.00000 -0.03434 -0.06847
40.50000 -0.03436 -0.06887
41.00000 -0.03031 -0.06107
41.50000 -0.02299 -0.04663
42.00000 -0.01354 -0.02779
42.50000 -0.00324 -0.00716
43.00000 0.00662 0.01266
43.50000 0.01491 0.02940
44.00000 0.02078 0.04129
44.50000 0.02372 0.04733
45.00000 0.02361 0.04727
45.50000 0.02070 0.04160
46.00000 0.01556 0.03146
46.50000 0.00898 0.01840
47.00000 0.00186 0.00420
47.50000 -0.00491 -0.00936
48.00000 -0.01056 -0.02073
48.50000 -0.01449 -0.02874
49.00000 -0.01639 -0.03270
49.50000 -0.01619 -0.03246
50.00000 -0.01408 -0.02838
***速度反應量***
時間(秒) 第0點速度 第1點速度
0.00000 0.00000 0.00000
0.50000 -0.23583 -0.46888
1.00000 -0.42608 -0.84336
1.50000 -0.55070 -1.08768
2.00000 -0.59906 -1.18431
2.50000 -0.57099 -1.13411
3.00000 -0.47610 -0.95456
3.50000 -0.33176 -0.67657
4.00000 -0.15994 -0.34010
4.50000 0.01612 0.01084
5.00000 0.17508 0.33355
5.50000 0.29982 0.59156
6.00000 0.37898 0.75872
6.50000 0.40741 0.82185
7.00000 0.38608 0.78150
7.50000 0.32137 0.65088
8.00000 0.22395 0.45320
8.50000 0.10749 0.21780
9.00000 -0.01304 -0.02400
9.50000 -0.12303 -0.24297
10.00000 -0.21002 -0.41521
10.50000 -0.26511 -0.52442
11.00000 -0.28395 -0.56304
11.50000 -0.26705 -0.53225
12.00000 -0.21939 -0.44117
12.50000 -0.14936 -0.30512
13.00000 -0.06738 -0.14355
13.50000 0.01567 0.02252
14.00000 0.08983 0.17301
14.50000 0.14719 0.29115
15.00000 0.18252 0.36524
15.50000 0.19360 0.38981
16.00000 0.18112 0.36583
16.50000 0.14837 0.30011
17.00000 0.10070 0.20397
17.50000 0.04477 0.09143
18.00000 -0.01223 -0.02274
18.50000 -0.06344 -0.12486
19.00000 -0.10315 -0.20388
19.50000 -0.12740 -0.25241
20.00000 -0.13445 -0.26726
20.50000 -0.12479 -0.24937
21.00000 -0.10095 -0.20345
21.50000 -0.06701 -0.13708
22.00000 -0.02791 -0.05966
22.50000 0.01124 0.01879
23.00000 0.04580 0.08886
23.50000 0.07210 0.14284
24.00000 0.08776 0.17553
24.50000 0.09184 0.18467
25.00000 0.08480 0.17105
25.50000 0.06834 0.13814
26.00000 0.04509 0.09146
26.50000 0.01830 0.03771
27.00000 -0.00861 -0.01614
27.50000 -0.03241 -0.06369
28.00000 -0.05050 -0.09985
28.50000 -0.06113 -0.12129
29.00000 -0.06359 -0.12667
29.50000 -0.05825 -0.11665
30.00000 -0.04638 -0.09362
30.50000 -0.02995 -0.06133
31.00000 -0.01131 -0.02430
31.50000 0.00714 0.01269
32.00000 0.02321 0.04527
32.50000 0.03523 0.06988
33.00000 0.04212 0.08422
33.50000 0.04350 0.08738
34.00000 0.03963 0.07987
34.50000 0.03140 0.06346
35.00000 0.02010 0.04084
35.50000 0.00729 0.01519
36.00000 -0.00538 -0.01018
36.50000 -0.01643 -0.03228
37.00000 -0.02466 -0.04878
37.50000 -0.02929 -0.05818
38.00000 -0.03005 -0.05995
38.50000 -0.02716 -0.05447
39.00000 -0.02127 -0.04299
39.50000 -0.01332 -0.02731
40.00000 -0.00444 -0.00964
40.50000 0.00424 0.00779
41.00000 0.01170 0.02291
41.50000 0.01718 0.03410
42.00000 0.02019 0.04035
42.50000 0.02057 0.04129
43.00000 0.01849 0.03725
43.50000 0.01439 0.02910
44.00000 0.00891 0.01815
44.50000 0.00280 0.00593
45.00000 -0.00316 -0.00601
45.50000 -0.00828 -0.01627
46.00000 -0.01201 -0.02378
46.50000 -0.01401 -0.02787
47.00000 -0.01418 -0.02833
47.50000 -0.01265 -0.02540
48.00000 -0.00973 -0.01969
48.50000 -0.00589 -0.01210
49.00000 -0.00167 -0.00368
49.50000 0.00241 0.00452
50.00000 0.00587 0.01152
*** 加速度反應量 ***
時間(秒) 第0點加速度 第1點加速度
0.00000 -0.50000 -1.00000
0.50000 -0.43415 -0.85816
1.00000 -0.32011 -0.62777
1.50000 -0.17479 -0.34367
2.00000 -0.01862 -0.04319
2.50000 0.12763 0.23808
3.00000 0.24601 0.46967
3.50000 0.32393 0.62880
4.00000 0.35550 0.70221
4.50000 0.34155 0.68716
5.00000 0.28851 0.59138
5.50000 0.20667 0.43184
6.00000 0.10825 0.23239
6.50000 0.00582 0.02035
7.00000 -0.08897 -0.17726
7.50000 -0.16629 -0.33733
8.00000 -0.21877 -0.44347
8.50000 -0.24204 -0.48754
9.00000 -0.23514 -0.46982
9.50000 -0.20063 -0.39802
10.00000 -0.14433 -0.28547
10.50000 -0.07456 -0.14886
11.00000 -0.00098 -0.00603
11.50000 0.06687 0.12607
12.00000 0.12093 0.23309
12.50000 0.15566 0.30453
13.00000 0.16859 0.33466
13.50000 0.16025 0.32285
14.00000 0.13375 0.27348
14.50000 0.09393 0.19513
15.00000 0.04665 0.09940
15.50000 -0.00210 -0.00077
16.00000 -0.04670 -0.09282
16.50000 -0.08247 -0.16621
17.00000 -0.10597 -0.21362
17.50000 -0.11533 -0.23157
18.00000 -0.11036 -0.22049
18.50000 -0.09256 -0.18426
19.00000 -0.06493 -0.12934
19.50000 -0.03151 -0.06374
20.00000 0.00315 0.00402
20.50000 0.03464 0.06591
21.00000 0.05933 0.11521
21.50000 0.07477 0.14711
22.00000 0.07992 0.15918
22.50000 0.07512 0.15144
23.00000 0.06188 0.12625
23.50000 0.04251 0.08792
24.00000 0.01982 0.04206
24.50000 -0.00333 -0.00522
25.00000 -0.02424 -0.04808
25.50000 -0.04072 -0.08169
26.00000 -0.05118 -0.10278
26.50000 -0.05483 -0.10988
27.00000 -0.05171 -0.10335
27.50000 -0.04264 -0.08514
28.00000 -0.02913 -0.05838
28.50000 -0.01315 -0.02692
29.00000 0.00316 0.00517
29.50000 0.01778 0.03410
30.00000 0.02905 0.05673
30.50000 0.03589 0.07091
31.00000 0.03786 0.07559
31.50000 0.03517 0.07093
32.00000 0.02856 0.05818
32.50000 0.01915 0.03949
33.00000 0.00828 0.01755
33.50000 -0.00269 -0.00474
34.00000 -0.01247 -0.02468
34.50000 -0.02003 -0.04005
35.00000 -0.02465 -0.04938
35.50000 -0.02602 -0.05208
36.00000 -0.02418 -0.04838
36.50000 -0.01961 -0.03926
37.00000 -0.01303 -0.02624
37.50000 -0.00540 -0.01118
38.00000 0.00228 0.00399
38.50000 0.00906 0.01748
39.00000 0.01419 0.02785
39.50000 0.01721 0.03411
40.00000 0.01792 0.03583
40.50000 0.01645 0.03317
41.00000 0.01316 0.02677
41.50000 0.00859 0.01767
42.00000 0.00338 0.00719
42.50000 -0.00180 -0.00331
43.00000 -0.00636 -0.01257
43.50000 -0.00982 -0.01959
44.00000 -0.01185 -0.02370
44.50000 -0.01232 -0.02466
45.00000 -0.01129 -0.02262
45.50000 -0.00900 -0.01806
46.00000 -0.00580 -0.01174
46.50000 -0.00217 -0.00454
47.00000 0.00144 0.00262
47.50000 0.00458 0.00890
48.00000 0.00692 0.01363
48.50000 0.00824 0.01637
49.00000 0.00847 0.01696
49.50000 0.00768 0.01549
50.00000 0.00605 0.01229
時間序列
0.0000, 0.5000, 1.0000, 1.5000, 2.0000,
2.5000, 3.0000, 3.5000, 4.0000, 4.5000,
5.0000, 5.5000, 6.0000, 6.5000, 7.0000,
7.5000, 8.0000, 8.5000, 9.0000, 9.5000,
10.0000, 10.5000, 11.0000, 11.5000, 12.0000,
12.5000, 13.0000, 13.5000, 14.0000, 14.5000,
15.0000, 15.5000, 16.0000, 16.5000, 17.0000,
17.5000, 18.0000, 18.5000, 19.0000, 19.5000,
20.0000, 20.5000, 21.0000, 21.5000, 22.0000,
22.5000, 23.0000, 23.5000, 24.0000, 24.5000,
25.0000, 25.5000, 26.0000, 26.5000, 27.0000,
27.5000, 28.0000, 28.5000, 29.0000, 29.5000,
30.0000, 30.5000, 31.0000, 31.5000, 32.0000,
32.5000, 33.0000, 33.5000, 34.0000, 34.5000,
35.0000, 35.5000, 36.0000, 36.5000, 37.0000,
37.5000, 38.0000, 38.5000, 39.0000, 39.5000,
40.0000, 40.5000, 41.0000, 41.5000, 42.0000,
42.5000, 43.0000, 43.5000, 44.0000, 44.5000,
45.0000, 45.5000, 46.0000, 46.5000, 47.0000,
47.5000, 48.0000, 48.5000, 49.0000, 49.5000,
50.0000,
第0點變位序列
1.0000, 0.9397, 0.7718, 0.5246, 0.2339,
-0.0617, -0.3259, -0.5295, -0.6531, -0.6888,
-0.6399, -0.5194, -0.3477, -0.1489, 0.0514,
0.2299, 0.3673, 0.4507, 0.4741, 0.4394,
0.3550, 0.2347, 0.0959, -0.0433, -0.1660,
-0.2589, -0.3134, -0.3261, -0.2992, -0.2391,
-0.1557, -0.0606, 0.0340, 0.1171, 0.1799,
0.2164, 0.2245, 0.2052, 0.1629, 0.1046,
0.0384, -0.0271, -0.0840, -0.1263, -0.1502,
-0.1542, -0.1397, -0.1098, -0.0694, -0.0240,
0.0206, 0.0592, 0.0878, 0.1037, 0.1061,
0.0957, 0.0746, 0.0464, 0.0149, -0.0159,
-0.0423, -0.0615, -0.0719, -0.0728, -0.0651,
-0.0503, -0.0307, -0.0091, 0.0119, 0.0298,
0.0428, 0.0496, 0.0501, 0.0445, 0.0341,
0.0205, 0.0055, -0.0090, -0.0212, -0.0299,
-0.0343, -0.0344, -0.0303, -0.0230, -0.0135,
-0.0032, 0.0066, 0.0149, 0.0208, 0.0237,
0.0236, 0.0207, 0.0156, 0.0090, 0.0019,
-0.0049, -0.0106, -0.0145, -0.0164, -0.0162,
-0.0141,
第1點變位序列
2.0000, 1.8798, 1.5469, 1.0582, 0.4840,
-0.1015, -0.6285, -1.0396, -1.2953, -1.3773,
-1.2892, -1.0546, -0.7129, -0.3133, 0.0917,
0.4531, 0.7314, 0.9000, 0.9481, 0.8799,
0.7130, 0.4752, 0.2004, -0.0762, -0.3218,
-0.5099, -0.6227, -0.6527, -0.6028, -0.4851,
-0.3190, -0.1281, 0.0627, 0.2307, 0.3577,
0.4319, 0.4489, 0.4112, 0.3279, 0.2125,
0.0811, -0.0493, -0.1636, -0.2494, -0.2988,
-0.3089, -0.2814, -0.2227, -0.1421, -0.0511,
0.0387, 0.1167, 0.1746, 0.2070, 0.2122,
0.1919, 0.1505, 0.0945, 0.0319, -0.0296,
-0.0826, -0.1216, -0.1431, -0.1459, -0.1312,
-0.1020, -0.0630, -0.0197, 0.0226, 0.0587,
0.0850, 0.0991, 0.1002, 0.0894, 0.0689,
0.0418, 0.0120, -0.0169, -0.0415, -0.0592,
-0.0685, -0.0689, -0.0611, -0.0466, -0.0278,
-0.0072, 0.0127, 0.0294, 0.0413, 0.0473,
0.0473, 0.0416, 0.0315, 0.0184, 0.0042,
-0.0094, -0.0207, -0.0287, -0.0327, -0.0325,
-0.0284,
第0點速度序列
0.0000, -0.2358, -0.4261, -0.5507, -0.5991,
-0.5710, -0.4761, -0.3318, -0.1599, 0.0161,
0.1751, 0.2998, 0.3790, 0.4074, 0.3861,
0.3214, 0.2240, 0.1075, -0.0130, -0.1230,
-0.2100, -0.2651, -0.2839, -0.2671, -0.2194,
-0.1494, -0.0674, 0.0157, 0.0898, 0.1472,
0.1825, 0.1936, 0.1811, 0.1484, 0.1007,
0.0448, -0.0122, -0.0634, -0.1031, -0.1274,
-0.1344, -0.1248, -0.1010, -0.0670, -0.0279,
0.0112, 0.0458, 0.0721, 0.0878, 0.0918,
0.0848, 0.0683, 0.0451, 0.0183, -0.0086,
-0.0324, -0.0505, -0.0611, -0.0636, -0.0583,
-0.0464, -0.0299, -0.0113, 0.0071, 0.0232,
0.0352, 0.0421, 0.0435, 0.0396, 0.0314,
0.0201, 0.0073, -0.0054, -0.0164, -0.0247,
-0.0293, -0.0300, -0.0272, -0.0213, -0.0133,
-0.0044, 0.0042, 0.0117, 0.0172, 0.0202,
0.0206, 0.0185, 0.0144, 0.0089, 0.0028,
-0.0032, -0.0083, -0.0120, -0.0140, -0.0142,
-0.0126, -0.0097, -0.0059, -0.0017, 0.0024,
0.0059,
第1點速度序列
0.0000, -0.4689, -0.8434, -1.0877, -1.1843,
-1.1341, -0.9546, -0.6766, -0.3401, 0.0108,
0.3336, 0.5916, 0.7587, 0.8218, 0.7815,
0.6509, 0.4532, 0.2178, -0.0240, -0.2430,
-0.4152, -0.5244, -0.5630, -0.5323, -0.4412,
-0.3051, -0.1436, 0.0225, 0.1730, 0.2911,
0.3652, 0.3898, 0.3658, 0.3001, 0.2040,
0.0914, -0.0227, -0.1249, -0.2039, -0.2524,
-0.2673, -0.2494, -0.2035, -0.1371, -0.0597,
0.0188, 0.0889, 0.1428, 0.1755, 0.1847,
0.1710, 0.1381, 0.0915, 0.0377, -0.0161,
-0.0637, -0.0999, -0.1213, -0.1267, -0.1166,
-0.0936, -0.0613, -0.0243, 0.0127, 0.0453,
0.0699, 0.0842, 0.0874, 0.0799, 0.0635,
0.0408, 0.0152, -0.0102, -0.0323, -0.0488,
-0.0582, -0.0599, -0.0545, -0.0430, -0.0273,
-0.0096, 0.0078, 0.0229, 0.0341, 0.0403,
0.0413, 0.0372, 0.0291, 0.0181, 0.0059,
-0.0060, -0.0163, -0.0238, -0.0279, -0.0283,
-0.0254, -0.0197, -0.0121, -0.0037, 0.0045,
0.0115,
第0點加速度序列
-0.5000, -0.4341, -0.3201, -0.1748, -0.0186,
0.1276, 0.2460, 0.3239, 0.3555, 0.3416,
0.2885, 0.2067, 0.1082, 0.0058, -0.0890,
-0.1663, -0.2188, -0.2420, -0.2351, -0.2006,
-0.1443, -0.0746, -0.0010, 0.0669, 0.1209,
0.1557, 0.1686, 0.1603, 0.1337, 0.0939,
0.0466, -0.0021, -0.0467, -0.0825, -0.1060,
-0.1153, -0.1104, -0.0926, -0.0649, -0.0315,
0.0031, 0.0346, 0.0593, 0.0748, 0.0799,
0.0751, 0.0619, 0.0425, 0.0198, -0.0033,
-0.0242, -0.0407, -0.0512, -0.0548, -0.0517,
-0.0426, -0.0291, -0.0131, 0.0032, 0.0178,
0.0290, 0.0359, 0.0379, 0.0352, 0.0286,
0.0192, 0.0083, -0.0027, -0.0125, -0.0200,
-0.0247, -0.0260, -0.0242, -0.0196, -0.0130,
-0.0054, 0.0023, 0.0091, 0.0142, 0.0172,
0.0179, 0.0164, 0.0132, 0.0086, 0.0034,
-0.0018, -0.0064, -0.0098, -0.0118, -0.0123,
-0.0113, -0.0090, -0.0058, -0.0022, 0.0014,
0.0046, 0.0069, 0.0082, 0.0085, 0.0077,
0.0060,
第1點加速度序列
-1.0000, -0.8582, -0.6278, -0.3437, -0.0432,
0.2381, 0.4697, 0.6288, 0.7022, 0.6872,
0.5914, 0.4318, 0.2324, 0.0203, -0.1773,
-0.3373, -0.4435, -0.4875, -0.4698, -0.3980,
-0.2855, -0.1489, -0.0060, 0.1261, 0.2331,
0.3045, 0.3347, 0.3229, 0.2735, 0.1951,
0.0994, -0.0008, -0.0928, -0.1662, -0.2136,
-0.2316, -0.2205, -0.1843, -0.1293, -0.0637,
0.0040, 0.0659, 0.1152, 0.1471, 0.1592,
0.1514, 0.1263, 0.0879, 0.0421, -0.0052,
-0.0481, -0.0817, -0.1028, -0.1099, -0.1034,
-0.0851, -0.0584, -0.0269, 0.0052, 0.0341,
0.0567, 0.0709, 0.0756, 0.0709, 0.0582,
0.0395, 0.0176, -0.0047, -0.0247, -0.0400,
-0.0494, -0.0521, -0.0484, -0.0393, -0.0262,
-0.0112, 0.0040, 0.0175, 0.0278, 0.0341,
0.0358, 0.0332, 0.0268, 0.0177, 0.0072,
-0.0033, -0.0126, -0.0196, -0.0237, -0.0247,
-0.0226, -0.0181, -0.0117, -0.0045, 0.0026,
0.0089, 0.0136, 0.0164, 0.0170, 0.0155,
0.0123,
請按任意鍵繼續 . . .
*/
特別解,依據系統受到各種之外力而定
CSharp 程式碼如下(4)
M * yp(t)'' + C * yp(t)' + K * yp(t) = fn(t)
fn(t) = Bf * u(t) 而 u(t)是StepFunction,譬如 StepFunc3 類別,此類別的一次和二次微分均為零
設 yp(t) = B0 * u(t),則 u'(t) = u''(t) = 0
yp(t)' = yp(t)'' = 0
M * 0 + C * 0 + K * yp(t) = fn(t) = Bf * u(t)
yp(t) = ~K * Bf * u(t) 。 『~』是逆矩陣的運算子。 故yp(t)是矩陣微分方程式的特別解。
說明
雖然土木建築結構, M、C、K 矩陣是對稱,但矩陣微分方程式求解器,M、C、K並不一定要對稱。理由是矩陣對稱是非對稱矩陣的特例,即對稱矩陣是非對稱矩陣的子集合(Subset)。
實例一
// .NET 10.0 @ C:\2509\Misc_A\App\App10
// Ray W. Clough & Joseph Penzien 之著作
// "Dynamics of Structures" Page 202頁至 203頁。
// 矩陣M和K參數保持不變,修正矩陣參數C如下。
// double M = {{1, 0, 0},{0, 1.5, 0}, {0, 0, 2}};
// double C = {{5, -2, 0},{9, 4, 2}, {1, -1, 3}}; // 阻尼矩陣修正如左式。
// double K = {{600, -600, 0},{-600, 1800, -1200}, {0, -1200, 3000}};
using Matrix_0;
// 每一個Step是0.25秒。週期為 2 * π 秒。設定共計有30秒。
double step = 0.25;
double tSpan = 6.28318; // 2 * π ≈ 6.28318
double tAxis = 40; // 時間軸總長度40秒。
int iRow = (int)(tAxis/0.25 + 1);
// 時間t和狀態響應兩者共計iCol = 2。
int iCol = 2;
ReMatrix A = new ReMatrix(iRow, iCol);
for(int i = 0; i != iRow; i++)
{
double t = step * i;
A.Matrix[i, 0] = t;
A.Matrix[i, 1] = (new StepFunc1(tSpan, t)).Value;
}
// 列印輸出結果。
Console.WriteLine("\n Matrix Disp :\n{0}\n", new PR(A));
// 有興趣的讀者,請自行測試此Step Function的輸出。
實例二
// .NET 10.0 @ C:\2509\Misc_A\App\App11
// Ray W. Clough & Joseph Penzien 的著作,
// "Dynamics of Structures 1st Editon" Page 第202頁至203頁。
// 參見 https://myyeh2.github.io 或 https://github.com/myyeh2/App_38A
// 動態系統之齊次解是複數矩陣。但特別解是實數矩陣(使用未定係數法)。
// M * yp''(t) + C * yp'(t) + K * yp(t) = f(t) = Bf * U(t)
// 本矩陣微分方程式(m=3, r=2)
// m=3即空間維度的自由度為3 : 3個節點。
// r=2即狀態維度的自由度為2(階,Order) : 即 yp(t)''、yp(t)'、和yp(t)。
// 因U(t)是StepFunc1與StepFunc3都是階梯函數,故yp'(t) 和 yp''(t)均為零向量。
using Matrix_0;
// 勁度矩陣K
double[,] K = { { 600, -600, 0 }, { -600, 1800, -1200 }, { 0, -1200, 300 } };
// 設定Bf如下:
double[,] Bf = { { 5000, -2000 }, { -1500, 2500 }, { -2000, 1500 } };
// 每一個Step是0.17秒。週期為4.0秒。設定時間軸為8秒。
double step = 0.17;
double tSpan = 4.0;
double tAxis = 8.0;
int iRow = (int)(tAxis / 0.17 + 1);
// 在每固定時間之系統響應值為yp。
ReMatrix yp = new ReMatrix(4, 1); //第1個參數為m+1=4,即4X1之向量(矩陣)。
// 建構儲存矩陣ypA,(t,yp0,yp1,yp2,ypc)。
ReMatrix ypA = new ReMatrix(iRow, 5); // 第二個參數為5,即iRowX5之矩陣。
for (int i = 0; i != iRow; i++)
{
double t = step * i;
double[,] Ut = { { new StepFunc1(tSpan, t).Value },
{new StepFunc3(tSpan, t).Value } };
yp = ~((ReMatrix)K) * Bf * Ut;
ypA.Matrix[i, 0] = t;
ypA.Matrix[i, 1] = yp.Matrix[0, 0];
ypA.Matrix[i, 2] = yp.Matrix[1, 0];
ypA.Matrix[i, 3] = yp.Matrix[2, 0];
ypA.Matrix[i, 4] = yp.Matrix[0, 0] + yp.Matrix[1, 0] + yp.Matrix[2, 0];
}
Console.WriteLine("{0,10}時間{0,10}第0點變位{0,8}第1點變位" +
"{0,8}第2點變位{0,8}合併變位","");
Console.WriteLine("\n{0}\n", new PR(ypA));
// yp'(t)和yp''(t)相同,故不在列出來。
/* 輸出結果(特別解)
時間 第0點變位 第1點變位 第2點變位 合併變位
0.00000 9.58333 1.25000 -1.66667 9.16667
0.17000 9.14653 1.09653 -1.85556 8.38750
0.34000 8.70972 0.94306 -2.04444 7.60833
0.51000 8.27292 0.78958 -2.23333 6.82917
0.68000 7.83611 0.63611 -2.42222 6.05000
0.85000 7.39931 0.48264 -2.61111 5.27083
1.02000 6.96250 0.32917 -2.80000 4.49167
1.19000 6.52569 0.17569 -2.98889 3.71250
1.36000 6.08889 0.02222 -3.17778 2.93333
1.53000 5.65208 -0.13125 -3.36667 2.15417
1.70000 5.21528 -0.28472 -3.55556 1.37500
1.87000 4.77847 -0.43819 -3.74444 0.59583
2.04000 -4.54722 0.51944 3.84444 -0.18333
2.21000 -4.98403 0.36597 3.65556 -0.96250
2.38000 -5.42083 0.21250 3.46667 -1.74167
2.55000 -5.85764 0.05903 3.27778 -2.52083
2.72000 -6.29444 -0.09444 3.08889 -3.30000
2.89000 -6.73125 -0.24792 2.90000 -4.07917
3.06000 -7.16806 -0.40139 2.71111 -4.85833
3.23000 -7.60486 -0.55486 2.52222 -5.63750
3.40000 -8.04167 -0.70833 2.33333 -6.41667
3.57000 -8.47847 -0.86181 2.14444 -7.19583
3.74000 -8.91528 -1.01528 1.95556 -7.97500
3.91000 -9.35208 -1.16875 1.76667 -8.75417
4.08000 9.37778 1.17778 -1.75556 8.80000
4.25000 8.94097 1.02431 -1.94444 8.02083
4.42000 8.50417 0.87083 -2.13333 7.24167
4.59000 8.06736 0.71736 -2.32222 6.46250
4.76000 7.63056 0.56389 -2.51111 5.68333
4.93000 7.19375 0.41042 -2.70000 4.90417
5.10000 6.75694 0.25694 -2.88889 4.12500
5.27000 6.32014 0.10347 -3.07778 3.34583
5.44000 5.88333 -0.05000 -3.26667 2.56667
5.61000 5.44653 -0.20347 -3.45556 1.78750
5.78000 5.00972 -0.35694 -3.64444 1.00833
5.95000 4.57292 -0.51042 -3.83333 0.22917
6.12000 -4.75278 0.44722 3.75556 -0.55000
6.29000 -5.18958 0.29375 3.56667 -1.32917
6.46000 -5.62639 0.14028 3.37778 -2.10833
6.63000 -6.06319 -0.01319 3.18889 -2.88750
6.80000 -6.50000 -0.16667 3.00000 -3.66667
6.97000 -6.93681 -0.32014 2.81111 -4.44583
7.14000 -7.37361 -0.47361 2.62222 -5.22500
7.31000 -7.81042 -0.62708 2.43333 -6.00417
7.48000 -8.24722 -0.78056 2.24444 -6.78333
7.65000 -8.68403 -0.93403 2.05556 -7.56250
7.82000 -9.12083 -1.08750 1.86667 -8.34167
7.99000 -9.55764 -1.24097 1.67778 -9.12083
*/
可將以上的輸出數值資料,使用Excel繪製時間與響應圖
實例三
// .NET 10.0 @ C:\2509\Misc_A\App\App12
using Matrix_0;
// 矩陣微分方程式(m=3, r=2)特別解,已知下列數據:
// M * yp''(t) + C * yp'(t) + K * yp(t) = F(t) = Bf * U(t)
double[,] M = {{4.5, 1.2, -1.2},{0.5, 4.5 ,0}, {-1.5, -2.0, 3.5}};
double[,] C = {{2.5, 1.0, -1.0},{2.0, 5.7 ,2.0}, {-2.5, -1.5, -8.0}};
double[,] K = {{8.5, -1.0, -1.0},{-2.0, 4.8, 2.0}, {1.0, -2.0, -5.5}};
double[,] B0 = {{0.48, 0, 0, 0, 10.5, 0}, {0, -3.5, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0}};
double[,] B1 = {{0, 0.96, 0, 0, 0, -10.5}, {0, 0, 3.2, 0, 0, 0}, {0, 0, 1, 0, 0, 0}};
double[,] B2 = {{0, 0, 0.96, 0, -10.5, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}};
// U(t) = {{t*t}, {t}, {1}, {0}, {cos(t)}, {sin(t)}};
// yp(t) = B0 * U(t);
// yp'(t) = B1 * U(t);
// yp''(t) = B2 * U(t);
// fn(t) = Bf * U(t);
// M * B2 + C * B1 + K * B0 = Bf
double step = 0.5;
double tSpan = 8.0;
double tAxis = 20.0;
int iRow = (int)(tAxis/step + 1);
ReMatrix yp0 = new ReMatrix(4, 1);
ReMatrix Ayp0 = new ReMatrix(iRow, 5);
// yp1 Ap1 yp2 Ap2 不再表示。即不再求 Bf。
for (int i = 0; i != iRow; i++)
{
double t = step * i;
t = new Remainder2(tSpan, t).Value;
double[,] U = { {t*t}, {t}, {1}, {0}, {Math.Cos(t)}, {Math.Sin(t)} };
yp0 = ((ReMatrix)B0) * U ;
Ayp0.Matrix[i, 0] = t;
Ayp0.Matrix[i, 1] = yp0.Matrix[0, 0];
Ayp0.Matrix[i, 2] = yp0.Matrix[1, 0];
Ayp0.Matrix[i, 3] = yp0.Matrix[2, 0];
Ayp0.Matrix[i, 4] = yp0.Matrix[0, 0] + yp0.Matrix[1, 0] + yp0.Matrix[2, 0];
}
Console.Write("{0,10}時間{0,10}第0點變位{0,8}第1點變位{0,8}第2點變位{0,8}合併變位\n","");
Console.WriteLine("\n{0}\n", new PR(Ayp0));
// 相同情況,可求得 yp'(t) 和 yp''(t)。
// 輸出結果可繪製圖表。
/*
時間 第0點變位 第1點變位 第2點變位 合併變位
0.00000 10.50000 0.00000 0.00000 10.50000
0.50000 9.33462 -1.75000 0.50000 8.08462
1.00000 6.15317 -3.50000 1.00000 3.65317
.
.
.
3.00000 -6.07492 -10.50000 3.00000 -13.57492
3.50000 -3.95280 -12.25000 3.50000 -12.70280
4.00000 0.81674 -14.00000 4.00000 -9.18326
*/
實例四
using Matrix_0;
// 矩陣微分方程式(m=3,r=2)特別解,已知下列數據。
// M * yp(t)'' + C * yp(t)' + K * yp(t) = F(t) = Bf * U(t)
double[,] M = { {0.5, 0.7, -0.9}, {-0.3, 0.3, 0.1}, {0.8, -0.4, 0.1} };
double[,] C = { {0.4, 0.1, 0.3}, {-0.2, -0.8, 0.3}, {0.9, -0.3, -0.7} };
double[,] K = { {0.3, 0.2, 0.4}, {-0.4, 0.5, -0.2}, {0.3, -0.3, 0.6} };
double[,] Bf = { {10.8, 0, 0, -10.5}, {0, 0, 0, 1.5}, {3, 1, 1, 1} };
double step = 0.47;
double tSpan = 8.7;
double tAxis = 25.9;
int iRow = (int)(tAxis/step + 1);
ReMatrix yp2 = new ReMatrix(4, 1);
ReMatrix Ayp2 = new ReMatrix(iRow, 5);
for(int i = 0; i != iRow; i++)
{
double t = step * i;
t = (new Remainder2(tSpan, t)).Value;
double temp0 = Math.Exp(t);
double[,] U = { {temp0}, {0}, {0}, {temp0} };
// U(t) = U'(t) = U''(t) = [e^t,0,0,e^t]^T
ReMatrix B0 = ~( (ReMatrix)M + C + K ) * Bf;
yp2 = B0 * U;
Ayp2.Matrix[i, 0] = t;
Ayp2.Matrix[i, 1] = yp2.Matrix[0, 0];
Ayp2.Matrix[i, 2] = yp2.Matrix[1, 0];
Ayp2.Matrix[i, 3] = yp2.Matrix[2, 0];
Ayp2.Matrix[i, 4] = yp2.Matrix[0, 0] + yp2.Matrix[1, 0] +
yp2.Matrix[2, 0];
}
Console.WriteLine("{0,10}時間{0,9}第0點加速度{0,7}第1點加速度{0,6}第2點加速度{0,6}合併變位\n","");
Console.WriteLine("\n{0}\n", new PR(Ayp2));
/*
時間 第0點加速度 第1點加速度 第2點加速度 合併變位
0.00000 2.52174 1.04348 18.84783 22.41304
0.47000 4.03477 1.66956 30.15641 35.86074
0.94000 6.45561 2.67128 48.25008 57.37697
1.41000 10.32893 4.27404 77.19986 91.80283
1.88000 16.52623 6.83844 123.51932 146.88399
2.35000 26.44187 10.94146 197.63019 235.01353
2.82000 42.30684 17.50628 316.20716 376.02028
3.29000 67.69070 28.00994 505.92963 601.63027
3.76000 108.30473 44.81575 809.48446 962.60494
4.23000 173.28693 71.70494 1295.17044 1540.16231
4.70000 277.25809 114.72748 2072.26519 2464.25076
5.17000 443.61133 183.56331 3315.61226 3942.78690
5.64000 709.77555 293.70023 5304.96037 6308.43615
6.11000 1135.63676 469.91866 8487.90578 10093.46120
6.58000 1817.01222 751.86713 13580.59997 16149.47931
7.05000 2907.20900 1202.98304 21728.88109 25839.07313
7.52000 4651.51752 1924.76587 34766.08356 41342.36696
7.99000 7442.40103 3079.61422 55625.53182 66147.54707
8.46000 11907.79843 4927.36487 89000.52791 105835.69121
0.23000 3.17386 1.31332 23.72187 28.20906
0.70000 5.07816 2.10131 37.95486 45.13433
1.17000 8.12502 3.36208 60.72756 72.21466
1.64000 12.99999 5.37931 97.16374 115.54304
2.11000 20.79991 8.60686 155.46142 184.86819
2.58000 33.27974 13.77093 248.73736 295.78803
3.05000 53.24739 22.03340 397.97834 473.25913
3.52000 85.19552 35.25332 636.76303 757.21186
3.99000 136.31233 56.40510 1018.81715 1211.53459
4.46000 218.09894 90.24784 1630.10153 1938.44830
4.93000 348.95703 144.39601 2608.15298 3101.50603
5.40000 558.32922 231.03278 4173.02963 4962.39163
5.87000 893.32352 369.65111 6676.82317 7939.79780
6.34000 1429.31244 591.43963 10682.87830 12703.63037
6.81000 2286.89160 946.29997 17092.54325 20325.73483
7.28000 3659.01328 1514.07446 27347.96995 32521.05769
7.75000 5854.40000 2422.51035 43756.59312 52033.50347
8.22000 9367.00601 3876.00249 70010.29491 83253.30340
8.69000 14987.15522 6201.58147 112016.06531 133204.80201
0.46000 3.99462 1.65295 29.85635 35.50392
0.93000 6.39137 2.64471 47.76999 56.80606
1.40000 10.22616 4.23151 76.43170 90.88937
1.87000 16.36179 6.77040 122.29028 145.42247
2.34000 26.17877 10.83259 195.66374 232.67511
2.81000 41.88588 17.33209 313.06085 372.27882
3.28000 67.01717 27.73124 500.89554 595.64395
3.75000 107.22708 44.36982 801.42996 953.02686
4.22000 171.56270 70.99146 1282.28328 1524.83744
4.69000 274.49932 113.58593 2051.64580 2439.73105
5.16000 439.19732 181.73682 3282.62137 3903.55552
5.63000 702.71317 290.77786 5252.17513 6245.66616
6.10000 1124.33699 465.24289 8403.44971 9993.02959
6.57000 1798.93265 744.38592 13445.47074 15988.78931
7.04000 2878.28179 1191.01315 21512.67511 25581.97005
7.51000 4605.23415 1905.61413 34420.15525 40931.00354
7.98000 7368.34790 3048.97155 55072.04853 65489.36798
8.45000 11789.31385 4878.33677 88114.95786 104782.60849
按任意鍵關閉此視窗…
*/
實例五
Ray W. Clough & Joseph Penzien "Dynamics of Structure" 第202-203頁 齊次解




--位移圖--

--速度圖--

--加速度圖--

實例六
參考https://github.com/myyeh2/App_41,並加入阻尼矩陣。
程式碼如下:






輸出結果如下:
/**** 輸出結果範例如下: ****
**** 系 統 與 狀 態 參 數 ****
*** 系統特徵值V ***
-0.03251 + 3.47271i
-0.03251 - 3.47271i
-0.41749 + 1.34745i
-0.41749 - 1.34745i
*** 系統特徵矩陣D ***
-0.03251 + 3.47271i, 0.00000 + 0.00000i, 0.00000 + 0.00000i,
0.00000 + 0.00000i
0.00000 + 0.00000i, -0.03251 - 3.47271i, 0.00000 + 0.00000i,
0.00000 + 0.00000i
0.00000 + 0.00000i, 0.00000 + 0.00000i, -0.41749 + 1.34745i,
0.00000 + 0.00000i
0.00000 + 0.00000i, 0.00000 + 0.00000i, 0.00000 + 0.00000i,
-0.41749 - 1.34745i
*** 系統模態矩陣Q ***
0.85393 + 0.00000i, 0.85393 + 0.00000i, 0.35012 + 0.00000i,
0.35012 + 0.00000i
-0.43841 + 0.04499i, -0.43841 - 0.04499i, 0.73011 - 0.09950i,
0.73011 + 0.09950i
-0.00230 - 0.24588i, -0.00230 + 0.24588i, -0.07346 - 0.23708i,
-0.07346 + 0.23708i
0.01414 + 0.12611i, 0.01414 - 0.12611i, -0.22056 - 0.47351i,
-0.22056 + 0.47351i
*** 係數向量d ***
0.68857 + 0.05097i
0.68857 - 0.05097i
-0.25131 - 0.12404i
-0.25131 + 0.12404i
**** 空 間 狀 態 響 應 ****
***位移反應量***
時間(秒) 第0點位移 第1點位移
0.00000 0.00000 0.00000
0.25000 0.21100 -0.22110
0.50000 0.24182 -0.32342
0.75000 0.05722 -0.27685
1.00000 -0.21812 -0.13993
1.25000 -0.39031 -0.01777
1.50000 -0.33481 0.01029
1.75000 -0.08444 -0.05730
2.00000 0.19423 -0.14829
2.25000 0.31813 -0.17236
2.50000 0.21487 -0.08824
2.75000 -0.02939 0.06540
3.00000 -0.23370 0.19656
3.25000 -0.25116 0.22443
3.50000 -0.07131 0.13586
3.75000 0.17510 -0.00586
4.00000 0.31080 -0.10555
4.25000 0.23792 -0.10205
4.50000 0.00607 -0.00914
4.75000 -0.22418 0.09671
5.00000 -0.29531 0.13213
5.25000 -0.16306 0.06630
5.50000 0.07451 -0.05783
5.75000 0.24816 -0.15471
6.00000 0.23724 -0.15715
6.25000 0.05340 -0.06349
6.50000 -0.16997 0.06174
6.75000 -0.27363 0.13366
7.00000 -0.18493 0.10638
7.25000 0.03242 0.00416
7.50000 0.22508 -0.09712
7.75000 0.25910 -0.12426
8.00000 0.11360 -0.05816
8.25000 -0.10636 0.05367
8.50000 -0.24548 0.13166
8.75000 -0.20796 0.12069
9.00000 -0.02364 0.02865
9.25000 0.17504 -0.07996
9.50000 0.24774 -0.13002
9.75000 0.14493 -0.08851
10.00000 -0.05879 0.01304
10.25000 -0.21901 0.10181
10.50000 -0.22405 0.11545
10.75000 -0.07278 0.04564
11.00000 0.12626 -0.05699
11.25000 0.23285 -0.11944
11.50000 0.17391 -0.09799
11.75000 -0.00625 -0.00853
12.00000 -0.17901 0.08553
12.25000 -0.22307 0.11847
12.50000 -0.10946 0.06843
12.75000 0.07957 -0.02801
13.00000 0.21010 -0.10239
13.25000 0.19142 -0.10293
13.50000 0.03895 -0.03060
13.75000 -0.13824 0.06247
14.00000 -0.21546 0.11041
14.25000 -0.14022 0.08012
14.50000 0.03214 -0.00604
14.75000 0.17903 -0.08681
15.00000 0.19774 -0.10565
15.25000 0.07719 -0.05035
15.50000 -0.09573 0.03909
15.75000 -0.19879 0.09940
16.00000 -0.16073 0.08878
16.25000 -0.01051 0.01591
16.50000 0.14466 -0.06699
16.75000 0.19582 -0.10151
17.00000 0.10875 -0.06414
17.25000 -0.05319 0.01775
17.50000 -0.17513 0.08599
17.75000 -0.17211 0.09288
18.00000 -0.04830 0.03458
18.25000 0.10746 -0.04698
18.50000 0.18529 -0.09420
18.75000 0.13182 -0.07451
19.00000 -0.01332 -0.00285
19.25000 -0.14679 0.06964
19.50000 -0.17510 0.09204
19.75000 -0.08007 0.04943
20.00000 0.06960 -0.02723
***速度反應量***
時間(秒) 第0點速度 第1點速度
0.00000 1.00000 -1.00000
0.25000 0.56413 -0.69698
0.50000 -0.34279 -0.10014
0.75000 -1.04412 0.43053
1.00000 -1.01902 0.58941
1.25000 -0.26898 0.33112
1.50000 0.68934 -0.10738
1.75000 1.19386 -0.38103
2.00000 0.90401 -0.28166
2.25000 0.03537 0.11893
2.50000 -0.79925 0.52626
2.75000 -1.02461 0.63672
3.00000 -0.50436 0.35449
3.25000 0.37203 -0.14095
3.50000 0.97255 -0.52210
3.75000 0.87117 -0.54332
4.00000 0.14415 -0.21039
4.25000 -0.69142 0.22829
4.50000 -1.04784 0.45987
4.75000 -0.68093 0.32692
5.00000 0.14351 -0.06569
5.25000 0.84379 -0.43001
5.50000 0.93507 -0.50144
5.75000 0.36748 -0.22534
6.00000 -0.44627 0.20699
6.25000 -0.92834 0.49587
6.50000 -0.74410 0.44500
6.75000 -0.03309 0.09745
7.00000 0.69674 -0.29812
7.25000 0.93171 -0.46502
7.50000 0.51332 -0.29263
7.75000 -0.25600 0.08915
8.00000 -0.83230 0.40541
8.25000 -0.81569 0.43200
8.50000 -0.22854 0.15230
8.75000 0.50710 -0.23427
9.00000 0.87215 -0.45564
9.25000 0.61640 -0.35929
9.50000 -0.07028 -0.01751
9.75000 -0.69843 0.32681
10.00000 -0.82743 0.43320
10.25000 -0.37413 0.23216
10.50000 0.33451 -0.12896
10.75000 0.79746 -0.39304
11.00000 0.69406 -0.37549
11.25000 0.10620 -0.09268
11.50000 -0.54567 0.25276
11.75000 -0.80306 0.41727
12.00000 -0.49186 0.28797
12.25000 0.16011 -0.04007
12.50000 0.68947 -0.33392
12.75000 0.72641 -0.38836
13.00000 0.25274 -0.16947
13.25000 -0.39099 0.16436
13.50000 -0.75027 0.37674
13.75000 -0.57755 0.32046
14.00000 -0.00261 0.03936
14.25000 0.56458 -0.26553
14.50000 0.72610 -0.37968
14.75000 0.37523 -0.22585
15.00000 -0.23341 0.08386
15.25000 -0.66837 0.32972
15.50000 -0.62710 0.34033
15.75000 -0.14619 0.11213
16.00000 0.42972 -0.19079
16.25000 0.69488 -0.35461
16.50000 0.46815 -0.26661
16.75000 -0.08342 0.00734
17.00000 -0.56748 0.27188
17.25000 -0.64539 0.34141
17.50000 -0.26905 0.17020
17.75000 0.29005 -0.11775
18.00000 0.63650 -0.31849
18.25000 0.53055 -0.29255
18.50000 0.05386 -0.06180
18.75000 -0.45300 0.20849
19.00000 -0.63377 0.32800
19.25000 -0.36680 0.21528
19.50000 0.15330 -0.04676
19.75000 0.55742 -0.27178
20.00000 0.56377 -0.30240
*** 加速度反應量 ***
時間(秒) 第0點加速度 第1點加速度
0.00000 -0.15000 0.30000
0.25000 -3.08570 2.00394
0.50000 -3.68256 2.51245
0.75000 -1.55365 1.51391
1.00000 1.75284 -0.27478
1.25000 3.87552 -1.62058
1.50000 3.31496 -1.63916
1.75000 0.47675 -0.40065
2.00000 -2.63994 1.14340
2.25000 -3.86828 1.84911
2.50000 -2.39540 1.19104
2.75000 0.68979 -0.37623
3.00000 3.19144 -1.75247
3.25000 3.36503 -1.97560
3.50000 1.13314 -0.89727
3.75000 -1.88873 0.72292
4.00000 -3.55517 1.76166
4.25000 -2.70681 1.52294
4.50000 0.03054 0.21684
4.75000 2.71304 -1.20462
5.00000 3.46400 -1.72897
5.25000 1.78996 -0.99533
5.50000 -1.09499 0.46297
5.75000 -3.14844 1.60802
6.00000 -2.94598 1.63509
6.25000 -0.67036 0.53504
6.50000 2.04331 -0.91079
6.75000 3.27916 -1.69059
7.00000 2.19026 -1.27513
7.25000 -0.42394 0.01918
7.50000 -2.70523 1.26624
7.75000 -3.05800 1.59014
8.00000 -1.26520 0.77889
8.25000 1.38140 -0.57785
8.50000 3.01192 -1.51612
8.75000 2.49995 -1.38075
9.00000 0.24098 -0.28072
9.25000 -2.14988 0.99925
9.50000 -2.99136 1.56020
9.75000 -1.71717 1.02154
10.00000 0.74444 -0.22015
10.25000 2.64641 -1.28196
10.50000 2.66237 -1.42206
10.75000 0.81099 -0.55798
11.00000 -1.57877 0.68638
11.25000 -2.82147 1.43018
11.50000 -2.06390 1.15824
11.75000 0.12953 0.07684
12.00000 2.19582 -1.04261
12.25000 2.68654 -1.41416
12.50000 1.28266 -0.78915
12.75000 -0.99977 0.37780
13.00000 -2.54435 1.25919
13.25000 -2.27861 1.24142
13.50000 -0.41801 0.35194
13.75000 1.70600 -0.77040
14.00000 2.59849 -1.33368
14.25000 1.65300 -0.95125
14.50000 -0.43712 0.09340
14.75000 -2.18635 1.05642
15.00000 -2.37242 1.26316
15.25000 -0.88999 0.58058
15.50000 1.19343 -0.49802
15.75000 2.40570 -1.20937
16.00000 1.90989 -1.06027
16.25000 0.08147 -0.16940
16.50000 -1.77476 0.82584
16.75000 -2.35549 1.22514
17.00000 -1.27367 0.75778
17.25000 0.68456 -0.23422
17.50000 2.13061 -1.04608
17.75000 2.05778 -1.11081
18.00000 0.54170 -0.39495
18.25000 -1.33017 0.58652
18.50000 -2.23821 1.14048
18.75000 -1.56057 0.88505
19.00000 0.20156 0.01261
19.25000 1.79386 -0.85452
19.50000 2.10143 -1.10777
19.75000 0.92908 -0.57928
20.00000 -0.87645 0.34736
時間序列 :
0.00, 0.25, 0.50, 0.75, 1.00,
1.25, 1.50, 1.75, 2.00, 2.25,
2.50, 2.75, 3.00, 3.25, 3.50,
3.75, 4.00, 4.25, 4.50, 4.75,
5.00, 5.25, 5.50, 5.75, 6.00,
6.25, 6.50, 6.75, 7.00, 7.25,
7.50, 7.75, 8.00, 8.25, 8.50,
8.75, 9.00, 9.25, 9.50, 9.75,
10.00, 10.25, 10.50, 10.75, 11.00,
11.25, 11.50, 11.75, 12.00, 12.25,
12.50, 12.75, 13.00, 13.25, 13.50,
13.75, 14.00, 14.25, 14.50, 14.75,
15.00, 15.25, 15.50, 15.75, 16.00,
16.25, 16.50, 16.75, 17.00, 17.25,
17.50, 17.75, 18.00, 18.25, 18.50,
18.75, 19.00, 19.25, 19.50, 19.75,
20.00,
第0點變位序列 :
0.0000, 0.2110, 0.2418, 0.0572, -0.2181,
-0.3903, -0.3348, -0.0844, 0.1942, 0.3181,
0.2149, -0.0294, -0.2337, -0.2512, -0.0713,
0.1751, 0.3108, 0.2379, 0.0061, -0.2242,
-0.2953, -0.1631, 0.0745, 0.2482, 0.2372,
0.0534, -0.1700, -0.2736, -0.1849, 0.0324,
0.2251, 0.2591, 0.1136, -0.1064, -0.2455,
-0.2080, -0.0236, 0.1750, 0.2477, 0.1449,
-0.0588, -0.2190, -0.2240, -0.0728, 0.1263,
0.2328, 0.1739, -0.0062, -0.1790, -0.2231,
-0.1095, 0.0796, 0.2101, 0.1914, 0.0389,
-0.1382, -0.2155, -0.1402, 0.0321, 0.1790,
0.1977, 0.0772, -0.0957, -0.1988, -0.1607,
-0.0105, 0.1447, 0.1958, 0.1087, -0.0532,
-0.1751, -0.1721, -0.0483, 0.1075, 0.1853,
0.1318, -0.0133, -0.1468, -0.1751, -0.0801,
0.0696,
第1點變位序列 :
0.0000, -0.2211, -0.3234, -0.2769, -0.1399,
-0.0178, 0.0103, -0.0573, -0.1483, -0.1724,
-0.0882, 0.0654, 0.1966, 0.2244, 0.1359,
-0.0059, -0.1056, -0.1021, -0.0091, 0.0967,
0.1321, 0.0663, -0.0578, -0.1547, -0.1572,
-0.0635, 0.0617, 0.1337, 0.1064, 0.0042,
-0.0971, -0.1243, -0.0582, 0.0537, 0.1317,
0.1207, 0.0287, -0.0800, -0.1300, -0.0885,
0.0130, 0.1018, 0.1154, 0.0456, -0.0570,
-0.1194, -0.0980, -0.0085, 0.0855, 0.1185,
0.0684, -0.0280, -0.1024, -0.1029, -0.0306,
0.0625, 0.1104, 0.0801, -0.0060, -0.0868,
-0.1056, -0.0504, 0.0391, 0.0994, 0.0888,
0.0159, -0.0670, -0.1015, -0.0641, 0.0178,
0.0860, 0.0929, 0.0346, -0.0470, -0.0942,
-0.0745, -0.0028, 0.0696, 0.0920, 0.0494,
-0.0272,
第0點速度序列 :
1.0000, 0.5641, -0.3428, -1.0441, -1.0190,
-0.2690, 0.6893, 1.1939, 0.9040, 0.0354,
-0.7992, -1.0246, -0.5044, 0.3720, 0.9726,
0.8712, 0.1441, -0.6914, -1.0478, -0.6809,
0.1435, 0.8438, 0.9351, 0.3675, -0.4463,
-0.9283, -0.7441, -0.0331, 0.6967, 0.9317,
0.5133, -0.2560, -0.8323, -0.8157, -0.2285,
0.5071, 0.8721, 0.6164, -0.0703, -0.6984,
-0.8274, -0.3741, 0.3345, 0.7975, 0.6941,
0.1062, -0.5457, -0.8031, -0.4919, 0.1601,
0.6895, 0.7264, 0.2527, -0.3910, -0.7503,
-0.5775, -0.0026, 0.5646, 0.7261, 0.3752,
-0.2334, -0.6684, -0.6271, -0.1462, 0.4297,
0.6949, 0.4682, -0.0834, -0.5675, -0.6454,
-0.2690, 0.2900, 0.6365, 0.5305, 0.0539,
-0.4530, -0.6338, -0.3668, 0.1533, 0.5574,
0.5638,
第1點速度序列 :
-1.0000, -0.6970, -0.1001, 0.4305, 0.5894,
0.3311, -0.1074, -0.3810, -0.2817, 0.1189,
0.5263, 0.6367, 0.3545, -0.1409, -0.5221,
-0.5433, -0.2104, 0.2283, 0.4599, 0.3269,
-0.0657, -0.4300, -0.5014, -0.2253, 0.2070,
0.4959, 0.4450, 0.0975, -0.2981, -0.4650,
-0.2926, 0.0891, 0.4054, 0.4320, 0.1523,
-0.2343, -0.4556, -0.3593, -0.0175, 0.3268,
0.4332, 0.2322, -0.1290, -0.3930, -0.3755,
-0.0927, 0.2528, 0.4173, 0.2880, -0.0401,
-0.3339, -0.3884, -0.1695, 0.1644, 0.3767,
0.3205, 0.0394, -0.2655, -0.3797, -0.2259,
0.0839, 0.3297, 0.3403, 0.1121, -0.1908,
-0.3546, -0.2666, 0.0073, 0.2719, 0.3414,
0.1702, -0.1177, -0.3185, -0.2926, -0.0618,
0.2085, 0.3280, 0.2153, -0.0468, -0.2718,
-0.3024,
第0點加速度序列
-0.1500, -3.0857, -3.6826, -1.5536, 1.7528,
3.8755, 3.3150, 0.4768, -2.6399, -3.8683,
-2.3954, 0.6898, 3.1914, 3.3650, 1.1331,
-1.8887, -3.5552, -2.7068, 0.0305, 2.7130,
3.4640, 1.7900, -1.0950, -3.1484, -2.9460,
-0.6704, 2.0433, 3.2792, 2.1903, -0.4239,
-2.7052, -3.0580, -1.2652, 1.3814, 3.0119,
2.4999, 0.2410, -2.1499, -2.9914, -1.7172,
0.7444, 2.6464, 2.6624, 0.8110, -1.5788,
-2.8215, -2.0639, 0.1295, 2.1958, 2.6865,
1.2827, -0.9998, -2.5444, -2.2786, -0.4180,
1.7060, 2.5985, 1.6530, -0.4371, -2.1864,
-2.3724, -0.8900, 1.1934, 2.4057, 1.9099,
0.0815, -1.7748, -2.3555, -1.2737, 0.6846,
2.1306, 2.0578, 0.5417, -1.3302, -2.2382,
-1.5606, 0.2016, 1.7939, 2.1014, 0.9291,
-0.8765,
第1點加速度序列
0.3000, 2.0039, 2.5125, 1.5139, -0.2748,
-1.6206, -1.6392, -0.4007, 1.1434, 1.8491,
1.1910, -0.3762, -1.7525, -1.9756, -0.8973,
0.7229, 1.7617, 1.5229, 0.2168, -1.2046,
-1.7290, -0.9953, 0.4630, 1.6080, 1.6351,
0.5350, -0.9108, -1.6906, -1.2751, 0.0192,
1.2662, 1.5901, 0.7789, -0.5779, -1.5161,
-1.3807, -0.2807, 0.9993, 1.5602, 1.0215,
-0.2202, -1.2820, -1.4221, -0.5580, 0.6864,
1.4302, 1.1582, 0.0768, -1.0426, -1.4142,
-0.7891, 0.3778, 1.2592, 1.2414, 0.3519,
-0.7704, -1.3337, -0.9513, 0.0934, 1.0564,
1.2632, 0.5806, -0.4980, -1.2094, -1.0603,
-0.1694, 0.8258, 1.2251, 0.7578, -0.2342,
-1.0461, -1.1108, -0.3950, 0.5865, 1.1405,
0.8851, 0.0126, -0.8545, -1.1078, -0.5793,
0.3474,
*/
--位移圖--

--速度圖--

--加速度圖--

實例七
參考維基百科:: https://en.wikipedia.org/wiki/Matrix_differential_equation

程式碼如下:


將C#輸出結果,使用 Visual Studio 2026 開啟 Python 專案

--位移圖--

--結論--
隨著時間增加,系統位移量變成無窮大,故此系統不穩定,自然界並不存在。

詳細的資訊,參見GitHub儲存庫 : https://myyeh2.github.io
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.20 | 100 | 8/8/2026 |
| 1.0.19 | 108 | 7/26/2026 |
| 1.0.18 | 103 | 7/3/2026 |
| 1.0.17 | 100 | 7/3/2026 |
| 1.0.16 | 112 | 6/18/2026 |
| 1.0.15 | 105 | 6/13/2026 |
| 1.0.14 | 99 | 5/19/2026 |
| 1.0.13 | 101 | 5/3/2026 |
| 1.0.12 | 123 | 2/5/2026 |
| 1.0.11 | 121 | 1/12/2026 |
| 1.0.10 | 121 | 1/5/2026 |
| 1.0.9 | 201 | 12/25/2025 |
| 1.0.8 | 200 | 12/23/2025 |
| 1.0.7 | 419 | 11/20/2025 |
| 1.0.6 | 295 | 11/12/2025 |
| 1.0.5 | 192 | 10/21/2025 |
| 1.0.4 | 198 | 10/7/2025 |
| 1.0.3 | 196 | 10/6/2025 |
| 1.0.2 | 192 | 10/5/2025 |
| 1.0.1 | 200 | 10/2/2025 |
