I have always been interested in using computers to simulate complex systems. The fuel system on a C-130 is definitely complex: there are pumps and valves, tanks, engines, and a whole lot more. All of these components can be connected in different ways, which is a programmer's nightmare. I've put off making this project because I felt like any system I made would just crumble into a sea of “if” statements, and maintaining it would be impossible.
Then I read about directed graphs. These are systems of nodes and edges, but the edges have a direction to them. That sounds a lot like a fuel system! I went about building some basic to code in JavaScript to implement a DG when I found CytoScript.js, an awesome library for building and manipulating nodes and edges.
This is not going to be the interface for the final sim, as I plan on creating an actual mockup of a fuel panel that is driven by this model. There will be an option to show the graph, which I think will be a great way to walk students through the fuel system.
The awesome thing about this system is the ease of adding and connecting more components. The graph on this page does not have everything the actual fuel system has, but all I have to do is add more nodes and program their behavior. The graphing library takes care of tracking connections. For example, the system is running an aStar pathfinders algorithm every second to see which fuel tanks are connected to which engines.
The Graph is fully interactive. You can zoom in, zoom out, and click on just about anything. If you click and drag on a node, you can move it around. If the node is a child of another node, it will resize the parent (the fuel tanks are the large gray squares, move a child node to resize them).
Anything that is Red or Green is something that you can turn on or off.
If the system detects there is higher pressure from a transfer pump, it will automatically disconnect a Check valve that is connected to that pressure.
The two buttons at the bottom will start and stop the fuel burn. The engines won't ‘flame out’ if they are fuel starved. This is functionality that I will add after I make the actual fuel panel sim.