Effacer les filtres
Effacer les filtres

Trial and error problem

9 vues (au cours des 30 derniers jours)
Learner
Learner le 11 Avr 2018
Commenté : Sunil Raiyani le 14 Juil 2022
Dear Matlab Community Members
As shown in the flowchart, My objective is to find the values b and c for the given value a, Both the values b and c lies in the range 0.000001 to 2 (Approximately), I wrote a simple code in matlab to search for the values (i.e. a = 0.000001:0.000000:2 and b = 0.000001:0.000000:2), that means for each value of a it will search for the value of b, when condition 1 is less the toleratnce, it will check conditon 2, if it also less than the toleracnce, it will break the loop and return the values. But my problem here is
  1. It is taking too much time (Approximately, for each value of a, it is taking almost 30 Minutes) I have nearly about 1000 values of a.
  2. I want to know, is there any better way or techniques to find the values (b and c).
Thanks you very much
* |Simplified version of flowchart|*
*
Original flowchart*
Code is really big, it involves multiple functions, This is the real flowchart of the code (This is softened membrane model, reinforced concrete)
This code will not run, since it has supported funciton files.
eps_2 = -[linspace(0.01, 0.1, 20), linspace(0.1, 5, 30)]*10^-3;
eps_1_initial = [linspace(0.01,1, 200), linspace(1, 100, 200)]*10^-3;
Gamma_12_initial = [linspace(0.01,1, 200), linspace(1, 100, 200)]*10^-3;
Tol = 1e-3;
%%SMM (Softened Membrane Model) Model
for i = 1:length(eps_2)
eps_2_trail = eps_2(i);
eps_1 = eps_1_initial;
Gamma_12 = Gamma_12_initial;
TotalError = [];
for m = 1:6
for j = 1:length(Gamma_12)
Gamma_12_trail = Gamma_12(j);
for k = 1:length(eps_1)
eps_1_trail = eps_1(k);
eps_l = eps_1_trail*(cosd(Alpha_1))^2 + eps_2_trail*(sind(Alpha_1))^2 - Gamma_12_trail*cosd(Alpha_1)*sind(Alpha_1);
eps_t = eps_1_trail*(sind(Alpha_1))^2 + eps_2_trail*(cosd(Alpha_1))^2 + Gamma_12_trail*cosd(Alpha_1)*sind(Alpha_1);
[v12, v21] = HsuZhuRatios(eps_l, eps_t, eps_yl, eps_yt);
eps_1_bar = eps_1_trail/(1 - v12*v21) + v12*eps_2_trail/(1 - v12*v21);
eps_2_bar = v21*eps_1_trail/(1 - v12*v21) + eps_2_trail/(1 - v12*v21);
eps_l_bar = eps_1_bar*(cosd(Alpha_1))^2 + eps_2_bar*(sind(Alpha_1))^2 - Gamma_12_trail*cosd(Alpha_1)*sind(Alpha_1);
eps_t_bar = eps_1_bar*(sind(Alpha_1))^2 + eps_2_bar*(cosd(Alpha_1))^2 + Gamma_12_trail*cosd(Alpha_1)*sind(Alpha_1);
Beta = 0.5*atand(Gamma_12_trail/(eps_1_trail - eps_2_trail));
Sigma_2c = ConcreteComp(fcDash, eps_c0, eps_2_bar, eps_1_bar, Beta);
Sigma_1c = ConcreteTension(fcDash, eps_c0, eps_cr, Ec, eps_2_bar, eps_1_bar);
Tau_12c = ConcreteShear(Sigma_1c, Sigma_2c, eps_1_trail, eps_2_trail, Gamma_12_trail);
% Longitudinal Steel:
fl = Steel(fcDash, rho_l, fyl, Esl, eps_l_bar);
ft = Steel(fcDash, rho_t, fyt, Est, eps_t_bar);
[SumError, DiffError] = Check( rho_l, rho_t, fl, ft, Sigma_l, Sigma_t, Sigma_1c, Sigma_2c, Tau_12c, Alpha_1 );
TotalError(j, k) = SumError^2 + DiffError^2;
Tau_lt_trial(j, k) = (Sigma_1c - Sigma_2c)*sind(Alpha_1)*cosd(Alpha_1) + Tau_12c*((cosd(Alpha_1))^2 - (sind(Alpha_1))^2);
Gamma_lt_trial(j, k) = 2*((eps_1_trail - eps_2_trail)*sind(Alpha_1)*cosd(Alpha_1) + 0.5*Gamma_12_trail*((cosd(Alpha_1))^2 - (sind(Alpha_1))^2));
end
end
[a, b] = find(TotalError == min(min(TotalError)));
Gamma_12_iterative = Gamma_12(a(1));
eps_1_iterative = eps_1(b(1));
if (min(min(TotalError)) >= Tol) && (m ~= 6)
eps_1 = [linspace(eps_1_iterative/10, eps_1_iterative, 100), linspace(eps_1_iterative, eps_1_iterative*10, 100)];
Gamma_12 = [linspace(Gamma_12_iterative/10, Gamma_12_iterative, 100), linspace(Gamma_12_iterative, Gamma_12_iterative*10, 100)];
TotalError = [];
Tau_lt_trial = [];
Gamma_lt_trial = [];
else
break;
end
end
Tau_lt(i) = Tau_lt_trial(a(1), b(1));
Gamma_lt(i) = Gamma_lt_trial(a(1), b(1));
eps_1_final = eps_1(b(1));
Gamma_12_final = Gamma_12(a(1));
fprintf('%d Out of %d Values of eps_2 completed \n', i, length(eps_2))
Values = table(eps_2_trail, eps_1_final, Gamma_12_final, Tau_lt(i), Gamma_lt(i), TotalError(a(1), b(1)))
end
%%Plotting
plot(Gamma_lt, smooth(Tau_lt))
  4 commentaires
Learner
Learner le 11 Avr 2018
Added, Please find the code in the question
Sunil Raiyani
Sunil Raiyani le 14 Juil 2022
Have you got the solution for the same. Actually I am also stuck with the same problem.

Connectez-vous pour commenter.

Réponses (1)

Torsten
Torsten le 12 Avr 2018
Condition 1 and Condition 2 hide two equations that must be fulfilled to accept eps1 and gamma1 as solutions. So you have two equations in two unknowns that can be solved using MATLAB's "fsolve".
Best wishes
Torsten.
  1 commentaire
Learner
Learner le 1 Juin 2018
Modifié(e) : Learner le 1 Juin 2018
I cannot use fsolve(), since for solving variables b and c, I need to calculate other variables such as fl, ft etc..., as shown in "Original flowchart" diagram, these variables comes from a series of equations and I have to select an equation out of several equations based on the values of b and c, i.e. it is a nonlinear problem.
That's why I tried with a linear search and bisection methods. Recently I tried with finsearch() tool in matlab, it is satisfying my requirement but, Initial guess is the problem.
Do you have any idea how to give initial guess??

Connectez-vous pour commenter.

Catégories

En savoir plus sur Particle & Nuclear Physics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by