Skip to main content
16-Pearl
February 10, 2019
Solved

Issue with While loop

  • February 10, 2019
  • 2 replies
  • 2100 views

I'm probably doing something silly, but I can't seem to find it.  I set up a while loop but it always finishes on the 2nd iteration, when I know fully well it hasn't converged.  Prime 4.0 attached.

2019-02-10_11-43-11.jpg

Thanks!

Best answer by Werner_E

As you can see in the attached Screenshot, the values after the first and second iteration are identical, so the iteration stops as demanded.

But after further iterations the two matrices differ again.

You may want to check the initial values of matrix P

2 replies

23-Emerald IV
February 10, 2019

I suppose Mdiv and Ndiv are properly defined...

 

Why do you keep summing the error in the inner loop? I should assume it would suffice to assign just abs to Error, not to add it.

 

Check your labels! You have two 'Error's, one is a 'variable', the other is an 'automatic'.

 

Success!
Luc

Werner_E25-Diamond IAnswer
25-Diamond I
February 10, 2019

As you can see in the attached Screenshot, the values after the first and second iteration are identical, so the iteration stops as demanded.

But after further iterations the two matrices differ again.

You may want to check the initial values of matrix P

DJF16-PearlAuthor
16-Pearl
February 11, 2019

Yep, that's it.  Eta doesn't change the first time through since it's using old temperatures.  So the next pressure calculation doesn't change.  

 

Just need to move the eta calculation down in the list and she works.  

 

Thanks.