Foxelmanian / ToOptixUpdate

Current development of tooptix
20 stars 7 forks source link

Topology optimization with ToOptix

Current version

Installation

General information

Blender Installation

Python / PyCharm Installation

Example no design space with file:


from run_optimization import run_optimization

cpus = 4

# Optimization type --> seperated (combined is only in beta )

opti_type = "seperated"
# no design space is used until redefinition
sol_type = ["no_design_space", "static"]
files = ["no_design_space.inp", "testinp\Cylinder_Mesh.inp"]
max_iteration = 20
vol_frac = 0.3
penal = 3.0
matSets = 10
weight_factors = [3.0]
workDir = "work"
solverPath = "ccx"
run_optimization(penal,  matSets, opti_type, sol_type,
                                      weight_factors, max_iteration, vol_frac,
                                      files, workDir, solverPath, cpus)

Example no design space with element set and several iterations:


from run_optimization import run_optimization

# Optimization type --> seperated (combined is only in beta )
cpus = 6
opti_type = "seperated"
sol_type = ["static"]
files = ["PlateWithNoDesignSpaceFine.inp"]

for vol_frac in [0.4, 0.6]:
    for penal in [3.0]:
        max_iteration = 100
        matSets = 20
        weight_factors = [1.0]
        workDir = "work"
        solverPath = "ccx"
        no_design_set = 'SolidMaterial001Solid'
        run_optimization(penal,  matSets, opti_type, sol_type,
                                              weight_factors, max_iteration, vol_frac,
                                              files, workDir, solverPath, cpus, no_design_set)

For using the python FreeCAD Macro


from run_optimization import run_optimization
import json
import os

json_path = 'config.json'
if __name__ == "__main__":
    # Optimization type --> seperated (combined is not implemented )
    cpus = 6
    opti_type = "seperated"
    sol_type = ["static"]
    with open(json_path, 'r') as file:
        data = json.load(file)
    files = [data['inp_path']]
    workDir = 'work'
    solverPath =  "\"" + str(data['ccx_path']) +  "\""
    inp_path = data['inp_path']
    files = [inp_path]
    for vol_frac in [0.4]:
        for penal in [3.0]:
            max_iteration = 100
            matSets = 20
            weight_factors = [1.0]
            no_design_set = 'SolidMaterial001Solid'
            no_design_set = None
            run_optimization(penal,  matSets, opti_type, sol_type,
                                                  weight_factors, max_iteration, vol_frac,
                                                  files, workDir, solverPath, cpus, no_design_set)

Using rendering module mayavi


use_trimesh_may_avi = True
if use_trimesh_may_avi:
    from mayavi import mlab
    import trimesh
    interactive_visualization_after_iteration = 10

Output

Licence

GNU GENERAL PUBLIC LICENSE Version 2, June 1991