Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
Close
From: Alex Naysmith <yeoman.python@gm...>  20111210 16:36:27
Attachments:
Message as HTML

Hello, I'm trying to plot the stresses in colour of a strained isoparametric element. I have a six noded triangle with vertice coordinates [(xa1,ya1),(xa2,ya2),(xa3,ya3)] = pos_a This triangle deforms and the new coordinate positions are [(xb1,yb1),(xa2,yb2),(xb3,yb3)] = pos_b The remaining nodes are mid nodes also with rest and deformed coordinate positions. To plot the edges of the triangle I use a Jacobian transformation function so that the coordinates of the triangle are in Jacobian coordinates xi1 and xi2 (with xi3 = 1  xi1  xi2). This is required as the elements are quadratic with midnodes. Each interval is hard coded so that: xi1 = [1.0,0.9,0.8,0.7,0.6,0.5, etc..] xi2 = [0.0,0.1,0.2,0.3,0.4,0.5, etc..] I would like to plot the strains in colour so that the interior of the triangle is filled but I don't want to hard code the Jacobian intervals as this seems an awkward way of doing it. With strain as a function of xi1 and xi2, How can matplotlib provide a continuous interior strain plot of the triangle for all the xi1 and xi2 values from 0 to 1? Regards Alex Naysmith My finite element program can be downloaded from here: http://www.pynw.org.uk/Talks?action=AttachFile&do=view&target=2D_FEA.zip 
From: Benjamin Root <ben.root@ou...>  20111212 19:04:03
Attachments:
Message as HTML

On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith <yeoman.python@...>wrote: > Hello, > > I'm trying to plot the stresses in colour of a strained isoparametric > element. > > I have a six noded triangle with vertice coordinates > [(xa1,ya1),(xa2,ya2),(xa3,ya3)] = pos_a > > This triangle deforms and the new coordinate positions are > [(xb1,yb1),(xa2,yb2),(xb3,yb3)] = pos_b > > The remaining nodes are mid nodes also with rest and deformed coordinate > positions. > > To plot the edges of the triangle I use a Jacobian transformation function > so that the coordinates of the triangle are in Jacobian coordinates xi1 and > xi2 (with xi3 = 1  xi1  xi2). This is required as the elements are > quadratic with midnodes. > > Each interval is hard coded so that: > xi1 = [1.0,0.9,0.8,0.7,0.6,0.5, etc..] > xi2 = [0.0,0.1,0.2,0.3,0.4,0.5, etc..] > > I would like to plot the strains in colour so that the interior of the > triangle is filled but I don't want to hard code the Jacobian intervals as > this seems an awkward way of doing it. > > With strain as a function of xi1 and xi2, How can matplotlib provide a > continuous interior strain plot of the triangle for all the xi1 and xi2 > values from 0 to 1? > > Regards > > Alex Naysmith > > Alex, Perhaps if you can provide an example figure, we might be able to better help you. Right now, I am having trouble envisioning what you describe. Ben Root 
From: Alex Naysmith <yeoman.python@gm...>  20111213 19:12:50
Attachments:
Message as HTML

On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root <ben.root@...> wrote: > On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith <yeoman.python@...>wrote: > >> Hello, >> >> I'm trying to plot the stresses in colour of a strained isoparametric >> element. >> >> I have a six noded triangle with vertice coordinates >> [(xa1,ya1),(xa2,ya2),(xa3,ya3)] = pos_a >> >> This triangle deforms and the new coordinate positions are >> [(xb1,yb1),(xa2,yb2),(xb3,yb3)] = pos_b >> >> The remaining nodes are mid nodes also with rest and deformed coordinate >> positions. >> >> To plot the edges of the triangle I use a Jacobian transformation >> function so that the coordinates of the triangle are in Jacobian >> coordinates xi1 and xi2 (with xi3 = 1  xi1  xi2). This is required as the >> elements are quadratic with midnodes. >> >> Each interval is hard coded so that: >> xi1 = [1.0,0.9,0.8,0.7,0.6,0.5, etc..] >> xi2 = [0.0,0.1,0.2,0.3,0.4,0.5, etc..] >> >> I would like to plot the strains in colour so that the interior of the >> triangle is filled but I don't want to hard code the Jacobian intervals as >> this seems an awkward way of doing it. >> >> With strain as a function of xi1 and xi2, How can matplotlib provide a >> continuous interior strain plot of the triangle for all the xi1 and xi2 >> values from 0 to 1? >> >> Regards >> >> Alex Naysmith >> >> > Alex, > > Perhaps if you can provide an example figure, we might be able to better > help you. Right now, I am having trouble envisioning what you describe. > > Ben Root > > Ben, I have created a script that uses one isoparametric triangle as an example. The triangle nodes undergo a displacement, resulting in strains inside the triangle. The new script calculates the strains inside the triangle for a range of xi1 and xi2 barycentric coordinates and returns the global coordinates with the corresponding strain. I would like matplotlib to give me a nice interpolated colour plot of the strains inside the triangle, but as the output global coordinates are not aligned in neat rows and columns, I cannot do a straightforward meshgrid plot with imshow. http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/files There are further comments in the script that may explain things better. I want a figure like this: http://matplotlib.sourceforge.net/examples/pylab_examples/animation_demo.html But for a 6 noded quadratic triangle instead of square. The intention is to have all the triangles in the mesh display their strains with interpolated colours. Regards Alex 
From: Alex Naysmith <yeoman.python@gm...>  20111215 21:18:57
Attachments:
Message as HTML

On Tue, Dec 13, 2011 at 7:12 PM, Alex Naysmith <yeoman.python@...>wrote: > > > On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root <ben.root@...> wrote: > >> On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith <yeoman.python@...>wrote: >> >>> Hello, >>> >>> I'm trying to plot the stresses in colour of a strained isoparametric >>> element. >>> >>> I have a six noded triangle with vertice coordinates >>> [(xa1,ya1),(xa2,ya2),(xa3,ya3)] = pos_a >>> >>> This triangle deforms and the new coordinate positions are >>> [(xb1,yb1),(xa2,yb2),(xb3,yb3)] = pos_b >>> >>> The remaining nodes are mid nodes also with rest and deformed coordinate >>> positions. >>> >>> To plot the edges of the triangle I use a Jacobian transformation >>> function so that the coordinates of the triangle are in Jacobian >>> coordinates xi1 and xi2 (with xi3 = 1  xi1  xi2). This is required as the >>> elements are quadratic with midnodes. >>> >>> Each interval is hard coded so that: >>> xi1 = [1.0,0.9,0.8,0.7,0.6,0.5, etc..] >>> xi2 = [0.0,0.1,0.2,0.3,0.4,0.5, etc..] >>> >>> I would like to plot the strains in colour so that the interior of the >>> triangle is filled but I don't want to hard code the Jacobian intervals as >>> this seems an awkward way of doing it. >>> >>> With strain as a function of xi1 and xi2, How can matplotlib provide a >>> continuous interior strain plot of the triangle for all the xi1 and xi2 >>> values from 0 to 1? >>> >>> Regards >>> >>> Alex Naysmith >>> >>> >> Alex, >> >> Perhaps if you can provide an example figure, we might be able to better >> help you. Right now, I am having trouble envisioning what you describe. >> >> Ben Root >> >> Ben, > > I have created a script that uses one isoparametric triangle as an > example. The triangle nodes undergo a displacement, resulting in strains > inside the triangle. The new script calculates the strains inside the > triangle for a range of xi1 and xi2 barycentric coordinates and returns the > global coordinates with the corresponding strain. > > I would like matplotlib to give me a nice interpolated colour plot of the > strains inside the triangle, but as the output global coordinates are not > aligned in neat rows and columns, I cannot do a straightforward meshgrid > plot with imshow. > > http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/files > > There are further comments in the script that may explain things better. > > I want a figure like this: > > http://matplotlib.sourceforge.net/examples/pylab_examples/animation_demo.html > But for a 6 noded quadratic triangle instead of square. The intention is > to have all the triangles in the mesh display their strains with > interpolated colours. > > Regards > > Alex > Hello, I tried using contour and now I have a figure! http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/figure.png I can now show clearly what I'm aiming for with this figure. I want the contour fill to remain inside the triangle. There will be a whole mesh of triangles to fill. The updated sample script is here: http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/triangle_fill_v2.py I arranged my data points into square X and Y arrays along with the strains in the Z array and then simply P.contourf(X, Y, Z) As the figure shows, it's not there yet as a couple of the corners aren't filled in and there's a big fill outside the triangle. I think this is due to difficulties in translating points from the natural triangle coordinates (barycentric) to the x,y coordinates. But the contour looks correct as it's interpolated between the strain points. Regards Alex 
From: Benjamin Root <ben.root@ou...>  20111215 21:32:57
Attachments:
Message as HTML

On Thu, Dec 15, 2011 at 3:18 PM, Alex Naysmith <yeoman.python@...>wrote: > > > On Tue, Dec 13, 2011 at 7:12 PM, Alex Naysmith <yeoman.python@...>wrote: > >> >> >> On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root <ben.root@...> wrote: >> >>> On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith <yeoman.python@... >>> > wrote: >>> >>>> Hello, >>>> >>>> I'm trying to plot the stresses in colour of a strained isoparametric >>>> element. >>>> >>>> I have a six noded triangle with vertice coordinates >>>> [(xa1,ya1),(xa2,ya2),(xa3,ya3)] = pos_a >>>> >>>> This triangle deforms and the new coordinate positions are >>>> [(xb1,yb1),(xa2,yb2),(xb3,yb3)] = pos_b >>>> >>>> The remaining nodes are mid nodes also with rest and deformed >>>> coordinate positions. >>>> >>>> To plot the edges of the triangle I use a Jacobian transformation >>>> function so that the coordinates of the triangle are in Jacobian >>>> coordinates xi1 and xi2 (with xi3 = 1  xi1  xi2). This is required as the >>>> elements are quadratic with midnodes. >>>> >>>> Each interval is hard coded so that: >>>> xi1 = [1.0,0.9,0.8,0.7,0.6,0.5, etc..] >>>> xi2 = [0.0,0.1,0.2,0.3,0.4,0.5, etc..] >>>> >>>> I would like to plot the strains in colour so that the interior of the >>>> triangle is filled but I don't want to hard code the Jacobian intervals as >>>> this seems an awkward way of doing it. >>>> >>>> With strain as a function of xi1 and xi2, How can matplotlib provide a >>>> continuous interior strain plot of the triangle for all the xi1 and xi2 >>>> values from 0 to 1? >>>> >>>> Regards >>>> >>>> Alex Naysmith >>>> >>>> >>> Alex, >>> >>> Perhaps if you can provide an example figure, we might be able to better >>> help you. Right now, I am having trouble envisioning what you describe. >>> >>> Ben Root >>> >>> Ben, >> >> I have created a script that uses one isoparametric triangle as an >> example. The triangle nodes undergo a displacement, resulting in strains >> inside the triangle. The new script calculates the strains inside the >> triangle for a range of xi1 and xi2 barycentric coordinates and returns the >> global coordinates with the corresponding strain. >> >> I would like matplotlib to give me a nice interpolated colour plot of the >> strains inside the triangle, but as the output global coordinates are not >> aligned in neat rows and columns, I cannot do a straightforward meshgrid >> plot with imshow. >> >> http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/files >> >> There are further comments in the script that may explain things better. >> >> I want a figure like this: >> >> http://matplotlib.sourceforge.net/examples/pylab_examples/animation_demo.html >> But for a 6 noded quadratic triangle instead of square. The intention is >> to have all the triangles in the mesh display their strains with >> interpolated colours. >> >> Regards >> >> Alex >> > > Hello, > > I tried using contour and now I have a figure! > > > http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/figure.png > > I can now show clearly what I'm aiming for with this figure. I want the > contour fill to remain inside the triangle. There will be a whole mesh of > triangles to fill. > > The updated sample script is here: > > > http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/triangle_fill_v2.py > > I arranged my data points into square X and Y arrays along with the > strains in the Z array and then simply P.contourf(X, Y, Z) > > As the figure shows, it's not there yet as a couple of the corners aren't > filled in and there's a big fill outside the triangle. I think this is due > to difficulties in translating points from the natural triangle coordinates > (barycentric) to the x,y coordinates. But the contour looks correct as it's > interpolated between the strain points. > > Regards > > Alex > > Alex, Just curious, have you checked to see if tricontourf() meets your needs? http://matplotlib.sourceforge.net/api/axes_api.html?highlight=tricontourf#matplotlib.axes.Axes.tricontourf Ben Root 
From: Alex Naysmith <yeoman.python@gm...>  20111218 18:47:22
Attachments:
Message as HTML

On Thu, Dec 15, 2011 at 9:32 PM, Benjamin Root <ben.root@...> wrote: > > On Thu, Dec 15, 2011 at 3:18 PM, Alex Naysmith <yeoman.python@...>wrote: > >> >> >> On Tue, Dec 13, 2011 at 7:12 PM, Alex Naysmith <yeoman.python@...>wrote: >> >>> >>> >>> On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root <ben.root@...> wrote: >>> >>>> On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith < >>>> yeoman.python@...> wrote: >>>> >>>>> Hello, >>>>> >>>>> I'm trying to plot the stresses in colour of a strained isoparametric >>>>> element. >>>>> >>>>> I have a six noded triangle with vertice coordinates >>>>> [(xa1,ya1),(xa2,ya2),(xa3,ya3)] = pos_a >>>>> >>>>> This triangle deforms and the new coordinate positions are >>>>> [(xb1,yb1),(xa2,yb2),(xb3,yb3)] = pos_b >>>>> >>>>> The remaining nodes are mid nodes also with rest and deformed >>>>> coordinate positions. >>>>> >>>>> To plot the edges of the triangle I use a Jacobian transformation >>>>> function so that the coordinates of the triangle are in Jacobian >>>>> coordinates xi1 and xi2 (with xi3 = 1  xi1  xi2). This is required as the >>>>> elements are quadratic with midnodes. >>>>> >>>>> Each interval is hard coded so that: >>>>> xi1 = [1.0,0.9,0.8,0.7,0.6,0.5, etc..] >>>>> xi2 = [0.0,0.1,0.2,0.3,0.4,0.5, etc..] >>>>> >>>>> I would like to plot the strains in colour so that the interior of the >>>>> triangle is filled but I don't want to hard code the Jacobian intervals as >>>>> this seems an awkward way of doing it. >>>>> >>>>> With strain as a function of xi1 and xi2, How can matplotlib provide a >>>>> continuous interior strain plot of the triangle for all the xi1 and xi2 >>>>> values from 0 to 1? >>>>> >>>>> Regards >>>>> >>>>> Alex Naysmith >>>>> >>>>> >>>> Alex, >>>> >>>> Perhaps if you can provide an example figure, we might be able to >>>> better help you. Right now, I am having trouble envisioning what you >>>> describe. >>>> >>>> Ben Root >>>> >>>> Ben, >>> >>> I have created a script that uses one isoparametric triangle as an >>> example. The triangle nodes undergo a displacement, resulting in strains >>> inside the triangle. The new script calculates the strains inside the >>> triangle for a range of xi1 and xi2 barycentric coordinates and returns the >>> global coordinates with the corresponding strain. >>> >>> I would like matplotlib to give me a nice interpolated colour plot of >>> the strains inside the triangle, but as the output global coordinates are >>> not aligned in neat rows and columns, I cannot do a straightforward >>> meshgrid plot with imshow. >>> >>> http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/files >>> >>> There are further comments in the script that may explain things better. >>> >>> I want a figure like this: >>> >>> http://matplotlib.sourceforge.net/examples/pylab_examples/animation_demo.html >>> But for a 6 noded quadratic triangle instead of square. The intention is >>> to have all the triangles in the mesh display their strains with >>> interpolated colours. >>> >>> Regards >>> >>> Alex >>> >> >> Hello, >> >> I tried using contour and now I have a figure! >> >> >> http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/figure.png >> >> I can now show clearly what I'm aiming for with this figure. I want the >> contour fill to remain inside the triangle. There will be a whole mesh of >> triangles to fill. >> >> The updated sample script is here: >> >> >> http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/triangle_fill_v2.py >> >> I arranged my data points into square X and Y arrays along with the >> strains in the Z array and then simply P.contourf(X, Y, Z) >> >> As the figure shows, it's not there yet as a couple of the corners aren't >> filled in and there's a big fill outside the triangle. I think this is due >> to difficulties in translating points from the natural triangle coordinates >> (barycentric) to the x,y coordinates. But the contour looks correct as it's >> interpolated between the strain points. >> >> Regards >> >> Alex >> >> > Alex, > > Just curious, have you checked to see if tricontourf() meets your needs? > > > http://matplotlib.sourceforge.net/api/axes_api.html?highlight=tricontourf#matplotlib.axes.Axes.tricontourf > > Ben Root > > Ben, I've now succeeded in producing the plot I want using just contour(X,Y,Z): http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/figure2.png The script used to produce figure2 is here: http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/triangle_fill_v3.py For the X,Y and Z arrays, the upper triangle repeats the same data point. This doesn't seem to be a problem for the contour(X,Y,Z) function. The tricontourf() approach may be better, but it involves creating a triangle mesh inside each element. The next step will be to plot the strain contours for all the elements in the mesh. Regards Alex Naysmith 