// J. L. Humar,"Dynamics of Structures",第502-504頁
// 與 ConsoleApp_6J 相同,僅多出一個合並點,第2點是合併第0點和第1點。
using System;
using Matrix_0;
namespace ConsoleApp6R
{
internal class Program
{
static void Main(string[] args)
{
double[,] M = { { 2, 0 }, { 0, 1 } };
double[,] K = { { 3, -1 }, { -1, 1 } };
double[,] C = { { 0.4, -0.05 }, { -0.05, 0.2 } };
// t=0時,第0點和第1點,速度和位移之初始值。
double[,] y0Start = { { 0 }, { 0 }, { 1 }, { 2 } };
ReMatrix y0 = new ReMatrix(y0Start);
MKCMatrix MKC = new MKCMatrix(M, K, C);
ReMatrix A = new ReMatrix(MKC.Matrix);
EIG eig = new EIG(A);
CxMatrix D = eig.CxMatrixD;
CxMatrix V = eig.CxVector;
CxMatrix Q = eig.CxMatrixQ;
CxToHexp Hexp = new CxToHexp(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\n{1}\n", "", new PR(V));
Console.Write("\n***{0,5}特徵向量矩陣Q{0,5}***\n\n{1}\n", "", new PR(Q));
Console.Write("\n***{0,5}係數向量d{0,5}***\n\n{1}\n", "", new PR(d));
double step = 0.5;
int iRow = (int)(50 / step + 1);
int iCol = M.GetLength(1) + 2;
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 CxToHexp(D, Q, t);
MatTemp = Hexp.GetCxMatrix;
ReMatrix y = (ReMatrix)(MatTemp * d);
ReMatrix yDot = A * y;
Acc.Matrix[i, 0] = t;
Acc.Matrix[i, 1] = yDot.Matrix[0, 0];
Acc.Matrix[i, 2] = yDot.Matrix[1, 0];
Acc.Matrix[i, 3] = Acc.Matrix[i, 1] + Acc.Matrix[i, 2];
Vel.Matrix[i, 0] = t;
Vel.Matrix[i, 1] = y.Matrix[0, 0];
Vel.Matrix[i, 2] = y.Matrix[1, 0];
Vel.Matrix[i, 3] = Vel.Matrix[i, 1] + Vel.Matrix[i, 2];
Disp.Matrix[i, 0] = t;
Disp.Matrix[i, 1] = y.Matrix[2, 0];
Disp.Matrix[i, 2] = y.Matrix[3, 0];
Disp.Matrix[i, 3] = Disp.Matrix[i, 1] + Disp.Matrix[i, 2];
}
// 列印標題。
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點合併變位序列\n{0}\n", new PR4(Disp, 3));
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點合併變位序列\n{0}\n", new PR4(Vel, 3));
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{0}\n", new PR4(Acc, 3));
Console.Write("\n\n");
}
}
}