09.04.2015 Views

Elemento Finito con el paquete IMS

Elemento Finito con el paquete IMS

Elemento Finito con el paquete IMS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Elemento</strong> <strong>Finito</strong> <strong>con</strong> <strong>el</strong> <strong>paquete</strong><br />

<strong>IMS</strong><br />

Para poder llevar a cabo los cálculos de esta práctica es necesario instalar <strong>el</strong> <strong>paquete</strong> gratis <strong>IMS</strong><br />

(Imtek Mathematica Suplement). El programa de instalación de <strong>IMS</strong> se descarga en la siguiente liga:<br />

http://portal.uni-freiburg.de/imteksimulation/downloads/ims .<br />

Adaptado por José Luis Gómez Muñoz<br />

http://homepage.cem.itesm.mx/jose.luis.gomez<br />

Primero hay que ejecutar los siguientes comandos Needs[], de tal manera<br />

que podamos usar los comandos de <strong>IMS</strong> d<strong>el</strong> resto de esta práctica:<br />

In[1]:=<br />

Needs@"Imtek`Assembler`"D;<br />

Needs@"Imtek`BoundaryConditions`"D;<br />

Needs@"Imtek`FEMOperators`"D;<br />

Needs@"Imtek`MeshElementLibrary`"D;<br />

Needs@"Imtek`StructuredMesher`"D;<br />

Print@"Contextos de los <strong>paquete</strong>s en esta sesión:", $ContextPathD<br />

SetD<strong>el</strong>ayed::write : Tag Hexahedron in Hexahedron@8a_, b_, c_, d_, e_, f_, g_, h_


2 FEM0500ims.nb<br />

Se va a calcular una solución aproximada a una ecuación diferencial<br />

ordinaria, lineal e inhomogénea, - d IpHxL d yHxLM + qHxL yHxL = f HxL, <strong>con</strong> las<br />

dx dx<br />

<strong>con</strong>diciones de frontera yHaL = y a , yHbL = y b , como se muestra a <strong>con</strong>tinuación<br />

:<br />

In[7]:=<br />

Clear@x, y, p, q, f, a, bD;<br />

p@x_D := x 2 ;<br />

q@x_D := 30;<br />

f@x_D := −14x;<br />

a = 0.0;<br />

b = 1.0;<br />

y a = 0.0;<br />

y b = 0.5;<br />

Print@"−∂ x Hp@xD ∂ x y@xDL+q@xD∗y@xDf@xD → ",<br />

−∂ x Hp@xD ∂ x y@xDL +q@xD ∗y@xD f@xDD;<br />

Print@y@aD y a D;<br />

Print@y@bD y b D;<br />

−∂ x Hp@xD ∂ x y@xDL+q@xD∗y@xDf@xD → 30y@xD −2xy ′ @xD −x 2 y ′′ @xD −14x<br />

y@0.D 0.<br />

y@1.D 0.5


FEM0500ims.nb 3<br />

Se usa <strong>el</strong> comando imsGenerateLinearStructuredMesh[] para generar <strong>el</strong><br />

mallado d<strong>el</strong> dominio. El mallado <strong>con</strong>siste de nodos (puntos en <strong>el</strong> dominio) y<br />

<strong>el</strong>ementos (en este caso unidimensional, los <strong>el</strong>ementos son intervalos entre<br />

nodo y nodo):<br />

In[18]:=<br />

numElem = 6;<br />

mapeo@x_D := NBa + Hb −aL<br />

Log@3x +4D<br />

Log@numElem +1D F;<br />

malla =<br />

imsGenerateLinearStructuredMesh@numElem, imsCoordinateMapping → mapeoD;<br />

Graphics@<br />

8Orange, imsDrawElements@mallaD,<br />

Purple, imsDrawElementIdText@mallaD,<br />

Red, imsDrawNodeText@mallaD


4 FEM0500ims.nb<br />

Estos son los <strong>el</strong>ementos d<strong>el</strong> mallado:<br />

In[26]:=<br />

<strong>el</strong>ementos = imsGetElements@mallaD;<br />

Print@"Los <strong>el</strong>ementos son: ", <strong>el</strong>ementosD<br />

Los <strong>el</strong>ementos son: 8imsLineLinear1DOF@1, 81, 2


FEM0500ims.nb 5<br />

Hay un vector local de fuerzas, o cargas, por cada <strong>el</strong>emento. Después ese<br />

vector local será “ensamblado” en <strong>el</strong> vector global en los renglones que<br />

corresponden a los nodos d<strong>el</strong> <strong>el</strong>emento:<br />

In[30]:=<br />

cargas = TableBimsMakeElementMatrixBK 0 0 O,<br />

nodosPor<strong>Elemento</strong>@@jDD, nodosPor<strong>Elemento</strong>@@jDDF, 8j, 1, numElem


6 FEM0500ims.nb<br />

Aquí se calcula <strong>el</strong> efecto de la “función de difusión” (coeficiente pHxL en la<br />

ecuación diferencial ) en las matrices y cargas (en las ecuaciones) de cada<br />

<strong>el</strong>emento:<br />

In[33]:=<br />

Out[33]=<br />

matricesycargas =<br />

Table@<br />

imsNFEMDiffusion@ 8matrices@@jDD, cargas@@jDD


FEM0500ims.nb 7<br />

El coeficiente qHxL en la ecuación diferencial es la “función de reacción”,<br />

- d IpHxL d yHxLM + qHxL yHxL = f HxL<br />

dx dx<br />

In[36]:=<br />

funcionReaccion@marker_, x_D := q@xD;<br />

Print@"funcionReaccion@marker,xD=", funcionReaccion@marker, xDD<br />

funcionReaccion@marker,xD=30<br />

Aquí se calcula <strong>el</strong> efecto de la “función de reacción” (coeficiente qHxL en la<br />

ecuación diferencial ) en las matrices y cargas (en las ecuaciones) de cada<br />

<strong>el</strong>emento:<br />

In[38]:=<br />

Out[38]=<br />

matricesycargas =<br />

Table@<br />

imsNFEMReaction@ 8matrices@@jDD, cargas@@jDD


8 FEM0500ims.nb<br />

Actualizamos la lista de cargas<br />

In[40]:=<br />

Out[40]=<br />

cargas = matricesycargas@@All, 2DD<br />

8imsElementMatrix@880


FEM0500ims.nb 9<br />

Actualizamos la lista de matrices<br />

In[44]:=<br />

Out[44]=<br />

matrices = matricesycargas@@All, 1DD<br />

8imsElementMatrix@883.68081, 1.6623


10 FEM0500ims.nb<br />

A <strong>con</strong>tinuación se “ensamblan” las matrices de cada <strong>el</strong>emento para formar<br />

la matriz global, y los vectores de carga de cada <strong>el</strong>emento para formar <strong>el</strong><br />

vector de carga global:<br />

In[46]:=<br />

matrizGlobal = SparseArray@8


FEM0500ims.nb 11<br />

El siguiente paso es insertar las <strong>con</strong>diciones de frontera, lo cual modifica a<br />

la matriz global y al vector global de cargas. En este ejemplo<br />

unidimensional, los únicos nodos de frontera son <strong>el</strong> primero y <strong>el</strong> último:<br />

In[52]:=<br />

imsDirichlet@8matrizGlobal, vectorCargas


12 FEM0500ims.nb<br />

Estos son los nuevos nodos interiores. Incluyen <strong>el</strong> valor de la solución:<br />

In[58]:=<br />

Out[58]=<br />

nodosNuevosInterior = nodosNuevos@@imsGetIds@imsGetInteriorNodes@mallaD D DD<br />

8imsNode@2, 80.356207


FEM0500ims.nb 13<br />

A <strong>con</strong>tinuación se muestra la gráfica de la solución analítica exacta,<br />

obtenida <strong>con</strong> <strong>el</strong> comando DSolve:<br />

In[61]:=<br />

solexacta =<br />

DSolve@8−∂ x Hp@xD ∂ x y@xDL +q@xD ∗y@xD f@xD, y@aD y a , y@bD y b


14 FEM0500ims.nb<br />

http://portal.uni-freiburg.de/imteksimulation/downloads/ims .<br />

Capítulo 6, Sección 6.3 “Finite Element Method” de la Tesis de Doctorado de Oliver Rüebenkönig “Free<br />

Surface Flow and the IMTEK Mathematica Supplement”, Institut für Mikrosystemtechnik (IMTEK),<br />

Albert-Ludwigs-Univesität, Freiburg, Alemania.<br />

ftp://<strong>el</strong>mo.imtek.uni-freiburg.de/pub/people/ruebenko/writing/dissertation1.1.pdf .<br />

Daryl L. Logan, “A First Course in the Finite Element Method”, Fifth Edition, 2012, Cengage Leraning<br />

Adaptado por José Luis Gómez Muñoz<br />

http://homepage.cem.itesm.mx/jose.luis.gomez

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!