Re: Automating a finite element procedure
- To: mathgroup at smc.vnet.net
- Subject: [mg108149] Re: Automating a finite element procedure
- From: "Nasser M. Abbasi" <nma at 12000.org>
- Date: Tue, 9 Mar 2010 06:23:35 -0500 (EST)
- References: <hn2mcj$454$1@smc.vnet.net>
"Kamil" <meetkamil at gmail.com> wrote in message news:hn2mcj$454$1 at smc.vnet.net... > 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. > > I'll let someone else tackle this. But I just wanted to point out that when posting a question, and then one says "it is not working", then this statement does not give the reader any useful insight into what is really meant "it is not working". To get better help, one needs to say what is the expected result, and explain the result that was obtained instead and why the result obtained is not correct. The reader is most likely unable to read the poster's mind, and so they will then have to guess, which can result in some misunderstanding. --Nasser
- Follow-Ups:
- Re: Re: Automating a finite element procedure
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: Re: Automating a finite element procedure