Standard Step / iterative solving with for loop Prime 8.0
- July 18, 2025
- 3 replies
- 997 views
Can someone help me to redefine a variable in a for loop or get me moving in the right direction? I am new to Mathcad.
I am calculating a standard step gradually varied flow profile in a steep pipe. Pages 1 and 2 are inputs and creating functions that define the geometric properties of the open channel flow in terms of flow depth (y)
In the solver block is the energy equation with upstream energy on the left and downstream energy + friction loss on the right. I want solver block to find the downstream depth (yd) that makes those sides equal, which I get. (note: the velocity V and friction slope Sf terms in the equation are functions of y, so I can't solve algebraically)
My problem is I need to repeat that step by step along the pipe. for simplicity now I have (100) 1 ft steps in a 100 foot long pipe but those values are arbitrary until I can get the for loop working.
In the for loop, for every step I want to redefine yu equal to yd. I want to be able to plot flow depth (y) vs station of the pipe (X). It should look like the S2 profile. I tried to use the yU←yD within the for loop to accomplish this, but it seems to not update the depth yu in the solver block. Most of the help available from mathcad is very basic with a claim that "programming in mathcad is intuitive and easy" so I may just be an idiot!







