-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCModalSolution.m
More file actions
88 lines (63 loc) · 2.61 KB
/
CModalSolution.m
File metadata and controls
88 lines (63 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
classdef CModalSolution < CBaseSolution
%CMesh
% Brief: Main class used to calculate the modal solution
% Author: S.Ramon
% Version: 0.0.1
properties
X
w
end
methods
function object = CModalSolution( Mesh, InitialData, LEMatrices, StaticSolution )
if nargin > 0
xpoints = Mesh.xpoints;
T = Mesh.T;
nnodepelem = Mesh.nnodepelem;
nelem = Mesh.nelem;
nnode = Mesh.nnode;
ndofpn = Mesh.ndofpn;
postProcessing = InitialData.ModalPost;
D = InitialData.D;
N = InitialData.N;
uD = InitialData.uD;
t = InitialData.t;
object.t = t;
M = LEMatrices.M;
K = LEMatrices.K;
MNN = M(N, N);
KNN = K(N, N);
Xo(D) = StaticSolution.u(D);
Xo(N) = StaticSolution.u(N);
Vo = zeros(size(LEMatrices.M,1),1);
[ XAux, lambda ] = eig(MNN^-1*KNN) ;
object.X(N,:) = XAux;
for i = 1:size(object.X,2)
object.X(D,i) = uD;
end
W = real(sqrt(lambda)) ;
object.w = diag(W) ;
A = object.X(N,:)\Xo(N)';
B = -(object.X(N,:)\Vo(N))./object.w;
object.potentialEnergy = zeros(1, size(t,2));
object.kineticEnergy = zeros(1, size(t,2));
for i = 1:size(t,2)
xt = zeros(size(object.X,1),1);
vt = zeros(size(object.X,1),1);
for j = 1:size(object.X,2)
xt(N) = xt(N) + object.X(N,j)*(A(j)*cos(object.w(j)*t(i))+B(j)*sin(object.w(j)*t(i)));
vt(N) = vt(N) + object.X(N,j)*object.w(j)*(A(j)*-sin(object.w(j)*t(i))+B(j)*cos(object.w(j)*t(i)));
end
xt(D) = Xo(D) ;
vt(D) = Vo(D) ;
if postProcessing
PostProcessing = CPostProcessing('data/Modal',t(i)) ;
PostProcessing.toGID ( xpoints(:,1:3), T, nnodepelem, nelem, nnode );
PostProcessing.toGIDPost( nnodepelem, ndofpn, 1, xt' );
end
object.potentialEnergy(i) = 0.5*xt'*K*xt;
object.kineticEnergy(i) = 0.5*vt'*M*vt;
end
end
end
end
end