Using @assert in loop within function

Thanks, almost, i do need dt_m as it is an input in the function that I call in the loop. But yes, I can get rid of some lines. Thanks!