import taichi as tc # import crash_report # crash_report.enable() version = 10 narrow_band = True volume_fraction = 0.2 # Initialize n = 128 opt = TopoOpt( res=(n, n, n), version=version, volume_fraction=volume_fraction, grid_update_start=2 if narrow_band else 1000000, fix_cells_at_dirichlet=True, fix_cells_near_force=True, progressive_vol_frac=0, fixed_cell_density=0.3, # minimum_stiffness=0, minimum_density=1e-2, # connectivity_filtering=True, cg_max_iterations=100) # obj_file_path = '/home/slovak/topoopt/taichi/projects/spgrid_topo_opt/data/wing_2.obj' # obj_file_path = '/home/slovak/topoopt/taichi/projects/spgrid_topo_opt/data/Halfcilinder.obj' # obj_file_path = '/home/slovak/topoopt/taichi/projects/spgrid_topo_opt/data/HalfcilinderThin.obj' # obj_file_path = '/home/slovak/topoopt/taichi/projects/spgrid_topo_opt/data/HalfcilinderMiddle.obj' obj_file_path = '/home/slovak/topoopt/taichi/projects/spgrid_topo_opt/data/Cube.obj' s = 1 tex = tc.Texture('mesh', translate=(0.5, 0.5, 0.5),
from topo_opt import TopoOpt # Change log # v1 This is designed to match the Mitchell Sphere in the TopOpt-Petsc paper. # v2 Use four loads. Does it make a difference? # Original name: opt_michell_sphere.py # Initialize version = 1 n = 256 opt = TopoOpt(res=(n, n, n), volume_fraction=0.05, mg_level=3, version=version, grid_update_start=10, fix_cells_at_dirichelt=False, fix_cells_near_force=True, check_log_file=False, cg_max_iterations=100, progressive_vol_frac=50, cg_tolerance=1e-6) outer_radius = 0.5 inner_radius = 0.48 opt.populate_grid(domain_type='sphere', inner_radius=inner_radius, outer_radius=outer_radius) delta = outer_radius - inner_radius center_radius = (inner_radius + outer_radius) * 0.5 # The radius of the Dirichlet region is 10% of the whole sphere opt.add_dirichlet_bc(center=(-center_radius, 0.0, 0.0), radius=delta * 12) d = delta opt.add_load(center=(outer_radius - delta * 0.5, d, 0), force=(0, 0, 8), size=0.04) opt.add_load(center=(outer_radius - delta * 0.5, -d, 0), force=(0, 0, -8), size=0.04) opt.add_load(center=(outer_radius - delta * 0.5, 0, d), force=(0, -8, 0), size=0.04) opt.add_load(center=(outer_radius - delta * 0.5, 0, -d), force=(0, 8, 0), size=0.04)
from topo_opt import TopoOpt # Initialize dense_container = False version = 6 n = 4096 opt = TopoOpt(res=(n, n, n), volume_fraction=0.04, mg_level=7, version=version, cg_tolerance=1e-2, grid_update_start=10, fix_cells_near_force=True, fix_cells_at_dirichlet=True) outer_radius = 0.50 inner_radius = 0.48 opt.populate_grid(domain_type='sphere', inner_radius=inner_radius, outer_radius=outer_radius, lower_only=True, mirror='xz') shell_thickness = outer_radius - inner_radius shell_center = (outer_radius + inner_radius) / 2.0 dirichlet_size = shell_thickness * 4.0 opt.add_dirichlet_bc(center=(0, -shell_center, 0.0), radius=dirichlet_size) opt.add_plane_load(force=(0, -1, 0), axis=1, extreme=1)
import taichi as tc # Change log # v1 Initial commit # v2 correct BC and plane wing force import crash_report crash_report.enable() version = 1 narrow_band = True volume_fraction = 0.1 # Initialize n = 3000 opt = TopoOpt(res=(n, n, n), version=version, volume_fraction=volume_fraction, grid_update_start=5 if narrow_band else 1000000, fix_cells_near_force=True, fixed_cell_density=0.1) s = 1.0 tex = tc.Texture('mesh', translate=(0.5, 0.5, 0.5), scale=(s, s, s), adaptive=False, filename='projects/topo_opt/data/beak.obj') opt.populate_grid(domain_type='texture', tex_id=tex.id, mirror='z') opt.general_action(action='voxel_connectivity_filtering') opt.general_action(action='add_box_dirichlet_bc', axis_to_fix='xyz',
import taichi as tc version = 8 wireframe = False narrow_band = False plane_force = True volume_fraction=0.08 use_mirror = True # Initialize n = 1800 #tc.core.set_core_trigger_gdb_when_crash(True); opt = TopoOpt(res=(n, n, n), version=version, volume_fraction=volume_fraction, grid_update_start=5 if narrow_band else 1000000, progressive_vol_frac=5, cg_tolerance=1e-3, minimum_stiffness=0, minimum_density=1e-2, fix_cells_at_dirichlet=False, fix_cells_near_force=True, connectivity_filtering=True, adaptive_min_fraction=False, verbose_snapshot=False) x, y, z = 0.1, 0.1, 0.4 if use_mirror: mirror = 'xz' else: mirror = '' opt.populate_grid(domain_type='box', size=(x, y, z), mirror=mirror) # Set up BCs opt.add_plane_dirichlet_bc(axis_to_fix="xyz", axis_to_search=2, extreme=-1) if not use_mirror: opt.add_plane_dirichlet_bc(axis_to_fix="xyz", axis_to_search=2, extreme=1)
from topo_opt import TopoOpt import taichi as tc version = 1 narrow_band = True volume_fraction = 0.01 # Initialize n = 1024 opt = TopoOpt(res=(n, n, n), version=version, volume_fraction=volume_fraction, grid_update_start=5 if narrow_band else 1000000, cg_tolerance=1e-2, cg_max_iterations=10, progressive_volume_fraction=5, fix_cells_near_force=True, fixed_cell_density=0.2, mg_level=5) #opt.populate_grid(domain_type='cylinder', radius=0.25, thickness=0.5, height=0.05) opt.populate_grid(domain_type='wheel', radius=0.25, thickness=0.5, height=0.05, mirror='') # Set up BCs opt.add_dirichlet_bc((0, 0, -0.1), radius=0.05, axis='xyz', value=(0, 0, 0)) opt.add_dirichlet_bc((0, 0, 0.1), radius=0.05, axis='xyz', value=(0, 0, 0)) opt.set_up_wheel()
narrow_band = True plane_force = True volume_fraction = 0.2 use_mirror = False # Initialize n = 256 #tc.core.set_core_trigger_gdb_when_crash(True); opt = TopoOpt(res=(n, n, n), version=version, volume_fraction=volume_fraction, grid_update_start=5 if narrow_band else 1000000, progressive_vol_frac=5, cg_tolerance=1e-3, minimum_stiffness=0, minimum_density=1e-2, fix_cells_at_dirichlet=False, fix_cells_near_force=True, connectivity_filtering=True, adaptive_min_fraction=False, verbose_snapshot=False, fixed_cell_density=1) k = 1 x, y, z = 1 * k, 1 * k, 1 * k if use_mirror: mirror = 'xy' else: mirror = ''
from topo_opt import TopoOpt import crash_report crash_report.enable() version = 3 narrow_band = True plane_force = True volume_fraction = 0.07 # Initialize n = 32 opt = TopoOpt(res=(n, n, n), version=version, volume_fraction=volume_fraction, grid_update_start=5 if narrow_band else 1000000, cg_max_iteraetions=30) x, y, z = 0.48, 0.48, 0.48 opt.populate_grid(domain_type='dense') # Set up BCs opt.add_plane_dirichlet_bc(axis_to_fix="xyz", axis_to_search=1, extreme=1) opt.add_plane_load(force=(1, 0, 0), axis=1, extreme=-1) # Optimize opt.run()
from topo_opt import TopoOpt import taichi as tc import crash_report crash_report.enable() version = 10 narrow_band = True volume_fraction = 0.2 # Initialize n = 2000 opt = TopoOpt(res=(n, n, n), version=version, volume_fraction=volume_fraction, grid_update_start=2 if narrow_band else 1000000, progressive_vol_frac=0, fixed_cell_density=0.21, cg_max_iterations=100) s = 1 tex = tc.Texture( 'mesh', translate=(0.5, 0.5, 0.5), scale=(s, s, s), adaptive=False, filename='projects/topo_opt/data/wing_2.obj') s *= 0.95 tex_shell = tc.Texture( 'mesh', translate=(0.5, 0.5, 0.5), scale=(s, s, s), adaptive=False, filename='projects/topo_opt/data/wing_2.obj')