Topology Optmization with two design variables using Dolfin-Adjoint


128
views
0
5 months ago by
Hi everyone,

I'm trying to perform a topology optimization with two variables design (\rho and \theta)  using Dolfin-Adjoint. There is in my problem a volume constraint where only \rho should be considered. The following error appears: "Constraint.output_workspace must be supplied"

u = forward(theta, rho)
controls_theta = File("control_iterations_theta.pdv")
theta_viz = Function(P, name="ControlVisualisation_theta")
def eval_cb_theta(j, theta):
      theta_viz.assign(theta)
      controls_theta << theta_viz
controls_rho = File("control_iterations_rho.pdv")
rho_viz = Function(P, name="ControlVisualisation_rho")
def eval_cb_theta(j, rho):
      rho_viz.assign(rho)
      controls_rho << rho_viz
J = Functional(inner(F1,u)*ds(2))
m_theta = Control(theta)
m_rho = Control(rho)
Jhat = ReducedFunctional(J,[m_theta, m_rho], eval_cb_post=eval_cb_theta)
lb_theta = theta_m[0]
ub_theta = theta_m[nc-1]
lb_rho = 0.0
ub_rho = 1.0      
class VolumeConstraint(InequalityConstraint):
     def __init__(self, vol):
            self.vol = float(vol)
            self.smass = assemble(TestFunction(P) * Constant(1) * dx)
            self.tmpvec = Function(P)
     def function(self, m_rho):
            self.tmpvec.vector()[:] = m_rho
            integral = self.smass.inner(self.tmpvec.vector())
            print "Current control: ", integral
            return [self.vol - integral]  
     def jacobian(self, m_rho):    
           return [-self.smass]
     def output_workspace(self):
           return [0.0]
     def length(self):
           return 1
problem = MinimizationProblem(Jhat, bounds=[(lb_theta, ub_theta),(lb_rho, ub_rho)], constraints=VolumeConstraint(vol))

Can someone help me?
Community: FEniCS Project
Please login to add an answer/comment or follow this question.

Similar posts:
Search »