GSoC 2023 | Python Software Foundation: PyElastica
This is a summary of the work I completed for the open-source project PyElastica under the Python Software Foundation organisation during the 2023 Google Summer of Code programme.
- Title: Extending Contact Module Capabilities
- Organization: Python Software Foundation: PyElastica
- Repo: PyElastica
- Project link: PyElastica - Extending contact module capabilities
- Mentors: Arman Tekinalp, Yashraj Bhosale, Ali Albazroun, Noel Naughton
At the moment of proposal of this project, in PyElastica we could model the contact of rods with a frictional plane or rigid cylinder and themselves.
This project aimed to extend the contact module for the rod and any arbitrary shape. Implementation of the contact module that could input any STL mesh and create its geometry in PyElastica and also apply contact force between the rod and imported shape. This would improve the capabilities of PyElastica as a whole.
Following is the overview of the tasks of this project:
- Develop an algorithm to import
STLmesh and convert it into
- Develop a library that implements contact forces between rod and imported shape.
- Validate implemented features/craft
Phase 1: Getting upto Pace
The project was kickstarted with a zoom meet with the PyElastica team. After introducing ourselves we discussed about the project and the tasks to be done.
It was decided by my mentors that it will be for the best, for me to start developing
unit testsfor the
contact module. This would be the starting steps towards the milestones for the
patch-0.3.2and also help me gain a better understanding of the contact module implementation.
Hence I did exactly the same thus setting myself up for the project.
Phase 2: Research and Rectifying Mistakes
This time I acutally got started with the project itself that is the
Firstly I researched about the possible ways/libraries to implement the functionality seamlessly with Elastica. The team settled with
PyVistalibrary as it was the most suitable for the task.
But the development of mesh module was put on hold, as my Mentor realised my
unit testsfor contact module. The unit tests's
assert clausesof the contact module were
comparingthe outputs with the
kernel outputsof the same functions; the outputs rather needed to be compared with
Analytically verified values.
I worked on this as a separate issue with urgency and crafted test cases for the contact module by hand; I added all the calculation/equations as comments beside the tests for better understanding.
Phase 3: Mesh Module Implementation
I worked on the
Meshclass that essentially initializes all the necessary attributes and methods of a mesh by taking the /path/ of the mesh file(STL/OBJ) as input using PyVista library.
Mesh class's attributes: - Faces - Face_normals - Face_center - Mesh_scale - Mesh_center - Mesh_orientation - Model_path Mesh class's methods: - Mesh_update - Visualize - Scale - Rotate
(Checkout detailed documentation of mesh at Mesh.py)
Another class is currently under process that will actually implement the contact between a
rod and mesh surfaceobject simply by providing a mesh file and rods as input along with other physical parameters like friction, k, nu etc.
Phase 4: Documentation and Testing
The code was
well documentedwith docstrings and comments right at the time of writing it. Moreover,
type hintswere added for ease of understanding and debugging.
Most of the
pytestshave been already written for the mesh module and the rest will be written soon.
- 13 Pull requests: PyElastica
- Helped with 8 Issues: PyElastica
- Overall Commits: PyElastica - main (all the latest commits will show once the update patch is merged into main branch)
- Weekly Blog Posts: Python-GSoC.org
rodmeshsurfacecontact class will be finalized and merged into the update branch.
Next we will work on writing an
example that showcases the use of the mesh module using the rodmeshsurfacecontact class likely to
simulate the contact between a snake and a mesh surface.
GSoC Experience and Learnings
This was my first time participating in the Google Summer of Code programme and I am glad that I got selected for the same. I got to learn a lot of new things and also got to work with a team of experienced developers.
Speaking of technical skills I can definitely say that I have improved my coding skills and also got to learn about the open-source community and how it works. The need for git/github along with writing and pushing professional code; I also got to learn about the importance of documentation and testing in a project.
I had a really great time this summer working with PyElastica. I would like to thank the Python Software Foundation, PyElastica and Google Summer of Code for this wonderful learning opportunity.
I would like to thank my mentor, Arman Tekinalp for always being there to answer all my questions, even the silliest of them! And keeping the pace of the project so convenient that I never felt like being left behind.
The best part about GSoC is that you get to know and work with professionals from all around the world and this experience is something that I will cherish forever.