calculix / beso

Python code for topology optimization using CalculiX FEM solver.
GNU Lesser General Public License v3.0
314 stars 47 forks source link

Setting initial state #30

Open sebastianmaklary opened 1 year ago

sebastianmaklary commented 1 year ago

Hi there

I can't seem to find any settings meant to set the initial state of an element set and I believe that such a setting could be very useful. A part that is conventionally designed is likely much closer to the optimum than having the whole design space as initially in the high state so having the option to place an initial seed could possibly bring down the computation time or just result in different resulting geometries. If I could set the initial state of one *ELSET as high and another as low, then the iterations needed could possibly be cut down while still having a large design space.

fandaL commented 1 year ago

See the beso_config.py file. There is a parameter continue_from Originally it served to restart the optimization from a given iteration so you can use it as well. Create two meshes from your design domain, e.g. initial0.inp - there are void elements initial1.inp - there are elements to start as solid (i.e. your initial situation) you will then use parameter as continue_from = "initial0.inp" With the actual code, files must end with numbers 0 and 1 and you have to create both files.

fandaL commented 1 year ago

iterations_limit = "auto" does not take it into account, so you might prescribe some value.

sebastianmaklary commented 1 year ago

Setting initial state is pretty simple it seems. In Beso_main, line 193 reads: elm_states[en] = len(domain_density[dn]) - 1 # set to highest state Ive changed this to: elm_states[en] = domain_initstate[dn] where domain_initstate is a newly added variable that´s set in beso_config to either 0, 1 or whatever the initial state of an elset is supposed to be. Then the code works as long as the initial state is sensible.

This has shown an issue if the initial state is not sensible. If it is below the mass goal as the code won´t start iterating and if the initial state violates the failure index in too many elements (more than the tolerance), then it will force the iteration to converge within a few iterations. The solution to the first part is to just set the mass goal ratio extremely low but the solution to the second part may require a larger alteration to the code so that the mass addition ratio is larger than the mass removal ratio if way too many elements have their failure index violated.

I've been using the analysis of a wishbone (automotive suspension member) as a tester for this and about 50 iterations is saved by having an initial seed mesh but the time saved isn't as great if the model setup includes a bonded contact between the seed mesh and the rest of the design domain as the runtime of each iteration is longer and I also noticed that it is a lot less stable as one iteration will have a lot of elements above the failure index and another iteration will have none and so on and so forth. image Above image: Whole domain with initial seed. image' Image above: Iteration 91 of starting with an initial seed, 55 minutes.

image Above image: the no of elements with failure index>=1

fandaL commented 1 year ago

I have implemented it to new branche. You can test it. If there will not be problems, I will merge it with the master branche. https://github.com/calculix/beso/compare/master...domain_initial_state The implementation is close to your suggestions. You can now use parameter domain_initial_state to define initial state of the domain.

By the way, I did not uploaded here any example of growing structure, but it is possible. If you are interested I can find some example, but it cannot stop on prescribed stress and I think it will give worse results on complex structures.