In the current state, CADET-Process uses sympy to solve the Flow Rates for every unit by creating symbols and generating general equations. This should be improvable by using numpy for solving this problem by generating a matrix and using numpy.linalg.solve.

Let us consider we have a Flow Sheet with n different units. Every unit has an equal total in- and outflow. For every unit we know the percentile w_{ji} of the flow Q_j \cdot w_{ji} from unit j to i (so Q_j is the total outflow of unit j). So we can assume the sum of every Q_j \cdot w_{ji} is equal to the total output Q_i of unit i:

If the unit i is an Inlet or a Cstr with a given flow rate Q_i, Q_i does not depend on the other flows and by setting every w_{ji} with j\ne i to zero, the corresponding rows are simplified to

w_{ii} Q_i = Q_i

with w_{ii} = 1.

This generates a solvable system of equations (in this example the first row has a given flow rate, most others have not):

@daklauss , @j.schmoelder , you probably already found out the correct solution yourself, but just wanted to share here that in case of CSTR with given flow rate this system of equation needs to be modified. I found out this after our discussion as some tests were failing

In this case the equation for CSTR is just Q_i = c_i, so what I did is to set all corresponding w_ji = 0, where i is the CSTR index. After that all tests passed.

Hey, thanks for your input! @daklauss has made good progress on this matter! You can track the progress here. Tests are already passing and AFAIK, we only need to clean up the code a bit. Daniel will also update this post later with the correct equations.

Hi,
thanks for your response. I’ve encountered the same issues with failing tests and modyfied my equations. I see i should have made more clear that simplifying an equation to w_{ii}Q_i = c_i meant to set every other w_{ji} to zero.

I found another small mistake. w_{ii} is not necessary -1. If a unit is connected to itself with Outputstate \tilde{w}_{ii}, this component is w_{ii}=\tilde{w}_{ii} -1.