Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hello,
i need help on how to iterate until convergence. please scroll down in my sheet until you see the red arrow where i begin the iterations. Right now i have 10 individual iterations, and checking the end for convergence. i dont know how to do in mathcad where you can automate the iteration until convergence, and let it decide how many iteration it needs until convergence. there are two values that each need to converge . one for moment and the other for delta. a ratio of 1.001 will be fine for convergence. Thanks!
Solved! Go to Solution.
One method to achieve your target would be to use a program 'while' statement.
First function (delta) will run the loop a given number of times & I have matched the iterations with your example so the result appears to be correct.
The next function (delta2) modifies this to loop until convergence.
It is possible for this to loop for ever so a counter to limit the max number of iterations is advised.
You will need to define the convergnce condition that you require, at the moment it is a simple sum of differences squared.
Hope this is helpful
Regards
Andy
One method to achieve your target would be to use a program 'while' statement.
First function (delta) will run the loop a given number of times & I have matched the iterations with your example so the result appears to be correct.
The next function (delta2) modifies this to loop until convergence.
It is possible for this to loop for ever so a counter to limit the max number of iterations is advised.
You will need to define the convergnce condition that you require, at the moment it is a simple sum of differences squared.
Hope this is helpful
Regards
Andy
Thank you so much Andy!
This stuff is a bit over my head. i am not sure i fully understand it.
why did you set delta last to 1 in at the begining. what does that do?
then you assign 1in to d what is that for?
please explain to me your statment while (d>.01 in) or n>10.
if also need to have the last values for Mue-wLC1 like delta2, how do i do that?
Again Thanks alot to you Andy!
HI,
In the Delta2 function:
1. the first assignment to delta.last should have been deleted (cut & paste strikes again)
2. d is initially set to 1in (inch) to ensure that the condition for the while loop is true.
3. the while loop will test the conditions that are set,
in this case { (d > 0.01 inch) and (n < 10) } - correction in the attached file
the first is initially true because we set a default value (1 inch) , at the end of the while loop we recalculate a value for d & the new value will be used for the next iteration.
the second is true , initial value is set to 0, at the end of the loop we increment n by 1 & if the function doesn't converge then there is a get out route & it stops the program from an infinite loop problem.
4. If you want to return another variable it is possible, BUT, Mathcad will not allow different units.
delta.u is in inches & M... is lbf*in.
To enable the return of these values you need to strip the units in the program & add them back later
see example attached
regards
andy