The ASHRAE Duct Fitting Database is the digital version of the classic "SMACNA" and ASHRAE fitting loss coefficient tables. It contains over 1,200 unique fitting types (round, rectangular, flat oval) with parametric equations to calculate Coefficient of Loss (Co) based on actual dimensions and flow rates—not just static lookup values.
Step 1 – Load DLL in Python using ctypes
import ctypes from ctypes import c_long, c_double import xlwings as xw
dll = ctypes.CDLL("C:/ASHRAE/ASHRAEDFDB.dll") dll.GetFittingData.argtypes = [c_long, c_double, c_double, c_double, ctypes.POINTER(c_double)]ashrae duct fitting database excel link
Step 2 – Call from Excel via xlwings UDF The ASHRAE Duct Fitting Database is the digital
@xw.func
@xw.arg('fit_id', numbers=int)
@xw.arg('p1', numbers=float)
def ashrae_co(fit_id, p1, p2=0.0, p3=0.0):
co = c_double()
ret = dll.GetFittingData(fit_id, p1, p2, p3, ctypes.byref(co))
return co.value if ret == 0 else None
Now use =ashrae_co(401, 1.5) directly in Excel.
If you cannot link the DLL, create a local Excel table using published Co values from ASHRAE Fundamentals (Chapter 34). This is static but works offline. Step 2 – Call from Excel via xlwings UDF
@xw
Example CSV import:
FittingID,Type,Param1,Param2,Co
401,Elbow 90 r/D=1.0,,,0.21
401,Elbow 90 r/D=1.5,,,0.15
403,Mitered elbow,,,1.20
Use INDEX-MATCH or XLOOKUP with multiple criteria.