-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbungee_plotStressStrain.m
executable file
·47 lines (35 loc) · 1.15 KB
/
bungee_plotStressStrain.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function bungee_plotStressStrain(valuesMap)
deplist = ...
{{'initialLength', 'maxLength', 'paramK', 'paramN', 'modulus'} ...
};
nancheck = cellfun(@(x) any(isnan(valuesMap(x))), deplist{1}, 'un', 0);
if max(cell2mat(nancheck)) == 0
samples = 50;
maxLength = valuesMap('maxLength');
initialLength = valuesMap('initialLength');
area = valuesMap('area');
modulus = valuesMap('modulus');
paramK = valuesMap('paramK');
paramN = valuesMap('paramN');
maxStrain = (maxLength / initialLength) - 1;
syms sigma;
stress = solve( (sigma / modulus) + ...
paramK*(sigma / modulus).^paramN ...
== maxStrain, sigma);
maxStress = double(stress(1));
stressList = linspace(0, maxStress, samples);
strainList = zeros(samples, 1);
for ii = 1:samples
strainList(ii) = (stressList(ii) / modulus) + paramK*(stressList(ii) / modulus).^paramN;
hookeanList(ii) = stressList(ii) / modulus;
end
figure
plot(strainList, stressList, 'black', 'LineWidth', 2);
hold on;
plot(hookeanList, stressList, 'blue', 'LineWidth', 0.75);
hold off;
title('Stress-Strain Curve');
xlabel('Strain');
ylabel('Stress');
end
end