def render(self, save_path="image.png"):
        dir_name = os.path.dirname(save_path)
        if not os.path.exists(dir_name):
            os.makedirs(dir_name)

        nodes_pos, edges_indices, edges_thickness, _ = self.extract_node_edge_info()

        lattice = EdgeInfoLattice(
            nodes_positions=nodes_pos,
            edges_indices=edges_indices,
            edges_thickness=edges_thickness,
            linear_stiffness=LINEAR_STIFFNESS,
            angular_stiffness=ANGULAR_STIFFNESS
        )

        for edge in lattice._possible_edges:
            lattice.flip_edge(edge)

        actuator = Actuator(
            lattice=lattice,
            input_nodes=self.input_nodes,
            input_vectors=self.input_vectors,
            output_nodes=self.output_nodes,
            output_vectors=self.output_vectors,
            frozen_nodes=self.frozen_nodes
        )
        show_actuator(actuator, save_path=save_path)
示例#2
0
# freeze the bottomn layer
frozen_nodes = [1, 3, 5, 7, 9, 11, 13, 15]

# construct the actuator
actuator = Actuator(lattice=lattice,
                    input_nodes=input_nodes,
                    input_vectors=input_vectors,
                    output_nodes=output_nodes,
                    output_vectors=output_vectors,
                    frozen_nodes=frozen_nodes)

print("initial efficiency", actuator.efficiency)

metropolis = Metropolis(actuator=actuator)
metropolis.run(initial_temperature=0.1, final_temperature=0, num_steps=500)

print("final efficiency", actuator.efficiency)
# final efficiency 2.8265941145286715

history_df = pd.DataFrame(metropolis.history)
"""
# 記録やOVITOを用いた可視化用
history_df.to_xlsx("/path/MC_history.xlsx")
history_df.to_csv("path/MC_history.csv")

actuator.to_lammps("path/output.lammps")
actuator._get_displaced_actuator().to_lammps("path/output_displaced.lammps")
"""
show_actuator(actuator)