morphopt 3.1.4__tar.gz → 3.1.5__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 (92) hide show
  1. morphopt-3.1.5/PKG-INFO +82 -0
  2. morphopt-3.1.5/README.md +58 -0
  3. {morphopt-3.1.4 → morphopt-3.1.5}/pyproject.toml +5 -5
  4. {morphopt-3.1.4 → morphopt-3.1.5}/setup.cfg +4 -4
  5. morphopt-3.1.5/src/morphopt/__init__.py +82 -0
  6. morphopt-3.1.5/src/morphopt/codesign/__init__.py +18 -0
  7. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/codesign/constraints.py +268 -245
  8. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/codesign/feaparams.py +74 -74
  9. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/codesign/geometry.py +359 -352
  10. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/codesign/material.py +53 -42
  11. morphopt-3.1.5/src/morphopt/codesign/params.py +4 -0
  12. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/opt_runner.py +143 -130
  13. morphopt-3.1.5/src/morphopt/optcore/__init__.py +4 -0
  14. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/optcore/baseobject.py +47 -47
  15. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/optcore/controller.py +484 -448
  16. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/optcore/history.py +440 -440
  17. morphopt-3.1.5/src/morphopt/optcore/modelparams/__init__.py +5 -0
  18. morphopt-3.1.4/src/morphopt/optcore/modelparams/base_params.py → morphopt-3.1.5/src/morphopt/optcore/modelparams/baseparam.py +133 -119
  19. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feainterface/__init__.py +9 -9
  20. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feainterface/basefeainterface.py +50 -50
  21. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feainterface/bodyforceinterface.py +70 -70
  22. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feainterface/boundaryconditioninterface.py +59 -59
  23. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feainterface/contactinterface.py +113 -113
  24. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feainterface/coupleinterface.py +31 -31
  25. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feainterface/pointinterface.py +79 -79
  26. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feainterface/pressureinterface.py +68 -68
  27. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feainterface/referencepointinterface.py +29 -29
  28. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feainterface/springinterface.py +156 -156
  29. {morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel → morphopt-3.1.5/src/morphopt/optcore/modelparams}/feaparams.py +239 -242
  30. morphopt-3.1.5/src/morphopt/optcore/modelparams/geometry.py +90 -0
  31. morphopt-3.1.4/src/morphopt/optcore/modelparams/materials/homogeneousmaterial.py → morphopt-3.1.5/src/morphopt/optcore/modelparams/materials.py +118 -98
  32. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/optcore/modelparams/params.py +201 -139
  33. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/optcore/objfunc.py +224 -217
  34. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/optcore/solver.py +178 -162
  35. morphopt-3.1.5/src/morphopt/optcore/updaters.py +384 -0
  36. morphopt-3.1.5/src/morphopt/shapeopt/__init__.py +8 -0
  37. morphopt-3.1.5/src/morphopt/shapeopt/geometryinterfaces/__init__.py +3 -0
  38. {morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/geometryinterfaces/basesurfaceinterface.py +991 -920
  39. {morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/geometryinterfaces/bspsurfaceinterface.py +904 -904
  40. {morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/geometryinterfaces/cpgeosurfaceinterface.py +637 -574
  41. {morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/geometryparams.py +778 -821
  42. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/objectivefuncs/__init__.py +7 -5
  43. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/objectivefuncs/basefuncs.py +126 -115
  44. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/objectivefuncs/boundarys.py +96 -90
  45. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/objectivefuncs/distancesurface.py +153 -123
  46. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/objectivefuncs/shapederivative.py +177 -182
  47. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/objectivefuncs/surfacefairness.py +38 -40
  48. morphopt-3.1.5/src/morphopt/shapeopt/objectivefuncs/volumemaximization.py +25 -0
  49. morphopt-3.1.5/src/morphopt/shapeopt/objfunc.py +13 -0
  50. {morphopt-3.1.4/src/morphopt/optcore/updaters/geometry → morphopt-3.1.5/src/morphopt/shapeopt}/update_geometry.py +334 -346
  51. morphopt-3.1.5/src/morphopt/simp/__init__.py +9 -0
  52. {morphopt-3.1.4/src/morphopt/optcore/updaters/materials → morphopt-3.1.5/src/morphopt/simp}/objectivefuncs/__init__.py +5 -12
  53. {morphopt-3.1.4/src/morphopt/optcore/updaters/materials → morphopt-3.1.5/src/morphopt/simp}/objectivefuncs/basefuncs.py +106 -106
  54. {morphopt-3.1.4/src/morphopt/optcore/updaters/materials → morphopt-3.1.5/src/morphopt/simp}/objectivefuncs/boundarys.py +71 -71
  55. {morphopt-3.1.4/src/morphopt/optcore/updaters/materials → morphopt-3.1.5/src/morphopt/simp}/objectivefuncs/densityfield.py +25 -25
  56. morphopt-3.1.5/src/morphopt/simp/objectivefuncs/sensitivity.py +52 -0
  57. morphopt-3.1.5/src/morphopt/simp/objectivefuncs/volfrac.py +47 -0
  58. morphopt-3.1.5/src/morphopt/simp/simpmaterial.py +891 -0
  59. morphopt-3.1.5/src/morphopt/simp/solver.py +41 -0
  60. {morphopt-3.1.4/src/morphopt/optcore/updaters/materials → morphopt-3.1.5/src/morphopt/simp}/update_material.py +312 -338
  61. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/taskoptmization.py +75 -75
  62. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt/taskui.py +493 -458
  63. morphopt-3.1.5/src/morphopt/utils/__init__.py +2 -0
  64. morphopt-3.1.5/src/morphopt/utils/gradient_check.py +133 -0
  65. morphopt-3.1.5/src/morphopt/utils/history_read.py +25 -0
  66. morphopt-3.1.5/src/morphopt.egg-info/PKG-INFO +82 -0
  67. morphopt-3.1.5/src/morphopt.egg-info/SOURCES.txt +71 -0
  68. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt.egg-info/dependency_links.txt +0 -0
  69. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt.egg-info/requires.txt +4 -4
  70. {morphopt-3.1.4 → morphopt-3.1.5}/src/morphopt.egg-info/top_level.txt +0 -0
  71. morphopt-3.1.5/tests/test_fixedGeometry.py +24 -0
  72. morphopt-3.1.5/tests/test_path.py +12 -0
  73. morphopt-3.1.5/tests/test_ui.py +62 -0
  74. morphopt-3.1.4/PKG-INFO +0 -223
  75. morphopt-3.1.4/README.md +0 -199
  76. morphopt-3.1.4/src/morphopt/__init__.py +0 -43
  77. morphopt-3.1.4/src/morphopt/codesign/__init__.py +0 -4
  78. morphopt-3.1.4/src/morphopt/optcore/modelparams/__init__.py +0 -4
  79. morphopt-3.1.4/src/morphopt/optcore/modelparams/feamodel/__init__.py +0 -1
  80. morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry/__init__.py +0 -3
  81. morphopt-3.1.4/src/morphopt/optcore/modelparams/geometry/geometryinterfaces/__init__.py +0 -1
  82. morphopt-3.1.4/src/morphopt/optcore/modelparams/materials/__init__.py +0 -3
  83. morphopt-3.1.4/src/morphopt/optcore/modelparams/materials/simpmaterial.py +0 -458
  84. morphopt-3.1.4/src/morphopt/optcore/updaters/__init__.py +0 -3
  85. morphopt-3.1.4/src/morphopt/optcore/updaters/base_updater.py +0 -110
  86. morphopt-3.1.4/src/morphopt/optcore/updaters/geometry/__init__.py +0 -2
  87. morphopt-3.1.4/src/morphopt/optcore/updaters/materials/__init__.py +0 -1
  88. morphopt-3.1.4/src/morphopt/optcore/updaters/materials/objectivefuncs/sensitivity.py +0 -38
  89. morphopt-3.1.4/src/morphopt/optcore/updaters/optimizer.py +0 -177
  90. morphopt-3.1.4/src/morphopt/optcore/updaters/updaters.py +0 -115
  91. morphopt-3.1.4/src/morphopt.egg-info/PKG-INFO +0 -223
  92. morphopt-3.1.4/src/morphopt.egg-info/SOURCES.txt +0 -64
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: morphopt
3
+ Version: 3.1.5
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: pyqt6>=6.11.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
49
+ python examples/basic/shapeoptimization.py
50
+
51
+ # SIMP topology optimization
52
+ python examples/basic/simp.py
53
+ ```
54
+
55
+ 3. More usage examples:
56
+
57
+ - Task definition guide: `docs/module_definition_guide.md`
58
+ - Module API reference: `docs/module_reference.md`
59
+ - Theory & papers: `docs/theory/`
60
+
61
+ ## Directory Overview
62
+
63
+ - `src/morphopt/`
64
+ - `optcore` — Core package (controller, params, solver, objective, updaters)
65
+ - `shapeopt/` — B-spline shape optimization
66
+ - `simp/` — SIMP topology optimization
67
+ - `examples/` — Example tasks (bending actuator, gripper, etc.)
68
+ - `docs/` — Usage guides, API reference, and theory papers
69
+ - `tests/` — Gradient checks, geometry tests, UI tests
70
+
71
+ ## License
72
+
73
+ Research use preferred. For production or commercial use, please evaluate and ensure numerical and engineering robustness first.
74
+
75
+ ## Citation
76
+
77
+ If you use MorphOpt in your research, please cite:
78
+
79
+ - TRO 2023 — Morphology Design
80
+ - TRO 2026 — Jacobian-based Optimization
81
+ - TMECH 2026 — Contact-aware Design
82
+
@@ -0,0 +1,58 @@
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
25
+ python examples/basic/shapeoptimization.py
26
+
27
+ # SIMP topology optimization
28
+ python examples/basic/simp.py
29
+ ```
30
+
31
+ 3. More usage examples:
32
+
33
+ - Task definition guide: `docs/module_definition_guide.md`
34
+ - Module API reference: `docs/module_reference.md`
35
+ - Theory & papers: `docs/theory/`
36
+
37
+ ## Directory Overview
38
+
39
+ - `src/morphopt/`
40
+ - `optcore` — Core package (controller, params, solver, objective, updaters)
41
+ - `shapeopt/` — B-spline shape optimization
42
+ - `simp/` — SIMP topology optimization
43
+ - `examples/` — Example tasks (bending actuator, gripper, etc.)
44
+ - `docs/` — Usage guides, API reference, and theory papers
45
+ - `tests/` — Gradient checks, geometry tests, UI tests
46
+
47
+ ## License
48
+
49
+ Research use preferred. For production or commercial use, please evaluate and ensure numerical and engineering robustness first.
50
+
51
+ ## Citation
52
+
53
+ If you use MorphOpt in your research, please cite:
54
+
55
+ - TRO 2023 — Morphology Design
56
+ - TRO 2026 — Jacobian-based Optimization
57
+ - TMECH 2026 — Contact-aware Design
58
+
@@ -1,11 +1,11 @@
1
1
  [project]
2
2
  name = "morphopt"
3
- version = "3.1.4"
3
+ version = "3.1.5"
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",
@@ -16,10 +16,10 @@ dependencies = [
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
  ]
@@ -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, view_optimization_result
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()