Ejemplo n.º 1
0
    def _get_fold_task(self):
        x_1 = self.init_displ_task.x_1
        cp = self.factory_task

        n_l_h = cp.N_h[0, :].flatten()
        n_r_h = cp.N_h[-1, :].flatten()
        n_lr_h = cp.N_h[(0, -1), :].flatten()
        n_fixed_y = cp.N_h[(0, -1), 1].flatten()

        u_max = self.u_x
        dof_constraints = fix(n_l_h, [0], lambda t: t * u_max) + fix(n_lr_h, [2]) + \
            fix(n_fixed_y, [1]) + fix(n_r_h, [0], lambda t: t * -u_max) + \
            link(cp.N_v[0, :].flatten(), 0, 1.0,
                 cp.N_v[1, :].flatten(), 0, 1.0) + \
            link(cp.N_i[:, 0].flatten(), 2, 1.0,
                 cp.N_i[:, -1].flatten(), 2, -1.0)

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(
            goal_function_type='gravity potential energy',
            gu={
                'cl': gu_constant_length,
                'dofs': gu_dof_constraints
            },
            acc=1e-5,
            MAX_ITER=500,
            debug_level=0)
        return SimulationTask(previous_task=self.init_displ_task,
                              config=sim_config,
                              n_steps=self.n_steps)
    def _get_fold_task(self):
        self.init_displ_task.x_1
        u_max = self.u_max
        fixed_nodes_x = fix([12, 14], (0))
        fixed_nodes_z = fix([1, 7, 10, 16, 19, 25], (2))
        fixed_nodes_y = fix([1, 25], (1))
        link_mid = link((6, 7, 8, 15, 16, 17, 24, 25, 26), (0), 1.0,
                        (0, 1, 2, 9, 10, 11, 18, 19, 20), (0), -1.0,
                        lambda t: -t * u_max)
        sym_y = link([0, 6, 9, 15, 18, 24], [2], 1.0, [2, 8, 11, 17, 20, 26],
                     [2], -1.0)

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y + \
            link_mid + sym_y
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(
            goal_function_type='gravity potential energy',
            gu={
                'cl': gu_constant_length,
                'dofs': gu_dof_constraints
            },
            acc=1e-5,
            MAX_ITER=500,
            debug_level=0)

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config,
                            n_steps=self.n_fold_steps)

        cp = st.formed_object
        cp.u[(
            4,
            13,
            22,
            3,
            12,
            21,
            5,
            14,
            23,
            28,
            30,
            36,
            42,
            27,
            29,
            35,
            41,
        ), 2] -= 0.2

        return st
Ejemplo n.º 3
0
    def _get_load_task(self):
        self.turn_task.x_1

        fixed_nodes_yz = fix([0, 2, 20,  22], (1, 2))  # + \
        fixed_nodes_x = fix([0, 2, 20, 22], (0))  # + \
        #    fix([1, 21], [0, 2])

        link_bnd = link([48, 49, 50, 56, 57, 58, 64, 65, 66, 72, 73, 74],
                        [0, 1, 2], 1.0,
                        [51, 52, 53, 59, 60, 61, 67, 68, 69, 75, 76, 77],
                        [0, 1, 2], -1.0)

        dof_constraints = fixed_nodes_x + fixed_nodes_yz + link_bnd
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='total potential energy',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints},
                                      acc=1e-5, MAX_ITER=1000,
                                      debug_level=0)
        load_nodes = [10, 11, 12]
        FN = lambda F: lambda t: t * F
        F_ext_list = [(n, 2, FN(-10)) for n in load_nodes]
        fu_tot_poteng = FuPotEngTotal(kappa=np.array([10]),
                                      F_ext_list=F_ext_list)  # (2 * n, 2, -1)])
        sim_config._fu = fu_tot_poteng
        st = SimulationTask(previous_task=self.turn_task,
                            config=sim_config, n_steps=1)
        fu_tot_poteng.forming_task = st
        cp = st.formed_object
        cp.x_0 = self.turn_task.x_1
        cp.u[:, :] = 0.0
        return st
Ejemplo n.º 4
0
    def _get_fold_task(self):
        self.init_displ_task.x_1

        fixed_z = fix(self.fixed_z, (2))
        fixed_y = fix(self.fixed_y, (1))
        fixed_x = fix(self.fixed_x, (0))
        link_z = link(self.link_z[0], [2], 1, self.link_z[1], [2], -1)

        dof_constraints = fixed_x + fixed_z + fixed_y + \
            link_z
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi): return lambda t: psi * t

        psi_constr = [([(i, 1.0)], FN(self.psi_max))
                      for i in self.psi_lines]

        gu_constant_length = GuConstantLength()

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=self.init_displ_task,
                             psi_constraints=psi_constr)

        sim_config = SimulationConfig(goal_function_type='gravity potential energy',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          'psi': gu_psi_constraints
                                          },
                                      acc=1e-5, MAX_ITER=500,
                                      debug_level=0)
        return SimulationTask(previous_task=self.init_displ_task,
                              config=sim_config, n_steps=self.n_steps)
Ejemplo n.º 5
0
    def get_merge_nodes_task(self,
                             prev_ft,
                             merge_nodes=[[]],
                             link_nodes=[],
                             fix_node=[],
                             stiff_lines=[],
                             init_nodes=(),
                             init_val=0.0):

        cp = self.factory_task.formed_object

        psi_constr = [
            ([(i, 1.0)], lambda t: self.fix_psi * t)  # fold_step(t, i))
            for i in stiff_lines
        ]

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=prev_ft,
                             psi_constraints=psi_constr)

        F_u_fix = cp.F_N[1]
        dof_constraints = fix([F_u_fix[0]], [0, 1, 2]) + \
            fix([F_u_fix[1]], [1, 2]) + \
            fix([F_u_fix[2]], [2])

        if len(link_nodes) > 0:
            ln = np.array(link_nodes, dtype=np.int_)
            link_nodes1, link_nodes2 = ln.T
            ldofs = link(link_nodes1, [0, 1, 2], 1.0, link_nodes2, [0, 1, 2],
                         -1.0)
            dof_constraints += ldofs

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()

        sim_config = SimulationConfig(
            goal_function_type='total potential energy',
            gu={
                'cl': gu_constant_length,
                'gu': gu_dof_constraints,
                'psi': gu_psi_constraints
            },
            acc=1e-5,
            MAX_ITER=500)

        fu_node_dist = \
            FuNodeDist(forming_task=prev_ft,
                       L=merge_nodes,
                       )

        sim_config._fu = fu_node_dist

        st = SimulationTask(previous_task=prev_ft,
                            config=sim_config,
                            n_steps=1)

        fu_node_dist.forming_task = st

        cp = st.formed_object
        return st
Ejemplo n.º 6
0
    def _get_fold_task(self):
        self.init_displ_task.x_1

        fixed_z = fix(self.fixed_z, (2))
        fixed_y = fix(self.fixed_y, (1))
        fixed_x = fix(self.fixed_x, (0))
        link_z = link(self.link_z[0], [2], 1, self.link_z[1], [2], -1)

        dof_constraints = fixed_x + fixed_z + fixed_y + \
            link_z
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        FN = lambda psi: lambda t: psi * t

        psi_constr = [([(i, 1.0)], FN(self.psi_max)) for i in self.psi_lines]

        gu_constant_length = GuConstantLength()

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=self.init_displ_task,
                             psi_constraints=psi_constr)

        sim_config = SimulationConfig(
            goal_function_type='gravity potential energy',
            gu={
                'cl': gu_constant_length,
                'dofs': gu_dof_constraints,
                'psi': gu_psi_constraints
            },
            acc=1e-5,
            MAX_ITER=500,
            debug_level=0)
        return SimulationTask(previous_task=self.init_displ_task,
                              config=sim_config,
                              n_steps=self.n_steps)
Ejemplo n.º 7
0
    def _get_fold_deform_task(self):
        ft = self.factory_task

        self.init_displ_task.x_1

        fixed_z = fix(self.fixed_z, (2))
        fixed_y = fix(self.fixed_y, (1))
        fixed_x = fix(self.fixed_x, (0))
        link_z = link(self.link_z[0], [2], 1, self.link_z[1], [2], -1)

        dof_constraints = fixed_x + fixed_z + fixed_y + \
            link_z
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi):
            return lambda t: psi * t

        psi_constr = [([(i, 1.0)], FN(self.psi_max)) for i in self.psi_lines]

        gu_constant_length = GuConstantLength()

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=ft,
                             psi_constraints=psi_constr)

        sim_config = SimulationConfig(
            goal_function_type='gravity potential energy',
            gu={
                'cl': gu_constant_length,
                'dofs': gu_dof_constraints,
                'psi': gu_psi_constraints
            },
            acc=1e-5,
            MAX_ITER=self.MAXITER,
            debug_level=0)

        fu_tot_poteng = FuPotEngTotal(kappa=np.array([self.kappa]),
                                      F_ext_list=[],
                                      rho=self.rho,
                                      exclude_lines=self.psi_lines)

        sim_config._fu = fu_tot_poteng

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config,
                            n_steps=self.n_steps)

        #
        #         st = SimulationTask(previous_task=ft,
        #                             config=sim_config, n_steps=self.n_steps)
        fu_tot_poteng.forming_task = st
        #         gu_psi_constraints.forming_task = st
        #
        #         cp = st.formed_object
        #         cp.u = it.u_1

        return st
Ejemplo n.º 8
0
    def _get_load_task(self):
        self.turn_task.x_1

        fixed_nodes_yz = fix([0, 2, 20, 22], (1, 2))  # + \
        fixed_nodes_x = fix([0, 2, 20, 22], (0))  # + \
        #    fix([1, 21], [0, 2])
        link_bnd = []
        if self.stiffening_boundary:
            link_bnd = link([48, 49, 50, 56, 57, 58, 64, 65, 66, 72, 73, 74],
                            [0, 1, 2], 1.0,
                            [51, 52, 53, 59, 60, 61, 67, 68, 69, 75, 76, 77],
                            [0, 1, 2], -1.0)

        dof_constraints = fixed_nodes_x + fixed_nodes_yz + link_bnd
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(
            goal_function_type='total potential energy',
            gu={
                'cl': gu_constant_length,
                'dofs': gu_dof_constraints
            },
            acc=1e-5,
            MAX_ITER=1000,
            debug_level=0)

        def FN(F):
            return lambda t: t * F

        H = 0
        P = 3.5 * self.load_factor
        F_ext_list = [(33, 2, FN(-P)), (34, 2, FN(-P)), (11, 2, FN(-P)),
                      (39, 2, FN(-P)), (40, 2, FN(-P)), (4, 0, FN(0.1609 * H)),
                      (4, 2, FN(-0.2385 * H)), (10, 2, FN(-0.3975 * H)),
                      (16, 0, FN(-0.1609 * H)), (16, 2, FN(-0.2385 * H)),
                      (6, 0, FN(0.1609 * H)), (6, 2, FN(-0.2385 * H)),
                      (12, 2, FN(-0.3975 * H)), (18, 0, FN(-0.1609 * H)),
                      (18, 2, FN(-0.2385 * H))]

        fu_tot_poteng = FuPotEngTotal(kappa=np.array([5.28]),
                                      F_ext_list=F_ext_list)

        #         load_nodes = [10, 11, 12]
        #         FN = lambda F: lambda t: t * F
        #         F_ext_list = [(n, 2, FN(-10)) for n in load_nodes]
        #         fu_tot_poteng = FuPotEngTotal(kappa=np.array([10]),
        # F_ext_list=F_ext_list)  # (2 * n, 2, -1)])
        sim_config._fu = fu_tot_poteng
        st = SimulationTask(previous_task=self.turn_task,
                            config=sim_config,
                            n_steps=self.n_load_steps)
        fu_tot_poteng.forming_task = st
        cp = st.formed_object
        cp.x_0 = self.turn_task.x_1
        cp.u[:, :] = 0.0
        return st
Ejemplo n.º 9
0
    def _get_fold_deform_task(self):
        ft = self.factory_task

        self.init_displ_task.x_1

        fixed_z = fix(self.fixed_z, (2))
        fixed_y = fix(self.fixed_y, (1))
        fixed_x = fix(self.fixed_x, (0))
        link_z = link(self.link_z[0], [2], 1, self.link_z[1], [2], -1)

        dof_constraints = fixed_x + fixed_z + fixed_y + \
            link_z
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi): return lambda t: psi * t

        psi_constr = [([(i, 1.0)], FN(self.psi_max))
                      for i in self.psi_lines]

        gu_constant_length = GuConstantLength()

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=ft,
                             psi_constraints=psi_constr)

        sim_config = SimulationConfig(goal_function_type='gravity potential energy',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          'psi': gu_psi_constraints
                                          },
                                      acc=1e-5, MAX_ITER=self.MAXITER,
                                      debug_level=0)

        fu_tot_poteng = FuPotEngTotal(kappa=np.array([self.kappa]),
                                      F_ext_list=[],
                                      rho=self.rho,
                                      exclude_lines=self.psi_lines)

        sim_config._fu = fu_tot_poteng

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_steps)

#
#         st = SimulationTask(previous_task=ft,
#                             config=sim_config, n_steps=self.n_steps)
        fu_tot_poteng.forming_task = st
#         gu_psi_constraints.forming_task = st
#
#         cp = st.formed_object
#         cp.u = it.u_1

        return st
Ejemplo n.º 10
0
    def get_merge_nodes_task(self, prev_ft, merge_nodes=[[]],
                             link_nodes=[], fix_node=[],
                             stiff_lines=[], init_nodes=(), init_val=0.0):

        cp = self.factory_task.formed_object

        psi_constr = [([(i, 1.0)], lambda t: self.fix_psi * t)  # fold_step(t, i))
                      for i in stiff_lines]

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=prev_ft,
                             psi_constraints=psi_constr)

        F_u_fix = cp.F_N[1]
        dof_constraints = fix([F_u_fix[0]], [0, 1, 2]) + \
            fix([F_u_fix[1]], [1, 2]) + \
            fix([F_u_fix[2]], [2])

        if len(link_nodes) > 0:
            ln = np.array(link_nodes, dtype=np.int_)
            link_nodes1, link_nodes2 = ln.T
            ldofs = link(
                link_nodes1, [0, 1, 2], 1.0,
                link_nodes2, [0, 1, 2], -1.0)
            dof_constraints += ldofs

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()

        sim_config = SimulationConfig(goal_function_type='total potential energy',
                                      gu={'cl': gu_constant_length,
                                          'gu': gu_dof_constraints,
                                          'psi': gu_psi_constraints},
                                      acc=1e-5, MAX_ITER=500)

        fu_node_dist = \
            FuNodeDist(forming_task=prev_ft,
                       L=merge_nodes,
                       )

        sim_config._fu = fu_node_dist

        st = SimulationTask(previous_task=prev_ft,
                            config=sim_config,
                            n_steps=1)

        fu_node_dist.forming_task = st

        cp = st.formed_object
        return st
Ejemplo n.º 11
0
    def _get_fold_task(self):
        pt = self.init_displ_task

        cp = self.init_displ_task.formed_object
        cp.u[(26, 25, 24, 23), 2] = 0.5

        H = pt.x_1[42, 2]
        Z0_r = pt.x_1[7, 2]

        fixed_nodes_z = fix(
            [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42], (2),
            lambda t: H)
        fixed_nodes_xr = fix(
            [3, 4, 5, 6, 7], (2),
            lambda t: Z0_r - t * 0.32)
        fixed_nodes_xl = fix(
            [15, 16, 17, 18, 19], (2),
            lambda t: Z0_r - t * 0.32)
        fixed_nodes_y = fix(
            [42, 36], (1))
        fixed_nodes_x = fix(
            [36], (0))
        front_facet = link([13], 2, 1.0, [14], 2, -1.0)
        back_facet = link([8], 2, 1.0, [9], 2, -1.0)

        dof_constraints = fixed_nodes_z + fixed_nodes_xl + fixed_nodes_xr +\
            front_facet + back_facet +\
            fixed_nodes_y + fixed_nodes_x
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='gravity potential energy',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints},
                                      acc=1e-5, MAX_ITER=500,
                                      debug_level=0)
        return SimulationTask(previous_task=self.init_displ_task,
                              config=sim_config, n_steps=self.n_steps)
Ejemplo n.º 12
0
    def _get_fold_task(self):
        pt = self.init_displ_task

        cp = self.init_displ_task.formed_object
        cp.u[(26, 25, 24, 23), 2] = 0.5

        H = pt.x_1[42, 2]
        Z0_r = pt.x_1[7, 2]

        fixed_nodes_z = fix([31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42],
                            (2), lambda t: H)
        fixed_nodes_xr = fix([3, 4, 5, 6, 7], (2), lambda t: Z0_r - t * 0.32)
        fixed_nodes_xl = fix([15, 16, 17, 18, 19], (2),
                             lambda t: Z0_r - t * 0.32)
        fixed_nodes_y = fix([42, 36], (1))
        fixed_nodes_x = fix([36], (0))
        front_facet = link([13], 2, 1.0, [14], 2, -1.0)
        back_facet = link([8], 2, 1.0, [9], 2, -1.0)

        dof_constraints = fixed_nodes_z + fixed_nodes_xl + fixed_nodes_xr +\
            front_facet + back_facet +\
            fixed_nodes_y + fixed_nodes_x
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(
            goal_function_type='gravity potential energy',
            gu={
                'cl': gu_constant_length,
                'dofs': gu_dof_constraints
            },
            acc=1e-5,
            MAX_ITER=500,
            debug_level=0)
        return SimulationTask(previous_task=self.init_displ_task,
                              config=sim_config,
                              n_steps=self.n_steps)
Ejemplo n.º 13
0
    def _get_load_task(self):
        self.turn_task.x_1

        fixed_nodes_yz = fix([0, 2, 20,  22], (1, 2))  # + \
        fixed_nodes_x = fix([0, 2, 20, 22], (0))  # + \
        #    fix([1, 21], [0, 2])
        link_bnd = []
        if self.stiffening_boundary:
            link_bnd = link([48, 49, 50, 56, 57, 58, 64, 65, 66, 72, 73, 74],
                            [0, 1, 2], 1.0,
                            [51, 52, 53, 59, 60, 61, 67, 68, 69, 75, 76, 77],
                            [0, 1, 2], -1.0)

        dof_constraints = fixed_nodes_x + fixed_nodes_yz + link_bnd
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='total potential energy',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints},
                                      acc=1e-5, MAX_ITER=1000,
                                      debug_level=0)

        FN = lambda F: lambda t: t * F

        H = 0
        P = 3.5 * self.load_factor
        F_ext_list = [(33, 2, FN(-P)), (34, 2, FN(-P)), (11, 2, FN(-P)), (39, 2, FN(-P)), (40, 2, FN(-P)), (4, 0, FN(0.1609 * H)), (4, 2, FN(-0.2385 * H)), (10, 2, FN(-0.3975 * H)), (16, 0, FN(-0.1609 * H)), (16, 2, FN(-0.2385 * H)),
                      (6, 0, FN(0.1609 * H)), (6, 2, FN(-0.2385 * H)), (12, 2, FN(-0.3975 * H)), (18, 0, FN(-0.1609 * H)), (18, 2, FN(-0.2385 * H))]

        fu_tot_poteng = FuPotEngTotal(kappa=np.array([5.28]),
                                      F_ext_list=F_ext_list)


#         load_nodes = [10, 11, 12]
#         FN = lambda F: lambda t: t * F
#         F_ext_list = [(n, 2, FN(-10)) for n in load_nodes]
#         fu_tot_poteng = FuPotEngTotal(kappa=np.array([10]),
# F_ext_list=F_ext_list)  # (2 * n, 2, -1)])
        sim_config._fu = fu_tot_poteng
        st = SimulationTask(previous_task=self.turn_task,
                            config=sim_config, n_steps=self.n_load_steps)
        fu_tot_poteng.forming_task = st
        cp = st.formed_object
        cp.x_0 = self.turn_task.x_1
        cp.u[:, :] = 0.0
        return st
Ejemplo n.º 14
0
    def _get_fold_task(self):
        x_1 = self.init_displ_task.x_1
        cp = self.factory_task

        n_l_h = cp.N_h[0, :].flatten()
        n_r_h = cp.N_h[-1, :].flatten()
        n_lr_h = cp.N_h[(0, -1), :].flatten()
        n_fixed_y = cp.N_h[(0, -1), 1].flatten()

        u_max = self.u_x
        dof_constraints = fix([0, 2, 4], [0], lambda t: t * u_max) + fix([0, 2, 4, 20, 22, 24], [2]) + \
            fix([2, 22], [1]) + fix([20, 22, 24], [0], lambda t: t * -u_max) + \
            link(cp.N_v[0, :].flatten(), 0, 1.0,
                 cp.N_v[1, :].flatten(), 0, 1.0)

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='gravity potential energy',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints},
                                      acc=1e-5, MAX_ITER=500,
                                      debug_level=0)
        return SimulationTask(previous_task=self.init_displ_task,
                              config=sim_config, n_steps=self.n_steps)
Ejemplo n.º 15
0
    def _get_fold_self_weight_cntl(self):

        self.init_displ_task.x_1

        f = self.factory_task
        cp = f.formed_object

        N_h = f.N_h
        N_i = f.N_i
        N_v = f.N_v
        fixed_nodes_x = fix(
            N_i[1, (0, 1)], (0))
        fixed_nodes_y = fix(
            [N_h[1, 1].flatten()], (1))
        fixed_nodes_z = fix(
            list(N_v[[0, 0, -1, -1], [0, -1, 0, -1]].flatten()) +
            list(N_i[[0, 0, -1, -1], [0, -1, 0, -1]].flatten()), (2)
        )
        cntl_z = fix(N_h[(1, 2), 1], 2, lambda t: 0.1 * t)
        link_nodes_y = link(
            list(N_v[[0, -1], [0, -1]].flatten()), 1, 1.0,
            list(N_i[[0, -1], [0, -1]].flatten()), 1, -1.0,
        )
        link_nodes_z = link(
            list(N_h[[1, 1, 1], [0, 1, -1]].flatten()), 2, 1.0,
            list(N_h[[2, 2, 2], [0, 1, -1]].flatten()), 2, -1.0,
        )
#         link_nodes_z = link(
#             N_h[1, 1], 2, 1.0,
#             N_h[2, 1], 2, -1.0,
#         )

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y + \
            link_nodes_z + \
            link_nodes_y

        # link_nodes_yz + link_nodes_z

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='total potential energy',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          },
                                      acc=1e-5, MAX_ITER=1000,
                                      debug_level=0)

        def FN(F): return lambda t: t * F

        H = 0
        P = 0.1
        F_ext_list = [(N_i[1, 1], 2, FN(-P)), (N_i[1, -1], 2, FN(-P)),
                      (N_h[(0, -1), 0], 2, FN(-P)),
                      (N_h[(0, -1), -1], 2, FN(-P))
                      ]

        fu_tot_poteng = FuPotEngTotal(kappa=0.0, thickness=0.01,
                                      rho=23.6,
                                      F_ext_list=F_ext_list)

        sim_config._fu = fu_tot_poteng
        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_fold_steps)
        fu_tot_poteng.forming_task = st

        cp = st.formed_object

        N_down = np.hstack([N_h[::3, :].flatten(),
                            N_i[1::3, :].flatten()
                            ])
        print 'N_down', N_down
        N_up = np.hstack([N_i[::3, :].flatten(),
                          N_i[2::3, :].flatten(),
                          N_v[:, :].flatten()])
        print 'N_up', N_up
        cp.u[N_down, 2] -= self.d_down
        cp.u[N_up, 2] += self.d_up
        cp.u[:, 2] += self.d_down

        return st
Ejemplo n.º 16
0
    def _get_fold_kinem_cntl(self):

        self.init_displ_task.x_1

        corner2_i_x = np.array([0, 0, -1, -1], dtype=np.int_)
        corner2_i_y = np.array([0, -1, 0, -1], dtype=np.int_)
        corner2_h_x = np.array([0, 0, -1, -1], dtype=np.int_)
        corner2_h_y = np.array([0, -1, 0, -1], dtype=np.int_)

        tb2_i_x = np.array([1, 1, 1], dtype=np.int_)
        tb2_i_y = np.array([0, -1, -1], dtype=np.int_)
        tb2_h_x = np.array([1, 1, 2], dtype=np.int_)
        tb2_h_y = np.array([0, -1, -1], dtype=np.int_)

        up2_i_x = np.array([0, 0, -1, -1], dtype=np.int_)
        up2_i_y = np.array([0, 1, 0, 1], dtype=np.int_)
        up2_h_x = np.array([0, 0, -1, -1], dtype=np.int_)
        up2_h_y = np.array([1, 1, 1, 1], dtype=np.int_)

        right2_i_x = np.array([2, 2, 3], dtype=np.int_)
        right2_i_y = np.array([0, 0, 0], dtype=np.int_)
        right2_h_x = np.array([3, 3, 3], dtype=np.int_)
        right2_h_y = np.array([0, 1, 0], dtype=np.int_)

        base_i_x = corner2_i_x
        base_i_y = corner2_i_y
        base_h_x = corner2_h_x
        base_h_y = corner2_h_y

        for c_x in range(0, self.n_cell_x):
            base_i_x = np.hstack([base_i_x, 3 * c_x + tb2_i_x])
            base_i_y = np.hstack([base_i_y, tb2_i_y])
            base_h_x = np.hstack([base_h_x, 3 * c_x + tb2_h_x])
            base_h_y = np.hstack([base_h_y, tb2_h_y])

        for c_x in range(0, self.n_cell_x - 1):
            base_i_x = np.hstack([base_i_x, 3 * c_x + right2_i_x])
            base_i_y = np.hstack([base_i_y, right2_i_y])
            base_h_x = np.hstack([base_h_x, 3 * c_x + right2_h_x])
            base_h_y = np.hstack([base_h_y, right2_h_y])

        for c_y in range(0, self.n_cell_y - 1):
            print 'c_y', c_y
            base_i_x = np.hstack([base_i_x, up2_i_x])
            base_i_y = np.hstack([base_i_y, c_y + up2_i_y])
            base_h_x = np.hstack([base_h_x, up2_h_x])
            base_h_y = np.hstack([base_h_y, c_y + up2_h_y])

        f = self.factory_task
        cp = f.formed_object
        m_nodes = f.N_i[base_i_x, base_i_y]
        n_nodes = f.N_h[base_h_x, base_h_y]

        psi_lines = cp.NN_L[m_nodes, n_nodes].flatten()
        print 'psi_lines', psi_lines

        cm_nodes = [f.N_i[0, 0], f.N_i[-1, 1]]
        cn_nodes = [f.N_h[1, 1], f.N_h[2, 1]]
        cpsi_lines = cp.NN_L[cm_nodes, cn_nodes]
        print 'cpsi_lines', cpsi_lines

        N_h = f.N_h
        N_i = f.N_i
        N_v = f.N_v
        fixed_nodes_x = fix(
            N_i[1, (0, 1)], (0))
        fixed_nodes_y = fix(
            [N_h[1, 1].flatten()], (1))
        fixed_nodes_z = fix(
            list(N_v[[0, 0, -1], [0, -1, 0]].flatten()), (2)
        )
        link_nodes_yz = link(
            list(N_v[[0, 0], [0, -1]].flatten()) +
            list(N_h[[0, 0], [0, -1]].flatten()), (1, 2), 1.0,
            list(N_i[[0, 0], [0, -1]].flatten()) +
            list(N_h[[-1, -1], [0, -1]].flatten()), (1, 2), -1.0,
        )
        link_nodes_z = link(
            N_h[1, 1], 2, 1.0,
            N_h[2, 1], 2, -1.0,
        )

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y + \
            link_nodes_yz + link_nodes_z

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi): return lambda t: psi * t
        cpsi_constr = [([(cpsi_line, 1.0)], FN(0.99 * np.pi))
                       for cpsi_line in cpsi_lines]

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=self.init_displ_task,
                             psi_constraints=cpsi_constr)

        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='none',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          'psi': gu_psi_constraints},
                                      acc=1e-5, MAX_ITER=500,
                                      debug_level=0)

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_fold_steps)

        cp = st.formed_object

        N_down = np.hstack([N_h[::3, :].flatten(),
                            N_i[1::3, :].flatten()
                            ])
        print 'N_down', N_down
        N_up = np.hstack([N_i[::3, :].flatten(),
                          N_i[2::3, :].flatten(),
                          N_v[:, :].flatten()])
        print 'N_up', N_up
        cp.u[N_down, 2] -= self.d_down
        cp.u[N_up, 2] += self.d_up
        cp.u[:, 2] += self.d_down

        return st
Ejemplo n.º 17
0
    def _get_fold_task(self):
        L_rigid = self.factory_task.L_rigid
        N_up = self.factory_task.N_up
        N_down = self.factory_task.N_down
        print 'N_up', N_up
        print 'N_down', N_down
        N_x_sym = self.factory_task.N_x_sym[2]
        print 'N_x_sym', N_x_sym
#        N_x_sym = []  # self.factory_task.N_x_sym[[0, -1]]

        print 'n_dofs', self.factory_task.formed_object.n_dofs

        self.init_displ_task.x_1

        fixed_z = fix(self.fixed_z, (2))
        fixed_x = fix(self.fixed_x, (1))
        fixed_y = fix(self.fixed_y, (1))
        fixed_y_plus = fix(self.fixed_y_plus, (1),
                           lambda t: t * self.u_max)
        fixed_y_minus = fix(self.fixed_y_minus, (1),
                            lambda t: -t * self.u_max)
        link_x1 = link([2], 0, 1, [6], 0, 1)
        link_x2 = link([10], 0, 1, [14], 0, 1)

        dof_constraints = fixed_y_minus + \
            fixed_y_plus + fixed_x + fixed_z + fixed_y + link_x1 + link_x2
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi): return lambda t: psi * t

        psi_constr = [([(i, 1.0)], FN(0))
                      for i in L_rigid]

        gu_constant_length = GuConstantLength()

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=self.init_displ_task,
                             psi_constraints=psi_constr)

        sim_config = SimulationConfig(goal_function_type='none',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          'psi': gu_psi_constraints
                                          },
                                      acc=1e-4, MAX_ITER=self.MAXITER,
                                      debug_level=0)

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_steps,
                            record_iter=False)

        gu_dof_constraints.forming_task = st

        st.sim_step.print_gu_lst()
        print 'dofs', st.formed_object.n_dofs

        cp = st.formed_object
        cp.u[N_up, 2] += 0.1
        cp.u[N_down, 2] -= 0.1
        cp.u[(1, 3, 13, 15), 2] += 0.2
        cp.u[(5, 7, 9, 11), 2] -= 0.2
        cp.u[(0, 16), 2] += 0.5
        cp.u[(0), 1] += 0.5
        cp.u[(16), 1] -= 0.5
        cp.u[(4), 1] += 0.3
        cp.u[(12), 1] -= 0.3
        cp.u[(4, 12), 2] -= 0.2
        return st
Ejemplo n.º 18
0
    def _get_fold_task(self):
        L_rigid = self.factory_task.L_rigid
        N_up = self.factory_task.N_up
        N_down = self.factory_task.N_down
        print('N_up', N_up)
        print('N_down', N_down)
        N_x_sym = self.factory_task.N_x_sym[2]
        print('N_x_sym', N_x_sym)
        #        N_x_sym = []  # self.factory_task.N_x_sym[[0, -1]]

        print('n_dofs', self.factory_task.formed_object.n_dofs)

        self.init_displ_task.x_1

        fixed_z = fix(self.fixed_z, (2))
        fixed_x = fix(self.fixed_x, (1))
        fixed_y = fix(self.fixed_y, (1))
        fixed_y_plus = fix(self.fixed_y_plus, (1), lambda t: t * self.u_max)
        fixed_y_minus = fix(self.fixed_y_minus, (1), lambda t: -t * self.u_max)
        link_x1 = link([2], 0, 1, [6], 0, 1)
        link_x2 = link([10], 0, 1, [14], 0, 1)

        dof_constraints = fixed_y_minus + \
            fixed_y_plus + fixed_x + fixed_z + fixed_y + link_x1 + link_x2
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi):
            return lambda t: psi * t

        psi_constr = [([(i, 1.0)], FN(0)) for i in L_rigid]

        gu_constant_length = GuConstantLength()

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=self.init_displ_task,
                             psi_constraints=psi_constr)

        sim_config = SimulationConfig(goal_function_type='none',
                                      gu={
                                          'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          'psi': gu_psi_constraints
                                      },
                                      acc=1e-4,
                                      MAX_ITER=self.MAXITER,
                                      debug_level=0)

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config,
                            n_steps=self.n_steps,
                            record_iter=False)

        gu_dof_constraints.forming_task = st

        st.sim_step.print_gu_lst()
        print('dofs', st.formed_object.n_dofs)

        cp = st.formed_object
        cp.u[N_up, 2] += 0.1
        cp.u[N_down, 2] -= 0.1
        cp.u[(1, 3, 13, 15), 2] += 0.2
        cp.u[(5, 7, 9, 11), 2] -= 0.2
        cp.u[(0, 16), 2] += 0.5
        cp.u[(0), 1] += 0.5
        cp.u[(16), 1] -= 0.5
        cp.u[(4), 1] += 0.3
        cp.u[(12), 1] -= 0.3
        cp.u[(4, 12), 2] -= 0.2
        return st
Ejemplo n.º 19
0
    def _get_fold_kinem_cntl(self):

        self.init_displ_task.x_1

        base_i_x = np.array([0, 0, -1, -1], dtype=np.int_)
        base_i_y = np.array([0, -1, 0, -1], dtype=np.int_)
        base_h_x = np.array([0, 0, -1, -1], dtype=np.int_)
        base_h_y = np.array([0, -1, 0, -1], dtype=np.int_)

        f = self.factory_task
        cp = f.formed_object
        m_n = f.N_h[(0, 0, -1, -1), (0, -1, 0, -1)]
        n_n = f.N_v[(0, 0, -1, -1), (0, -1, 0, -1)]
        print m_n.flatten()
        print n_n.flatten()

        fix_psi_lines = cp.NN_L[m_n, n_n].flatten()
        print 'psi_lines', fix_psi_lines

        cm_nodes = [f.N_i[0, 0], f.N_i[-1, 1]]
        cn_nodes = [f.N_h[1, 1], f.N_h[2, 1]]
        cpsi_lines = cp.NN_L[cm_nodes, cn_nodes]
        print 'cpsi_lines', cpsi_lines

        N_h = f.N_h
        N_i = f.N_i
        N_v = f.N_v
        fixed_nodes_x = fix(
            N_i[1, (0, 1)], (0))
        fixed_nodes_y = fix(
            [N_h[1, 1].flatten()], (1))
        fixed_nodes_z = fix(
            list(N_v[[0, 0, -1], [0, -1, 0]].flatten()), (2)
        )
        link_nodes_yz = link(
            list(N_v[[0, 0], [0, -1]].flatten()) +
            list(N_h[[0, 0], [0, -1]].flatten()), (1, 2), 1.0,
            list(N_i[[0, 0], [0, -1]].flatten()) +
            list(N_h[[-1, -1], [0, -1]].flatten()), (1, 2), -1.0,
        )
        link_nodes_z = link(
            N_h[1, 1], 2, 1.0,
            N_h[2, 1], 2, -1.0,
        )

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y + \
            link_nodes_yz + link_nodes_z

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi): return lambda t: psi * t
        cpsi_constr = [([(cpsi_line, 1.0)], FN(0.502 * np.pi))
                       for cpsi_line in cpsi_lines]

        fix_psi_constr = [([(i, 1.0)], 0.0)
                          for i in fix_psi_lines]

        print 'fix_psi_lines', fix_psi_lines
        gu_psi_constraints = \
            GuPsiConstraints(forming_task=self.init_displ_task,
                             psi_constraints=fix_psi_constr + cpsi_constr)

        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='none',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          'psi': gu_psi_constraints},
                                      acc=1e-5, MAX_ITER=500,
                                      debug_level=0)

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_fold_steps)

        cp = st.formed_object

        N_down = np.hstack([N_h[::3, :].flatten(),
                            N_i[1::3, :].flatten(),
                            [23, 26]
                            ])
        print 'N_down', N_down
        N_up = np.hstack([N_i[::3, :].flatten(),
                          N_i[2::3, :].flatten(),
                          N_v[:, :].flatten()])
        print 'N_up', N_up
        cp.u[N_down, 2] -= self.d_down
        cp.u[N_up, 2] += self.d_up
        cp.u[:, 2] += self.d_down

        return st
Ejemplo n.º 20
0
    def _get_fold_kinem_cntl(self):

        self.init_displ_task.x_1

        base_i_x = np.array([0, 0, -1, -1], dtype=np.int_)
        base_i_y = np.array([0, -1, 0, -1], dtype=np.int_)
        base_h_x = np.array([0, 0, -1, -1], dtype=np.int_)
        base_h_y = np.array([0, -1, 0, -1], dtype=np.int_)

        f = self.factory_task
        cp = f.formed_object
        m_n = f.N_h[(0, 0, -1, -1), (0, -1, 0, -1)]
        n_n = f.N_v[(0, 0, -1, -1), (0, -1, 0, -1)]
        print(m_n.flatten())
        print(n_n.flatten())

        fix_psi_lines = cp.NN_L[m_n, n_n].flatten()
        print('psi_lines', fix_psi_lines)

        cm_nodes = [f.N_i[0, 0], f.N_i[-1, 1]]
        cn_nodes = [f.N_h[1, 1], f.N_h[2, 1]]
        cpsi_lines = cp.NN_L[cm_nodes, cn_nodes]
        print('cpsi_lines', cpsi_lines)

        N_h = f.N_h
        N_i = f.N_i
        N_v = f.N_v
        fixed_nodes_x = fix(
            N_i[1, (0, 1)], (0))
        fixed_nodes_y = fix(
            [N_h[1, 1].flatten()], (1))
        fixed_nodes_z = fix(
            list(N_v[[0, 0, -1], [0, -1, 0]].flatten()), (2)
        )
        link_nodes_yz = link(
            list(N_v[[0, 0], [0, -1]].flatten()) +
            list(N_h[[0, 0], [0, -1]].flatten()), (1, 2), 1.0,
            list(N_i[[0, 0], [0, -1]].flatten()) +
            list(N_h[[-1, -1], [0, -1]].flatten()), (1, 2), -1.0,
        )
        link_nodes_z = link(
            N_h[1, 1], 2, 1.0,
            N_h[2, 1], 2, -1.0,
        )

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y + \
            link_nodes_yz + link_nodes_z

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi): return lambda t: psi * t
        cpsi_constr = [([(cpsi_line, 1.0)], FN(0.502 * np.pi))
                       for cpsi_line in cpsi_lines]

        fix_psi_constr = [([(i, 1.0)], 0.0)
                          for i in fix_psi_lines]

        print('fix_psi_lines', fix_psi_lines)
        gu_psi_constraints = \
            GuPsiConstraints(forming_task=self.init_displ_task,
                             psi_constraints=fix_psi_constr + cpsi_constr)

        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='none',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          'psi': gu_psi_constraints},
                                      acc=1e-5, MAX_ITER=500,
                                      debug_level=0)

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_fold_steps)

        cp = st.formed_object

        N_down = np.hstack([N_h[::3, :].flatten(),
                            N_i[1::3, :].flatten(),
                            [23, 26]
                            ])
        print('N_down', N_down)
        N_up = np.hstack([N_i[::3, :].flatten(),
                          N_i[2::3, :].flatten(),
                          N_v[:, :].flatten()])
        print('N_up', N_up)
        cp.u[N_down, 2] -= self.d_down
        cp.u[N_up, 2] += self.d_up
        cp.u[:, 2] += self.d_down

        return st
Ejemplo n.º 21
0
    def _get_fold_task(self):
        self.init_displ_task.x_1
        u_max = self.u_max
        fa = self.factory_task
        N_h = fa.N_h
        N_i = fa.N_i
        N_v = fa.N_v
        n_x, n_y = N_h.shape
        mid_n_x = n_x / 2
        i_fixed_x = N_h[mid_n_x, (0, -1)]
        fixed_nodes_x = fix(
            i_fixed_x, (0))

        n_x, n_y = N_i.shape
        mid_n_y = n_y / 2
        i_fixed_z = np.hstack([N_i[:-1:3, mid_n_y],
                               N_i[1::3, mid_n_y]])
        i_fixed_z = np.hstack([N_i[:-1:6, mid_n_y],
                               N_i[1::6, mid_n_y]])
        fixed_nodes_z = fix(
            i_fixed_z, (2))

        i_fixed_y = N_i[(1, -2), mid_n_y]
        fixed_nodes_y = fix(
            i_fixed_y, (1))

        i_link_xh_r = N_h[2::3, :]
        i_link_xh_l = N_h[0:-2:3, :]
        i_link_xi_r = N_i[3::3, :]
        i_link_xi_l = N_i[1:-2:3, :]
        link_mid = link(
            np.hstack([i_link_xh_r.flatten(), i_link_xi_r.flatten()]),
            (0), 1.0,
            np.hstack([i_link_xh_l.flatten(), i_link_xi_l.flatten()]),
            (0), -1.0,
            lambda t: -t * u_max
        )
        sym_y = link(
            N_h[(0, -1), 0], [2], 1.0,
            N_h[(0, -1), -1], [2], -1.0
        )

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y + \
            link_mid + sym_y
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='gravity potential energy',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints},
                                      acc=1e-5, MAX_ITER=500,
                                      debug_level=0)

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_fold_steps)

        cp = st.formed_object

        d_u = 0.02
        i_down_h = N_h[1::3, :]
        i_down_i = N_i[2::3, :]
        i_left = N_v[0, :]
        i_right = N_v[-1, :]
        cp.u[np.hstack([i_down_h.flatten(), i_down_i.flatten()]), 2] -= d_u
        cp.u[i_left, 0] -= d_u
        cp.u[i_right, 0] += d_u
#         cp.u[(
#             36, 48, 57, 39,
#             37, 49, 58, 40,
#             38, 50, 59, 41,
#             4, 16, 28,
#             5, 17, 29,
#             6, 18, 30,
#             7, 19, 31,
#         ), 2] -= 0.2

        return st
Ejemplo n.º 22
0
    def _get_fold_task(self):
        self.init_displ_task.x_1
        u_max = self.u_max
        fa = self.factory_task
        N_h = fa.N_h
        N_i = fa.N_i
        N_v = fa.N_v
        n_x, n_y = N_h.shape
        mid_n_x = n_x / 2
        i_fixed_x = N_h[mid_n_x, (0, -1)]
        fixed_nodes_x = fix(i_fixed_x, (0))

        n_x, n_y = N_i.shape
        mid_n_y = n_y / 2
        i_fixed_z = np.hstack([N_i[:-1:3, mid_n_y], N_i[1::3, mid_n_y]])
        i_fixed_z = np.hstack([N_i[:-1:6, mid_n_y], N_i[1::6, mid_n_y]])
        fixed_nodes_z = fix(i_fixed_z, (2))

        i_fixed_y = N_i[(1, -2), mid_n_y]
        fixed_nodes_y = fix(i_fixed_y, (1))

        i_link_xh_r = N_h[2::3, :]
        i_link_xh_l = N_h[0:-2:3, :]
        i_link_xi_r = N_i[3::3, :]
        i_link_xi_l = N_i[1:-2:3, :]
        link_mid = link(
            np.hstack([i_link_xh_r.flatten(),
                       i_link_xi_r.flatten()]), (0), 1.0,
            np.hstack([i_link_xh_l.flatten(),
                       i_link_xi_l.flatten()]), (0), -1.0,
            lambda t: -t * u_max)
        sym_y = link(N_h[(0, -1), 0], [2], 1.0, N_h[(0, -1), -1], [2], -1.0)

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y + \
            link_mid + sym_y
        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)
        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(
            goal_function_type='gravity potential energy',
            gu={
                'cl': gu_constant_length,
                'dofs': gu_dof_constraints
            },
            acc=1e-5,
            MAX_ITER=500,
            debug_level=0)

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config,
                            n_steps=self.n_fold_steps)

        cp = st.formed_object

        i_down_h = N_h[1::3, :]
        i_down_i = N_i[2::3, :]

        cp.u[np.hstack([i_down_h.flatten(), i_down_i.flatten()]), 2] -= 0.1
        #         cp.u[(
        #             36, 48, 57, 39,
        #             37, 49, 58, 40,
        #             38, 50, 59, 41,
        #             4, 16, 28,
        #             5, 17, 29,
        #             6, 18, 30,
        #             7, 19, 31,
        #         ), 2] -= 0.2

        return st
Ejemplo n.º 23
0
    def _get_fold_angle_cntl(self):

        self.init_displ_task.x_1

        corner2_i_x = np.array([0, 0, -1, -1], dtype=np.int_)
        corner2_i_y = np.array([0, -1, 0, -1], dtype=np.int_)
        corner2_h_x = np.array([0, 0, -1, -1], dtype=np.int_)
        corner2_h_y = np.array([0, -1, 0, -1], dtype=np.int_)

        tb2_i_x = np.array([1, 1, 1], dtype=np.int_)
        tb2_i_y = np.array([0, -1, -1], dtype=np.int_)
        tb2_h_x = np.array([1, 1, 2], dtype=np.int_)
        tb2_h_y = np.array([0, -1, -1], dtype=np.int_)

        up2_i_x = np.array([0, 0, -1, -1], dtype=np.int_)
        up2_i_y = np.array([0, 1, 0, 1], dtype=np.int_)
        up2_h_x = np.array([0, 0, -1, -1], dtype=np.int_)
        up2_h_y = np.array([1, 1, 1, 1], dtype=np.int_)

        right2_i_x = np.array([2, 2, 3], dtype=np.int_)
        right2_i_y = np.array([0, 0, 0], dtype=np.int_)
        right2_h_x = np.array([3, 3, 3], dtype=np.int_)
        right2_h_y = np.array([0, 1, 0], dtype=np.int_)

        base_i_x = corner2_i_x
        base_i_y = corner2_i_y
        base_h_x = corner2_h_x
        base_h_y = corner2_h_y

        for c_x in range(0, self.n_cell_x):
            base_i_x = np.hstack([base_i_x, 3 * c_x + tb2_i_x])
            base_i_y = np.hstack([base_i_y, tb2_i_y])
            base_h_x = np.hstack([base_h_x, 3 * c_x + tb2_h_x])
            base_h_y = np.hstack([base_h_y, tb2_h_y])

        for c_x in range(0, self.n_cell_x - 1):
            base_i_x = np.hstack([base_i_x, 3 * c_x + right2_i_x])
            base_i_y = np.hstack([base_i_y, right2_i_y])
            base_h_x = np.hstack([base_h_x, 3 * c_x + right2_h_x])
            base_h_y = np.hstack([base_h_y, right2_h_y])

        for c_y in range(0, self.n_cell_y - 1):
            print('c_y', c_y)
            base_i_x = np.hstack([base_i_x, up2_i_x])
            base_i_y = np.hstack([base_i_y, c_y + up2_i_y])
            base_h_x = np.hstack([base_h_x, up2_h_x])
            base_h_y = np.hstack([base_h_y, c_y + up2_h_y])

        f = self.factory_task
        cp = f.formed_object
        m_nodes = f.N_i[base_i_x, base_i_y]
        n_nodes = f.N_h[base_h_x, base_h_y]

        psi_lines = cp.NN_L[[m_nodes], n_nodes].flatten()
        print('psi_lines', psi_lines)

        cm_node = f.N_i[0, 0]
        cn_node = f.N_h[1, 1]
        cpsi_line = cp.NN_L[cm_node, cn_node]
        print('cpsi_lines', cpsi_line)

        N_h = f.N_h
        N_i = f.N_i
        N_v = f.N_v
        y_mid = N_i.shape[1] / 2
        fixed_nodes_x = fix(
            N_h[0, 0], (0))
        fixed_nodes_y = fix(
            N_h[(0, -1), 0], (1))
        fixed_nodes_z = fix(
            [N_h[0, 0], N_h[-1, 0], N_h[0, -1]], (2))

        u_max = (1.999 * self.c * self.t_max)
        link_mid = link(
            N_i[0, 0], (0), 1.0,
            N_i[2, 0], (0), -1.0,
            lambda t: t * u_max
        )

        print('--------------------------')
        print(N_i[0, 0].flatten())
        print(N_i[2, 0].flatten())
        print('--------------------------')

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y  # + \
        # link_mid

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi): return lambda t: psi * t
        cpsi_constr = [([(cpsi_line, 1.0)], FN(0.99 * np.pi))]

        lpsi_constr = [([(psi_lines[0], 1.0), (i, -1.0)], 0.0)
                       for i in psi_lines[1:]]

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=self.init_displ_task,
                             psi_constraints=lpsi_constr + cpsi_constr)

        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='none',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          'psi': gu_psi_constraints},
                                      acc=1e-5, MAX_ITER=500,
                                      debug_level=0)

        st = SimulationTask(node='Fold angle control',
                            previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_fold_steps)

        cp = st.formed_object

        N_down = np.hstack([N_h[::3, :].flatten(),
                            N_i[1::3, :].flatten()
                            ])
        print('N_down', N_down)
        N_up = np.hstack([N_i[::3, :].flatten(),
                          N_i[2::3, :].flatten(),
                          N_v[:, :].flatten()])
        print('N_up', N_up)
        cp.u[N_down, 2] -= self.d_down
        cp.u[N_up, 2] += self.d_up
        cp.u[:, 2] += self.d_down

        return st
    def _get_fold_kinem_cntl(self):

        self.init_displ_task.x_1

        corner2_i_x = np.array([0, 0, -1, -1], dtype=np.int_)
        corner2_i_y = np.array([0, -1, 0, -1], dtype=np.int_)
        corner2_h_x = np.array([0, 0, -1, -1], dtype=np.int_)
        corner2_h_y = np.array([0, -1, 0, -1], dtype=np.int_)

        tb2_i_x = np.array([1, 1, 1], dtype=np.int_)
        tb2_i_y = np.array([0, -1, -1], dtype=np.int_)
        tb2_h_x = np.array([1, 1, 2], dtype=np.int_)
        tb2_h_y = np.array([0, -1, -1], dtype=np.int_)

        up2_i_x = np.array([0, 0, -1, -1], dtype=np.int_)
        up2_i_y = np.array([0, 1, 0, 1], dtype=np.int_)
        up2_h_x = np.array([0, 0, -1, -1], dtype=np.int_)
        up2_h_y = np.array([1, 1, 1, 1], dtype=np.int_)

        right2_i_x = np.array([2, 2, 3], dtype=np.int_)
        right2_i_y = np.array([0, 0, 0], dtype=np.int_)
        right2_h_x = np.array([3, 3, 3], dtype=np.int_)
        right2_h_y = np.array([0, 1, 0], dtype=np.int_)

        base_i_x = corner2_i_x
        base_i_y = corner2_i_y
        base_h_x = corner2_h_x
        base_h_y = corner2_h_y

        for c_x in range(0, self.n_cell_x):
            base_i_x = np.hstack([base_i_x, 3 * c_x + tb2_i_x])
            base_i_y = np.hstack([base_i_y, tb2_i_y])
            base_h_x = np.hstack([base_h_x, 3 * c_x + tb2_h_x])
            base_h_y = np.hstack([base_h_y, tb2_h_y])

        for c_x in range(0, self.n_cell_x - 1):
            base_i_x = np.hstack([base_i_x, 3 * c_x + right2_i_x])
            base_i_y = np.hstack([base_i_y, right2_i_y])
            base_h_x = np.hstack([base_h_x, 3 * c_x + right2_h_x])
            base_h_y = np.hstack([base_h_y, right2_h_y])

        for c_y in range(0, self.n_cell_y - 1):
            print('c_y', c_y)
            base_i_x = np.hstack([base_i_x, up2_i_x])
            base_i_y = np.hstack([base_i_y, c_y + up2_i_y])
            base_h_x = np.hstack([base_h_x, up2_h_x])
            base_h_y = np.hstack([base_h_y, c_y + up2_h_y])

        f = self.factory_task
        cp = f.formed_object
        m_nodes = f.N_i[base_i_x, base_i_y]
        n_nodes = f.N_h[base_h_x, base_h_y]

        psi_lines = cp.NN_L[m_nodes, n_nodes].flatten()
        print('psi_lines', psi_lines)

        cm_nodes = [f.N_i[0, 0], f.N_i[-1, 1]]
        cn_nodes = [f.N_h[1, 1], f.N_h[2, 1]]
        cpsi_lines = cp.NN_L[cm_nodes, cn_nodes]
        print('cpsi_lines', cpsi_lines)

        N_h = f.N_h
        N_i = f.N_i
        N_v = f.N_v
        fixed_nodes_x = fix(
            N_i[1, (0, 1)], (0))
        fixed_nodes_y = fix(
            [N_h[1, 1].flatten()], (1))
        fixed_nodes_z = fix(
            list(N_v[[0, 0, -1], [0, -1, 0]].flatten()), (2)
        )
        link_nodes_yz = link(
            list(N_v[[0, 0], [0, -1]].flatten()) +
            list(N_h[[0, 0], [0, -1]].flatten()), (1, 2), 1.0,
            list(N_i[[0, 0], [0, -1]].flatten()) +
            list(N_h[[-1, -1], [0, -1]].flatten()), (1, 2), -1.0,
        )
        link_nodes_z = link(
            N_h[1, 1], 2, 1.0,
            N_h[2, 1], 2, -1.0,
        )

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y + \
            link_nodes_yz + link_nodes_z

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi): return lambda t: psi * t
        cpsi_constr = [([(cpsi_line, 1.0)], FN(0.99 * np.pi))
                       for cpsi_line in cpsi_lines]

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=self.init_displ_task,
                             psi_constraints=cpsi_constr)

        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='none',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          'psi': gu_psi_constraints},
                                      acc=1e-5, MAX_ITER=500,
                                      debug_level=0)

        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_fold_steps)

        cp = st.formed_object

        N_down = np.hstack([N_h[::3, :].flatten(),
                            N_i[1::3, :].flatten()
                            ])
        print('N_down', N_down)
        N_up = np.hstack([N_i[::3, :].flatten(),
                          N_i[2::3, :].flatten(),
                          N_v[:, :].flatten()])
        print('N_up', N_up)
        cp.u[N_down, 2] -= self.d_down
        cp.u[N_up, 2] += self.d_up
        cp.u[:, 2] += self.d_down

        return st
Ejemplo n.º 25
0
    def _get_fold_self_weight_cntl(self):

        self.init_displ_task.x_1

        f = self.factory_task
        cp = f.formed_object

        N_h = f.N_h
        N_i = f.N_i
        N_v = f.N_v
        fixed_nodes_x = fix(
            N_i[1, (0, 1)], (0))
        fixed_nodes_y = fix(
            [N_h[1, 1].flatten()], (1))
        fixed_nodes_z = fix(
            list(N_v[[0, 0, -1, -1], [0, -1, 0, -1]].flatten()) +
            list(N_i[[0, 0, -1, -1], [0, -1, 0, -1]].flatten()), (2)
        )
        cntl_z = fix(N_h[(1, 2), 1], 2, lambda t: 0.1 * t)
        link_nodes_y = link(
            list(N_v[[0, -1], [0, -1]].flatten()), 1, 1.0,
            list(N_i[[0, -1], [0, -1]].flatten()), 1, -1.0,
        )
        link_nodes_z = link(
            list(N_h[[1, 1, 1], [0, 1, -1]].flatten()), 2, 1.0,
            list(N_h[[2, 2, 2], [0, 1, -1]].flatten()), 2, -1.0,
        )
#         link_nodes_z = link(
#             N_h[1, 1], 2, 1.0,
#             N_h[2, 1], 2, -1.0,
#         )

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y + \
            link_nodes_z + \
            link_nodes_y

        # link_nodes_yz + link_nodes_z

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='total potential energy',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          },
                                      acc=1e-5, MAX_ITER=1000,
                                      debug_level=0)

        def FN(F): return lambda t: t * F

        H = 0
        P = 0.1
        F_ext_list = [(N_i[1, 1], 2, FN(-P)), (N_i[1, -1], 2, FN(-P)),
                      (N_h[(0, -1), 0], 2, FN(-P)),
                      (N_h[(0, -1), -1], 2, FN(-P))
                      ]

        fu_tot_poteng = FuPotEngTotal(kappa=0.0, thickness=0.01,
                                      rho=23.6,
                                      F_ext_list=F_ext_list)

        sim_config._fu = fu_tot_poteng
        st = SimulationTask(previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_fold_steps)
        fu_tot_poteng.forming_task = st

        cp = st.formed_object

        N_down = np.hstack([N_h[::3, :].flatten(),
                            N_i[1::3, :].flatten()
                            ])
        print('N_down', N_down)
        N_up = np.hstack([N_i[::3, :].flatten(),
                          N_i[2::3, :].flatten(),
                          N_v[:, :].flatten()])
        print('N_up', N_up)
        cp.u[N_down, 2] -= self.d_down
        cp.u[N_up, 2] += self.d_up
        cp.u[:, 2] += self.d_down

        return st
Ejemplo n.º 26
0
    def _get_fold_angle_cntl(self):

        self.init_displ_task.x_1

        corner2_i_x = np.array([0, 0, -1, -1], dtype=np.int_)
        corner2_i_y = np.array([0, -1, 0, -1], dtype=np.int_)
        corner2_h_x = np.array([0, 0, -1, -1], dtype=np.int_)
        corner2_h_y = np.array([0, -1, 0, -1], dtype=np.int_)

        tb2_i_x = np.array([1, 1, 1], dtype=np.int_)
        tb2_i_y = np.array([0, -1, -1], dtype=np.int_)
        tb2_h_x = np.array([1, 1, 2], dtype=np.int_)
        tb2_h_y = np.array([0, -1, -1], dtype=np.int_)

        up2_i_x = np.array([0, 0, -1, -1], dtype=np.int_)
        up2_i_y = np.array([0, 1, 0, 1], dtype=np.int_)
        up2_h_x = np.array([0, 0, -1, -1], dtype=np.int_)
        up2_h_y = np.array([1, 1, 1, 1], dtype=np.int_)

        right2_i_x = np.array([2, 2, 3], dtype=np.int_)
        right2_i_y = np.array([0, 0, 0], dtype=np.int_)
        right2_h_x = np.array([3, 3, 3], dtype=np.int_)
        right2_h_y = np.array([0, 1, 0], dtype=np.int_)

        base_i_x = corner2_i_x
        base_i_y = corner2_i_y
        base_h_x = corner2_h_x
        base_h_y = corner2_h_y

        for c_x in range(0, self.n_cell_x):
            base_i_x = np.hstack([base_i_x, 3 * c_x + tb2_i_x])
            base_i_y = np.hstack([base_i_y, tb2_i_y])
            base_h_x = np.hstack([base_h_x, 3 * c_x + tb2_h_x])
            base_h_y = np.hstack([base_h_y, tb2_h_y])

        for c_x in range(0, self.n_cell_x - 1):
            base_i_x = np.hstack([base_i_x, 3 * c_x + right2_i_x])
            base_i_y = np.hstack([base_i_y, right2_i_y])
            base_h_x = np.hstack([base_h_x, 3 * c_x + right2_h_x])
            base_h_y = np.hstack([base_h_y, right2_h_y])

        for c_y in range(0, self.n_cell_y - 1):
            print 'c_y', c_y
            base_i_x = np.hstack([base_i_x, up2_i_x])
            base_i_y = np.hstack([base_i_y, c_y + up2_i_y])
            base_h_x = np.hstack([base_h_x, up2_h_x])
            base_h_y = np.hstack([base_h_y, c_y + up2_h_y])

        f = self.factory_task
        cp = f.formed_object
        m_nodes = f.N_i[base_i_x, base_i_y]
        n_nodes = f.N_h[base_h_x, base_h_y]

        psi_lines = cp.NN_L[[m_nodes], n_nodes].flatten()
        print 'psi_lines', psi_lines

        cm_node = f.N_i[0, 0]
        cn_node = f.N_h[1, 1]
        cpsi_line = cp.NN_L[cm_node, cn_node]
        print 'cpsi_lines', cpsi_line

        N_h = f.N_h
        N_i = f.N_i
        N_v = f.N_v
        y_mid = N_i.shape[1] / 2
        fixed_nodes_x = fix(
            N_h[0, 0], (0))
        fixed_nodes_y = fix(
            N_h[(0, -1), 0], (1))
        fixed_nodes_z = fix(
            [N_h[0, 0], N_h[-1, 0], N_h[0, -1]], (2))

        u_max = (1.999 * self.c * self.t_max)
        link_mid = link(
            N_i[0, 0], (0), 1.0,
            N_i[2, 0], (0), -1.0,
            lambda t: t * u_max
        )

        print '--------------------------'
        print N_i[0, 0].flatten()
        print N_i[2, 0].flatten()
        print '--------------------------'

        dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y  # + \
        # link_mid

        gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints)

        def FN(psi): return lambda t: psi * t
        cpsi_constr = [([(cpsi_line, 1.0)], FN(0.99 * np.pi))]

        lpsi_constr = [([(psi_lines[0], 1.0), (i, -1.0)], 0.0)
                       for i in psi_lines[1:]]

        gu_psi_constraints = \
            GuPsiConstraints(forming_task=self.init_displ_task,
                             psi_constraints=lpsi_constr + cpsi_constr)

        gu_constant_length = GuConstantLength()
        sim_config = SimulationConfig(goal_function_type='none',
                                      gu={'cl': gu_constant_length,
                                          'dofs': gu_dof_constraints,
                                          'psi': gu_psi_constraints},
                                      acc=1e-5, MAX_ITER=500,
                                      debug_level=0)

        st = SimulationTask(node='Fold angle control',
                            previous_task=self.init_displ_task,
                            config=sim_config, n_steps=self.n_fold_steps)

        cp = st.formed_object

        N_down = np.hstack([N_h[::3, :].flatten(),
                            N_i[1::3, :].flatten()
                            ])
        print 'N_down', N_down
        N_up = np.hstack([N_i[::3, :].flatten(),
                          N_i[2::3, :].flatten(),
                          N_v[:, :].flatten()])
        print 'N_up', N_up
        cp.u[N_down, 2] -= self.d_down
        cp.u[N_up, 2] += self.d_up
        cp.u[:, 2] += self.d_down

        return st