Can you provide a routine which calculates the displacements or the max displacement for a specific period T (which then should be a parameter of that function).
You wrote that your uuu routine does just that, but then I am unsure as of the role of your Delta_t (0.02) which seems to be the stepwidth of your range of periods and then should have nothing to do with the calculation for a single value T. As written now Delta_t influences the result.