A bit of background: I am working on a project for university. Right now, I need to create shear force diagram. This is done by integrating the loads that are acting along the beam of interest. This is all well and good, and it is pretty straight forward I think. I am using the integrate.quad function, see also my code below.
def ShearIntegral(z):
result = np.zeros_like(z)
for i, val in enumerate(z):
q,error = integrate.quad(Loading, 0, val)
y = -q + 22028.2 + 68351.55 - L/2 #numerical terms take into account the reaction force at the root
result[i] = y
return result
In this code, z is an array of the form np.arange(0,18,0.25) (e.g. the beam I'm interested in extends from 0 meters to 18 meters). The loading is a combination of a few functions, but I don't think it is of much importance here, as the time needed to compute the value of each iteration is negligible.
My main "issue", if you will, is the time needed to compute the the result. In total, it takes 71 iterations to find the result. Of these iterations, the first 30 or so only take 30 seconds total. However, the remaining 41 iterations start taking ever longer, giving me a total program runtime of 4 minutes and 30 seconds.
Are there any computational enhancements that are available to speed up this process?