morphopt 3.1.4__tar.gz → 3.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of morphopt might be problematic. Click here for more details.

Files changed (126) hide show
  1. morphopt-3.1.6/PKG-INFO +95 -0
  2. morphopt-3.1.6/README.md +71 -0
  3. {morphopt-3.1.4 → morphopt-3.1.6}/pyproject.toml +10 -6
  4. {morphopt-3.1.4 → morphopt-3.1.6}/setup.cfg +4 -4
  5. morphopt-3.1.6/src/morphopt/__init__.py +82 -0
  6. morphopt-3.1.6/src/morphopt/codesign/__init__.py +18 -0
  7. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/codesign/constraints.py +268 -245
  8. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/codesign/feaparams.py +74 -74
  9. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/codesign/geometry.py +359 -352
  10. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/codesign/material.py +53 -42
  11. morphopt-3.1.6/src/morphopt/codesign/params.py +4 -0
  12. morphopt-3.1.6/src/morphopt/opt_runner.py +82 -0
  13. morphopt-3.1.6/src/morphopt/optcore/__init__.py +4 -0
  14. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/optcore/baseobject.py +47 -47
  15. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/optcore/controller.py +484 -448
  16. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/optcore/history.py +440 -440
  17. morphopt-3.1.6/src/morphopt/optcore/modelparams/__init__.py +5 -0
  18. morphopt-3.1.4/src/morphopt/optcore/modelparams/base_params.py → morphopt-3.1.6/src/morphopt/optcore/modelparams/baseparam.py +133 -119
  19. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feainterface/__init__.py +9 -9
  20. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feainterface/basefeainterface.py +50 -50
  21. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feainterface/bodyforceinterface.py +70 -70
  22. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feainterface/boundaryconditioninterface.py +59 -59
  23. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feainterface/contactinterface.py +113 -113
  24. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feainterface/coupleinterface.py +31 -31
  25. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feainterface/pointinterface.py +79 -79
  26. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feainterface/pressureinterface.py +68 -68
  27. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feainterface/referencepointinterface.py +29 -29
  28. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feainterface/springinterface.py +156 -156
  29. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.6/src/morphopt/optcore/modelparams}/feaparams.py +239 -242
  30. morphopt-3.1.6/src/morphopt/optcore/modelparams/geometry.py +90 -0
  31. morphopt-3.1.4/src/morphopt/optcore/modelparams/materials/homogeneousmaterial.py → morphopt-3.1.6/src/morphopt/optcore/modelparams/materials.py +118 -98
  32. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/optcore/modelparams/params.py +201 -139
  33. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/optcore/objfunc.py +224 -217
  34. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/optcore/solver.py +178 -162
  35. morphopt-3.1.6/src/morphopt/optcore/updaters.py +384 -0
  36. morphopt-3.1.6/src/morphopt/shapeopt/__init__.py +8 -0
  37. morphopt-3.1.6/src/morphopt/shapeopt/geometryinterfaces/__init__.py +3 -0
  38. {morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/geometryinterfaces/basesurfaceinterface.py +969 -920
  39. {morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/geometryinterfaces/bspsurfaceinterface.py +899 -904
  40. {morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/geometryinterfaces/cpgeosurfaceinterface.py +635 -574
  41. {morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/geometryparams.py +778 -821
  42. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/objectivefuncs/__init__.py +7 -5
  43. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/objectivefuncs/basefuncs.py +126 -115
  44. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/objectivefuncs/boundarys.py +96 -90
  45. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/objectivefuncs/distancesurface.py +153 -123
  46. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/objectivefuncs/shapederivative.py +177 -182
  47. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/objectivefuncs/surfacefairness.py +38 -40
  48. morphopt-3.1.6/src/morphopt/shapeopt/objectivefuncs/volumemaximization.py +25 -0
  49. morphopt-3.1.6/src/morphopt/shapeopt/objfunc.py +13 -0
  50. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.6/src/morphopt/shapeopt}/update_geometry.py +334 -346
  51. morphopt-3.1.6/src/morphopt/simp/__init__.py +9 -0
  52. {morphopt-3.1.4/src/morphopt/optcore/updaters/materials → morphopt-3.1.6/src/morphopt/simp}/objectivefuncs/__init__.py +5 -12
  53. {morphopt-3.1.4/src/morphopt/optcore/updaters/materials → morphopt-3.1.6/src/morphopt/simp}/objectivefuncs/basefuncs.py +106 -106
  54. {morphopt-3.1.4/src/morphopt/optcore/updaters/materials → morphopt-3.1.6/src/morphopt/simp}/objectivefuncs/boundarys.py +71 -71
  55. {morphopt-3.1.4/src/morphopt/optcore/updaters/materials → morphopt-3.1.6/src/morphopt/simp}/objectivefuncs/densityfield.py +25 -25
  56. morphopt-3.1.6/src/morphopt/simp/objectivefuncs/sensitivity.py +52 -0
  57. morphopt-3.1.6/src/morphopt/simp/objectivefuncs/volfrac.py +47 -0
  58. morphopt-3.1.6/src/morphopt/simp/simpmaterial.py +891 -0
  59. morphopt-3.1.6/src/morphopt/simp/solver.py +41 -0
  60. {morphopt-3.1.4/src/morphopt/optcore/updaters/materials → morphopt-3.1.6/src/morphopt/simp}/update_material.py +312 -338
  61. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt/taskoptmization.py +70 -75
  62. morphopt-3.1.6/src/morphopt/taskui.py +18 -0
  63. morphopt-3.1.6/src/morphopt/ui/__init__.py +37 -0
  64. morphopt-3.1.6/src/morphopt/ui/__main__.py +6 -0
  65. morphopt-3.1.6/src/morphopt/ui/app.py +57 -0
  66. morphopt-3.1.6/src/morphopt/ui/codegen/__init__.py +1 -0
  67. morphopt-3.1.6/src/morphopt/ui/codegen/generator.py +367 -0
  68. morphopt-3.1.6/src/morphopt/ui/codegen/objective_templates.py +52 -0
  69. morphopt-3.1.6/src/morphopt/ui/launcher.py +153 -0
  70. morphopt-3.1.6/src/morphopt/ui/mainwindow.py +146 -0
  71. morphopt-3.1.6/src/morphopt/ui/model/__init__.py +16 -0
  72. morphopt-3.1.6/src/morphopt/ui/model/loaders.py +32 -0
  73. morphopt-3.1.6/src/morphopt/ui/model/problem.py +170 -0
  74. morphopt-3.1.6/src/morphopt/ui/model/schemas.py +489 -0
  75. morphopt-3.1.6/src/morphopt/ui/monitor.py +558 -0
  76. morphopt-3.1.6/src/morphopt/ui/observe_panel.py +533 -0
  77. morphopt-3.1.6/src/morphopt/ui/schemes/__init__.py +14 -0
  78. morphopt-3.1.6/src/morphopt/ui/schemes/base.py +101 -0
  79. morphopt-3.1.6/src/morphopt/ui/schemes/codesign.py +173 -0
  80. morphopt-3.1.6/src/morphopt/ui/schemes/shapeopt.py +127 -0
  81. morphopt-3.1.6/src/morphopt/ui/schemes/simp.py +115 -0
  82. morphopt-3.1.6/src/morphopt/ui/widgets/__init__.py +1 -0
  83. morphopt-3.1.6/src/morphopt/ui/widgets/codeeditor.py +207 -0
  84. morphopt-3.1.6/src/morphopt/ui/widgets/editor.py +305 -0
  85. morphopt-3.1.6/src/morphopt/ui/widgets/model_tree.py +282 -0
  86. morphopt-3.1.6/src/morphopt/ui/widgets/objective_editor.py +141 -0
  87. morphopt-3.1.6/src/morphopt/ui/widgets/param_form.py +152 -0
  88. morphopt-3.1.6/src/morphopt/ui/widgets/solver_editor.py +181 -0
  89. morphopt-3.1.6/src/morphopt/ui/widgets/stepmatrix.py +207 -0
  90. morphopt-3.1.6/src/morphopt/ui/widgets/updater_editor.py +214 -0
  91. morphopt-3.1.6/src/morphopt/ui/widgets/values.py +63 -0
  92. morphopt-3.1.6/src/morphopt/ui/widgets/viewer.py +252 -0
  93. morphopt-3.1.6/src/morphopt/ui/workbench.py +313 -0
  94. morphopt-3.1.6/src/morphopt/utils/__init__.py +2 -0
  95. morphopt-3.1.6/src/morphopt/utils/gradient_check.py +133 -0
  96. morphopt-3.1.6/src/morphopt/utils/history_read.py +25 -0
  97. morphopt-3.1.6/src/morphopt.egg-info/PKG-INFO +95 -0
  98. morphopt-3.1.6/src/morphopt.egg-info/SOURCES.txt +103 -0
  99. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt.egg-info/dependency_links.txt +0 -0
  100. morphopt-3.1.6/src/morphopt.egg-info/entry_points.txt +2 -0
  101. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt.egg-info/requires.txt +5 -5
  102. {morphopt-3.1.4 → morphopt-3.1.6}/src/morphopt.egg-info/top_level.txt +0 -0
  103. morphopt-3.1.6/tests/test_fixedGeometry.py +24 -0
  104. morphopt-3.1.6/tests/test_path.py +12 -0
  105. morphopt-3.1.6/tests/test_ui.py +62 -0
  106. morphopt-3.1.4/PKG-INFO +0 -223
  107. morphopt-3.1.4/README.md +0 -199
  108. morphopt-3.1.4/src/morphopt/__init__.py +0 -43
  109. morphopt-3.1.4/src/morphopt/codesign/__init__.py +0 -4
  110. morphopt-3.1.4/src/morphopt/opt_runner.py +0 -130
  111. morphopt-3.1.4/src/morphopt/optcore/modelparams/__init__.py +0 -4
  112. morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel/__init__.py +0 -1
  113. morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry/__init__.py +0 -3
  114. morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry/geometryinterfaces/__init__.py +0 -1
  115. morphopt-3.1.4/src/morphopt/optcore/modelparams/materials/__init__.py +0 -3
  116. morphopt-3.1.4/src/morphopt/optcore/modelparams/materials/simpmaterial.py +0 -458
  117. morphopt-3.1.4/src/morphopt/optcore/updaters/__init__.py +0 -3
  118. morphopt-3.1.4/src/morphopt/optcore/updaters/base_updater.py +0 -110
  119. morphopt-3.1.4/src/morphopt/optcore/updaters/geometry/__init__.py +0 -2
  120. morphopt-3.1.4/src/morphopt/optcore/updaters/materials/__init__.py +0 -1
  121. morphopt-3.1.4/src/morphopt/optcore/updaters/materials/objectivefuncs/sensitivity.py +0 -38
  122. morphopt-3.1.4/src/morphopt/optcore/updaters/optimizer.py +0 -177
  123. morphopt-3.1.4/src/morphopt/optcore/updaters/updaters.py +0 -115
  124. morphopt-3.1.4/src/morphopt/taskui.py +0 -459
  125. morphopt-3.1.4/src/morphopt.egg-info/PKG-INFO +0 -223
  126. morphopt-3.1.4/src/morphopt.egg-info/SOURCES.txt +0 -64
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.4
2
+ Name: morphopt
3
+ Version: 3.1.6
4
+ Summary: A morphing optimization framework using PyTorch and Abaqus.
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: torch>=2.9.1
8
+ Requires-Dist: torchvision>=0.15.1
9
+ Requires-Dist: numpy>=2.0.0
10
+ Requires-Dist: pypardiso>=0.4.7
11
+ Requires-Dist: pyside6>=6.8.0
12
+ Requires-Dist: pyvista>=0.47.1
13
+ Requires-Dist: pyvistaqt>=0.11.3
14
+ Requires-Dist: vtk>=9.6.1
15
+ Requires-Dist: gmsh>=4.15.0
16
+ Requires-Dist: tabulate>=0.9.0
17
+ Requires-Dist: imageio>=2.37.3
18
+ Requires-Dist: bspmap>=1.0.3
19
+ Requires-Dist: torchfea>=1.0.17
20
+ Requires-Dist: trimesh>=4.11.5
21
+ Requires-Dist: networkx>=3.6.1
22
+ Requires-Dist: scipy>=1.17.1
23
+ Requires-Dist: cpgeo>=1.0.12
24
+
25
+ # MorphOpt — A Differentiable Optimization Framework for Soft Structure & Morphology Design
26
+
27
+ **Developed by Zenan Song**
28
+
29
+ A differentiable structural optimization framework that eliminates manual sensitivity derivation by fusing the adjoint method with automatic differentiation (AD). The sensitivity corresponds to the virtual work of residual force derivatives on the adjoint displacement field, computed via a single backpropagation through the residual graph. MorphOpt provides a unified interface for geometry, load, and material definition, calls torchfea for GPU-accelerated differentiable nonlinear FEA and adjoint-AD sensitivity, and employs a trust-region optimizer with L-BFGS for design updates. Validated on SIMP topology optimization with B-spline density fields and pneumatic soft robot shape optimization with deformation-dependent follower loads.
30
+
31
+ ## Features
32
+
33
+ - Custom model definition covering geometry, material, and load parameters
34
+ - Differentiable FEA via torchfea with automatic solving and sensitivity propagation
35
+ - L-BFGS and trust-region methods for parameter updates within a subproblem framework
36
+ - Fully extensible via inheritance — users customize every component in their definition scripts
37
+
38
+ ## Quick Start
39
+
40
+ ```bash
41
+ pip install morphopt
42
+ ```
43
+
44
+ 1. Install dependencies. Python ≥ 3.12, PyTorch (float64) recommended.
45
+ 2. Run a minimal example:
46
+
47
+ ```bash
48
+ # Shape optimization (pneumatic bending actuator)
49
+ python examples/bendingactuator.py
50
+
51
+ # SIMP topology optimization (compliant gripper)
52
+ python examples/gripper.py
53
+ ```
54
+
55
+ 3. **Launch the GUI (recommended)** — define, run and observe an optimization all inside one window:
56
+
57
+ ```bash
58
+ morphopt-ui # console command, available after `pip install morphopt`
59
+ # python -m morphopt.ui works too (handy when running from a source code directory)
60
+ ```
61
+
62
+ The complete UI workflow (definition part + observer part) is described in [`docs/UI_usage.md`](docs/UI_usage.md).
63
+
64
+ Further references:
65
+
66
+ - Task definition guide: `docs/module_definition_guide.md`
67
+ - Module API reference: `docs/module_reference.md`
68
+ - Theory & papers: `docs/theory/`
69
+
70
+ ## Directory Overview
71
+
72
+ - `src/morphopt/`
73
+ - `optcore` — Core package (controller, params, solver, objective, updaters)
74
+ - `shapeopt/` — B-spline shape optimization
75
+ - `simp/` — SIMP topology optimization
76
+ - `codesign/` — Shell co-design (shape + material)
77
+ - `ui/` — PySide6 graphical UI (definition + observer in one window)
78
+ - `examples/` — Example tasks (bending actuator, gripper, etc.)
79
+ - `docs/` — Usage guides, API reference, theory papers
80
+ - [`UI_usage.md`](docs/UI_usage.md) — graphical UI user guide
81
+ - `tests/` — Gradient checks, geometry tests, UI tests
82
+ - `ui_runs/` — runs launched from the UI and their results (`<label>_T<timestamp>/`)
83
+
84
+ ## License
85
+
86
+ Research use preferred. For production or commercial use, please evaluate and ensure numerical and engineering robustness first.
87
+
88
+ ## Citation
89
+
90
+ If you use MorphOpt in your research, please cite:
91
+
92
+ - TRO 2023 — Morphology Design
93
+ - TRO 2026 — Jacobian-based Optimization
94
+ - TMECH 2026 — Contact-aware Design
95
+
@@ -0,0 +1,71 @@
1
+ # MorphOpt — A Differentiable Optimization Framework for Soft Structure & Morphology Design
2
+
3
+ **Developed by Zenan Song**
4
+
5
+ A differentiable structural optimization framework that eliminates manual sensitivity derivation by fusing the adjoint method with automatic differentiation (AD). The sensitivity corresponds to the virtual work of residual force derivatives on the adjoint displacement field, computed via a single backpropagation through the residual graph. MorphOpt provides a unified interface for geometry, load, and material definition, calls torchfea for GPU-accelerated differentiable nonlinear FEA and adjoint-AD sensitivity, and employs a trust-region optimizer with L-BFGS for design updates. Validated on SIMP topology optimization with B-spline density fields and pneumatic soft robot shape optimization with deformation-dependent follower loads.
6
+
7
+ ## Features
8
+
9
+ - Custom model definition covering geometry, material, and load parameters
10
+ - Differentiable FEA via torchfea with automatic solving and sensitivity propagation
11
+ - L-BFGS and trust-region methods for parameter updates within a subproblem framework
12
+ - Fully extensible via inheritance — users customize every component in their definition scripts
13
+
14
+ ## Quick Start
15
+
16
+ ```bash
17
+ pip install morphopt
18
+ ```
19
+
20
+ 1. Install dependencies. Python ≥ 3.12, PyTorch (float64) recommended.
21
+ 2. Run a minimal example:
22
+
23
+ ```bash
24
+ # Shape optimization (pneumatic bending actuator)
25
+ python examples/bendingactuator.py
26
+
27
+ # SIMP topology optimization (compliant gripper)
28
+ python examples/gripper.py
29
+ ```
30
+
31
+ 3. **Launch the GUI (recommended)** — define, run and observe an optimization all inside one window:
32
+
33
+ ```bash
34
+ morphopt-ui # console command, available after `pip install morphopt`
35
+ # python -m morphopt.ui works too (handy when running from a source code directory)
36
+ ```
37
+
38
+ The complete UI workflow (definition part + observer part) is described in [`docs/UI_usage.md`](docs/UI_usage.md).
39
+
40
+ Further references:
41
+
42
+ - Task definition guide: `docs/module_definition_guide.md`
43
+ - Module API reference: `docs/module_reference.md`
44
+ - Theory & papers: `docs/theory/`
45
+
46
+ ## Directory Overview
47
+
48
+ - `src/morphopt/`
49
+ - `optcore` — Core package (controller, params, solver, objective, updaters)
50
+ - `shapeopt/` — B-spline shape optimization
51
+ - `simp/` — SIMP topology optimization
52
+ - `codesign/` — Shell co-design (shape + material)
53
+ - `ui/` — PySide6 graphical UI (definition + observer in one window)
54
+ - `examples/` — Example tasks (bending actuator, gripper, etc.)
55
+ - `docs/` — Usage guides, API reference, theory papers
56
+ - [`UI_usage.md`](docs/UI_usage.md) — graphical UI user guide
57
+ - `tests/` — Gradient checks, geometry tests, UI tests
58
+ - `ui_runs/` — runs launched from the UI and their results (`<label>_T<timestamp>/`)
59
+
60
+ ## License
61
+
62
+ Research use preferred. For production or commercial use, please evaluate and ensure numerical and engineering robustness first.
63
+
64
+ ## Citation
65
+
66
+ If you use MorphOpt in your research, please cite:
67
+
68
+ - TRO 2023 — Morphology Design
69
+ - TRO 2026 — Jacobian-based Optimization
70
+ - TMECH 2026 — Contact-aware Design
71
+
@@ -1,25 +1,29 @@
1
1
  [project]
2
2
  name = "morphopt"
3
- version = "3.1.4"
3
+ version = "3.1.6"
4
4
  description = "A morphing optimization framework using PyTorch and Abaqus."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
7
7
  dependencies = [
8
- "torch>=2.0.0",
8
+ "torch>=2.9.1",
9
9
  "torchvision>=0.15.1",
10
10
  "numpy>=2.0.0",
11
11
  "pypardiso>=0.4.7",
12
- "pyqt6>=6.11.0",
12
+ "pyside6>=6.8.0",
13
13
  "pyvista>=0.47.1",
14
14
  "pyvistaqt>=0.11.3",
15
15
  "vtk>=9.6.1",
16
16
  "gmsh>=4.15.0",
17
17
  "tabulate>=0.9.0",
18
18
  "imageio>=2.37.3",
19
- "bspmap>=1.0.0",
20
- "torchfea>=1.0.11",
19
+ "bspmap>=1.0.3",
20
+ "torchfea>=1.0.17",
21
21
  "trimesh>=4.11.5",
22
22
  "networkx>=3.6.1",
23
23
  "scipy>=1.17.1",
24
- "cpgeo>=1.0.8",
24
+ "cpgeo>=1.0.12",
25
25
  ]
26
+
27
+ [project.scripts]
28
+ # console entry for the graphical UI (after `pip install morphopt`)
29
+ morphopt-ui = "morphopt.ui:run_app"
@@ -1,4 +1,4 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,82 @@
1
+ """
2
+ A differentiable structural optimization framework that eliminates manual sensitivity derivation by fusing the adjoint method with automatic differentiation (AD). The sensitivity corresponds to the virtual work of residual force derivatives on the adjoint displacement field, computed via a single backpropagation through the residual graph. MorphOpt provides a unified interface for geometry, load, and material definition, calls torchfea for GPU-accelerated differentiable nonlinear FEA and adjoint-AD sensitivity, and employs a trust-region optimizer with L-BFGS for design updates. Validated on SIMP topology optimization with B-spline density fields and pneumatic soft robot shape optimization with deformation-dependent follower loads.
3
+ """
4
+
5
+
6
+ # region: Logging Configuration
7
+ import logging as __logging
8
+
9
+ def enable_logging(level=__logging.INFO, log_file=None, file_log_level=__logging.DEBUG):
10
+ """
11
+ Enable logging for the FEA package.
12
+
13
+ Parameters
14
+ ----------
15
+ level : int
16
+ the logging level (e.g., logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL)
17
+ log_file : str, optional
18
+ the path to a log file where logs will be written. If None, logs will only be printed to the console.
19
+ file_log_level : int
20
+ the logging level for the log file. Default is logging.INFO.
21
+
22
+ Examples
23
+ --------
24
+ >>> import torchfea
25
+ >>> torchfea.enable_logging(level=logging.DEBUG, log_file='fem.log')
26
+ """
27
+ logger = __logging.getLogger(__name__)
28
+ logger.setLevel(min(level, file_log_level))
29
+
30
+ # clear existing handlers to avoid duplicate logs
31
+ logger.handlers.clear()
32
+
33
+ # logging to console
34
+ console = __logging.StreamHandler()
35
+ console.setLevel(level)
36
+ console.setFormatter(__logging.Formatter(
37
+ '%(asctime)s | %(levelname)-7s | %(message)s',
38
+ datefmt='%Y-%m-%d %H:%M:%S'
39
+ ))
40
+ logger.addHandler(console)
41
+
42
+ # logging to file if log_file is provided
43
+ if log_file:
44
+ file_handler = __logging.FileHandler(log_file, encoding='utf-8')
45
+ file_handler.setLevel(file_log_level)
46
+ file_handler.setFormatter(__logging.Formatter(
47
+ '%(asctime)s | %(levelname)-7s | %(name)s | %(message)s'
48
+ ))
49
+ logger.addHandler(file_handler)
50
+
51
+ return logger
52
+ # endregion
53
+
54
+
55
+
56
+
57
+
58
+ # region optcore imports
59
+ from .optcore.controller import Controller
60
+ from .optcore.modelparams import FEAParams, FixedGeometryINP, FixedGeometry, HomogeneousMaterial, Params
61
+ from .optcore.solver import Solver
62
+ from .optcore.modelparams import Params
63
+ from .optcore.updaters import Updaters
64
+ from .optcore.objfunc import ObjectiveFunction
65
+ from .optcore.history import History
66
+ from .optcore.baseobject import BaseObject
67
+ # endregion
68
+
69
+ from .opt_runner import start_optimization, debug_optimization
70
+
71
+ # region modules
72
+ from . import shapeopt
73
+ from . import codesign
74
+ from . import simp
75
+ # endregion
76
+
77
+ # region scripts
78
+ from .utils import check_gradients, get_controller
79
+ # endregion
80
+
81
+ controller: Controller = None
82
+
@@ -0,0 +1,18 @@
1
+ from .material import CodesignMaterials
2
+ from .geometry import CodesignGeometry
3
+ from .constraints import InwardCurvatureRadius, OffsetSurfaceMinThickness
4
+ from .feaparams import CodesignFEAParams
5
+ from .params import Params
6
+ from ..optcore import Solver, Updaters
7
+ from ..shapeopt import GeometryParams, UpdaterGeometries, ObjectiveFunction
8
+ from ..simp import UpdaterMaterials
9
+
10
+ def plot_geometry_and_materials(geometry: CodesignGeometry, materials: CodesignMaterials):
11
+ import pyvista as pv
12
+ plotter = pv.Plotter(window_size=(1400, 900))
13
+ plotter.set_background('white')
14
+
15
+ plotter = materials.plot(plotter=plotter)
16
+ geometry.plot(plotter=plotter, opacity=[0.0, 1.0])
17
+
18
+ plotter.show()