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

Issue #354 analytical damper fix #437

Open
wants to merge 13 commits into
base: update-0.3.3
Choose a base branch
from

Conversation

sy-cui
Copy link
Contributor

@sy-cui sy-cui commented Oct 10, 2024

Fix #354.

Instead of the dimensionally inconsistent implementation, three variations of analytical linear dampers are now supported:

  1. Uniform damper. The input damping constant uniform_damping_constant $\gamma$ is of dimension 1 / T. Translation and rotation uses the same exponential damping coefficient $\exp(-\gamma t)$. Example:
    simulator.dampen(rod).using(
        AnalyticalLinearDamper,
        uniform_damping_constant=0.1,
        time_step=1e-4, 
    )
  1. Physical damper. The translational and rotational damping constant are in general different, which follows the following formulae
$$m\frac{\partial v}{\partial t} = -\gamma_t v, ~~~~ \frac{J}{e}\frac{\partial \omega}{\partial t} = -\gamma_r \omega$$

such that

$$[\gamma_t] = FL^{-1} T, ~~~~ [\gamma_r] = FLT$$

The users are responsible for choosing the appropriate, dimensionally consistent damping constants for both modes. Example:

    simulator.dampen(rod).using(
        AnalyticalLinearDamper,
        translational_damping_constant=0.1,
        rotational_damping_constant=0.05,
        time_step=1e-4, 
    )
  1. Old implementation (to be deprecated). The syntax is designed to be identical as before, so that client codes do not break. Example:
    simulator.dampen(rod).using(
        AnalyticalLinearDamper,
        damping_constant=0.1,
        time_step=1e-4, 
    )

Test cases are updated to accommodate the changes. Dissipation module and test cases are moved to dedicated directories.

@sy-cui sy-cui self-assigned this Oct 10, 2024
@sy-cui sy-cui requested review from Ali-7800 and removed request for bhosale2 October 10, 2024 21:50
Copy link
Collaborator

@skim0119 skim0119 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the changes in dissipation.py?

Copy link
Contributor

@armantekinalp armantekinalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I have one small comment.

@skim0119 I did not get your point? Can you clarify.

elastica/dissipation/analytical_linear_damper.py Outdated Show resolved Hide resolved
@skim0119
Copy link
Collaborator

skim0119 commented Nov 19, 2024

I think changes are good. I'm just asking why we are making separate directory for dissipation. I think it is okay to keep them in single file dissipation.py, similar to boundary_condition.py, external_forces.py, etc. We typically don't make directory structure for these "implementation" classes.

I guess collision is exceptional because it requires so many periphery implementation that becomes cluttered, but dissipation implementations are not so complicated at this point.

Unlike CPP or Java, I don't think it is necessary to organize files exclusively class-based hierarchy for python. It leads to too complicate repository structure and too many files to organize for simple stuffs. I'm open for discussion.

@sy-cui
Copy link
Contributor Author

sy-cui commented Nov 26, 2024

@skim0119 Reverted to a single file.

Copy link
Collaborator

@skim0119 skim0119 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

3 participants