Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Rahul-JOON/8772eca4aeaebf2e49504c3cadd41a96 to your computer and use it in GitHub Desktop.
Save Rahul-JOON/8772eca4aeaebf2e49504c3cadd41a96 to your computer and use it in GitHub Desktop.
Final Report GSoC23 Python: PyElastica - Rahul_Joon

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.

Project Details


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 STL mesh and convert it into PyElastica Geometry.
  • Develop a library that implements contact forces between rod and imported shape.
  • Validate implemented features/craft examples.
  • Document implemented work.

Job Done

  • 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 tests for the contact module. This would be the starting steps towards the milestones for the patch-0.3.2 and 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 mesh-module implementation.

    Firstly I researched about the possible ways/libraries to implement the functionality seamlessly with Elastica. The team settled with PyVista library as it was the most suitable for the task.

    But the development of mesh module was put on hold, as my Mentor realised my mistake in the unit tests for contact module. The unit tests's assert clauses of the contact module were comparing the outputs with the kernel outputs of the same functions; the outputs rather needed to be compared with Hand-crafted or 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 Mesh class 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

    Another class is currently under process that will actually implement the contact between a rod and mesh surface object 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 documented with docstrings and comments right at the time of writing it. Moreover, type hints were added for ease of understanding and debugging.

    Most of the pytests have been already written for the mesh module and the rest will be written soon.


What's Next

Firstly the 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment