Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hey,
at the moment i´m calculating the massstreams in a powerplant.
For the calculation there is a for-loop necessary because one of the last streams is going back to the beginning of the calculation.
My problem is that the for-loop will not be calculated while using Units (like kg/hr or mol/hr).
I added a simpel example which should discribe my problems more accurate.
The output of for-loop should be a Matrix with different Units like [kg/hr] for the Massstream and [ ] (no Unit) for the iteration number.
Solved! Go to Solution.
Its not aproblem with the for-loop.
You compared a value with unit kg/hr against a unitless value (0,01)
See attached
Its not aproblem with the for-loop.
You compared a value with unit kg/hr against a unitless value (0,01)
See attached
Ok, Thanks that helped.
I have one more question.
If I add one more variable without an unit it wont calculate again (see attached file).
Why?
Florian Bünger wrote:
Ok, Thanks that helped.
I have one more question.
If I add one more variable without an unit it wont calculate again (see attached file).
Why?
Because you still have not initialized m4 in your routine as I advised in the sheet I posted. This time Prime's dynamic unit checking chokes on m1+m4*a. You cannot add kg/hr and a unitless value (even if the latter is zero).
Furthermore is a bad habit to use a for-loop and jump out of it using break. Use a for-loop only when the number of iteration steps is known, otherwise use the while-loop. Unfortunately we don't have a do...while or repeat...untlil in Mathcad
Even worse is that you change the loop variable i in the for-loop - thats an absolute no go even if it doesn't do any harm (and also has no effect for the loop) the way the for-loop is implemented in Prime.
Ok, got it.
Thank you again.