Open mishkat1096 opened 1 year ago
Hi, mishkat1096.
I'm so sorry to my too-late response. The error "Adjoint value is None, is the functional independent of the control variable?" is raised from the pyadjoint. This is because of the discontinuous calculated chain or not-differentiable model. Can you provide a more detailed function of Homogenization_2D(rho_m)
?
Thanks for your reply. I am using periodic BC. following the tutorial. W is mixed function space.
``
Ve = VectorElement("CG", mesh_m.ufl_cell(), 1)
Re = VectorElement("R", mesh_m.ufl_cell(), 0)
W = FunctionSpace(mesh_m, MixedElement([Ve, Re]), constrained_domain=PeriodicBoundary(vertices, tolerance=1e-10))
``
``
def eps(v):
return sym(grad(v))
def sigma(Eps,rho_m, v):
E, nu = material_parameters#[i]
E = (rho_m**3) *E
lmbda = E*nu/(1+nu)/(1-2*nu)
mu = E/2/(1+nu)
return lmbda*tr(eps(v) + Eps)*Identity(2) + 2*mu*(eps(v)+Eps)
``
``
``
def Homogenization_2D(rho_m):
Eps = Constant(((0, 0), (0, 0)))
v_,lamb_ = TestFunctions(W)
dv, dlamb = TrialFunctions(W)
w = Function(W)
F = inner(SIMP(rho_m,p)*sigma(Eps,rho_m,dv), eps(v_))*dy
a, L = lhs(F), rhs(F)
a += dot(lamb_,dv)*dy + dot(dlamb,v_)*dy
solve(a == L, w, [], solver_parameters={"linear_solver": "cg"})
Chom = np.zeros((3, 3))
y = SpatialCoordinate(mesh_m)
for (j, case) in enumerate(["Exx", "Eyy", "Exy"]):
print("Solving {} case...".format(case))
Eps.assign(Constant(macro_strain(j)))
solve(a == L, w, [], solver_parameters={"linear_solver": "cg"})
(v, lamb) = split(w)
Sigma = np.zeros((3,))
for k in range(3):
Sigma[k] = assemble(sum([stress2Voigt(sigma( Eps, rho_m, dv))[k]*dy]))/vol
Chom[j, :] = Sigma
return Chom
``
Hi Thanks for the great tool. I am trying to do a Concurrent topology optimization. Optimizing both macro and microstructure. However, i get an error "Adjoint value is None, is the functional independent of the control variable?" My set up is following: ``
``
I am getting the homogenized material property from the function. my objective is minimize the compliance of Macro structure. and with two constraints:
``
`` Thanks