matto.driver#

The optimization driver. Takes the problem dictionary from an input file, builds the design variables, the state problem and the sensitivity machinery, and runs the MMA loop over the load cases until the design stops changing and every continuation schedule has run out. Contains no material-specific equations.

class matto.driver.OptimizationDriver(problem)[source]#

Bases: object

Run a material and topology optimization problem.

The input problem defines:

  • Mesh

  • Communicator (optional comm, default mesh.comm)

  • Design variables

  • Boundary conditions

  • Load cases

  • Free-energy density

  • Objective

  • Constraints

  • Requested output fields

  • FEM, MMA, and output options

Construction reads and checks the problem and builds the design variables, the state problem and the sensitivity object. After that the object can be used three ways:

driver.run()               optimize, save and report
driver.evaluate()          solve every load case for the current
                           design; objective, gradients,
                           constraints, no optimization step
driver.solve_load_case(c)  one forward analysis

forward() pushes the raw design through the operator chains; call it after changing raw values by hand and before evaluate().

solve_load_case(load_case)[source]#

Solve one load case; returns its name and the max abs u.

continuation_complete()[source]#
forward(iteration=0)[source]#

Push every raw design field through its operator chain.

iteration is passed to the operators’ continuation schedules; the default of 0 never triggers one. Returns True if any operator advanced its schedule.

run()[source]#

Iterate to convergence, then re-solve, save and report the design.

Returns a dictionary with the final objective, constraint values, maximum displacements, the number of iterations taken, and the output directory. Calling run() again continues from the current design and continuation state with a fresh MMA history.

evaluate(write_output=False, report=False)[source]#

Solve every load case and accumulate the objective and its gradients.

The objective is the weighted sum over load cases and the gradients are in raw space. Constraints are design-dependent and load-independent, so their values and gradients are taken from the first load case only.

Returns a dictionary:

objective             weighted sum over load cases
objective_gradients   {variable: owned raw-space array}
constraints           {name: {"value", "residual"}}
constraint_gradients  {name: {variable: owned array}}
max_displacements     {load case: max abs u over all ranks}