コード例 #1
0
ファイル: test_trajectory.py プロジェクト: schwinma/pyinduct
    def test_temporal_derive(self):

        b_desired = 0.4
        k = 5  # = k1 + k2
        k1, k2, b = ut.split_domain(k, b_desired, self.l, mode='coprime')[0:3]
        # q
        E = tr.coefficient_recursion(self.y, self.beta * self.y, self.param)
        q = tr.temporal_derived_power_series(self.l - b, E,
                                             int(self.n_y / 2) - 1, self.n_y)
        # u
        B = tr.coefficient_recursion(self.y, self.alpha * self.y, self.param)
        xq = tr.temporal_derived_power_series(self.l,
                                              B,
                                              int(self.n_y / 2) - 1,
                                              self.n_y,
                                              spatial_der_order=0)
        d_xq = tr.temporal_derived_power_series(self.l,
                                                B,
                                                int(self.n_y / 2) - 1,
                                                self.n_y,
                                                spatial_der_order=1)
        u = d_xq + self.beta * xq
        # x(0,t)
        C = tr.coefficient_recursion(q, self.beta * q, self.param)
        D = tr.coefficient_recursion(np.zeros(u.shape), u, self.param)
        x_0t = tr.power_series(0, self.t, C)
        if show_plots:
            pw = pg.plot(title="control_input")
            pw.plot(self.t, x_0t)
            app.exec_()
コード例 #2
0
ファイル: test_trajectory.py プロジェクト: TanDro/pyinduct
    def test_temporal_derive(self):

        b_desired = 0.4
        k = 5 # = k1 + k2
        k1, k2, b = ut.split_domain(k, b_desired, self.l, mode='coprime')[0:3]
        # q
        E = tr.coefficient_recursion(self.y, self.beta*self.y, self.param)
        q = tr.temporal_derived_power_series(self.l-b, E, int(self.n_y/2)-1, self.n_y)
        # u
        B = tr.coefficient_recursion(self.y, self.alpha*self.y, self.param)
        xq = tr.temporal_derived_power_series(self.l, B, int(self.n_y/2)-1, self.n_y, spatial_der_order=0)
        d_xq = tr.temporal_derived_power_series(self.l, B, int(self.n_y/2)-1, self.n_y, spatial_der_order=1)
        u = d_xq + self.beta*xq
        # x(0,t)
        C = tr.coefficient_recursion(q, self.beta*q, self.param)
        D = tr.coefficient_recursion(np.zeros(u.shape), u, self.param)
        x_0t = tr.power_series(0, self.t, C)
        if show_plots:
            pw = pg.plot(title="control_input")
            pw.plot(self.t, x_0t)
            app.exec_()
コード例 #3
0
ファイル: test_trajectory.py プロジェクト: TanDro/pyinduct
    def test_recursion_vs_explicit(self):

        # recursion
        B = tr.coefficient_recursion(self.y, self.alpha*self.y, self.param)
        x_l = tr.power_series(self.l, self.t, B)
        d_x_l = tr.power_series(self.l, self.t, B, spatial_der_order=1)
        u_c = d_x_l + self.beta*x_l
        u_a = tr.InterpTrajectory(self.t, u_c, show_plot=show_plots)
        u_a_t = u_a(time=self.t)
        # explicit
        u_b = tr.RadTrajectory(self.l, self.T, self.param, "robin", "robin", n=self.n_y, show_plot=show_plots)
        u_b_t = u_b(time=self.t)
        self.assertTrue(all(np.isclose(u_b_t, u_a_t, atol=0.005)))
        if show_plots:
            pw = pg.plot(title="control_input")
            pw.plot(self.t, u_a_t)
            pw.plot(self.t, u_b_t)
            app.exec_()
コード例 #4
0
ファイル: test_trajectory.py プロジェクト: schwinma/pyinduct
    def test_recursion_vs_explicit(self):

        # recursion
        B = tr.coefficient_recursion(self.y, self.alpha * self.y, self.param)
        x_l = tr.power_series(self.l, self.t, B)
        d_x_l = tr.power_series(self.l, self.t, B, spatial_der_order=1)
        u_c = d_x_l + self.beta * x_l
        u_a = tr.InterpTrajectory(self.t, u_c, show_plot=show_plots)
        u_a_t = u_a(time=self.t)
        # explicit
        u_b = tr.RadTrajectory(self.l,
                               self.T,
                               self.param,
                               "robin",
                               "robin",
                               n=self.n_y,
                               show_plot=show_plots)
        u_b_t = u_b(time=self.t)
        self.assertTrue(all(np.isclose(u_b_t, u_a_t, atol=0.005)))
        if show_plots:
            pw = pg.plot(title="control_input")
            pw.plot(self.t, u_a_t)
            pw.plot(self.t, u_b_t)
            app.exec_()
コード例 #5
0
k1, k2, b = ut.split_domain(k, b_desired, l, mode='coprime')[0:3]
M = np.linalg.inv(ut.get_inn_domain_transformation_matrix(k1, k2, mode="2n"))

# original intermediate ("_i") and target intermediate ("_ti") system parameters
_, _, a0_i, alpha_i, beta_i = ef.transform2intermediate(param)
param_i = a2, 0, a0_i, alpha_i, beta_i
_, _, a0_ti, alpha_ti, beta_ti = ef.transform2intermediate(param_t)
param_ti = a2, 0, a0_ti, alpha_ti, beta_ti

# COMPUTE DESIRED FIELDVARIABLE
# THE NAMING OF THE POWER SERIES COEFFICIENTS IS BASED ON THE PUBLICATION:
#      - WANG; WOITTENNEK:BACKSTEPPING-METHODE FUER PARABOLISCHE SYSTEM MIT PUNKTFOERMIGEM INNEREN EINGRIFF
# compute input u_i of the boundary-controlled intermediate (_i) system with n_y/2 temporal derivatives
n_y = 80
y, t_x = tr.gevrey_tanh(T, n_y, 1.1, 2)
B = tr.coefficient_recursion(y, alpha_i * y, param_i)
x_i_at_l = tr.temporal_derived_power_series(l, B, int(n_y / 2) - 1, n_y, spatial_der_order=0)
dx_i_at_l = tr.temporal_derived_power_series(l, B, int(n_y / 2) - 1, n_y, spatial_der_order=1)
u_i = dx_i_at_l + beta_i * x_i_at_l

# compute coefficients C, D and E for the power series
E = tr.coefficient_recursion(y, beta_i * y, param_i)
q = tr.temporal_derived_power_series(l - b, E, int(n_y / 2) - 1, n_y)
C = tr.coefficient_recursion(q, alpha_i * q, param_i)
D = tr.coefficient_recursion(np.zeros(u_i.shape), u_i, param_i)

# 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)
コード例 #6
0
k1, k2, b = ut.split_domain(k, b_desired, l, mode='coprime')[0:3]
M = np.linalg.inv(ut.get_inn_domain_transformation_matrix(k1, k2, mode="2n"))

# original intermediate ("_i") and target intermediate ("_ti") system parameters
_, _, a0_i, alpha_i, beta_i = ef.transform2intermediate(param)
param_i = a2, 0, a0_i, alpha_i, beta_i
_, _, a0_ti, alpha_ti, beta_ti = ef.transform2intermediate(param_t)
param_ti = a2, 0, a0_ti, alpha_ti, beta_ti

# COMPUTE DESIRED FIELDVARIABLE
# THE NAMING OF THE POWER SERIES COEFFICIENTS IS BASED ON THE PUBLICATION:
#      - WANG; WOITTENNEK:BACKSTEPPING-METHODE FUER PARABOLISCHE SYSTEM MIT PUNKTFOERMIGEM INNEREN EINGRIFF
# compute input u_i of the boundary-controlled intermediate (_i) system with n_y/2 temporal derivatives
n_y = 80
y, t_x = tr.gevrey_tanh(T, n_y, 1.1, 2)
B = tr.coefficient_recursion(y, alpha_i * y, param_i)
x_i_at_l = tr.temporal_derived_power_series(l,
                                            B,
                                            int(n_y / 2) - 1,
                                            n_y,
                                            spatial_der_order=0)
dx_i_at_l = tr.temporal_derived_power_series(l,
                                             B,
                                             int(n_y / 2) - 1,
                                             n_y,
                                             spatial_der_order=1)
u_i = dx_i_at_l + beta_i * x_i_at_l

# compute coefficients C, D and E for the power series
E = tr.coefficient_recursion(y, beta_i * y, param_i)
q = tr.temporal_derived_power_series(l - b, E, int(n_y / 2) - 1, n_y)
コード例 #7
0
ファイル: parabolic_minimal.py プロジェクト: rihe/pyinduct
# init trajectory
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 xrange(n)])
ss = sim.StateSpace("eig_funcs", A, B)

# 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, control_law, initial_weights, temporal_domain)

# pyqtgraph visualization
evald_x = ut.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=T / len(temporal_domain) * 4)
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
コード例 #8
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, cf.input_function, 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 = ut.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=T / len(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()
コード例 #9
0
# init trajectory
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
コード例 #10
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()