On Thu, Dec 15, 2011 at 9:32 PM, Benjamin Root <ben.r...@ou.edu> wrote:

>
> On Thu, Dec 15, 2011 at 3:18 PM, Alex Naysmith <yeoman.pyt...@gmail.com>wrote:
>
>>
>>
>> On Tue, Dec 13, 2011 at 7:12 PM, Alex Naysmith 
>> <yeoman.pyt...@gmail.com>wrote:
>>
>>>
>>>
>>> On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root <ben.r...@ou.edu> wrote:
>>>
>>>> On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith <
>>>> yeoman.pyt...@gmail.com> 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 mid-nodes.
>>>>>
>>>>> 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
------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to