The equation calculates the flow through a pipe based on the pressure at the end points.
This simple equation will later be used to calculate the flow through a more complex system of pipes (which will have to be also solve iteratively, hopefully I can apply the same methodology)
Also, I want to add that I am seeking for something computationally efficient. In the final system form, there will be potentially thousands of “pipes”, and each one will need to be solved for every iteration of the system solution.
I’m suggesting using Alpha once to get an equation, which can involve multiple input parameters, and then make an ‘Evaluate’ component with those inputs.
You wouldn’t need to use Alpha each time if the equation stays the same, and the input values can still change.
It is based on the Darcy equation, that calculates pressure loss:
Although in my case the pressure differential is driving the flow. In the formula the friction factor also depends on the flow (velocity), and that’s why I cant solve it directly.
Ok, I didnt understand you before. That makes sense and would be the most effiecient way if the there is a solution for the system of equations… will give it a try.
Anyway, I am also interested in exploring a iterative solution as I would eventually need it for a interconnected system of pipes.
Yes sure, it is already attached on my previous comment.
I hope it makes sense what I am trying to do. It is solving for “v”, so at the beggining a “v” value is input and resulting in a “v” output, if this ouput is used as input in a a loop a solution for “v” will be convereged in a number of iterations.
private void RunScript(double v, double D, double A, double B, double L, double P1, double P2, double rho, double nu, int i, ref object Final_v) {
for(int counter = 0; counter < i;counter++){
double Re = (v * D * rho) / nu;
double f_D = Math.Pow((A * Re), B);
v = Math.Pow((2 * (P1 - P2) * D / (f_D * L * rho)), 0.5);
}
Final_v = v;
}
You can see how your value stabilize by increasing the loop count slider.
Calc is light-weight, you could even shoot a fixed i=100 and forget about it…
(is importat that your loop have a count limit, otherwise it would loop endlessly and freeze c#, grasshopper, rhino… )
I wonder if there is a way of doing this using the original components (formulas), so the script just controls the data flow through the components rather than the formulas being defined in the script? It is what I have in my head originally… still curious if it is possible.