• News
• About

• Industries

• Learning & Support

• Community

• Marketplace

Download # Help a firefighter psuedocode programming a pump (math is hard)

Going to need some help with setting some equations up here. Hydralic caulcations and friction lose I’ve been using for years, but this may need some trig or some heavy duty algebra. Hopefully some math whiz can chime in-

I have a master pressure on my truck (rpm’s from transferred rod/tranmission raises this pressure as can hydrant pressure/incoming lines, but that’s irrelvant for the time being. We just have a master pressure for now)

The master pressure is “outputted” to any lines that are discharged from the truck. For example, if I have a master pressure of 200 PSI and two lines, and they are opened FULLY, each would get 100 psi. If I had 3 fully opened, that pressure is shared evenly, so about 66 psi each. as a note, the pressure is shared EVENLY amongst all lines, the only prioritization is done by the pump operator who closes valves, eliminating them from the equation so to speak.

However, the problem for me is that that the valves can be partially opened, affecting the pressure. (that literally is how you control each one, you ‘gate’ them down. I tried numerous times to sketch this out, I know that ultimately the values are proportional and can be expressed as a percentage, I just am not sure how to do this. (I tried plugging various numbers and seeing if I could find a pattern to derive an equation from, but so far, no dice)

So, for example, if I had 3 lines, line A , line B, line C - and a master pressure of 300 psi. If line A is open fully, line B is 50 % open and line C is completely closed, I know that line A would get 200 psi and line B would get 100 (this is all theoretically but should make sense, it’s a pressurized system). What equation can I pull from this that I could replicate into programming.

Thanks for any help you might be able to give!

(Note, I am probably going to do this in blueprint but it shouldn’t make a difference either way)

Seems pretty simple. You could do something like this. I’ll write it in pseudo code:

``````

Float MaxPressure = 300.0f;

Float ValveA = 1.0f; // 1.0 is fully open, 0.0 is fully closed.
Float ValveB = 0.5f;
Float ValveC = 0.0f;

Float SumTotalOfValves = ValveA + ValveB + ValveC;

Float ValveAPressure = ValveA / SumTotalOfValves * MaxPressure;
Float ValveBPressure = ValveB / SumTotalOfValves * MaxPressure;
Float ValveCPressure = ValveC / SumTotalOfValves * MaxPressure;

``````

You want to take each output’s proportionality of the total sum of all outputs and take that portion of the master pressure.

Since each hose can be closed, open, or any degree between open and closed, lets call this value Hose.Valve. This Hose.Valve term would be a floating point number between 0 and 1 where 1.0 meant fully open. `Hose.Valve = 0.5` therefore would mean the hose is half open.

Hoses can have different diameters, effectively meaning more/less water can flow through them. Call this term Hose.Size. In your case, all hoses have the same size, so
`Hose.Size = 1`

How much water a hose was currently demanding would be the “flow” amount of the hose. Call this term Hose.Flow.
`Hose.Flow = Hose.Valve * Hose.Size`

Now you need to know the total flow of all lines, call this TotalFlow. TotalFlow doesn’t care how much the hoses are capable of delivering, but how much they ARE delivering. It’s the simple sum of each of the individual hoses Flow value.

`TotalFlow = HoseA.Flow + hoseB.Flow + hoseC.Flow`

To determine what a particular hose therefore gets in terms of the master pressure you would multiply the master pressure by the proportion of the total flow each hose represented.

`HoseA.ActualPressure = MasterPressure * (HoseA.Flow / TotalFlow)`
`HoseB.ActualPressure = MasterPressure * (HoseB.Flow / TotalFlow)`
`HoseC.ActualPressure = MasterPressure * (HoseC.Flow / TotalFlow)`