-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #367 from GazzolaLab/update/mypy
Type-hinting elastica
- Loading branch information
Showing
101 changed files
with
4,362 additions
and
5,055 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ __pycache__/ | |
# C extensions | ||
*.so | ||
|
||
*.swp | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,114 @@ | ||
# Code Design: Mixin and Composition | ||
# Code Design | ||
|
||
## Mixin and Composition | ||
|
||
Elastica package follows Mixin and composition design patterns that may be unfamiliar to users. Here is a collection of references that introduce the package design. | ||
|
||
## References | ||
### References | ||
|
||
- [stackoverflow discussion on Mixin](https://stackoverflow.com/questions/533631/what-is-a-mixin-and-why-are-they-useful) | ||
- [example of Mixin: python collections](https://docs.python.org/dev/library/collections.abc.html) | ||
|
||
## Duck Typing | ||
|
||
Elastica package uses duck typing to allow users to define their own classes and functions. Here is a `typing.Protocol` structure that is used in the package. | ||
|
||
### Systems | ||
|
||
``` {mermaid} | ||
flowchart LR | ||
direction RL | ||
subgraph Systems Protocol | ||
direction RL | ||
SLBD(SlenderBodyGeometryProtool) | ||
SymST["SymplecticSystem:\n• KinematicStates/Rates\n• DynamicStates/Rates"] | ||
style SymST text-align:left | ||
ExpST["ExplicitSystem:\n• States (Unused)"] | ||
style ExpST text-align:left | ||
P((position\nvelocity\nacceleration\n..)) --> SLBD | ||
subgraph StaticSystemType | ||
Surface | ||
Mesh | ||
end | ||
subgraph SystemType | ||
direction TB | ||
Rod | ||
RigidBody | ||
end | ||
SLBD --> SymST | ||
SystemType --> SymST | ||
SLBD --> ExpST | ||
SystemType --> ExpST | ||
end | ||
subgraph Timestepper Protocol | ||
direction TB | ||
StP["StepperProtocol\n• step(SystemCollection, time, dt)"] | ||
style StP text-align:left | ||
SymplecticStepperProtocol["SymplecticStepperProtocol\n• PositionVerlet"] | ||
style SymplecticStepperProtocol text-align:left | ||
ExpplicitStepperProtocol["ExpplicitStepperProtocol\n(Unused)"] | ||
end | ||
subgraph SystemCollection | ||
end | ||
SymST --> SystemCollection --> SymplecticStepperProtocol | ||
ExpST --> SystemCollection --> ExpplicitStepperProtocol | ||
StaticSystemType --> SystemCollection | ||
``` | ||
|
||
### System Collection (Build memory block) | ||
|
||
``` {mermaid} | ||
flowchart LR | ||
Sys((Systems)) | ||
St((Stepper)) | ||
subgraph SystemCollectionType | ||
direction LR | ||
StSys["StaticSystem:\n• Surface\n• Mesh"] | ||
style StSys text-align:left | ||
DynSys["DynamicSystem:\n• Rod\n • CosseratRod\n• RigidBody\n • Sphere\n • Cylinder"] | ||
style DynSys text-align:left | ||
BlDynSys["BlockSystemType:\n• BlockCosseratRod\n• BlockRigidBody"] | ||
style BlDynSys text-align:left | ||
F{{"Feature Group (OperatorGroup):\n• Synchronize\n• Constrain values\n• Constrain rates\n• Callback"}} | ||
style F text-align:left | ||
end | ||
Sys --> StSys --> F | ||
Sys --> DynSys -->|Finalize| BlDynSys --> St | ||
DynSys --> F <--> St | ||
``` | ||
|
||
### System Collection (Features) | ||
|
||
``` {mermaid} | ||
flowchart LR | ||
Sys((Systems)) | ||
St((Stepper)) | ||
subgraph SystemCollectionType | ||
direction LR | ||
StSys["StaticSystem:\n• Surface\n• Mesh"] | ||
style StSys text-align:left | ||
DynSys["DynamicSystem:\n• Rod\n • CosseratRod\n• RigidBody\n • Sphere\n • Cylinder"] | ||
style DynSys text-align:left | ||
subgraph Feature | ||
direction LR | ||
Forcing -->|add_forcing_to| Synchronize | ||
Constraints -->|constrain| ConstrainValues | ||
Constraints -->|constrain| ConstrainRates | ||
Contact -->|detect_contact_between| Synchronize | ||
Connection -->|connect| Synchronize | ||
Damping -->|dampen| ConstrainRates | ||
Callback -->|collect_diagnosis| CallbackGroup | ||
end | ||
end | ||
Sys --> StSys --> Feature | ||
Sys --> DynSys | ||
DynSys --> Feature <--> St | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.