def pressure_network_jacobian(flow_rates, Qtot, k):
 n = len(flow_rates)
 pdiff = np.diag((((flow_rates[1:] * 2) * k[1:]) - ((2 * flow_rates[0]) * k[0])))
 jac = np.empty((n, n))
 jac[:(n - 1), :(n - 1)] = (pdiff * 0)
 jac[:(n - 1), (n - 1)] = 0
 jac[(n - 1), :] = np.ones(n)
 return jac

def pressure_network_jacobian ( flow_rates , Qtot , k ) : n = len ( flow_rates ) pdiff = np . diag ( ( ( ( flow_rates [ 1 : ] * 2 ) * k [ 1 : ] ) - ( ( 2 * flow_rates [ 0 ] ) * k [ 0 ] ) ) ) jac = np . empty ( ( n , n ) ) jac [ : ( n - 1 ) , : ( n - 1 ) ] = ( pdiff * 0 ) jac [ : ( n - 1 ) , ( n - 1 ) ] = 0 jac [ ( n - 1 ) , : ] = np . ones ( n ) return jac
return the jacobian of the equation system f computed by pressure_network with respect to *flow_rates* .