Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Controlling custom design variables for topology optimization with LiveLink

Hendrik Mechanical Engineering

Please login with a confirmed email address before reporting spam

The goal of our project is to do topology optimization (TO), letting COMSOL carry out the FEA and computing objective/design density updates with MATLAB, using LiveLink.

For density-based TO, is it possible to iteratively define the vector of design densities ?

The process should look something like this :

while not converged { 1 MATLAB sets new design densities : theta_c = ( theta_c1 , theta_c2, ... ) 2 COMSOL takes these densitites and computes the performance of the structure 3 MATLAB computes the objective function, constraint (and their derivatives) based on the extracted solution vector and system matrices. 4 MMA (running in MATLAB) computes an update to the design density vector }

The reason for the usage of LiveLink is the implementation of a custom objective function.

Would anyone be able to help me clarify the way in which the MATLAB can prescribe the vector of design densities , to use in a single computation for COMSOL ? Currently, my COMSOL takes the "initial value" of theta_c in the density model each time.

PS. The paper by J. Kook (2021) describes a similar problem that is implemented. However, in their case they defined their own PDEs to solve, and my problem is purely structural (thoroughly implemented in COMSOL).


4 Replies Last Post Jul 11, 2023, 4:42 a.m. EDT
Kristian Ejlebjærg Jensen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Jul 7, 2023, 7:40 a.m. EDT
Updated: 1 year ago Jul 7, 2023, 7:40 a.m. EDT

Hi

You can use the setU() method to set the solution vector, and this includes the control variables. It is important to call createSolution() afterwards.

Best regards, Kristian E. Jensen Technical Product Manager, Optimization

Hi You can use the setU() method to set the solution vector, and this includes the control variables. It is important to call createSolution() afterwards. Best regards, Kristian E. Jensen Technical Product Manager, Optimization

Hendrik Mechanical Engineering

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Jul 7, 2023, 9:38 a.m. EDT
Updated: 1 year ago Jul 7, 2023, 9:45 a.m. EDT

Hi,

Thanks for the reply. However, I still have a question about running the script with the updated values.

Right now, I conduct the following steps in my loop

U = mphgetu() <---- extract solution

U_new(index) = .... <--- update the vector at the index of the densities (from mphmatrix)

model.sol('sol1').setU(U_new) <--- update solution vector

model.sol('sol1').createSolution() <---- update solution

Even though my densities update , my actual solution does not update (the values in the vector remain identical). Therefore, I think that the computation of the solution with the new design variables is not carried out somehow.

Would you be able to help me figure out what command I am missing, or what other mistake could be present?

Thanks in advance,

Hi, Thanks for the reply. However, I still have a question about running the script with the updated values. Right now, I conduct the following steps in my loop U = mphgetu()

Kristian Ejlebjærg Jensen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Jul 10, 2023, 4:40 a.m. EDT

Hi

You probably need to modify the expression for the initialization of the control variables to something along the lines of

if(reUseTheta,withsol('sol1',dtopo1.theta_c),volfrac)

where reUseTheta is parameter set to 0 for the first iteration and 1 for the rest.

Best regards,

Kristian E. Jensen

Technical Product Manager, Optimization

Hi You probably need to modify the expression for the initialization of the control variables to something along the lines of **if(reUseTheta,withsol('sol1',dtopo1.theta_c),volfrac)** where **reUseTheta** is parameter set to 0 for the first iteration and 1 for the rest. Best regards, Kristian E. Jensen Technical Product Manager, Optimization

Hendrik Mechanical Engineering

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Jul 11, 2023, 4:42 a.m. EDT

Hi Kristian,

Thanks for your reply - I have implemented it and it works great!

For others who have the same issue, one should insert the if() statement in the initialization of the design variables (in the Density Model).

Much obliged.

Hi Kristian, Thanks for your reply - I have implemented it and it works great! For others who have the same issue, one should insert the if() statement in the initialization of the design variables (in the Density Model). Much obliged.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.