Core code for Fluid and Gas networks