I have a code that I would like to modify to plot multiple items all together

5 vues (au cours des 30 derniers jours)
I have this code
% Matrix properties (Al2O3)
Em = 380E3; % Young's modulus
num = 0.22; % Poisson's ratio
Vv_vals = [0.01, 0.35, 0.47]; % different porosity volumes
KIc = 3.63; % MPa*sqrt(m) fracture toughness
% Dv = 1E-3; % void diameter
%
Porous_AL2O3;
% Crack density parameter (from Budiansky and O'Connel, IJSS 12:81-97, 1976)
cdp0 = 0;
cdp = cdp0;
a = 1;
%
%%
% MECHANISMS OF CYCLIC FATIGUE-CRACK PROPAGATION IN A FINE-GRAINED ALUMINA
% CERAMIC: THE ROLE OF CRACK CLOSURE C. J. Gilbert, R. O. Ritchie 2008
C = 1.3E-18; % Paris law coefficient
m = 23; % material exponent
delta_gmcv = 2.5;
%
%%
N_cycles = 1E7;
sigma_avg = [569, 59, 13]; % average strength
sigma_max = [0.9*sigma_avg 0.8*sigma_avg 0.7*sigma_avg 0.6*sigma_avg; 0 0 0; 0 0 0; 0 0 0; 0 0 0; 0 0 0]; % max stress
% needs to be 0.9, 0.8, 0,7, and 0.6 of sigma_avg for the three Vv_vals
R = sigma_min/sigma_max; % stress ratio
%%
%% Critical eneergy release rate for matrix
GIc = KIc^2/Em*1000;
% eps_step = zeros(6,6);
rmcv = 2/3*(1-Vv_vals)*pi*GIc/a;
% Stiffness and compliance matrices of uncracked material (6 x 6)
[S2m,C2m] = S2_C2_ortho(Em,Em,Em,num,num,num,Em/2/(1+num),Em/2/(1+num),Em/2/(1+num)); % matrix
%
num_Vv = length(Vv_vals);
for Vv_idx = 1 : num_Vv
Vv = Vv_vals(Vv_idx);
for k = 1:N_cycles
% F tensor for crakcs
Fc = F_tens_penny_iso(num);
%
% Swap axis 3 with axis 1 (so axis 3 of the crack is aligned with material axis 1)
Fc = Fc([3 2 1 6 5 4],[3 2 1 6 5 4]);
%
% Strain concentration tensor for voids
[~,SE2v] = eshelby_tens_sph_iso(num); % Eshelby tensor for voids
inv_Tv = eye(6)-SE2v; % inverse T tensor for voids
Tv = inv_Tv\eye(6); % T tensor for voids
% Homogenised stiffness and compliance with voids and cracks
inv_Am = (1-Vv)*eye(6) + Vv*Tv + cdp*Fc; % inverse absolute strain concentration tensor for the matrix
Am = inv_Am\eye(6); % absolute strain concentration tensor for the matrix
C2 = (1-Vv)*C2m*Am; % stiffness tensor of matrix + cracks + voids
S2 = C2\eye(6); % compliance tensor of matrix + cracks + voids
%
%
% Equivalent elastic moduli from compliance matrix
%
[E1,E2,E3,nu12,nu13,nu23,G12,G13,G23] = moduli_ortho(S2);
eps_max = S2*sigma_max;
s_mcv = C2*eps_max;
eps_mcv_max = Am*eps_max;
s_mcv_max = Am*s_mcv;
gmcv_max = 1/2*(1-Vv)*eps_mcv_max'*C2*Am*Fc*Am*eps_mcv_max;
cdp = cdp + C * (delta_gmcv)^m * k;
eps_mcv_step(:,k) = eps_mcv_max;
s_mcv_step(:,k) = s_mcv_max;
end
end
loglog(s_mcv_step(1,:),'r','LineWidth',2)
hold
loglog(AL01_SIGMA08(:,1),AL01_SIGMA08(:,2),'bo','MarkerSize',8,'MarkerFaceColor',[0 0 1])
loglog(meanAL0108(:,1),meanAL0108(:,2),'bo','MarkerSize',8,'MarkerFaceColor',[0 1 1])
there is one material which has three varying porosities (0.01, 0.35, and 0.47). Each case is being loaded to 0.9,0.8,0.7, and 0.6 of their average respective strengths. the test data is found in
Porous_AL2O3
Which has 12 data sets. I would like to take the mean of each data set and then plot all of it against each other to generat a graph that resembles this one but with the 12 different data sets, their means and the respective comparison all on the same plot
I realise that this maybe a bit of a huge ask but any help is greatly welcomed.
Thanks
Alex
  6 commentaires
Chris Burschyk
Chris Burschyk le 6 Juin 2023
Everything in the loop before the line
inv_Am = (1-Vv)*eye(6) + Vv*Tv + cdp*Fc;
is calculated everytime but it doesnt get changed because the variable "num" stays at 0.22.
For your plotting problem I could suggest to put one more loop between the two which iterates over the different loads
figure()
hold on
for Vv_idx = 1 : num_Vv
for idx_load = 0:4
Vv = Vv_vals(Vv_idx) * (1-(idx_load/10);
for k = 1:N_cycles
...
end
loglog(s_mcv_step(1,:),'r','LineWidth',2)
end
end
hold off
This will give you only the red lines for each Iteration. As for the means I do not know how your dataset looks like so its hard to give you advice on that.
A Poyser
A Poyser le 6 Juin 2023
The Vv value does stay the same, however the cdp value increments but only by a very small amount at first however. It is exponential so cdp*Fc eventually starts to cause a fatigue response in the material

Connectez-vous pour commenter.

Réponse acceptée

Tushar
Tushar le 6 Juin 2023
Hi Alex,
I think we can do it like this.Try adding this to your code.
% calculate the mean value for each data set in Porous_AL2O3
mean_values = zeros(12,1);
for i = 1:12
mean_values(i) = mean(Porous_AL2O3(:,i+1));
end
% plot the mean values against each other
figure
hold on
for Vv_idx = 1:num_Vv
plot(mean_values, s_mcv_step(Vv_idx,:))
end
% plot the mean values of the data set and the mean of all data sets
mean_all = mean(mean_values);
plot(mean_all,mean(s_mcv_step,2),'ks','MarkerSize',10,'LineWidth',2,'MarkerFaceColor',[1 0.5 0])
% add labels and a legend to the plot
xlabel('Mean strength of each data set')
ylabel('Maximum stress during cyclic loading')
title('Comparison of cyclic loading behavior for porous Al2O3')
legend({'0.01 Vv','0.35 Vv','0.47 Vv','Mean of all data sets'})
  1 commentaire
A Poyser
A Poyser le 6 Juin 2023
I forgot to add that each porosity material has a different sigma average

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Stress and Strain dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by