GSoC 2025: Expanding SymPy’s Force and Torque Models

299 views
Skip to first unread message

Rushabh Mehta

unread,
Feb 14, 2025, 1:05:23 AM2/14/25
to sympy

Dear SymPy Developers,

I hope this message finds you well! My name is Rushabh Mehta, and I am a computer engineering sophomore at VJTI, Mumbai. I’ve been contributing to SymPy for some time now, with merged pull requests and a few more currently under review. Working with the SymPy codebase has been an enriching learning experience, and I am looking forward to contributing more.

I am writing to share my interest in working on a GSoC project this year to enhance the force and torque models in the mechanics module. This project builds upon the work done by last year’s contributor, Hwayeon Kang, who implemented several foundational classes like LinearSpring, DuffingSpring, and LinearDamper. While these additions were a significant step forward, I feel the scope of their usage remains limited. My goal is to broaden the applicability of these prebuilt classes by introducing additional force and torque models that are both versatile and representative of real-world systems.

Here’s a rough outline of the proposed enhancements:


Proposed Deliverables

1. Nonlinear Models:

  • HysteresisSpring: Extend the Duffing Spring to include hysteresis and piecewise nonlinear behavior, enabling modeling of materials like rubber.
  • NonlinearDamper: Model damping forces proportional to  (velocity raised to fractional or higher-order power). This can represent progressive damping systems.

2. Aerodynamic Forces:

  • AerodynamicDrag: Implement drag forces as a function of velocity, fluid density, and drag coefficient.
  • AerodynamicLift: Add lift forces for aerodynamic systems, incorporating lift coefficients and surface area.

3. Building on GSoC 2024 Work:
As suggested in last year’s project (link to the report):

  • Finalize the Hill’s muscle model actuator and add an example to the documentation.
  • Complete the friction example (sliding block on a rotating disc).

4. Documentation and Examples:

  • Add practical examples to the SymPy documentation, such as:
    • Damped oscillations.
    • Aerodynamic forces in free fall.
    • Dynamic muscle models.

Why This Project

The expansion of force and torque models will enhance SymPy's versatility, making it applicable to a wider range of use cases in fields such as biomechanics, aerodynamics, and mechanical systems.

I would greatly appreciate your feedback on this direction. Please let me know if there are any areas you think should be prioritized or if there's anything I should adjust.

Thank you for your time, and I look forward to your valuable input.

Best regards,
Rushabh Mehta

Jason Moore

unread,
Feb 14, 2025, 2:39:46 AM2/14/25
to sy...@googlegroups.com
Dear Rushabh,

This seems like a good follow up to Hwayeon's project. You have a good starting idea to turn into a proposal.

Keep in mind that adding an aerodynamic force, like simply 1/2*CD*A*rho*v**2, is trivial to include, i.e. Force(point, 1/2*CD*A*rho*v**2). If we bother to make a special object for the force, it should be something that people have a harder time implementing and takes many lines of code. This way our object saves them that effort. So I'd like to see adding fewer more difficult forces than a lot of trivial forces.

There is interest from the biomechanics community to have muscle models and many prebuilt wrapping objects. Muscles wrap around your bones and soft tissue in complex geometrical ways and until we have more wrapping options, many musculoskeletal models cannot be created. So maybe this is of interest to you too.

Jason


--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/sympy/ada5689e-76a3-4d81-ab76-0677061052b2n%40googlegroups.com.

Rushabh Mehta

unread,
Feb 14, 2025, 3:14:26 AM2/14/25
to sympy

Hello,

Thank you for your valuable and quick feedback! 

I completely agree with your point that forces like aerodynamic drag are relatively straightforward to implement, and we want to ensure that any new models we add to SymPy provide significant value beyond simple equations. The goal would be to focus on forces or torque models that are difficult to implement and would save users time and effort.

I also appreciate your insights on biomechanics. I will research and study up on muscle models and the challenges around wrapping objects for musculoskeletal models. I’ll definitely keep it in mind as I refine the proposal.

Thank you again for your guidance, and I’ll be sure to keep your comments in mind as I develop the full proposal. I will be sure to communicate my progress and queries here. 

Best regards,
Rushabh Mehta

Rushabh Mehta

unread,
Feb 15, 2025, 11:54:56 AM2/15/25
to sympy

Hello again,

Thank you for your valuable feedback and insights! Based on the discussion so far, I’ve refined my proposed project scope to ensure meaningful contributions that align with current needs. This remains open to any and all feedback.

Current Proposed Scope

  1. Completing Future Work from GSoC 2024 (H. Kang)

  2. Expanding Nonlinear Models in sympy.physics.mechanics

    • HysteresisSpring: A spring model incorporating hysteresis effects, enabling the simulation of materials like rubber.
    • NonlinearDamper: A generalized damping model extending DuffingSpring with nonlinear damping behavior.
    • Accompanying documentation, tests, and relevant examples.
  3. Advancing sympy.physics.biomechanics

    • Implementing the two not-yet-implemented methods in musculotendon dynamics listed here by you:
      • Fiber length state (damped elastic tendon).
      • Tendon force state (damped elastic tendon).
  4. (If Time Permits) Additional Extensions

    • Possible additions like rolling friction, viscous friction, or other commonly used models based on complexity and feasibility.
    • Further improvements based on feedback.

Queries and Next Steps

Given my limited background in biomechanics, I wanted to clarify:

  • Will implementing the musculotendon dynamics methods require introducing new geometrical wrapping functionality?
  • Are there specific requirements or high-priority areas within the biomechanics module that I should direct my proposal towards?

I’d love to hear your thoughts on this refined scope and any guidance on it.

Looking forward to your feedback!

Best regards,
Rushabh Mehta

Rushabh Mehta

unread,
Feb 20, 2025, 1:16:10 PM2/20/25
to sympy

Dear Jason,

I hope you're doing well! I wanted to follow up on my previous message regarding my proposed GSoC project. I understand you must be busy, but I’d really appreciate any feedback on the refined scope I shared—especially concerning the biomechanics aspect.

If there are specific priorities or areas that would strengthen my proposal, I’d be happy to adjust accordingly. Your insights would be invaluable in shaping a more impactful contribution.

Looking forward to your thoughts!

Best regards,
Rushabh Mehta

Hwayeon Kang

unread,
Feb 25, 2025, 3:50:26 PM2/25/25
to sympy
Hi Rushabh,

It looks like a great start! I'm not very familiar with the hysteresis effect, but I was wondering if there is any reference paper or a specific plan for implementing the force. Also, how do you plan to extend DuffingSpring with nonlinear damping behaviour? I think you've read pull request #26438, which added DuffingSpring actuator, but as you can see, the current class is built on the assumption that when the linear stiffness parameter (alpha) is negative, chaotic motion occurs. This makes it a rather complex case, so I'm curious how you want to incorporate nonlinear damping into this framework.

Best,
Hwayeon

Rushabh Mehta

unread,
Feb 27, 2025, 12:46:37 PM2/27/25
to sympy

Dear Hwayeon,

Thank you for your feedback! I wanted to follow up with more details on both of your mentioned points.

For the HysteresisSpring class, I plan to implement it using the Bouc-Wen model, which is widely used for modeling hysteretic behavior in materials like rubber. The reference I'll try to follow is Ismail et al. (2009), "The Bouc-Wen Model, a Survey."  This model captures different types of hysteresis loops and effects, making it a good fit for SymPy in my opinion. Let me know if you have thoughts or concerns about this approach.

Regarding Nonlinear Damping in DuffingSpring, I see your comment about the current implementation assuming that negative stiffness leads to chaotic motion. To work around this, instead of modifying the DuffingSpring class directly, I’m thinking of subclassing it to create a NonLinearDamperSpring (name not fixed). This subclass would introduce a velocity-dependent damping term:

where is configurable to allow for different damping behaviors. This way, the original DuffingSpring remains unchanged, and users can opt into nonlinear damping separately.

Would love to hear your thoughts on this. Thanks again for your guidance and time.

Best,
Rushabh Mehta

Rushabh Mehta

unread,
Mar 17, 2025, 12:44:56 PM3/17/25
to sympy

Hello, sympy community,

I wanted to follow up on my proposed GSoC project on expanding force and torque models. I haven't received a response to my last message, so I wanted to check if there is still interest in this direction.

If there are any specific concerns or priorities that I should consider, I’d be happy to adjust my approach accordingly. I appreciate any feedback and would love to know if it makes sense to continue refining the proposal.

Looking forward to your thoughts!

Best regards,
Rushabh Mehta


Hwayeon Kang

unread,
Mar 27, 2025, 9:58:58 AM3/27/25
to sympy
Hi Rushabh,

Your idea looks good to me! Please make sure to explain all the details and implementation plans in your proposal, so we can clearly understand your approach.

Rushabh Mehta

unread,
Mar 28, 2025, 2:02:41 PM3/28/25
to sympy
Hello Hwayeon,
I just finished my proposal for this project! I have added it to the wiki and for your convenience here is the link to it.

Looking forward to your feedback and comments on it!
Best regards,
Rushabh Mehta

Reply all
Reply to author
Forward
0 new messages