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

Add torques #21

Merged
merged 78 commits into from
Sep 19, 2024
Merged

Add torques #21

merged 78 commits into from
Sep 19, 2024

Conversation

RaulPPelaez
Copy link
Contributor

@RaulPPelaez RaulPPelaez commented Jun 3, 2024

Reintroduces torques into the interface.

Mdot will now take two optional arrays (force and/or torque) and will return two arrays, (linear and angular displacements).
Similarly for computeHydrodynamicDisplacements.
sqrtMdot will simply return two arrays.

A new parameter, needsTorque, has been added to the MobilityInterface parameters. Some solvers need to know in advance if torques are required. For instance DPStokes needs different parameters if torques are needed vs only forces.

Currently all modules will fail if torques are provided by raising a "not implemented" error.
@rykerfish please add torque tests to this PR, remove the exception throwing as you enable solvers to use torques.

  • Add tests
  • Update documentation

Closes #12

@rykerfish
Copy link
Contributor

@RaulPPelaez Functionality is finally all here- I had a bit of a time getting the NBody wall corrections to work, but they're all tested now.

I made the necessary interface changes to get everything to work as I went along, but some of them might need to change. Here are a few things of note:

  1. I modified call_mdot in pythonify.h for torques by emulating the behavior for forces. I think this made the behavior for Mdot a bit odd in some of the modules since the actual pybind binding sets torques to pyarray() by default.
  2. The currently implemented behavior in NBody (and I believe DPStokes) is to always compute with torques. This seems unnecessary, especially for NBody where it would be useful to sometimes only compute the M_tt block (e.g. to use with Rigid Multiblobs). Do you have any suggestions for how to rework the interface and kernel calls to do this without causing unnecessary slowdowns?

Let me know any other fixes I should make! I know the documentation still needs to get updated, but I thought I'd wait until the interface was more solidified.

@RaulPPelaez
Copy link
Contributor Author

@RaulPPelaez Functionality is finally all here- I had a bit of a time getting the NBody wall corrections to work, but they're all tested now.

You da best ❤️

1. I modified call_mdot in pythonify.h for torques by emulating the behavior for forces. I think this made the behavior for Mdot a bit odd in some of the modules since the actual pybind binding sets torques to `pyarray()` by default.

Your call_mdot looks fine to me, python side the user can call:

mf, mt = solver.Mdot(forces=f, torques=t)

But also

mf, mt = solver.Mdot(f)

which will interpret f as forces.

2. The currently implemented behavior in NBody (and I believe DPStokes) is to always compute with torques. This seems unnecessary, especially for NBody where it would be useful to sometimes only compute the M_tt block (e.g. to use with Rigid Multiblobs). Do you have any suggestions for how to rework the interface and kernel calls to do this without causing unnecessary slowdowns?

We have the "needs_torque" variable (which we should rename to needsTorque for consistent btw). If that is false you can safely assume only the M_tt block is needed. Why would we need to change the interface here? As a matter of fact, I will add checks for torques being passed when needs_torques is false.

If you are going more along the lines of the implementation computing torques always due to laziness I think that is ok for this PR. Interface is more important than implementation/performance. Let's get the functionality out there and make it fast in another PR.

@rykerfish
Copy link
Contributor

If you are going more along the lines of the implementation computing torques always due to laziness I think that is ok for this PR.

That is what I was mostly talking about. Since we're happy with just the functionality and tests and it looks like you updated the documentation (thanks for that!), I think this should be good to go! Thank you for your help!

@RaulPPelaez RaulPPelaez merged commit f07856c into main Sep 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supporting torques
2 participants