-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathlinearAnalysis.m
executable file
·84 lines (69 loc) · 2.2 KB
/
linearAnalysis.m
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
function linearAnalysis(mod)
% LINEARANALYSIS(MOD) Linear analysis on model MOD.
%
% Input Parameters
% ----------------
% MOD = The model to be analyzed
% G2 - Matrix Structural Analysis with Matlab
% Version 0.1
% University of California, Berkeley
% Copyright 1999, Gregory L. Fenves
% --------------------------------------
% Variables used in function
% ---------------------------------------------------------
% ndof = number of DOF
% ntot = total number of all DOF
% free = range of free DOF (1:ndof)
% nelem = number of elements in elemlist
% elemlist = list of elements
% lamba = 1 (load factor)
% U = vector of displacements for all DOF
% P = nodal load vector in model for all DOF
% P0 = restoring force vector for all DOF
% Kf = stiffness matrix for all DOF
% K = stiffness matrix for free DOF
% Pr = residual force vector (P-P0) for free DOF
% nresidual = 2-norm of Pr (Euclidean norm)
% ---------------------------------------------------------
% Get data from model
[ ndof ntot P elemlist] = getData(mod);
free = 1:ndof;
nelem = length(elemlist);
% Initialize global vectors and matrix
P0 = zeros(ntot,1);
U = zeros(ntot,1);
Kf = zeros(ntot,ntot);
lambda = 1;
% Initialize element state
for i=1:nelem
[id xyz ue] = localize( mod, i, U);
elemlist{i} = initialize( elemlist{i}, xyz, [], lambda );
end
% Loop over elements to assemble stiffness matrix and load
% vector
for i=1:nelem
[id xyz ue] = localize( mod, i, U );
[ke pe] = state( elemlist{i}, xyz, ue, lambda );
Kf(id,id) = Kf(id,id) + ke;
P0(id) = P0(id) + pe;
end
% Partition free DOF and solve
K = Kf(free,free);
Pr = P(free) - P0(free);
U(free) = K \ Pr;
% Print solution displacements and element response
printHead ( mod );
printDOF ( mod, U );
printElemResp ( mod, U, lambda );
% Loop over elements to compute restoring force
% and check residual
P0(:) = 0;
for i=1:nelem
[id xyz ue] = localize( mod, i, U );
[ke pe] = state( elemlist{i}, xyz, ue, lambda );
P0(id) = P0(id) + pe;
end
Pr = P(free) - P0(free);
nresidual = norm(Pr);
disp(sprintf('\nResidual after solution: %10.3e', nresidual ));