예제 #1
0
 def test_animated_plot(self):
     if show_plots:
         lim = 50
         short_data = vis.EvalData([
             self.test_data[0].input_data[0][0:lim],
             self.test_data[0].input_data[1][0:lim]
         ],
                                   self.test_data[0].output_data[0:lim,
                                                                 0:lim],
                                   name="short set")
         pt = vis.PgAnimatedPlot(self.test_data + [short_data],
                                 title="Test Plot")
         app.exec_()
예제 #2
0
    def test_trajectory(self):
        # build flatness based trajectory generator
        fs = tr.FlatString(y0=self.y0,
                           y1=self.y1,
                           z0=self.z_start,
                           z1=self.z_end,
                           t0=self.t_start,
                           dt=2,
                           params=self.params)
        zz, tt = np.meshgrid(self.z_values, self.t_values)
        x_values = fs.system_state(zz, tt)
        u_values = fs.control_input(self.t_values)
        eval_data_x = vis.EvalData([self.t_values, self.z_values], x_values)

        if show_plots:
            # plot stuff
            pw = pg.plot(title="control_input")
            pw.plot(self.t_values, u_values)
            ap = vis.PgAnimatedPlot(eval_data_x)
            app.exec_()
예제 #3
0
# compute power series for the desired in-domain intermediate (_id) fieldvariable (subdivided in x1_i & x2_i)
z_x1 = np.linspace(0, b, len(spatial_domain) * k1 / k)
x1_id_desired = tr.power_series(z_x1, t_x, C)
z_x2 = np.linspace(b, l, len(spatial_domain) * k2 / k)[1:]
x2_id_desired = tr.power_series(z_x2, t_x, C) - tr.power_series(
    z_x2 - b, t_x, D)
z_x = np.array(list(z_x1) + list(z_x2))
x_id = np.concatenate((x1_id_desired, x2_id_desired), axis=1)

# get the original system field variable: x = e^(-a1/2/a2*z)*x_id
x_desired = np.nan * np.zeros(x_id.shape)
for i in range(x_id.shape[0]):
    x_desired[i, :] = x_id[i, :] * np.exp(-a1 / 2 / a2 * z_x)

evald_xd = vis.EvalData([t_x, z_x], x_desired, name="x(z,t) power series")

# compute desired intermediate (_i) fieldvariable
C_i = tr.coefficient_recursion(y, alpha_i * y, param_i)
xi_desired = tr.power_series(z_x, t_x, C_i)
evald_xi_desired = vis.EvalData([t_x, z_x],
                                xi_desired,
                                name="x(z,t) power series")

# THE TOOLBOX OFFERS TWO WAYS TO GENERATE A TRAJECTORY FOR THE TARGET SYSTEM
if False:
    # First way: simply instantiate tr.RadTrajectory
    traj = tr.RadTrajectory(l,
                            T,
                            param_ti,
                            bound_cond_type,
예제 #4
0
traj = tr.RadTrajectory(l, T, param_t, bound_cond_type, actuation_type)

# 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()
예제 #5
0
                                                            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()