I am trying to create a simulation to help visualize how different chemical components flow through a network of pipes with associated valves, pumps, and chemical inputs. In this simulation, the pipes will be represented in 1D and the pump flow rates and valve states will ideally be able to be changed by the user during the simulation.
For example, the simplest pipe network might consist of three pipes and two pumps. The images below show what the simulation ideally would be able to do in real time. The arrows represent pumps, the circles represent inputs and outputs, and the lines represent pipes.
I have already created a program that can take a representation of such a pipe network with pumps and valves in a given configuration and determine the flow rate in each pipe.
The difficulty I am having is in simulating the mass transport of the chemicals through the pipes. So far, I have tried an agent-based approach, where discrete boluses of fluid move through the pipes (one bolus for every v_pipe * dt meters in each pipe), and a simple finite difference scheme. The agent-based approach works in some situations, although doesn't work well when the flow rates of the pipes change. I have had some success with the finite difference method for a single pipe, but have problems with numerical diffusion and getting it to work well with a network of pipes.
Is there a good simulation method for implementing such a simulation of mass transport in a network of pipes where the flow rates in each pipe can vary? Would something like the finite volume method work?