Automating a finite element procedure
- To: mathgroup at smc.vnet.net
- Subject: [mg108112] Automating a finite element procedure
- From: Kamil <meetkamil at gmail.com>
- Date: Mon, 8 Mar 2010 06:16:57 -0500 (EST)
Hello all,
I have this function in Mathematica:
BeamElement[EI_, {x1_, x2_}] := Module[{L = x2 - x1, ke, kt},
ke = {{(12*EI)/L^3, (6*EI)/L^2, -((12*EI)/L^3), (6*EI)/
L^2}, {(6*EI)/L^2, (4*EI)/L, -((6*EI)/L^2), (2*EI)/
L}, {-((12*EI)/L^3), -((6*EI)/L^2), (12*EI)/
L^3, -((6*EI)/L^2)}, {(6*EI)/L^2, (2*EI)/
L, -((6*EI)/L^2), (4*EI)/L}};
kt = {{6/(5 L), 1/10, -(6/(5 L)), 1/10}, {1/10, (2 L)/
15, -(1/10), -(L/30)}, {-(6/(5 L)), -(1/10), 6/(
5 L), -(1/10)}, {1/10, -(L/30), -(1/10), (2 L)/15}}; {ke, kt}
];
I have called the above function with the following and it worked
well:
{k[1], kt[1]} = BeamElement[EI, nodes[[{1, 2}]]];
{k[2], kt[2]} = BeamElement[EI, nodes[[{2, 3}]]];
{k[3], kt[3]} = BeamElement[EI, nodes[[{3, 4}]]];
lm[1] = {1, 2, 3, 4};
lm[2] = {3, 4, 5, 6};
lm[3] = {5, 6, 7, 8};
K = Table[0, {8}, {8}];
R = Table[0, {8}, {8}];
Do[K[[lm[i], lm[i]]] += ke[i]; R[[lm[i], lm[i]]] += kt[i], {i, 1, 3}];
Now; I tried to automate it using this procedure and it is not
working:
Do[{ke[i], kt[i]} =
BucklingLinElement[EI, nodes[[{(i - 1) + 1, (i - 1) + 2}]]], {i, 1,
3}];
K = Table[0, {8}, {8}]; (R = Table[0, {8}, {8}]) // MatrixForm;
Do[lm[i] = {(2 i - 1), (2 i - 1) + 1, (2 i - 1) + 2, (2 i - 1) + 3};
K[[lm[i], lm[i]]] += ke[i]; R[[lm[i], lm[i]]] += kt[i], {i, 1, 3}];
I would be grateful to know where the wrong is. Thank you.