cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Trying to build Mohr's Circle in mathcad

Threshold
1-Visitor

Trying to build Mohr's Circle in mathcad

I beleive im very close to figuring this out. I was able to find a previous example yet I cant seem to get things just quite right. My biggest problem is units and scaleing the axes. Im I asking too much if somebody was willing to look it over and tell me where im screwing things up?


And my second question is with the axis lables. Is there a way to have them automatically update with the correct units? Say I want to use this template but instead of being in ksi I now want to me in Pa (pascals). Or do I just have to go in and manually change it every time.

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:Threshold)

There are two sources which where important for my learning of Mathcad - the built-in help with its quicksheets, etc. and the Mathsoft Collab Forum, the predecessor of this community, which was so poorly and faulty integrated here by PTC staff (most of the old threads are broken, links to other post don't work and attachments are missing). Sometimes you still may be able to find some gems, though.

There are a lot of interesting things you can do with scripted components (look at Richards fine collection to get an idea: http://communities.ptc.com/docs/DOC-1071), but I have chosen a more simple web control because it does the job well enough, is easy to setup, in my opinion web controls have the better look and you are not going to be asked if you want to disable scripting whenever you open that sheet.

View solution in original post

19 REPLIES 19
Werner_E
25-Diamond I
(To:Threshold)

Whats the reason for the multiplication with 10^-6 in the plot? Shouldn't it be 1.45*10^-7 to turn Pa into ksi?

You reversed the ordinate - negative values at the top, positive values below. Was this done on purpose?

When you plot with units its best to make the expression unitless by dividing by the unit, So plot x(theta)/unit und unit may be ksi.

BTW, I see that you still have two unanswered questions pending - lost interest?

RichardJ
19-Tanzanite
(To:Threshold)

Divide each quantity by the desired unit.

You can make it easier to change units by assigning your desired unit to a variable, and then dividing each quantity by that. You should also assign theta explicitly using a range variable. Mathcad's quickplot feature does not always choose the best range (as you will see if you disable the assignment!).

Unfortunately, there is no way to automatically change the axis labels.

Werner_E
25-Diamond I
(To:RichardJ)

OK, so here is my attempt.

Unfortunately, there is no way to automatically change the axis labels.

I remember that a long time ago Stuart had posted a component where all(?) those parameters of a 3D plot where accessible by variables. He used it for some kind of "inplace animation". I don't know how he component was created and if it would be possible to do the same with a 2D plot.

RichardJ
19-Tanzanite
(To:Werner_E)

Here's that worksheet. The 3D plot component in Mathcad is an OLE object. Stuart figured out which file it was and enough of the properties to create a scripted component in Mathcad. I think there was another worksheet based on this, but I can't find it. You could create a 2D plot using this by fixing the orientation of the 3D plot. Doing something with the built-in 2D plots is not possible, because they can't be accessed as a public object.

I think a better approach would be to use the routines from the Amazing Images book to create axes and labels as parts of the plot, and disable the graph axes. That would be quite a lot of work though!

Werner_E
25-Diamond I
(To:RichardJ)

I think there was another worksheet based on this, but I can't find it.

Maybe the attached one?

It works in MC15, we only have to set blackwhite as colormap in the plots after that colormap is created and saved to experience the hiding of the unwanted lines. Was the behaviour of colormap different in older versions of Mathcad? Here, e.g. at the animation of the sine, there is a mix of black to grey where we would expect all black. This is as the plots obviously where created at different z levels and the colormap is interpolated from all 0 to all 255.

I am not able to save that sheet with MC15 - whenever I try, I see the hourglass (endless) and have to kill the mathcad process using the task manager. Mathcad would have created a zero byte temp file only.

EDIT: OK, "endless" would mean longer than my patience allowed. While typing this I forgot about the saving process and it finally finished 😉

I think a better approach would be to use the routines from the Amazing Images book to create axes and labels as parts of the plot, and disable the graph axes. That would be quite a lot of work though!

Thats sure true. 😞

Another approach could be to use a matrix to create the whole plot and use the image region to display it. I once tried to implement that approach but very soon stopped the project as even with a rather low resolution a simple Bresenham algorithm to draw a line or a segment of a circle was so slow that the whole project didn't seemed much promising. Main reason at that time was that I wanted to have small nice arrows at the end of the axis and wanted to be able to make the number of grid lines dependent on a variable.

RichardJ
19-Tanzanite
(To:Werner_E)

That's the one!

It works in MC15, we only have to set blackwhite as colormap in the plots after that colormap is created and saved to experience the hiding of the unwanted lines. Was the behaviour of colormap different in older versions of Mathcad? Here, e.g. at the animation of the sine, there is a mix of black to grey where we would expect all black. This is as the plots obviously where created at different z levels and the colormap is interpolated from all 0 to all 255.

I'm not sure what you mean. In the sine example I see a multicolored line, not a grayscale line

Edit:

Was the behaviour of colormap different in older versions of Mathcad?

Evidently it was. The attached pdf shows what it looks like in MC11.

As an aside, total time to calculate the sheet in MC11 is 4s. Total time to calculate the sheet in MC15 is 340s. I guess that's "progress".

Werner_E
25-Diamond I
(To:RichardJ)

No, I think it shouldn't look like that in MC11, too (the file seems to date back to MC2001(. We should not see those traceback lines in the first graph.

The colormap for the plots (at least for those which are supposed to hide some lines) is set to "blackwhite". When the sheet is loaded on your computer the first time chances are that this colormap is not already present at load time. Stuart is creating and saving this map in the "Hiding Lines by colormaps" area. This map consists of just 2 entries for each color (RGB), 255 and 0. Lines which should be hidden are given a low value and so are colormapped to white. It looks to me that the Mathcad sheet does not save the name of the colormap but just an index, so depending on the content of our cmaps directory, different colormaps are assigned. Thats the reason we see those traceback lines in the first plot. Change the colormap to blackwhite manually and those line are drawn white on white. The curves are drawn in different shades of grey and I wonder if they are supposed to be drawn all black - that was the reason for asking if colormapping worked differently in older version, that is if there possibly was no automatic interpolation - just white and black. At least it doesn't look good at the sine animation, but maybe this plot isn't supposed to use blackwhite anyway.

As an aside, total time to calculate the sheet in MC11 is 4s. Total time to calculate the sheet in MC15 is 340s. I guess that's "progress".

Unbelievable! Should we feel lucky that we can't compare to Prime 😉

RichardJ
19-Tanzanite
(To:Werner_E)

I see what you mean. MC11 shows the same grayscale as MC15 though. It's possible there was a change between MC2001 and MC11, but I don't think so.

Anyway, apart from the speed issues (which I actually already knew about. I have a couple of worksheets that do not work with MC12 and later because the overhead to call a component is about 2 orders of magnitude higher than with MC11 and earlier), I now try to avoid creating worksheets using "tricks". I am resigned to the fact that at some point I will either have to dump Mathcad altogether or be dragged, kicking and screaming, into the world of Prime. Currently we can't even convert a lot of content that was officially supported in the real Mathcad, so I think there's no chance PTC will accommodate any of our "tricks".

Werner_E
25-Diamond I
(To:RichardJ)

so I think there's no chance PTC will accommodate any of our "tricks".

Thats sure right, but given a normal program development and advancement, those tricks won't be necessary anyway - in the next release we could make all parameters of a plot dependent on variables, could use NaN in 3D plots, use multidimensional arrays,... - oh yeah, in a perfect world ....

RichardJ
19-Tanzanite
(To:Werner_E)

oh yeah, in a perfect world ....

Or even an acceptable world

Thank you, I just opened what you did and thats exactly what I was trying to do (add a button to change units on the fly. Do you have any suggestions on where I can look to figure this out on my own?

Werner_E
25-Diamond I
(To:Threshold)

There are two sources which where important for my learning of Mathcad - the built-in help with its quicksheets, etc. and the Mathsoft Collab Forum, the predecessor of this community, which was so poorly and faulty integrated here by PTC staff (most of the old threads are broken, links to other post don't work and attachments are missing). Sometimes you still may be able to find some gems, though.

There are a lot of interesting things you can do with scripted components (look at Richards fine collection to get an idea: http://communities.ptc.com/docs/DOC-1071), but I have chosen a more simple web control because it does the job well enough, is easy to setup, in my opinion web controls have the better look and you are not going to be asked if you want to disable scripting whenever you open that sheet.

Sounds good, one final question, so the y axis needs to be flipped. Ive been playing with what you did for the last 20 minutes trying to figure out how, yet. . . well nothing yet. Any suggestions on where you coded it in the form? I started with the y hi and lo functions but nothing, then tried signs, and nothing again, and well ill keep playing with it and spend some time on that link too

Werner_E
25-Diamond I
(To:Threshold)

Greg Harris wrote:

Sounds good, one final question, so the y axis needs to be flipped. Ive been playing with what you did for the last 20 minutes trying to figure out how, yet. . . well nothing yet. Any suggestions on where you coded it in the form? I started with the y hi and lo functions but nothing, then tried signs, and nothing again, and well ill keep playing with it and spend some time on that link too

I simply switched the 90° / 270° in your original sheet (initial calculation of y.lo and y.hi in my sheet 😉

As angles are measured positive counterclockwise, 90° will be the top and 270° the bottom.

I'm not sure what you need (as I have no idea what a Mohr circle is supposed to be): do you want to reverse the y axis as you had it in your sheet? There may be some strange effects in Mathcad if you do it, e.g. you won't see the three X points in the plot. No idea why this is so and how one would workaround it.

BTW, your adding of 10% by multiplying with 1.1 is not adding a constant frame around the circle and may even fail (if both lo and hi values have the same sign). A better approach would be to add/subtract 5% or 10% of the radius to hi/lo.

Thats exactly it. The idea is the positive stresses on the y-axis are on the bottom while negative are up top. and ill have to see about that 5% thing

Werner_E
25-Diamond I
(To:Threshold)

I was playing around a lot to determine good limits and in doing so I was assuming that y.hi>y.lo. So simply switching 90° and 270° won't do the job. To reverse the axis you may at the end of that area put the three regions: tmp:=y.hi y.hi:=y.lo y.lo:=tmp

Alternatively you can switch y.hi and y.lo in the plot itself which probably would make more sense, as you want the higher values at the bottom.

Mathcad seems not to like reversed axis. You won't see the three points you formatted as big X's anymore and you may also notice that the two axis don't cross at 0/0 anymore but the x-axis will always be drawn at the bottom of the plot.

Hi,

The following document can be useful:

http://communities.ptc.com/docs/DOC-1291

Werner_E
25-Diamond I
(To:VladimirN)

I am not sure but compared to Greg's sheet I guess this is exactly the example which Greg wrote about in his first post that he found and worked on to derive his own version.

Guys I think I found a way to plot units in Mathcad for Mohr Circle

Announcements

Top Tags