def test_mpl_slice_plot(self): if show_plots: vis.MplSlicePlot(self.test_data + self.test_data + self.test_data, spatial_point=0.5, ylabel='$x(0,t)$', legend_label=['1', '2', '3', '4', '5', '6']) plt.show()
evald_shifted_x.output_data + evald_modal_xi.output_data - evald_modal_T0_xid.output_data, name="x_i(t) approximated") # evaluate approximation of x evald_fem_x = sim.evaluate_approximation("fem_funcs", q, t, spatial_domain, name="x(z,t) simulation") # pyqtgraph visualisations win1 = vis.PgAnimatedPlot( [evald_fem_x, evald_modal_xi, evald_appr_xi, evald_xd, evald_xi_desired], dt=temporal_domain.step) win2 = vis.PgSurfacePlot([evald_xd], title=evald_xd.name, grid_height=1) win3 = vis.PgSurfacePlot([evald_fem_x], title=evald_fem_x.name, grid_height=1) # plots vis.MplSurfacePlot([evald_appr_xi]) vis.MplSlicePlot( [evald_xd, evald_fem_x], spatial_point=0, legend_label=[evald_xd.name, evald_fem_x.name], ) # show pyqtgraph and matplotlib plots/visualizations pg.QtGui.QApplication.instance().exec_() plt.show()
# input with feedback control_law = sim.SimulationInputSum([traj, controller]) # determine (A,B) with modal-transfomation A = np.diag(eig_values) B = -a2 * np.array([eig_funcs[i].derive()(l) for i in range(n)]) ss = sim.StateSpace("eig_funcs", A, B, input_handle=control_law) # evaluate desired output data z_d = np.linspace(0, l, len(spatial_domain)) y_d, t_d = tr.gevrey_tanh(T, 80) C = tr.coefficient_recursion(np.zeros(y_d.shape), y_d, param) x_l = tr.power_series(z_d, t_d, C) evald_traj = vis.EvalData([t_d, z_d], x_l, name="x(z,t) desired") # simulate t, q = sim.simulate_state_space(ss, initial_weights, temporal_domain) # pyqtgraph visualization evald_x = sim.evaluate_approximation("eig_funcs", q, t, spatial_domain, name="x(z,t) with x(z,0)=" + str(init_profile)) win1 = vis.PgAnimatedPlot([evald_x, evald_traj], title="animation", dt=temporal_domain.step) win2 = vis.PgSurfacePlot([evald_x], title=evald_x.name, grid_height=1) win3 = vis.PgSurfacePlot([evald_traj], title=evald_traj.name, grid_height=1) pg.QtGui.QApplication.instance().exec_() # visualization vis.MplSlicePlot([evald_x, evald_traj], time_point=1, legend_label=["$x(z,1)$", "$x_d(z,1)$"], legend_location=2) plt.show()
d_approx_target_state=xd_ti_at_l, integral_kernel_zz=int_kernel_zz(l), original_beta=beta_i, target_beta=beta_ti, trajectory=traj, scale=transform_i(-l)) # determine (A,B) rad_pde = ut.get_parabolic_robin_weak_form("fem_funcs", "fem_funcs", controller, param, spatial_domain.bounds) cf = sim.parse_weak_formulation(rad_pde) ss_weak = cf.convert_to_state_space() # simulate t, q = sim.simulate_state_space(ss_weak, init_profile * np.ones(n_fem), temporal_domain) # evaluate desired output data y_d, t_d = tr.gevrey_tanh(T, 80) C = tr.coefficient_recursion(y_d, alpha * y_d, param) x_l = tr.power_series(np.array(spatial_domain), t_d, C) evald_traj = vis.EvalData([t_d, spatial_domain], x_l, name="x(z,t) desired") # pyqtgraph visualization eval_d = sim.evaluate_approximation("fem_funcs", q, t, spatial_domain, name="x(z,t) with x(z,0)=" + str(init_profile)) win1 = vis.PgAnimatedPlot([eval_d, evald_traj], title="animation", dt=temporal_domain.step) win2 = vis.PgSurfacePlot([eval_d], title=eval_d.name, grid_height=1) win3 = vis.PgSurfacePlot([evald_traj], title=evald_traj.name, grid_height=1) pg.QtGui.QApplication.instance().exec_() # matplotlib visualization vis.MplSlicePlot([evald_traj, eval_d], spatial_point=0, legend_label=["$x_d(0,t)$", "$x(0,t)$"]) plt.show()
rad_pde = ut.get_parabolic_robin_weak_form("fem_funcs", "fem_funcs", controller, param, spatial_domain.bounds) cf = sim.parse_weak_formulation(rad_pde) ss_weak = cf.convert_to_state_space() # simulate t, q = sim.simulate_state_space(ss_weak, np.zeros((len(fem_funcs))), temporal_domain) # pyqtgraph visualization evald_x = sim.evaluate_approximation("fem_funcs", q, t, spatial_domain, name="x(z,t)") win1 = vis.PgAnimatedPlot([evald_x], title="animation", dt=temporal_domain.step * .25) win2 = vis.PgSurfacePlot(evald_x, title=evald_x.name, grid_height=1) pg.QtGui.QApplication.instance().exec_() # visualization vis.MplSlicePlot([evald_x], time_point=1, legend_label=["$x(z,1)$"], legend_location=1) vis.MplSurfacePlot(evald_x) plt.show()