# Complex math with Arcade

Question asked by adlukas1 on Sep 29, 2020
Latest reply on Oct 2, 2020 by xander_bakker

I want to start by saying I am fairly adept at reading Arcade language but not so much at writing it. To date I have only written simple scripts having to do with labels and such. When it comes to using Arcade for mathematical functions I know very little so I'm not sure if what I want to do is even possible.

I have put together a map to be used with Collector for ArcGIS for our city's Fire Department to conduct fire hydrant inspections. They gather 3 readings in the field (Static Pressure, Residual Pressure and Pitot Pressure) which they then add into a third-party software to determine Rated Flow at 20psi. Based on Rated Flow the hydrant is assigned a color: Red 0-499, Yellow 500-999, etc..

The Fire Department then sends me an excel spreadsheet of the hydrant number and its assigned color that I join to an existing hydrant layer in GIS using the hydrant number as the primary key. I then display the hydrants on the Hydrant map on our portal according to their assigned color. This process is time consuming for all parties involved and creates several weeks of lag before data is updated on our portal.

I have included the formula and example that was sent to me below. The Fire Department would like, if possible, to have the Rated Flow calculated on the fly in the field and by proxy the appropriate color assigned.

I am hoping someone might be able to tell me:

a) Is this type of complex math even possible using Arcade language and b) how to go about constructing the formula

Thanks for the help!

The three things you should have listed are Static Pressure, Residual Pressure, and Pitot Pressure. With these three we will be able to determine what the hydrant will flow at 20psi residual pressure which is what we have to have for the state.

167.0625 x SR(P) = Q

SR( ) is Square Root

P is Pitot pressure

Q is the amount of water flowed during the test in gallons per minute

Q x ( S - 20 / S - R ) ^ 0.54 = Rated Flow at 20psi

S is the static pressure

R is the Residual Pressure

and example a hydrant flow test with a Static pressure of 108psi with a residual pressure of 55psi  and a Pitot pressure of 40

167.0625 x SR(40) = 1,056.2 gallons per minute flowed

1056.2 x (108 - 20 / 108 - 55 ) ^ 0.54 = 1,388.86 round to the nearest whole number 1,389 gallons per minute is what it is rated for at 20psi