def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument("--I", type=float, default=1.0) parser.add_argument("--V", type=float, default=0.0) parser.add_argument("--m", type=float, default=1.0) parser.add_argument("--b", type=float, default=0.0) parser.add_argument("--s", type=str, default="u") parser.add_argument("--F", type=str, default="0") parser.add_argument("--dt", type=float, default=0.05) # parser.add_argument('--T', type=float, default=10) parser.add_argument("--T", type=float, default=20) parser.add_argument("--window_width", type=float, default=30.0, help="Number of periods in a window") parser.add_argument("--damping", type=str, default="linear") parser.add_argument("--savefig", action="store_true") # Hack to allow --SCITOOLS options (scitools.std reads this argument # at import) parser.add_argument("--SCITOOLS_easyviz_backend", default="matplotlib") a = parser.parse_args() from scitools.std import StringFunction s = StringFunction(a.s, independent_variable="u") F = StringFunction(a.F, independent_variable="t") I, V, m, b, dt, T, window_width, savefig, damping = ( a.I, a.V, a.m, a.b, a.dt, a.T, a.window_width, a.savefig, a.damping, ) u, t = solver(I, V, m, b, s, F, dt, T, damping) num_periods = plot_empirical_freq_and_amplitude(u, t) if num_periods <= 40: plt.figure() visualize(u, t) else: visualize_front(u, t, window_width, savefig) visualize_front_ascii(u, t) plt.show()
def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('--I', type=float, default=1.0) parser.add_argument('--V', type=float, default=0.0) parser.add_argument('--m', type=float, default=1.0) parser.add_argument('--b', type=float, default=0.0) parser.add_argument('--s', type=str, default='4*pi**2*u') parser.add_argument('--F', type=str, default='0') parser.add_argument('--dt', type=float, default=0.05) parser.add_argument('--T', type=float, default=20) parser.add_argument('--window_width', type=float, default=30., help='Number of periods in a window') parser.add_argument('--damping', type=str, default='linear') parser.add_argument('--savefig', action='store_true') # Hack to allow --SCITOOLS options # (scitools.std reads this argument at import) parser.add_argument('--SCITOOLS_easyviz_backend', default='matplotlib') a = parser.parse_args() from scitools.std import StringFunction s = StringFunction(a.s, independent_variable='u') F = StringFunction(a.F, independent_variable='t') I, V, m, b, dt, T, window_width, savefig, damping = \ a.I, a.V, a.m, a.b, a.dt, a.T, a.window_width, a.savefig, \ a.damping # compute u by both methods and then visualize the difference u, t = solver2(I, V, m, b, s, F, dt, T, damping) u_bw, _ = solver_bwdamping(I, V, m, b, s, F, dt, T, damping) u_diff = u - u_bw num_periods = plot_empirical_freq_and_amplitude(u_diff, t) if num_periods <= 40: plt.figure() legends = [ '1st-2nd order method', '2nd order method', '1st order method' ] visualize([(u_diff, t), (u, t), (u_bw, t)], legends) else: visualize_front(u_diff, t, window_width, savefig) #visualize_front_ascii(u_diff, t) plt.show()
def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('--I', type=float, default=1.0) parser.add_argument('--V', type=float, default=0.0) parser.add_argument('--m', type=float, default=1.0) parser.add_argument('--b', type=float, default=0.0) parser.add_argument('--s', type=str, default='4*pi**2*u') parser.add_argument('--F', type=str, default='0') parser.add_argument('--dt', type=float, default=0.05) parser.add_argument('--T', type=float, default=20) parser.add_argument('--window_width', type=float, default=30., help='Number of periods in a window') parser.add_argument('--damping', type=str, default='linear') parser.add_argument('--savefig', action='store_true') # Hack to allow --SCITOOLS options # (scitools.std reads this argument at import) parser.add_argument('--SCITOOLS_easyviz_backend', default='matplotlib') a = parser.parse_args() from scitools.std import StringFunction s = StringFunction(a.s, independent_variable='u') F = StringFunction(a.F, independent_variable='t') I, V, m, b, dt, T, window_width, savefig, damping = \ a.I, a.V, a.m, a.b, a.dt, a.T, a.window_width, a.savefig, \ a.damping # compute u by both methods and then visualize the difference u, t = solver2(I, V, m, b, s, F, dt, T, damping) u_bw, _ = solver_bwdamping(I, V, m, b, s, F, dt, T, damping) u_diff = u - u_bw num_periods = plot_empirical_freq_and_amplitude(u_diff, t) if num_periods <= 40: plt.figure() legends = ['1st-2nd order method', '2nd order method', '1st order method'] visualize([(u_diff, t), (u, t), (u_bw, t)], legends) else: visualize_front(u_diff, t, window_width, savefig) #visualize_front_ascii(u_diff, t) plt.show()
def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('--I', type=float, default=1.0) parser.add_argument('--V', type=float, default=0.0) parser.add_argument('--m', type=float, default=1.0) parser.add_argument('--b', type=float, default=0.0) parser.add_argument('--s', type=str, default='u') parser.add_argument('--F', type=str, default='0') parser.add_argument('--dt', type=float, default=0.05) #parser.add_argument('--T', type=float, default=10) parser.add_argument('--T', type=float, default=20) parser.add_argument('--window_width', type=float, default=30., help='Number of periods in a window') parser.add_argument('--damping', type=str, default='linear') parser.add_argument('--savefig', action='store_true') # Hack to allow --SCITOOLS options (scitools.std reads this argument # at import) parser.add_argument('--SCITOOLS_easyviz_backend', default='matplotlib') a = parser.parse_args() from scitools.std import StringFunction s = StringFunction(a.s, independent_variable='u') F = StringFunction(a.F, independent_variable='t') I, V, m, b, dt, T, window_width, savefig, damping = \ a.I, a.V, a.m, a.b, a.dt, a.T, a.window_width, a.savefig, \ a.damping u, t = solver(I, V, m, b, s, F, dt, T, damping) num_periods = plot_empirical_freq_and_amplitude(u, t) if num_periods <= 40: plt.figure() visualize(u, t) else: visualize_front(u, t, window_width, savefig) visualize_front_ascii(u, t) plt.show()