how to re-run/continue the terminated inner while loop at nested while loop?

3 views (last 30 days)
Hello guys and gals also lovely admins + veteran warriors,i am a student who do small FEM project, and i would like to ask some ideas and guidance how to re-run the terminated inner while loop at nested while loop.
The idea is from Finite Element Method 2D Frame in simple form (base is fixed or pinned on the left, and the right side is either free or rolled support) with two single forces at different position, which is 2 (assume forces and position in same axis, for example in y axis). With crude explanation, given all initial position and the desired two ideal deflection position is known, the current deflection is obtained by calculating with two forces. The program is accomplished when both current deflection is near enough (in my program i call it 'corr' or correction relative) single ideal deflection for each nodes. The two forces will get calibrated (each force have increase and decrease in loops, depends on the value of each 'corr') according to the value of correction relative of each nodes.
The problem is, when one nodes is near enough ( corr >= 0.90 & corr<1) and other is not near enough (corr < 0.9), the one that satisfied first, program will be terminated (i'm using break feature).When the other one get calculated by obtained calibrated force, the deflection of the first node (the one that get the first satisfied enough) will change, the corr at first node also change. Personally i still didn't get the details of how to implemented this logic on matlab :(
the detail questions:
  1. How to re-run the inner while loop?
  2. how to re-run the while loop if the outer loop is the one that satisfied enough?
for getting initial idea of this, the following is single cycle force system of simple FEM 2D Frame and excel input&output, and not multi cycle system as i describe above, as i also still thinking about the logic of this kind of problem :(
thankyou guys and gals also lovely admins + veteran warriors, much love.
edit: don't forget to attach the files as 1 folder for run the program, thanks
%% the following is only part of the program, for full program yo can download the attached file(s)
calc = 1; %index for looping process
loop(calc) = 0; %pre-looping process
ideal_dp_1 = data2(:,7); %need input-change in the future
corr(calc)=abs((desg_defl_int)/(ideal_dp_1 - desg_pos_int))
%% PART 4: Looping part for generating force with correction error >= 90%
% Addiing looping force
while corr(calc) >= 0
calc = calc + 1
loop(calc)=loop(calc-1)+1
if corr < 0.90
act_f = act_f + act_fl_inc
elseif corr >= 0.9 & corr <1
act_f = act_f
disp('we got good force!')
else corr > 1
act_f = act_f + act_fl_dec
end
defl_loop_ans = kkk*act_f; %deflection toward acting dofs
%%% Mapping generated Deflection
% #1 Deflection & Acting Force data each dof
def_table_loop = zeros(big_dof,1); %empty matrix for after added force loop
for_table_loop = zeros(big_dof,1);
for mm=1:tot_act_dof;
dof_act=t_act_dof(mm,1);
def_value=defl_loop_ans(mm,1);
for_value=act_f(mm,1);
def_table_loop(dof_act,1)=def_table_loop(dof_act,1)+def_value;
for_table_loop(dof_act,1)=for_table_loop(dof_act,1)+for_value;
end
% #2 Deflection for each axis
defl = def_table_loop(:,1);
defl_x = defl(1:3:big_dof);
defl_y = defl(2:3:big_dof);
defl_theta = defl(3:3:big_dof);
% #3 Post-Deflect position
newp_x = pos_x+defl_x;
newp_y = pos_y+defl_y;
newp_theta = (pos_theta + defl_theta); %1 RAD = 57.296 DEG
%deflection position
all3defl_loop= zeros(big_nod,3);
all3defl_loop(:,1) = defl_x;
all3defl_loop(:,2) = defl_y;
all3defl_loop(:,3) = defl_theta
desg_defl_loop= all3defl_loop((round(data2(:,5)/3)),data2(:,4));
corr(calc)=abs((desg_defl_loop)/(ideal_dp_1 - desg_pos_int))
last_corr = corr(calc)
if last_corr >= 0.9 & last_corr < 1
disp('force calc is done!!')
break
end
end
  3 Comments
M Adli Hawariyan
M Adli Hawariyan on 28 Jun 2022
Edited: M Adli Hawariyan on 28 Jun 2022
Hello Johan, thanks for the suggestion
The matlab program that I bring to show is pre eleminary program, which is like "grinding" the logic. The program is about a 2DFrame which is fixed at base(left) and free at the other(right) given single cycle force system toward one deflection. My question is about multicycle force system toward multi deflection which is focusing on while loop with many correction relative (or you can say, tolerance).
if at one nodes the deflection is satisfied enough, with 'break' feature it will terminated the line program so it will not be run at that line (correct me if i'm wrong, thanks, i'm new in matlab). But the other nodes is still not satisfied, so it will callibrating force of that nodes ( plus or minus force) that will impact the previous node. How we re-run the first node that we had done before?How to re-run the terminated while inner loops?
or maybe how to run multi while loops at the same time and finish at certain condition?
like 'corr_1stnode >= 0.9 & corr_1stnode<1 & corr_2ndnode >= 0.9 & corr_2ndnode<1'
Thanks,
Hawariyan
edit: i will try to make the line program of this problem even it doesn't work for generating some ideas
M Adli Hawariyan
M Adli Hawariyan on 28 Jun 2022
Hello again, Mr. Johan.
as i think about this type of problem, it seems like either nested while loop or centralised program with the core is deflection line program, and the sub/other is force with increase and decrease calibrate line program. any idea of these type of problem? thanks.
Regards,
Hawariyan

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!