# PyElastica Examples
This directory contains number of examples of elastica. Each [example cases](#example-cases) are stored in separate subdirectories, containing case descriptions, run file, and all other data/script necessary to run. More [advanced cases](#advanced-cases) are stored in separate repository with its description.
## Case Examples
Some examples provide additional files or links to published paper for a complete description. Examples can serve as a starting template for customized usages.
- [AxialStretchingCase](./AxialStretchingCase)
__Purpose__: Physical convergence test of simple stretching rod.
__Features__: CosseratRod, OneEndFixedRod, EndpointForces
- [TimoshenkoBeamCase](./TimoshenkoBeamCase)
__Purpose__: Physical convergence test of simple Timoshenko beam.
__Features__: CosseratRod, OneEndFixedRod, EndpointForces,
- [FlexibleSwingingPendulumCase](./FlexibleSwingingPendulumCase)
__Purpose__: Physical convergence test of simple pendulum with flexible rod.
__Features__: CosseratRod, HingeBC, GravityForces
- [ContinuumSnakeCase](./ContinuumSnakeCase)
__Purpose__: Demonstrate simple case of modeling biological creature using PyElastica. The example uses friction to create slithering snake, and optimize the speed using [CMA](CMA-ES/pycma).
__Features__: CosseratRod, MuscleTorques, RodPlaneContactWithAnisotropicFriction, Gravity, CMA Optimization
- [ContinuumSnakeWithLiftingWaveCase](./ContinuumSnakeWithLiftingWaveCase)
__Purpose__: Demonstrate simple case of modeling biological creature using PyElastica. The example uses friction to create slithering snake with lift.
__Features__: CosseratRod, MuscleTorquesLifting(custom implemented), SnakeRodPlaneContact(custom implemented), Gravity
- [MuscularSnake](./MuscularSnake)
__Purpose__: Example of [Parallel connection module](../elastica/experimental/connection_contact_joint/parallel_connection.py) and customized [Force module](./MuscularSnake/muscle_forces.py) to implement muscular snake.
__Features__: MuscleForces(custom implemented)
- [ButterflyCase](./ButterflyCase)
__Purpose__: Demonstrate simple restoration with initial strain.
__Features__: CosseratRod
- [CantileverDistributedLoad](./CantileverDistributedLoad)
__Purpose__: Demonstrate the demformation of a straight cantilever under both conservative (like water pressure) and non-conservative (like gravity) distributed load, compared with numerical solutions from Tschisgale, Silvio (2019).[<strong>”Chapter 3: Numerical models of partitioned problems”</strong>](https://nbn-resolving.org/urn:nbn:de:bsz:14-qucosa2-387063) Technische Univerisitat Dresden Institution of Fluid Mechanics
__Features__: CosseratRod
- [CantileverTransversalLoadCase](./CantileverTransversalLoadCase)
__Purpose__: Demonstrate the demformation of a curved cantilever under transversal one-end load, and also do Physical convergence test, compared with numerical solutions from Tschisgale, Silvio (2019).
__Features__: CosseratRod
- [TumblingUnconstrainedRod](./TumblingUnconstrainedRod)
__Purpose__: Demostrate the dynamics of tumbling uncontrained rod, compared with analytical solution from [Hisao, Kou Hou (1998).](https://www.sciencedirect.com/science/article/pii/S0045782598001522), Computer methods in applied mechanics and engineering.
__Features__: CosseratRod
- [FrictionValidationCases](./FrictionValidationCases)
__Purpose__: Physical validation of rolling and translational friction.
__Features__: CosseratRod, UniformForces, RodPlaneContactWithAnisotropicFriction
- [JointCases](./JointCases)
__Purpose__: Demonstrate various joint usage with Cosserat Rod.
__Features__: FreeJoint, FixedJoint, HingeJoint, OneEndFixedRod, EndpointForcesSinusoidal
- [RigidBodyCases](./RigidBodyCases)
__Purpose__: Demonstrate usage of rigid body on simulation.
__Features__: Cylinder, Sphere
- [RodRigidBodyContact](./RigidBodyCases/RodRigidBodyContact)
__Purpose__: Demonstrate contact between cylinder and rod, for different intial conditions.
__Features__: Cylinder, CosseratRods, RodCylinderContact
- [HelicalBucklingCase](./HelicalBucklingCase)
__Purpose__: Demonstrate helical buckling with extreme twisting boundary condition.
__Features__: HelicalBucklingBC
- [ContinuumFlagellaCase](./ContinuumFlagellaCase)
__Purpose__: Demonstrate flagella modeling using PyElastica.
__Features__: SlenderBodyTheory, MuscleTorques,
- [MuscularFlagella](./MuscularFlagella)
__Purpose__: Example of customizing [Joint module](./MuscularFlagella/connection_flagella.py) and [Force module](./MuscularFlagella/muscle_forces_flagella.py) to implement muscular flagella.
__Features__: MuscleForces(custom implemented)
- [RodContactCase](./RodContactCase)
- [RodRodContact](./RodContactCase/RodRodContact)
__Purpose__: Demonstrates contact between two rods, for different initial conditions.
__Features__: CosseratRod, RodRodContact
- [RodSelfContact](./RodContactCase/RodSelfContact)
- [PlectonemesCase](./RodContactCase/RodSelfContact/PlectonemesCase)
__Purpose__: Demonstrates rod self contact with Plectoneme example, and how to use link-writhe-twist after simulation completed.
__Features__: CosseratRod, SelonoidsBC, RodSelfContact, Link-Writhe-Twist
- [SolenoidsCase](./RodContactCase/RodSelfContact/SolenoidsCase)
__Purpose__: Demonstrates rod self contact with Solenoid example, and how to use link-writhe-twist after simulation completed.
__Features__: CosseratRod, SelonoidsBC, RodSelfContact, Link-Writhe-Twist
- [BoundaryConditionsCases](./BoundaryConditionsCases)
__Purpose__: Demonstrate the usage of boundary conditions for constraining the movement of the system.
__Features__: GeneralConstraint, CosseratRod
- [DynamicCantileverCase](./DynamicCantileverCase)
__Purpose__: Validation of dynamic cantilever vibration for multiple modes.
__Features__: CosseratRod, OneEndFixedRod
- [RingRodCase](./RingRodCase)
__Purpose__: Demonstrate simulation of ring rod.
__Features__: RingCosseratRod, OneEndFixedRod, GravityForce
- [CatenaryCase](./CatenaryCase)
__Purpose__: Demonstrate simulation of cosserat rod under gravity with fixed ends, compared with Catenary Analytical Solution from Routh, Edward John (1891). [<strong>”Chapter X: On Strings”</strong>](https://books.google.com/books?id=3N5JAAAAMAAJ&pg=PA315#v=onepage&q&f=false). A Treatise on Analytical Statics. University Press.
__Features__: CosseratRod, FixedConstraint, GravityForce
- [KnotCase](./KnotCase)
__Purpose__: Demonstrate simulation of rod forming a knot using a tip-pose control.
__Features__: CosseratRod, KnotTheory, FixedConstraint, RodSelfContact, Custom p-controller for SO3.
## Functional Examples
- [RestartExample](./RestartExample)
__Purpose__: Demonstrate the usage of restart module.
__Features__: save_state, load_state
## Advanced Cases
[Elastica RL control](GazzolaLab/Elastica-RL-control) - Case presented in [<strong>Elastica: A compliant mechanics environment for soft robotic control</strong>](https://doi.org/10.1109/LRA.2021.3063698)
[Gym Softrobot](skim0119/gym-softrobot) - Soft-robot control environment developed in OpenAI-gym format to study slender body control with reinforcement learning.
## Experimental Cases
- [ParallelConnectionExample](./ExperimentalCases/ParallelConnectionExample)
__Purpose__: Demonstrate the usage of parallel connection.
__Features__: connect two parallel rods