josephcslater / mousai

Harmonic balance solvers
BSD 3-Clause "New" or "Revised" License
22 stars 11 forks source link

lack of initial guess causes fail: try with fewer points and fewer harmonics to initiate. #13

Open josephcslater opened 6 years ago

josephcslater commented 6 years ago
def duff_osc_ss(x, params):
    omega = params['omega']
    t = params['cur_time']
    xdot = np.array([[x[1]],[-x[0]-.1*x[0]**3-.1*x[1]+1*sin(omega*t)]])
    return xdot

t, x, e, amps, phases = ms.hb_freq(duff_osc_ss, num_variables = 2, omega = 0.1,
                                   eqform='first_order', num_harmonics=5, num_time_steps=51,             
                                   mask_constant=True, f_rtol = 1e-8)#, f_rtol=1e-8)
time, xc = ms.time_history(t, x)
plt.plot(time, xc.T, label='5 harmonics')

Results in failed start.

num_harmonics =1 works fine. This would be a good fall-back call should convergence fail.