-
Notifications
You must be signed in to change notification settings - Fork 109
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
Update and generalize fixed rod BC #54
Update and generalize fixed rod BC #54
Conversation
This reverts commit c4b97a0.
@nmnaughton Could you redirect the PR to https://github.com/GazzolaLab/PyElastica/blob/master/CONTRIBUTING.md#project-workflow |
@nmnaughton Hi, 👋 I'm going over this PR, and it appears to me that there is more than one place to make the modification, especially because the change involves the backend. I understand your opinions above and I agree with your points, but we should be careful in modifying the A couple of identified issues:
Here is my suggestion. ☕
|
Hi @skim0119, for the issues you raised
|
Yes, I agree. This part of the user interface needs an update.
The issue is that init is not really what the user is exposed to, instead users are supposed to use 'using'. I think the biggest mistake here is that the name Sugestion ☕How about we change the syntax such that if you pass some arbitrary index that is not named class CustomBC(FreeRod):
def __init__(self, middle_indices:list[int]):
FreeRod.__init__(self)
self.middle_indices = middle_indices
self.fixed_positions = self.get_system.position_collection[:, middle_indices]
def constrain_values(self, rod, time): # Maybe rod can be replaced to self.get_system later
rod.position_collection[:, middle_indices] = self.fixed_positions
...
...
simulator.constrain(rod).using(
CustomBC,
middle_indices=(6,7)
) In this way, we don't need any deprecation warnings, as the previous features are all preserved. Passing arbitrary index is probably working even in the current version, but we just need If you already have a suggestion implemented as code, please link them 😄. |
After talking to @nmnaughton and @tp5uiuc, I decided to change the current structure of constraint, so that indices are passed to the constraint. It looks like this feature was intentionally removed in the past, but it probably makes more sense to bring it back. Ill make the modification and include in the next version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm merging these commits into wip_constraint. I'm going to continue on this problem.
This partially addresses one of the comments in #36 regarding the
OneEndFixedRod
BC and also works to generalize the BC overall. There are three parts to the change.In the constraints wrapper, currently the 'constrained_position_idx' argument gets popped from the kwargs dict. If we change this to
get
then this idx argument continues onto the boundary condition and allows the boundary condition to associate the position and directors with specific idx in the rod. @tp5uiuc I think you coded this originally, is there a reason we should be aware of why usingget
instead ofpop
would be advised?Using the additional arguments from (1), any combination of nodes and elements can now be fixed in place by associating the idx and positions/directors info. Currently, I have added changes to
OneEndFixedRod
BC and also created an identicalFixedRodBC
. This is likely not the best solution. I am interested in hearing how people think we should proceed. Do we want to depreciateOneEndFixedRod
? Is there a better naming scheme we could use?I also included a separate BC (
FixedNodeBC
) where only the node is fixed. This would be a 'pinned' BC where the rod can still rotate around the point.The most useful part of this change (to me at least) is that one can now fix either end (or both) of a rod.
I think one question for discussion is what should the name of the BCs be. Currently, there are
OneEndFixedRod
,FixedRodBC
, andFixedNodeBC
. I likeFixedRodBC
andFixedNodeBC
, but is there a better name forFixedRodBC
? It should idealy denote that both an element and node is bing fixed. MaybeFixedSectionBC
? Not sure...