Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CZI] Addition of biomechanical modelling to SymPy #24240

Closed
brocksam opened this issue Nov 9, 2022 · 5 comments
Closed

[CZI] Addition of biomechanical modelling to SymPy #24240

brocksam opened this issue Nov 9, 2022 · 5 comments
Labels
CZI: Codegen/Biomech Sam Brockie's CZI-funded postdoc work on codegen and biomechanics

Comments

@brocksam
Copy link
Contributor

brocksam commented Nov 9, 2022

CZI EOSS Grant & Biomechanics

One stated outcome from the CZI work is the development of performance-critical musculoskeletal models using SymPy. Creation of musculoskeletal models requires the merging of multibody dynamics and biomechanical models. The former is already implemented supported by SymPy thanks to sympy.physics.mechanics. The latter requires the development of additional SymPy-based classes, functions, and integrations.

Development Proposal

I propose that certain biomechanical modelling capabilities are added directly into SymPy. This would be done through the creation of a new biomechanics submodule. The intention would be for this to be sympy.physics.biomechanics. However, it would initially be developed as the private development submodule sympy.physics._biomechanics. This would allow for the submodule to be developed transparently, with other SymPy users able to contribute and feed back during its development, while also not adding any restrictions around backwards compatibility guarantees or breaking changes.

Eventually, once the submodule features and API have been reviewed and tested, the intention would be to transition sympy.physics._biomechanics to the public module sympy.physics.biomechanics.

Development Workflow

Submodule Requirements

  • Extends and interfaces nicely with sympy.physics.mechanics and sympy.physics.vector.
  • Implements published models from the literature.
  • Supports torque- and muscle-driven musculoskeletal models.
  • Supports creation of 2D and 3D musculoskeletal models.
  • Fully documented, tested, and benchmarked.
  • Provides a basic set of sample models for users to get started with.
@brocksam
Copy link
Contributor Author

brocksam commented Nov 9, 2022

Features Proposal

@brocksam
Copy link
Contributor Author

brocksam commented Nov 9, 2022

Related Issues and PRs

  • (None yet)

@brocksam brocksam added the CZI: Codegen/Biomech Sam Brockie's CZI-funded postdoc work on codegen and biomechanics label Jan 10, 2023
@moorepants
Copy link
Member

I discussed this issue with Sam today. This seems like a good approach and getting _biomechanics started with these is a good launching point. Some things to think about are:

  • Whether or how we maintain the symbolic-numeric divide (like we've had with mechanics & PyDy) and what should we be doing on the sympy side when the mathematical models increase in complexity and tightly rely on specific floating point parameter values. I don't think I've seen a similar class design in SymPy that stores numerical values for symbolics, so we should evaluate if that's the right direction.
  • How will the mathematical expressions be accessible from these classes?
  • Sam will show some of the example problems so we can see how these classes will work.
  • We also discussed some how these classes relate to code gen and how they connect. Some thought is needed on that.

@brocksam feel free to add other notes you took here. Good that we keep the info public on these issues/PRs.

@ThePauliPrinciple
Copy link
Contributor

  • I don't think I've seen a similar class design in SymPy
  • How will the mathematical expressions be accessible from these classes?

It could be considered to only add generic mechanics functionality to SymPy and create a seperate library for biomechanics instead of a module inside SymPy.

  • tightly rely on specific floating point parameter values

I think in most cases people should use a Rational rather than a Float to accurately represent what they want when they think they want to use Float (at least in SymPy). To obtain float-like behaviour as one might expect in a numerical framework, it's probably best to ensure that the biomechanics classes work with lambdify.

@brocksam
Copy link
Contributor Author

Closing as #25772 has made sympy.physics.biomechanics public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CZI: Codegen/Biomech Sam Brockie's CZI-funded postdoc work on codegen and biomechanics
Projects
None yet
Development

No branches or pull requests

3 participants