from ansys import dpf
from ansys.dpf import core
result_file = r"C:\Users\DELL\Desktop\ansys-demo\file.rst"
model = core.Model(result_file)
print(model)
design_variable = dpf.core.field.simple.ConstantField(0.5)
target_function = dpf.core.function.Functional(dpf.core.function.VolumeFunction())
constraint = dpf.core.function.Functional(dpf.core.function.MinStressFunction(component=1, value=100))
topology_optimization = dpf.core.TopologyOptimization(optimized_model_name="Optimized_Model")
topology_optimization.set_model(model)
topology_optimization.set_design_variable(design_variable)
topology_optimization.set_target_function(target_function)
topology_optimization.add_constraint(constraint)
topology_optimization.set_time_step(0.3)
topology_optimization.set_iterations(10)
topology_optimization.run_optimization()
optimized_result_file = r"C:\Users\DELL\Desktop\ansys-demo\optimized_result_file.rst"
topology_optimization.get_optimized_model().save_as(optimized_result_file)
ansys-api-mapdl==0.5.1
ansys-api-platform-instancemanagement==1.0.0b3
ansys-dpf-core==0.8.1
ansys-dpf-gate==0.3.1
ansys-dpf-gatebin==0.3.1
ansys-grpc-dpf==0.7.0
ansys-mapdl-core==0.65.1
ansys-mapdl-reader==0.52.19
ansys-platform-instancemanagement==1.1.1
ansys-tools-path==0.3.1
appdirs==1.4.4
cachetools==5.3.1
certifi==2023.7.22
charset-normalizer==3.2.0
click==8.1.6
colorama==0.4.6
contourpy==1.1.0
cycler==0.11.0
fonttools==4.41.1
geomdl==5.3.1
google-api-core==2.11.1
google-api-python-client==2.95.0
google-auth==2.22.0
google-auth-httplib2==0.1.0
googleapis-common-protos==1.59.1
grpcio==1.56.2
httplib2==0.22.0
idna==3.4
importlib-metadata==6.8.0
iniconfig==2.0.0
kiwisolver==1.4.4
matplotlib==3.7.2
numpy==1.25.1
packaging==23.1
pexpect==4.8.0
Pillow==10.0.0
platformdirs==3.9.1
pluggy==1.2.0
pooch==1.7.0
progressbar2==4.2.0
protobuf==3.20.3
protoc-gen-swagger==0.1.0
psutil==5.9.5
ptyprocess==0.7.0
pyansys-tools-versioning==0.4.0
pyasn1==0.5.0
pyasn1-modules==0.3.0
pyiges==0.3.1
pyparsing==3.0.9
pytest==7.4.0
python-dateutil==2.8.2
python-utils==3.7.0
pyvista==0.39.0
requests==2.31.0
rsa==4.9
scipy==1.11.1
scooby==0.7.2
six==1.16.0
tqdm==4.65.0
typing_extensions==4.7.1
uritemplate==4.1.1
urllib3==1.26.16
vtk==9.2.6
zipp==3.16.2