write a tresca failure function that takes in 6 stress values and yield strength that predicts yielding. in matlab

Here's an implementation of the Tresca Failure Function in Matlab:

main.m
function [is_yielded] = tresca_failure(sx, sy, sz, txy, tyz, txz, yield_strength)
% This function checks if the material subjected to given stresses has yielded or not.
% If Tresca Failure Criterion is met, that will indicate yielding.

% Taking half of the shear stress values to ensure yield criterion is met
txy_abs = abs(txy)/2;
tyz_abs = abs(tyz)/2;
txz_abs = abs(txz)/2;

% Calculating the Tresca Stress
tresca_stress = max([abs(sx-sy), abs(sy-sz), abs(sz-sx), txy_abs, tyz_abs, txz_abs]);

% Comparing the Tresca Stress with Yield Strength
if tresca_stress > yield_strength
    is_yielded = true;
else
    is_yielded = false;
end
end
641 chars
20 lines

Here's how you can use this function:

main.m
% Sample stresses
sx = 100;
sy = 80;
sz = 120;
txy = -50;
tyz = 0;
txz = 0;

% Specify yield strength of the material
yield_strength = 150;

% Check if the material has yielded or not
is_yielded = tresca_failure(sx, sy, sz, txy, tyz, txz, yield_strength);

if is_yielded
    disp('Material has yielded.')
else
    disp('Material has not yielded.')
end
352 chars
20 lines

Note: This implementation assumes that the stresses are given in SI units, i.e. in Pascal (Pa).

related categories

gistlibby LogSnag