Python program based on the code from the book:
- Brebbia, C. A., & Ferrante, A. J. (2013). Computational hydraulics. Butterworth-Heinemann.
Net Simulation is a code that solves systems connected by one-dimensional elements, as shown in the figure:
where the one-dimensional element is represented as follows:
Each element of the system is mathematically related as shown below, using the local matrix of the element:
where
There are problems where the matrix
where the global matrix
The code works for me with the following:
- python 3.7.0
- numpy 1.21.5
- scipy 1.4.1
- numba 0.55.1
- matplotlib 3.5.3
The improvements compared to the code in Brebbia's book are mentioned below:
- The matrices are stored in CSR format, using the scipy.sparse library.
- The system of equations in linear problems can be solved using the full variety of Scipy solvers.
- When solving the system of equations, the matrices are partitioned.
- There is no limitation that node 1 must necessarily be a flow entry node. You can freely select any node with any boundary condition.
- Nonlinear problems can be solved using the full range of scipy.optimize.minimize optimizers.