Matrix Issue Line 33, 35, 37

4 visualizzazioni (ultimi 30 giorni)
Briana Canet
Briana Canet il 22 Mar 2022
Commentato: Briana Canet il 22 Mar 2022
Hi. Line 33, 35, and 37 (v_a2, s1_a2, s2_a2) are supposed to create a matrix/array (not sure what the right term is) like Line 27 and Line 29 does.
Note that v_a2 uses K_a1 and Mu_a1 which are both matrix/array and then v_a2 is used for s1_a2 and s2_a2.
I am not sure how to accomplish this. Please help!
% Approach 1
E_m = 70000; % Elastic modulus of matrix, MPa
v_m = .33; % Poisson ratio of matrix
E_i = 250000; % Elastic modulus of inclusion, MPa
v_i = .2; % Poisson ratio of inclusion
% Fiber volume fraction
f_i = 0:0.01:1;
% 0 is 0% fiber and 1 is 100% fiber content
% points to be plotted
K_m = (E_m)/(3*(1-2*v_m));
K_i = (E_i)/(3*(1-2*v_i));
Mu_m = (E_m)/(2*(1+v_m));
Mu_i = (E_i)/(2*(1+v_i));
% Iteration 1
s1_a1 = (1+v_m)/(3*(1-v_m));
s2_a1 = (2*(4-5*v_m))/(15*(1-v_m));
K_a1 = K_m*((1+f_i*(K_m/(K_m-K_i)-s1_a1)^-1)).^-1;
Mu_a1 = Mu_m*((1+f_i*(Mu_m/(Mu_m-Mu_i)-s2_a1)^-1)).^-1;
% Iteration 2
v_a2 = (3*K_a1-2*Mu_a1)/(2*(3*K_a1+Mu_a1));
s1_a2 = (1+v_a2)/(3*(1-v_a2));
s2_a2 = (2*(4-5*v_a2))/(15*(1-v_a2));
K_a2 = K_m*(1+(f_i*((K_i/K_m)-1).*(1+((K_i./K_a1)-1)*s1_a2).^-1));
Mu_a2 = Mu_m*(1+(f_i*((Mu_i/Mu_m)-1).*(1+((Mu_i./Mu_a1)-1)*s2_a2).^-1));
% Plotting
figure(1)
plot(f_i,K_a1, 'Color', 'red', 'LineWidth', 2);
hold on;
plot(f_i,K_a2, 'Color', 'black', 'LineWidth', 2);
hold off;
%plot(f_i,K_a3, 'Color', 'blue', 'LineWidth', 2);
%hold on;
%plot(f_i,K_a4, 'Color', 'cyan', 'LineWidth', 2);
%hold on;
%plot(f_i,K_a5, 'Color', 'yellow', 'LineWidth', 2);
%hold on;
%plot(f_i,K_Reuss, 'Color', 'magenta', 'LineWidth', 2);
%hold on;
%plot(f_i,K_Voigt, 'Color', 'green', 'LineWidth', 2);
%hold off;
grid off;
legend('K_a_1', 'K_a_2','K_a_3', 'K_a_4', 'K_a_5', 'K_R_e_u_s_s',...
'K_V_o_i_g_t')
legend('Location','northwest','FontSize',12)
title('Approach 1: Bulk Modulus vs. Inclusion Volume Fraction')
xlabel('Inclusion Volume Fraction, f_i')
ylabel('Bulk Modulus, K [MPa]')

Risposta accettata

Voss
Voss il 22 Mar 2022
Use element-wise division (./) in the calculations on those lines, and use element-wise multiplication (.*) in the subsequent calculations of K_a2 and Mu_a2, since they are using vectors now.
% Approach 1
E_m = 70000; % Elastic modulus of matrix, MPa
v_m = .33; % Poisson ratio of matrix
E_i = 250000; % Elastic modulus of inclusion, MPa
v_i = .2; % Poisson ratio of inclusion
% Fiber volume fraction
f_i = 0:0.01:1;
% 0 is 0% fiber and 1 is 100% fiber content
% points to be plotted
K_m = (E_m)/(3*(1-2*v_m));
K_i = (E_i)/(3*(1-2*v_i));
Mu_m = (E_m)/(2*(1+v_m));
Mu_i = (E_i)/(2*(1+v_i));
% Iteration 1
s1_a1 = (1+v_m)/(3*(1-v_m));
s2_a1 = (2*(4-5*v_m))/(15*(1-v_m));
K_a1 = K_m*((1+f_i*(K_m/(K_m-K_i)-s1_a1)^-1)).^-1;
Mu_a1 = Mu_m*((1+f_i*(Mu_m/(Mu_m-Mu_i)-s2_a1)^-1)).^-1;
% Iteration 2
% v_a2 = (3*K_a1-2*Mu_a1)/(2*(3*K_a1+Mu_a1));
% s1_a2 = (1+v_a2)/(3*(1-v_a2));
% s2_a2 = (2*(4-5*v_a2))/(15*(1-v_a2));
v_a2 = (3*K_a1-2*Mu_a1)./(2*(3*K_a1+Mu_a1))
v_a2 = 1×101
0.3300 0.3290 0.3281 0.3270 0.3260 0.3250 0.3239 0.3228 0.3216 0.3204 0.3192 0.3180 0.3167 0.3154 0.3141 0.3127 0.3113 0.3098 0.3083 0.3068 0.3052 0.3035 0.3018 0.3001 0.2983 0.2964 0.2945 0.2925 0.2904 0.2883
s1_a2 = (1+v_a2)./(3*(1-v_a2))
s1_a2 = 1×101
0.6617 0.6603 0.6588 0.6573 0.6558 0.6542 0.6527 0.6510 0.6494 0.6477 0.6460 0.6442 0.6424 0.6405 0.6386 0.6366 0.6347 0.6326 0.6305 0.6283 0.6261 0.6239 0.6215 0.6192 0.6167 0.6142 0.6116 0.6089 0.6062 0.6034
s2_a2 = (2*(4-5*v_a2))./(15*(1-v_a2))
s2_a2 = 1×101
0.4677 0.4679 0.4682 0.4685 0.4688 0.4692 0.4695 0.4698 0.4701 0.4705 0.4708 0.4712 0.4715 0.4719 0.4723 0.4727 0.4731 0.4735 0.4739 0.4743 0.4748 0.4752 0.4757 0.4762 0.4767 0.4772 0.4777 0.4782 0.4788 0.4793
% K_a2 = K_m*(1+(f_i*((K_i/K_m)-1).*(1+((K_i./K_a1)-1)*s1_a2).^-1));
% Mu_a2 = Mu_m*(1+(f_i*((Mu_i/Mu_m)-1).*(1+((Mu_i./Mu_a1)-1)*s2_a2).^-1));
K_a2 = K_m*(1+(f_i.*((K_i/K_m)-1).*(1+((K_i./K_a1)-1).*s1_a2).^-1))
K_a2 = 1×101
1.0e+05 * 0.6863 0.6905 0.6947 0.6991 0.7034 0.7078 0.7123 0.7168 0.7214 0.7260 0.7307 0.7354 0.7402 0.7451 0.7500 0.7550 0.7600 0.7651 0.7703 0.7755 0.7808 0.7862 0.7916 0.7971 0.8027 0.8083 0.8140 0.8198 0.8257 0.8317
Mu_a2 = Mu_m*(1+(f_i.*((Mu_i/Mu_m)-1).*(1+((Mu_i./Mu_a1)-1).*s2_a2).^-1))
Mu_a2 = 1×101
1.0e+07 * 0.0026 0.0027 0.0027 0.0027 0.0028 0.0028 0.0028 0.0029 0.0029 0.0030 0.0030 0.0030 0.0031 0.0031 0.0032 0.0032 0.0032 0.0033 0.0033 0.0034 0.0034 0.0035 0.0035 0.0036 0.0036 0.0037 0.0038 0.0038 0.0039 0.0039
% Plotting
figure(1)
plot(f_i,K_a1, 'Color', 'red', 'LineWidth', 2);
hold on;
plot(f_i,K_a2, 'Color', 'black', 'LineWidth', 2);
hold off;
%plot(f_i,K_a3, 'Color', 'blue', 'LineWidth', 2);
%hold on;
%plot(f_i,K_a4, 'Color', 'cyan', 'LineWidth', 2);
%hold on;
%plot(f_i,K_a5, 'Color', 'yellow', 'LineWidth', 2);
%hold on;
%plot(f_i,K_Reuss, 'Color', 'magenta', 'LineWidth', 2);
%hold on;
%plot(f_i,K_Voigt, 'Color', 'green', 'LineWidth', 2);
%hold off;
grid off;
legend('K_a_1', 'K_a_2','K_a_3', 'K_a_4', 'K_a_5', 'K_R_e_u_s_s',...
'K_V_o_i_g_t')
Warning: Ignoring extra legend entries.
legend('Location','northwest','FontSize',12)
title('Approach 1: Bulk Modulus vs. Inclusion Volume Fraction')
xlabel('Inclusion Volume Fraction, f_i')
ylabel('Bulk Modulus, K [MPa]')

Più risposte (2)

Mathieu NOE
Mathieu NOE il 22 Mar 2022
hello
I put the dots so that the multiplication and division are performed element by element between arrays , but the result looks strange to me (a modulus that drop until it gets negative seems wrong)
also , but this is my preference , instead of writing A .* (B.^-1) I prefer the simpler A./B
It's late now for me so I'll have a look again tomorrow
i'm surprised for example so see this equation that mix a modulus and poisson ratio as physically equivalent terms ... like adding tomatoes with oranges ??
v_a2 = (3*K_a1-2*Mu_a1)./(2*(3*K_a1+Mu_a1));
code
clc
clearvars
% Approach 1
E_m = 70000; % Elastic modulus of matrix, MPa
v_m = .33; % Poisson ratio of matrix
E_i = 250000; % Elastic modulus of inclusion, MPa
v_i = .2; % Poisson ratio of inclusion
% Fiber volume fraction
f_i = 0:0.01:1;
% 0 is 0% fiber and 1 is 100% fiber content
% points to be plotted
K_m = (E_m)/(3*(1-2*v_m));
K_i = (E_i)/(3*(1-2*v_i));
Mu_m = (E_m)/(2*(1+v_m));
Mu_i = (E_i)/(2*(1+v_i));
% Iteration 1
s1_a1 = (1+v_m)/(3*(1-v_m));
s2_a1 = (2*(4-5*v_m))/(15*(1-v_m));
% K_a1 = K_m*((1+f_i*(K_m/(K_m-K_i)-s1_a1)^-1)).^-1;
K_a1 = K_m./((1+f_i*(K_m/(K_m-K_i)-s1_a1)^-1));
% Mu_a1 = Mu_m*((1+f_i*(Mu_m/(Mu_m-Mu_i)-s2_a1)^-1)).^-1;
Mu_a1 = Mu_m./((1+f_i*(Mu_m/(Mu_m-Mu_i)-s2_a1)^-1));
% Iteration 2
v_a2 = (3*K_a1-2*Mu_a1)./(2*(3*K_a1+Mu_a1));
s1_a2 = (1+v_a2)./(3*(1-v_a2));
s2_a2 = (2*(4-5*v_a2))./(15*(1-v_a2));
% K_a2 = K_m*(1+(f_i*((K_i/K_m)-1).*(1+((K_i./K_a1)-1).*s1_a2).^-1));
K_a2 = K_m*(1+(f_i*((K_i/K_m)-1)./(1+((K_i./K_a1)-1).*s1_a2)));
% Mu_a2 = Mu_m*(1+(f_i*((Mu_i/Mu_m)-1).*(1+((Mu_i./Mu_a1)-1).*s2_a2).^-1));
Mu_a2 = Mu_m*(1+(f_i*((Mu_i/Mu_m)-1)./(1+((Mu_i./Mu_a1)-1).*s2_a2)));
% Plotting
figure(1)
plot(f_i,K_a1, 'Color', 'red', 'LineWidth', 2);
hold on;
plot(f_i,K_a2, 'Color', 'black', 'LineWidth', 2);
% plot(f_i,K_a3, 'Color', 'blue', 'LineWidth', 2);
% plot(f_i,K_a4, 'Color', 'cyan', 'LineWidth', 2);
% plot(f_i,K_a5, 'Color', 'yellow', 'LineWidth', 2);
% plot(f_i,K_Reuss, 'Color', 'magenta', 'LineWidth', 2);
% plot(f_i,K_Voigt, 'Color', 'green', 'LineWidth', 2);
hold off;
grid off;
legend('K_a_1', 'K_a_2','K_a_3', 'K_a_4', 'K_a_5', 'K_R_e_u_s_s',...
'K_V_o_i_g_t')
legend('Location','northwest','FontSize',12)
title('Approach 1: Bulk Modulus vs. Inclusion Volume Fraction')
xlabel('Inclusion Volume Fraction, f_i')
ylabel('Bulk Modulus, K [MPa]')
  2 Commenti
Briana Canet
Briana Canet il 22 Mar 2022
Yes these results look strange to me as well. Please look into it! Appreciate it.
Briana Canet
Briana Canet il 22 Mar 2022
The equations were provided by my instructor.

Accedi per commentare.


Briana Canet
Briana Canet il 22 Mar 2022
K_a2 = K_m*(1+(f_i.*((K_i/K_m)-1).*(1+((K_i./K_a1)-1).*s1_a2).^-1))
Why is there a dot after :((K_i/K_m)-1)
K_i and K_m are constants non-arrays.
Why is there a dot immediately after K_i
Also constant
  1 Commento
Briana Canet
Briana Canet il 22 Mar 2022
Hi! There was something wrong my logic! I fixed it but thank you the dot operator tip helped.

Accedi per commentare.

Categorie

Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by