topoptlab.topology_optimization module
- topoptlab.topology_optimization.main(nelx: int, nely: int, volfrac: float, rmin: float, ft: int = 1, filter_kw: ~typing.Dict = {}, simulation_kw: ~typing.Dict = {'element order': 1, 'grid': 'regular', 'meshfile': None}, nelz: None | int = None, filter_mode: str = 'matrix', lin_solver_kw: ~typing.Dict = {'name': 'scipy-direct'}, preconditioner_kw: ~typing.Dict = {'name': None}, assembly_mode: str = 'full', materials_kw: ~typing.Dict = {'E': 1.0}, body_forces_kw: ~typing.Dict = {}, bcs: ~typing.Callable = <function mbb_2d>, lk: None | ~typing.Callable = None, l: float | ~typing.List | ~numpy.ndarray = 1.0, obj_func: ~typing.Callable = <function compliance>, obj_kw: ~typing.Dict = {}, matinterpol: ~typing.Callable = <function simp>, matinterpol_dx: ~typing.Callable = <function simp_dx>, matinterpol_kw: ~typing.Dict = {'eps': 1e-09, 'penal': 3.0}, el_flags: None | ~numpy.ndarray = None, optimizer: str = 'mma', optimizer_kw: None | ~typing.Dict = None, mix: None | float = None, accelerator_kw: ~typing.Dict = {'accel_freq': 4, 'accel_start': 20, 'accelerator': None, 'max_history': 0}, nouteriter: int = 2000, ninneriter: int = 15, output_kw: ~typing.Dict = {'display': True, 'export': True, 'file': 'topopt', 'output_movie': False, 'profile': False, 'verbosity': 20, 'write_log': True}) Tuple[ndarray, float][source]
Topology optimization workflow with the material interpolation method. Can treat single physics stationary problems.
- Parameters:
nelx (int) – number of elements in x direction.
nely (int) – number of elements in y direction.
volfrac (float) – volume fraction.
penal (float) – penalty exponent for the SIMP method.
rmin (float) – cutoff radius for the filter. Only elements within the element-center to element center distance are used for filtering.
ft (int) – integer flag for the filter. 0 sensitivity filtering, 1 density filtering, -1 no filter.
nelz (int or None) – number of elements in z direction. If None, simulation is 2d.
filter_mode (str) – indicates how filtering is done. Possible values are “matrix” or “helmholtz”. If “matrix”, then density/sensitivity filters are implemented via a sparse matrix and applied by multiplying said matrix with the densities/sensitivities.
assembly_mode (str) – whether full or only lower triangle of linear system / matrix is created.
materials_kw (dict) – dictionary containing all materials and their properties. Conventions must still be determined.
bcs (str or callable) – returns the boundary conditions
lk (None or callable) – element stiffness matrix
l (float or tuple of length (ndim) or np.ndarray of shape (ndim)) – side lengths of each element
obj_func (callable) – objective function. Should update the objective value, the rhs of the the adjoint problem (currently only for stationary lin. problems) and a flag indicating whether the objective is self adjoint.
obj_kw (dict) – keywords needed for the objective function. E. g. for a compliant mechanism and maximization of the displacement it would be the indicator array for output nodes. Check the objective for the necessary entries.
matinterpol (callable) – callable for material interpolation. Default is SIMP (simp).
matinterpol_dx (callable) – callable of derivative of the material interpolation with regards to the design variable. Default is SIMP (simp_dx).
matinterpol_kw (callable) – dictionary containing the arguments for the material interpolation.
el_flags (np.ndarray or None) – array of flags/integers that switch behaviour of specific elements. Currently 1 marks the element as passive (zero at all times), while 2 marks it as active (1 at all time).
optimizer (str) – solver options which are “oc”, “mma” and “gcmma” for the optimality criteria method, the method of moving asymptotes and the globally covergent method of moving asymptotes.
optimizer_kw (dict) – dictionary with parameters for optimizer.
mix (None or float,) – mixing parameter for design variable update.
nouteriter (int) – number of TO iterations
ninneriter (int) – number of inner iterations for GCMMA.
output_kw (dict) – dictionary containing output options.
- Return type:
None.