Skip to main content
11-Garnet
December 6, 2025
Solved

Prepare the contour stress plot

  • December 6, 2025
  • 3 replies
  • 1841 views

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"
Best answer by Werner_E

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:

Werner_E_0-1765028828994.png

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:

Werner_E_0-1765046181966.png

BTW, is there a specific reason for the addition of 0.001 in the calculation of "r"?

3 replies

ranto11-GarnetAuthor
11-Garnet
December 6, 2025

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"
25-Diamond I
December 6, 2025

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

Werner_E_0-1765013794398.png

 

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

ranto11-GarnetAuthor
11-Garnet
December 6, 2025

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.

25-Diamond I
December 6, 2025

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.

Werner_E_1-1765023539929.png

 

Maybe you can try to post the file again, maybe a @PTCModerator  can help fixing this problem.

21-Topaz I
December 11, 2025

image.pngimage.png

n:=150

image.pngimage.png

z is a hight vector to make contour lines.

image.png

We can change the direction of hight not only z axis but -z or xyz etc.

image.pngimage.png

Computer display shows white shadow but copy and past here, it shows no white shadow.

21-Topaz I
December 12, 2025

Make contour lines for colors bands.

image.pngimage.pngimage.png

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.

image.png

 


image.png

Now, number of colors can select by Cn vector.

image.png

image.png

image.pngimage.pngimage.pngimage.png

21-Topaz I
December 14, 2025