cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Using Units in a for-loop

FloRian
1-Newbie

Using Units in a for-loop

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.

1 ACCEPTED SOLUTION

Accepted Solutions

Its not aproblem with the for-loop.

You compared a value with unit kg/hr against a unitless value (0,01)

See attached

View solution in original post

4 REPLIES 4

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.

Top Tags