Ejemplo n.º 1
0
def main():
    """Distributed load."""
    # Default input parameters
    nelx, nely, volfrac, penalty, rmin, ft = cli.parse_args(
        nelx=120, volfrac=0.2, rmin=1.2)
    cli.main(nelx, nely, volfrac, penalty, rmin, ft,
             bc=DistributedLoadBoundaryConditions(nelx, nely))
Ejemplo n.º 2
0
def main():
    """Two simultaneous point loads."""
    # Default input parameters
    nelx, nely, volfrac, penalty, rmin, ft = cli.parse_args(
        nelx=120, volfrac=0.2, rmin=1.5)
    cli.main(nelx, nely, volfrac, penalty, rmin, ft,
             bc=SimultaneousLoadsBoundaryConditions(nelx, nely))
Ejemplo n.º 3
0
def main():
    """Multiple loads."""
    # Default input parameters
    nelx, nely, volfrac, penalty, rmin, ft = cli.parse_args(nelx=120,
                                                            volfrac=0.2,
                                                            rmin=1.5)
    bc = MultipleLoadsBoundaryConditions(nelx, nely)
    problem = ComplianceProblem(bc, penalty)
    cli.main(nelx, nely, volfrac, penalty, rmin, ft, bc=bc, problem=problem)
Ejemplo n.º 4
0
def main():
    """I-shaped beam domain with stress computation."""
    # Default input parameters
    nelx, nely, volfrac, penalty, rmin, ft = cli.parse_args(
        nelx=120, nely=120, volfrac=0.3, penalty=12, rmin=1.2)
    bc = IBeamBoundaryConditions(nelx, nely)
    problem = VonMisesStressProblem(nelx, nely, penalty, bc)
    gui = StressGUI(problem, title="Stress on I Beam")
    filter = [topopt.filters.SensitivityBasedFilter,
              topopt.filters.DensityBasedFilter][ft](nelx, nely, rmin)
    solver = TopOptSolver(problem, volfrac, filter,
                          gui, maxeval=4000, ftol_rel=1e-5)
    cli.main(nelx, nely, volfrac, penalty, rmin, ft, solver=solver)
Ejemplo n.º 5
0
def main():
    """Explore affects of parameters using complicance problem and MBB Beam."""
    # Default input parameters
    nelx, nely, volfrac, penalty, rmin, ft = cli.parse_args()
    cli.main(nelx, nely, volfrac, penalty, rmin, ft)
    # Vary the filter radius
    for scaled_factor in [0.25, 2]:
        cli.main(nelx, nely, volfrac, penalty, scaled_factor * rmin, ft)
    # Vary the penalization power
    for scaled_factor in [0.5, 4]:
        cli.main(nelx, nely, volfrac, scaled_factor * penalty, rmin, ft)
    # Vary the discreization
    for scale_factor in [0.5, 2]:
        cli.main(int(scale_factor * nelx), int(scale_factor * nely), volfrac,
                 penalty, rmin, ft)
Ejemplo n.º 6
0
def main():
    """Run the example by constructing the TopOpt objects."""
    # Default input parameters
    nelx, nely, volfrac, penalty, rmin, ft = cli.parse_args(nelx=300,
                                                            nely=100,
                                                            volfrac=0.3,
                                                            penalty=3,
                                                            rmin=1.4)
    bc = MBBBeamBoundaryConditions(nelx, nely)
    problem = HarmonicLoadsProblem(bc, penalty)
    title = cli.title_str(nelx, nely, volfrac, rmin, penalty)
    gui = GUI(problem, title)
    filter = [SensitivityBasedFilter, DensityBasedFilter][ft](nelx, nely, rmin)
    solver = TopOptSolver(problem, volfrac, filter, gui)

    # Allocate design variables (as array), initialize and allocate sens.
    x = volfrac * numpy.ones(nely * nelx, dtype=float)

    print(
        textwrap.dedent(f"""\
        {solver:s}
        dims: {nelx:d} x {nely:d}
        volfrac: {volfrac:g}, penalty: {penalty:g}, rmin: {rmin:g}
        Filter method: {solver.filter:s}"""))

    frequency_response = []
    for angular_frequency in numpy.linspace(0.0, 0.2, 11):
        # Solve the problem
        print("angular_frequency={}".format(angular_frequency))
        problem.angular_frequency = angular_frequency
        x = solver.optimize(x)
        x = solver.filter_variables(x)
        if gui is not None:
            gui.update(x)
        dobj = numpy.empty(x.shape)
        frequency_response.append(
            [angular_frequency,
             problem.compute_objective(x, dobj)])

    frequency_response = numpy.array(frequency_response)
    fig, ax = plt.subplots()
    ax.plot(frequency_response[:, 0], frequency_response[:, 1])
    ax.set_title("Frequency Response")
    ax.set_xlabel(r"$\omega$")
    ax.set_ylabel(r"$\mathbf{u}^T\mathbf{f}$")

    # Make sure the plot stays and that the shell remains
    input("Press any key...")
Ejemplo n.º 7
0
def main():
    """Run the example by constructing the TopOpt objects."""
    # Default input parameters
    nelx, nely, volfrac, penalty, rmin, ft = cli.parse_args(nelx=100,
                                                            nely=100,
                                                            volfrac=0.3,
                                                            penalty=10,
                                                            rmin=1.4)
    bc = DisplacementInverterBoundaryConditions(nelx, nely)
    # bc = GripperBoundaryConditions(nelx, nely)
    # bc = CrossSensitivityExampleBoundaryConditions(nelx, nely)
    problem = MechanismSynthesisProblem(bc, penalty)
    title = cli.title_str(nelx, nely, volfrac, rmin, penalty)
    gui = GUI(problem, title)
    filter = [SensitivityBasedFilter, DensityBasedFilter][ft](nelx, nely, rmin)
    solver = MechanismSynthesisSolver(problem, volfrac, filter, gui)
    cli.main(nelx, nely, volfrac, penalty, rmin, ft, solver=solver)
Ejemplo n.º 8
0
def main():
    """Multiple simultaneous point loads with stress computation."""
    # Default input parameters
    nelx, nely, volfrac, penalty, rmin, ft = cli.parse_args(nelx=120,
                                                            volfrac=0.2,
                                                            rmin=1.2)
    bc = DistributedLoadBoundaryConditions(nelx, nely)
    problem = VonMisesStressProblem(nelx, nely, penalty, bc)
    gui = StressGUI(problem, title="Stresses of Distributed Load Example")
    cli.main(nelx,
             nely,
             volfrac,
             penalty,
             rmin,
             ft,
             bc=bc,
             problem=problem,
             gui=gui)
Ejemplo n.º 9
0
def main():
    """Multiple loads with stresses."""
    # Default input parameters
    nelx, nely, volfrac, penalty, rmin, ft = cli.parse_args(nelx=120,
                                                            volfrac=0.2,
                                                            rmin=1.5)
    bc = MultipleLoadsBoundaryConditions(nelx, nely)
    problem = VonMisesStressProblem(nelx, nely, penalty, bc)
    title = cli.title_str(nelx, nely, volfrac, rmin, penalty)
    gui = StressGUI(problem, title)
    cli.main(nelx,
             nely,
             volfrac,
             penalty,
             rmin,
             ft,
             bc=bc,
             problem=problem,
             gui=gui)