Select to view content in your preferred language

Complex math with Arcade

2267
3
Jump to solution
09-29-2020 01:25 PM
AriLukas
Regular Contributor

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

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Ari Lukas ,

The math is not too complex to be handled by Arcade. See example below:

// read values from feature
//var P = $feature["Pitot_Pressure"];
//var S = $feature["Static_Pressure"];
//var R = $feature["Residual_Pressure"];

// example values
var P = 40;
var S = 108;
var R = 55;

// apply math to calculate amount of water flow
var Q = 167.0625 * Sqrt(P); 
Console("Q:" + Q);

// rated flow at 20 psi
var RF = Q * Pow(((S - 20) / (S - R)), 0.54);
Console("RF:" + RF);

The values returned are: 

Q:1056.5960232037598
RF:1389.3787273337343

In your formula for the rated flow you were missing some brackets before applying the division. Since the results are not the same as the values you provided, I did the same in Excel and it seems that your result is off for Q by 0.4. I wonder why...?

View solution in original post

3 Replies
XanderBakker
Esri Esteemed Contributor

Hi Ari Lukas ,

The math is not too complex to be handled by Arcade. See example below:

// read values from feature
//var P = $feature["Pitot_Pressure"];
//var S = $feature["Static_Pressure"];
//var R = $feature["Residual_Pressure"];

// example values
var P = 40;
var S = 108;
var R = 55;

// apply math to calculate amount of water flow
var Q = 167.0625 * Sqrt(P); 
Console("Q:" + Q);

// rated flow at 20 psi
var RF = Q * Pow(((S - 20) / (S - R)), 0.54);
Console("RF:" + RF);

The values returned are: 

Q:1056.5960232037598
RF:1389.3787273337343

In your formula for the rated flow you were missing some brackets before applying the division. Since the results are not the same as the values you provided, I did the same in Excel and it seems that your result is off for Q by 0.4. I wonder why...?

AriLukas
Regular Contributor

Xander,

That entire example was sent to me. After I did math with a scientific calculator I got same answer as you. Contacted Fire Dept and apparently he typed instead of copy and paste and miss-typed. 

XanderBakker
Esri Esteemed Contributor

Hi Ari Lukas ,

Glad to hear that! Do you need any additional explanation for the Arcade expression or did my answer resolve your question? If so, can you mark the answer as the correct answer?

0 Kudos