CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

stop test inside (while) and Nusselt number

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By LuckyTran

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 4, 2022, 18:01
Default stop test inside (while) and Nusselt number
  #1
New Member
 
Ammar
Join Date: Jan 2022
Posts: 11
Rep Power: 4
chberbelali is on a distinguished road
I have just searched the Nusselt number delicate and compared it with those of other literatures,
I found that I have to do the test of stop inside the loop "While",
here is what I have added in the Matlab script:

%************************************************* *
initialize Theta;
Tnew = Theta;
Told = Tnew;

while (norm(Tnew-Told,1)/norm(Tnew),1) <= 1e-6


Told = Tnew;
.....
..... The body of the program.
.....
Tnew = Theta (Calculated);


end (while)

%*************************************************

(it doesn't work!!! it just passes the 1st iteration.)

i'll be grateful for any help !
chberbelali is offline   Reply With Quote

Old   March 4, 2022, 21:47
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,675
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
I would recommend testing. If you really want to test if a flag is being respected or not, try:
Code:
while false
%body of code
 end
Note that in matlab the test can be an expression and is not limited to simple logical booleans. Any non-empty vector that contains any non-zero elements will be evaluated. Also note that / is matrix division and you should be using ./ for element wise arithmetic. If you Tnew is a row vector and you do norm(Tnew,1) that will return a vector. And then if you divide a vector by a vector, unexpected things can happen.
chberbelali likes this.

Last edited by LuckyTran; March 5, 2022 at 01:25.
LuckyTran is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 03:08.