Пример #1
0
def calculate(FILE_IN, plot_flag):

    for file in FILE_IN:
        #print("Calculating",file)
        assembly = Assembly.from_json(file)

        # ==============================================================================
        # Identify interfaces
        # ==============================================================================
        assembly_interfaces_numpy(assembly, tmax=0.02)

        # ==============================================================================
        # Equilibrium
        # ==============================================================================
        compute_interface_forces_cvx(assembly, solver='CPLEX', verbose=False)
        #compute_interface_forces_cvx(assembly, solver='ECOS', verbose=True)

        # ==============================================================================
        # Export
        # ==============================================================================
        assembly.to_json(output_path(file))

        if plot_flag:
            R = Rotation.from_axis_and_angle([1.0, 0, 0], -pi / 2)
            assembly.transform(R)

            plotter = AssemblyPlotter(assembly, figsize=(16, 10), tight=True)
            plotter.draw_nodes(radius=0.05)
            plotter.draw_edges()
            plotter.draw_blocks(
                facecolor={
                    key: '#ff0000'
                    for key in assembly.nodes_where({'is_support': True})
                })
            plotter.show()
Пример #2
0
# ==============================================================================
# Load assembly from file
# ==============================================================================

assembly = Assembly.from_json(FILE_I)

# ==============================================================================
# Identify interfaces
# ==============================================================================

assembly_interfaces_numpy(assembly, tmax=0.05)

# ==============================================================================
# Export
# ==============================================================================

assembly.to_json(FILE_O)

# ==============================================================================
# Visualize
# ==============================================================================

R = Rotation.from_axis_and_angle([1.0, 0, 0], -pi / 2, [0, 0, 0])
assembly.transform(R)

plotter = AssemblyPlotter(assembly, figsize=(16, 10), tight=True)
plotter.draw_nodes(radius=0.05)
plotter.draw_edges()
plotter.draw_blocks(facecolor={key: '#ff0000' for key in assembly.nodes_where({'is_support': True})})
plotter.show()