def dt_conv_test(dt_vals): error = np.zeros_like(dt_vals) params['plot'] = False for i in range(dt_vals.shape[0]): dt = dt_vals[i] params['delta_t'] = dt # params['t_max'] = dt error[i] = run() print error
def main(): # t_psim, Y_psim = mio.read_csv('bldc_startup_psim_1us_resolution.csv') # mp.plot_output(t_psim, Y_psim, '.') freq_sim = 1e6 # simulation frequency compress_factor = 3 time = pl.arange(0.0, 0.01, 1. / freq_sim) # create time slice vector X = np.zeros((time.size, dm.sv_size)) # allocate state vector Xdebug = np.zeros((time.size, dm.dv_size)) # allocate debug data vector Y = np.zeros((time.size, dm.ov_size)) # allocate output vector U = np.zeros((time.size, dm.iv_size)) # allocate input vector X0 = [0, mu.rad_of_deg(0.1), 0, 0, 0] # X[0, :] = X0 W = [0, 1] for i in range(1, time.size): if i == 1: Uim2 = np.zeros(dm.iv_size) else: Uim2 = U[i - 2, :] Y[i - 1, :] = dm.output(X[i - 1, :], Uim2) # get the output for the last step U[i - 1, :] = ctl.run(0, Y[i - 1, :], time[i - 1]) # run the controller for the last step tmp = integrate.odeint(dm.dyn, X[i - 1, :], [time[i - 1], time[i]], args=(U[i - 1, :], W)) # integrate X[i, :] = tmp[1, :] # copy integration output to the current step X[i, dm.sv_theta] = mu.norm_angle( X[i, dm.sv_theta]) # normalize the angle in the state tmp, Xdebug[i, :] = dm.dyn_debug(X[i - 1, :], time[i - 1], U[i - 1, :], W) # get debug data print_simulation_progress(i, time.size) Y[-1, :] = Y[-2, :] U[-1, :] = U[-2, :] if compress_factor > 1: time = compress(time, compress_factor) Y = compress(Y, compress_factor) X = compress(X, compress_factor) U = compress(U, compress_factor) Xdebug = compress(Xdebug, compress_factor) mp.plot_output(time, Y, '-') # pl.show() plt.figure(figsize=(10.24, 5.12)) display_state_and_command(time, X, U) plt.figure(figsize=(10.24, 5.12)) mp.plot_debug(time, Xdebug) pl.show()
def main(): # t_psim, Y_psim = mio.read_csv('bldc_startup_psim_1us_resolution.csv') # mp.plot_output(t_psim, Y_psim, '.') freq_sim = 1e6 # simulation frequency compress_factor = 3 time = pl.arange(0.0, 0.01, 1./freq_sim) # create time slice vector X = np.zeros((time.size, dm.sv_size)) # allocate state vector Xdebug = np.zeros((time.size, dm.dv_size)) # allocate debug data vector Y = np.zeros((time.size, dm.ov_size)) # allocate output vector U = np.zeros((time.size, dm.iv_size)) # allocate input vector X0 = [0, mu.rad_of_deg(0.1), 0, 0, 0] # X[0,:] = X0 W = [0, 1] for i in range(1,time.size): if i==1: Uim2 = np.zeros(dm.iv_size) else: Uim2 = U[i-2,:] Y[i-1,:] = dm.output(X[i-1,:], Uim2) # get the output for the last step U[i-1,:] = ctl.run(0, Y[i-1,:], time[i-1]) # run the controller for the last step tmp = integrate.odeint(dm.dyn, X[i-1,:], [time[i-1], time[i]], args=(U[i-1,:], W)) # integrate X[i,:] = tmp[1,:] # copy integration output to the current step X[i, dm.sv_theta] = mu.norm_angle( X[i, dm.sv_theta]) # normalize the angle in the state tmp, Xdebug[i,:] = dm.dyn_debug(X[i-1,:], time[i-1], U[i-1,:], W) # get debug data print_simulation_progress(i, time.size) Y[-1,:] = Y[-2,:] U[-1,:] = U[-2,:] if compress_factor > 1: time = compress(time, compress_factor) Y = compress(Y, compress_factor) X = compress(X, compress_factor) U = compress(U, compress_factor) Xdebug = compress(Xdebug, compress_factor) mp.plot_output(time, Y, '-') # pl.show() plt.figure(figsize=(10.24, 5.12)) display_state_and_command(time, X, U) plt.figure(figsize=(10.24, 5.12)) mp.plot_debug(time, Xdebug) pl.show()
from pyzt import inputi,inputs,inputf import platform import settings if _name_ == '_main_': if platform.python_version()[0] == '3': import control control=control.Control() if settings.DEBUG: print("DEBUG MODE") else: control.run() else: exit("SHOP: Unsupported Python Version!")
def star_test(): script = request.form.to_dict()['detail '] control.run(script) return '开始测试'
else: #没有下一页就退出循环 break except: STATE = False else: models.IdFinished.objects( year=queryset.year).update(add_to_set__ids=[process]) if STATE: this.update(set__state=2) else: this.update(set__state=3) this.update(set__inprocess=False) def mtime_worker(): terminating = multiprocessing.Event() w = Worker(mapper, initializer=initializer, initargs=(terminating, )) try: w.run() except: error('Other error') def main(): periodic(scheduler, mtime_worker) scheduler.run() if __name__ == '__main__': run(main, __file__)
def control_post(): if request.method == 'POST': results = control.run(request) return results else: return render_template('post.html')
host = config.get( sec, "host" ) path = config.get( sec, "path" ) platform = config.get( sec, "platform" ) print( "** Add FTP location {0}:{1} ({2})".format( host, path, platform ) ) source.addLocation( host, path, platform ) except ConfigParser.NoSectionError: found = False cdashHost = utils.get_config_option( config, None, "host", "", "CDash" ) cdashLocation = utils.get_config_option( config, None, "location", "", "CDash" ) cdashProject = utils.get_config_option( config, None, "project", "", "CDash" ) if len( cdashHost ) > 0: reporter = cdashreporter.CDashReporter( cdashHost, cdashLocation, cdashProject ) else: reporter = reporter.Reporter() control = control.Control( vmrun, checkerInstallation, source, reporter ) control.setGuiEnabled( useGui ) control.setCreateErrorSnapshots( createErrorSnapshots ) if len( hostType ) > 0: control.setRemoteHost( hostType, hostLocation, hostUsername, hostPassword ) for i in vms: control.addVM( i ) for i in testcases: control.addTestCase( i ) control.run()
from control import run from params import params params['plot'] = True # params['adaptive_mesh'] = False # params['all_steps_adaptive'] = False params['x_min'] = 10.0 # params['x_points'] = 200 # params['y_points'] = 200 params['t_max'] = 100.0 * 3600 * 24 * 365.0 params['adapt_tol'] = 1e-5 params['delta_t'] = params['t_max'] / 128.0 params['t_max'] = params['t_max'] / 1.0 run()
def action(): result = entry.get().strip() print(result) control2 = control.Order() control.run(result)
def run(self, **kwargs): """ Calls :func:`run` with the same parameters. """ run(self, **kwargs)