I am trying to make a custom function in the QGIS expression editor that takes three arguments. Below is the tested standalone function, which I would like to integrate:
import math
def qfull_circle(DN, kb, I):
#Input: DN in mm, kb in mm, I in ppm
#Output: Q in l/s
viscosity = 1.31 * math.pow(10,-6)
roughness = kb / 1000
Acircle = (DN * DN * math.pi / 4) * math.pow(10,-6)
Xroot = math.pow((2 * 9.81 * DN * math.pow(10,-3) * I * math.pow(10,-3)),0.5)
fraction1 = (2.51 * viscosity) / (DN * math.pow(10,-3) * Xroot)
fraction2 = roughness / (3.71 * DN * math.pow(10,-3))
return Acircle * (-2 * math.log(fraction1 + fraction2, 10) * Xroot) * math.pow(10,3)
Unfortunately, I cannot make it work. Any assistance on how to define it within the function editor is highly welcome.
Acircle
andXroot
, turned light blue in the code block, which might indicate that those variable names are already defined (and thus not available for you to use). See if it works with something likemyAcircle
andmyXroot
.Parser Errors: qfull_circle function is called with wrong number of arguments. Expected 1 but got 3.