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

feat(model): #35 add an interface of integrals of motion #54

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

cmp0xff
Copy link
Collaborator

@cmp0xff cmp0xff commented Jun 15, 2024

No description provided.

@cmp0xff cmp0xff added the enhancement New feature or request label Jun 15, 2024
@cmp0xff cmp0xff requested a review from emptymalei June 15, 2024 21:37
@cmp0xff cmp0xff self-assigned this Jun 15, 2024
@cmp0xff cmp0xff linked an issue Jun 15, 2024 that may be closed by this pull request
Copy link
Contributor

github-actions bot commented Jun 15, 2024

Coverage

Coverage Report (73a702c, 3.12, ubuntu-latest)
FileStmtsMissCoverMissing
hamilflow
   __init__.py00100% 
hamilflow/models
   __init__.py00100% 
   brownian_motion.py4111 98%
   pendulum.py5677 88%
hamilflow/models/harmonic_oscillator
   __init__.py8044 95%
   initial_conditions.py210100% 
TOTAL1981294% 

Tests Skipped Failures Errors Time
62 0 💤 0 ❌ 0 🔥 4.309s ⏱️

Copy link
Contributor

Coverage

Coverage Report (73a702c, 3.11, macos-latest)
FileStmtsMissCoverMissing
hamilflow
   __init__.py00100% 
hamilflow/models
   __init__.py00100% 
   brownian_motion.py4111 98%
   pendulum.py5677 88%
hamilflow/models/harmonic_oscillator
   __init__.py8044 95%
   initial_conditions.py210100% 
TOTAL1981294% 

Tests Skipped Failures Errors Time
62 0 💤 0 ❌ 0 🔥 2.532s ⏱️

Copy link
Contributor

Coverage

Coverage Report (73a702c, 3.12, macos-latest)
FileStmtsMissCoverMissing
hamilflow
   __init__.py00100% 
hamilflow/models
   __init__.py00100% 
   brownian_motion.py4111 98%
   pendulum.py5677 88%
hamilflow/models/harmonic_oscillator
   __init__.py8044 95%
   initial_conditions.py210100% 
TOTAL1981294% 

Tests Skipped Failures Errors Time
62 0 💤 0 ❌ 0 🔥 2.501s ⏱️

Copy link
Contributor

PR Preview Action v1.4.7
🚀 Deployed preview to https://kausalflow.github.io/hamilflow/pr-preview/pr-54/
on branch gh-pages at 2024-06-15 21:38 UTC

Copy link
Member

Choose a reason for hiding this comment

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

If we are moving initial conditions to a dedicated module, let's also move the following lines to a dedicated module (maybe model.py or something).

I feel most people won't look into __init__.py unless it is related to __all__.
Maybe we only do imports in __init__.py. Something like

from hamilflow.models.harmonic_oscillator.model import SimpleHarmonicOscillator, DampdHamonicOscillator


__all__ = ["SimpleHarmonicOscillator", "DampdHamonicOscillator"]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I propose to separate engineering and scientific efforts to different issues and MRs, so we can streamline iterations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

More concretely, I propose to merge #56 first, then this #54, and finally the newly created #57.

@cmp0xff cmp0xff marked this pull request as draft June 16, 2024 19:43
],
)
def test_output(
self, omega: float, input: dict[str, float], expected: dict[str, float]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now I see what is not compatible with py39... It is expected: dict[str, float]. Should be expected: Dict[str, float], where Dict is imported from typing.

@@ -155,6 +147,7 @@ def __init__(
system: Dict[str, float],
initial_condition: Optional[Dict[str, float]] = {},
):
initial_condition = parse_ic_for_sho(system["omega"], **initial_condition)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To be honest I am not happy with the syntax system["omega"]. It breaks the design and steals data from the system dictionary. I guess we need to improve the design at some point. @emptymalei

phi: float = Field(default=0.0)


def parse_ic_for_sho(omega: float, **kwargs: Any) -> Dict[str, float]:
Copy link
Member

Choose a reason for hiding this comment

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

This one looks quite bad. Can we reduce the complexity by settle on one certain kind of convention?

Copy link
Member

@emptymalei emptymalei Jun 17, 2024

Choose a reason for hiding this comment

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

We don't aim to generate a good interface for users to use. As long as we can set the convention for ourselves, I am okay with anyone of the three choices.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that $(E, t_0)$ is associated with the first integral of the system. First integrals, or constants of motion, have special and physical meaning in the framework of analytical mechanics. This is in contrast with the phase $\phi$.

Let us sleep over it a bit and then decide.

Copy link
Member

@emptymalei emptymalei Jun 17, 2024

Choose a reason for hiding this comment

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

Note that (E,t0) is associated with the first integral of the system. First integrals, or constants of motion, have special and physical meaning in the framework of analytical mechanics. This is in contrast with the phase ϕ.

Let us sleep over it a bit and then decide.

Can we just keep $(E, t_0)$ and drop the others? I am still not sure how you are gonna use it. But I am okay with any of these choices. But the last thing I want is all of them clustered in a function. It would be easier to just chose one and force it.

@cmp0xff cmp0xff closed this Jul 23, 2024
@cmp0xff cmp0xff deleted the feature/yw/35-add-an-alternative-initial-condition-for-undamped-simple-harmonic-oscillator branch July 27, 2024 10:05
@cmp0xff cmp0xff restored the feature/yw/35-add-an-alternative-initial-condition-for-undamped-simple-harmonic-oscillator branch August 18, 2024 19:29
@cmp0xff cmp0xff reopened this Aug 18, 2024
@cmp0xff cmp0xff changed the title feat(oscillator): 35 add an alternative initial condition for simple harmonic oscillator feat(model): #35 add an interface of integrals of motion Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an interface of integrals of motion
2 participants