Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Create the contour plot in mathcad prime version 11
/ API 650 TANK NOZZLE ANALYSIS WITH 30mm PAD
// Mathcad Prime Worksheet
// Date: 2024
// ============================================
// 1. INPUT PARAMETERS
// ============================================
// Tank Geometry
D_tank ≔ 80.0
R_tank ≔ (D_tank ⋅ 1000)/2
// Shell and Pad
t_shell ≔ 30
t_pad ≔ 30
t_total ≔ t_shell + t_pad
// Nozzle
DN ≔ 24
D_nozzle ≔ 610
d_nozzle ≔ 584.6
r_nozzle ≔ (D_nozzle + d_nozzle)/4
// Material Properties
S_shell ≔ 163
S_nozzle ≔ 118
// Loads
F_axial ≔ 15000
Mx ≔ 300000 ⋅ 1000
My ≔ 300000 ⋅ 1000
// Pressure
P_total ≔ 0.1602
// ============================================
// 2. BASIC STRESS CALCULATIONS
// ============================================
// Membrane stress with pad
σ_mem_pad ≔ (P_total ⋅ R_tank)/(2 ⋅ t_total)
// Original membrane stress (for comparison)
σ_mem_original ≔ (P_total ⋅ R_tank)/(2 ⋅ t_shell)
// Stress reduction percentage
stress_reduction ≔ ((σ_mem_original - σ_mem_pad)/σ_mem_original) ⋅ 100
// Display results
"BASIC STRESS RESULTS WITH 30mm PAD" =
"
Shell thickness: " t_shell " mm
Pad thickness: " t_pad " mm
Total thickness: " t_total " mm
Membrane stress (original): " σ_mem_original " MPa
Membrane stress (with pad): " σ_mem_pad " MPa
Stress reduction: " stress_reduction " %
"
// ============================================
// 3. SCL PLOT DATA
// ============================================
// Stress components with pad
σ_membrane ≔ 42.65
σ_bending ≔ 28.65
// Create normalized thickness array
s ≔ 0, 0.05‥1.0
N_points ≔ length(s)
// X-axis: Distance from ID
x_distance ≔ s ⋅ t_total
// Y-axis: Stress distribution
y_stress ≔ σ_membrane + (2⋅s - 1) ⋅ σ_bending
// Allowable stress lines
S_m_allow ≔ 118
S_L_allow ≔ 177
S_Pb_allow ≔ 177
y_Pm ≔ matrix(N_points, 1, S_m_allow)
y_PL ≔ matrix(N_points, 1, S_L_allow)
y_PLPb ≔ matrix(N_points, 1, S_Pb_allow)
// ============================================
// 4. CREATE SCL PLOT
// ============================================
// IN MATHCAD PRIME:
// 1. Insert → Graph → XY Plot
// 2. In the placeholder, type:
// x_distance, y_stress, y_Pm, y_PL, y_PLPb
// 3. Format as needed
// ============================================
// 5. CONTOUR PLOT DATA
// ============================================
// Create coordinate grid
grid_size ≔ 20
X ≔ matrix(grid_size, grid_size, 0)
Y ≔ matrix(grid_size, grid_size, 0)
Z ≔ matrix(grid_size, grid_size, 0)
// Fill the grid
for i ∈ 0‥grid_size-1
for j ∈ 0‥grid_size-1
// Coordinates from -200 to 200 mm
x_val ≔ -200 + 400⋅(i/(grid_size-1))
y_val ≔ -200 + 400⋅(j/(grid_size-1))
X[i,j] ≔ x_val
Y[i,j] ≔ y_val
// Stress calculation
r ≔ sqrt(x_val^2 + y_val^2 + 0.001)
Z[i,j] ≔ σ_membrane⋅exp(-r/150) + σ_bending⋅(x_val/200)⋅exp(-r/180)
// Display contour data info
"CONTOUR PLOT DATA" =
"
Grid size: " grid_size " × " grid_size "
X range: -200 to 200 mm
Y range: -200 to 200 mm
Stress range: " min(Z) " to " max(Z) " MPa
"
// ============================================
// 6. CREATE CONTOUR PLOT
// ============================================
// IN MATHCAD PRIME:
// 1. Insert → Graph → Contour Plot
// 2. In the placeholder, type:
// X, Y, Z
// 3. Format:
// - Contour levels: 10, 20, 30, 40, 50, 60, 70
// - Color map: Thermal
// - Title: "Stress Contour - With 30mm Pad"
Solved! Go to Solution.
As I suspected, zipping doesn't help either, unfortunately.
Not sure what is going wrong here.
Actually you should not be able to send me an E-Mail as you should not be allowed to see my mail address in my profile.
But you could send a PM via the message system here inside the forum. If you did, it did not work as I didn't receive anything.
In the meantime I was curious and played around with the AI proposal.
I guess you are looking for that kind of plot:
On contrary to the AI proposal grid size 20 means in my approach to divide the range from -200 to 200 into 20 intervals and so we have a 21 x 21 matrix and not a 20 x 20 matrix is suggested by the AI.
May be a matter of personal preference or habit how to interpret the term "grid size".
EDIT: An easier way to create the plot is to define a function for the z-values depending on x an y and then use "CreateMesh" to create the necessary data structure:
BTW, is there a specific reason for the addition of 0.001 in the calculation of "r"?
Prepare the contour plot for the below in mathcad - I am getting errors while preparing
5. CONTOUR PLOT DATA
// ============================================
// Create coordinate grid
grid_size ≔ 20
X ≔ matrix(grid_size, grid_size, 0)
Y ≔ matrix(grid_size, grid_size, 0)
Z ≔ matrix(grid_size, grid_size, 0)
// Fill the grid
for i ∈ 0‥grid_size-1
for j ∈ 0‥grid_size-1
// Coordinates from -200 to 200 mm
x_val ≔ -200 + 400⋅(i/(grid_size-1))
y_val ≔ -200 + 400⋅(j/(grid_size-1))
X[i,j] ≔ x_val
Y[i,j] ≔ y_val
// Stress calculation
r ≔ sqrt(x_val^2 + y_val^2 + 0.001)
Z[i,j] ≔ σ_membrane⋅exp(-r/150) + σ_bending⋅(x_val/200)⋅exp(-r/180)
// Display contour data info
"CONTOUR PLOT DATA" =
"
Grid size: " grid_size " × " grid_size "
X range: -200 to 200 mm
Y range: -200 to 200 mm
Stress range: " min(Z) " to " max(Z) " MPa
"
// ============================================
// 6. CREATE CONTOUR PLOT
// ============================================
// IN MATHCAD PRIME:
// 1. Insert → Graph → Contour Plot
// 2. In the placeholder, type:
// X, Y, Z
// 3. Format:
// - Contour levels: 10, 20, 30, 40, 50, 60, 70
// - Color map: Thermal
// - Title: "Stress Contour - With 30mm Pad"
What you show is not the content of a Prime sheet - maybe an AI generated text? Why do you expect it to work OK in Prime?
And where is your Prime sheet showing what you tried to do and which errors you get.
Just two examples of wrong syntax:
// Create normalized thickness array
s ≔ 0, 0.05‥1.0
N_points ≔ length(s)
Can't work. If you do it that way, "s" would be a range, not an array.
You could create a vector using s:=vec(0,0.05,1) and to get the number of elements in this vector you could use N_points:=rows(s) but the suggested N_points:=length(s) would work equally well once s is created a vector and not as a range.
S_m_allow ≔ 118
S_L_allow ≔ 177
S_Pb_allow ≔ 177
y_Pm ≔ matrix(N_points, 1, S_m_allow)
Wrong syntax! The third argument of the "matrix" function must be a function in two arguments (representing the zero based matrix indices) and not a constant scalar as shown, You may use
As you say you experience problems implementing step 5, contour plot, I have to assume that you managed to implement steps 1 to 4 successfully. But the examples of wrong syntax which I showed above stem from step 3 and the variables created there are used to create the plot in step 4. So can we assume that you already have fixed the errors mentioned!?
Maybe you have troubles with another error in step 5 of this AI stuff:
X[i,j] ≔ x_val
Y[i,j] ≔ y_val
These assignments can't work. This is not how matrix elements are addressed!
In Prime you have to use matrix indices (not the literal subscripts !) when you assign values - like Xi,j:=x_val
I suggest that you come back here and attach the worksheet showing what you have done so far and which error(s) in implementing step 5 you experience.
BTW, when you ask questions here you are supposed to close the threads when you got your answer or to follow up if you didn't.
how to do the goal seek in mathcad prime 3.1 - PTC Community
Re: How to ignore if the expression is divided b... - PTC Community
his expression is giving divide by zero error - gu... - PTC Community
How to Prepare Logarithmic graph as per the attach... - PTC Community
Please check the uploaded file, you are correct, i had prepared the calculation based on DeepSeek ai only.
However, i need to prepare the stress contour plot in the attached mathcad file
I had got error while prepare the calculations, Hence please guide me to prepare the stress contour plot.
Unfortunately the file can't be opened because the Virus scan seems to run forever (its now already half an hour after you posted the file).
You posted at 12:44 and now its already 13:17 (my local time). An automatic virus scan sure can't take that much time.
Maybe you can try to post the file again, maybe a @PTCModerator can help fixing this problem.
please find attached the file
Unfortunately the same effect. I guess that you also see the message "(Virus scan in progress ...)", don't you?
I guess it won't help if you zip the file and post the archive.
So it looks that we have to wait for a @PTCModerator2 to help.
Until then, you could use the time to close your open threads. 😉
They error only I am also getting
meanwhile please check your email
I had sent through email
As I suspected, zipping doesn't help either, unfortunately.
Not sure what is going wrong here.
Actually you should not be able to send me an E-Mail as you should not be allowed to see my mail address in my profile.
But you could send a PM via the message system here inside the forum. If you did, it did not work as I didn't receive anything.
In the meantime I was curious and played around with the AI proposal.
I guess you are looking for that kind of plot:
On contrary to the AI proposal grid size 20 means in my approach to divide the range from -200 to 200 into 20 intervals and so we have a 21 x 21 matrix and not a 20 x 20 matrix is suggested by the AI.
May be a matter of personal preference or habit how to interpret the term "grid size".
EDIT: An easier way to create the plot is to define a function for the z-values depending on x an y and then use "CreateMesh" to create the necessary data structure:
BTW, is there a specific reason for the addition of 0.001 in the calculation of "r"?
I'll try to add my worksheet - let's see if it works for me.
I added a 3D plot,
but it doesn't look good in Prime compared to real Mathcad. Here mathcad 15
Looks that my attachment shows the same problem as yours.
Let's notify @admin as well. Hopefully the forum bug can be fixed even though its weekend ...
EDIT: In the meantime its Tuesday and it looks as if the problem finally is fixed. The attachments seem to be downloadable by now.
I've been trying this with Prime Express and have been puzzled for some time as to why my (simple) contours were so different from Werner's. The difference has been driving me round the bend! Luckily for my sanity, I've just noticed that there is a difference in the definition of the value of Z used by Werner and Ranto.
xval is divided by 200 in Ranto's case (which is what I used).
Alan
Arghh! Sorry for the confusion. I remember that I had a second look at this very expression because I wondered if there really was no factor xval or yval at the first summand, but completely overlooked the most obvious division by 200.
Small cause, big effect:
As contour plot is a premium feature I suppose you created it using the 'normal' xy-plot?
Than you
@Werner_E wrote:
As contour plot is a premium feature I suppose you created it using the 'normal' xy-plot?
Yes. Here is an image of my rather simplistic attempt at a 3D graph and a contour plot. (Incidentally, although ranto originally asked for contours of 10, 20, 30, 40, 50, 60 and 70, I note that the last three aren't possible as the largest value of Z is just over 40.)
Alan
although ranto originally asked for contours of 10, 20, 30, 40, 50, 60 and 70,
It wasn't him but rather the AI (Deepseek) he had asked which also did not 'know' amongst others that Prime does not offer any "color maps" 😉
Ah, yes. It has also included what seems to me to be a completely unnecessary 0.001 in the definition of r. I doubt it's needed from a stressing point of view, and there aren't any division by zeros to avoid. However, it's probably cleverer than me, so I left the 0.001 in my calculations!
Alan
Yes, I was also wondering about this summand 0.001 and asked ranto about it, but didn't get an answer. I also think that this summand has no special meaning and is simply an AI error. On the other hand, it has hardly any effect on the result.
Hi, thank you for your reply,
the 0.001 is not required as per the calculation
Just realised there's a much better way of calculating contours for this problem using polar coordinates:
Alan
And, just to show it can be done in Prime Express, here's my combined 3d/contour plot:
Alan
Looks nice from the picture. Now you just need to implement a hidden line algorithm and maybe also some transparency to beat the poor 3D plot offered by the full version. 😈
@Werner_E wrote:
Looks nice from the picture. Now you just need to implement a hidden line algorithm and maybe also some transparency to beat the poor 3D plot offered by the full version. 😈
Some devils are never satisfied!!
A nice thought! But I'll leave it at that - as just a thought!
n:=150
z is a hight vector to make contour lines.
We can change the direction of hight not only z axis but -z or xyz etc.
Computer display shows white shadow but copy and past here, it shows no white shadow.
Make contour lines for colors bands.
Version up contour lines by using Program author: Viacheslav N. Mezentsev, 2006, Uni Home Lab, All rights reserved. Algorithm same as well as for implicitplot3d(), uploaded by Werner_E.
Now, number of colors can select by Cn vector.
Could you provide the mathcad sheet
