n = 2j #y1, y2, y3 = np.mgrid[0.1:0.9:n, 0.1:0.9:n, 0.1:0.9:n] y1, y2, y3 = np.mgrid[0.15:0.17:n, 0.15:0.17:n, 0.15:0.17:n] starting_yy1 = y1.flatten() starting_yy2 = y2.flatten() starting_yy3 = y3.flatten() final_y = list() responses = list() for i in range(len(starting_yy1)): res, y = simulate((starting_yy1[i], starting_yy2[i], starting_yy3[i]), t_begin=0.0, t_end=0.02, dt=.0001, stop=False) final_y.append(y) responses.append(res) final_y = np.array(final_y) end_points = np.array([y[-1] for y in final_y]) print("Endpoints in the plot.") plot_scatter(end_points) print("last 25 points in the plot") fig = plt.figure() for y in final_y: plot2(y[-25:], fig) plt.show() print("traces in the plot") fig = plt.figure() for y in final_y: plot2(y, fig) plt.show()
try: res = float(res) except: res = np.nan if res == np.nan: print "NaN" return res n = 4j y1, y2, y3 = np.mgrid[0.1:0.9:n, 0.1:0.9:n, 0.1:0.9:n] starting_yy1 = y1.flatten() starting_yy2 = y2.flatten() starting_yy3 = y3.flatten() starting_values = np.array([(starting_yy1[i], starting_yy2[i], starting_yy3[i]) for i in range(len(starting_yy1))]) bounds = ((0.0001, 0.9999), (0.0001, 0.9999), (0.0001, 0.9999)) x = list() results = list() for starting in starting_values: res = optimize.minimize(fe, starting, method='L-BFGS-B', bounds=bounds) x.append(res["x"]) results.append(res) yy = np.array(x) print("\n\nPlot is ready!") plot_scatter(yy)