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

Enh/liquid motors optimization #354

Merged
merged 38 commits into from
Jun 9, 2023

Conversation

phmbressan
Copy link
Collaborator

Pull request type

Please check the type of change your PR introduces:

  • Code base additions (bugfix, features)
  • Code maintenance (refactoring, formatting, renaming, tests)
  • ReadMe, Docs and GitHub maintenance
  • Other (please describe):

Pull request checklist

Please check if your PR fulfills the following requirements, depending on the type of PR:

  • Code base additions (for bug fixes / features):

    • Tests for the changes have been added
    • Docs have been reviewed and added / updated if needed
    • Lint (black rocketpy) has passed locally and any fixes were made
    • All tests (pytest --runslow) have passed locally

What is the current behavior?

The liquid motor simulations were accurate, but performed really poorly (20+ seconds to generate inertia tensor plots).

What is the new behavior?

The main focus is optimize the Tank code in order to speed up the implementation. The results are now in the sub 1 second range.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Important docs: docs/notebooks/example_liquid, docs/notebooks/example_hybrid.

@phmbressan phmbressan added the Motors Every propulsion related issue or PR label Apr 24, 2023
@phmbressan phmbressan added this to the Release v1.0.0 milestone Apr 24, 2023
@phmbressan phmbressan self-assigned this Apr 24, 2023
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@Gui-FernandesBR Gui-FernandesBR removed their request for review April 24, 2023 13:42
@Gui-FernandesBR
Copy link
Member

Great one!

I'm a little bit out of what has been doing in the enh/liquid-motors branch later, therefore I'm letting my name out of the reviewers list for now.

@giovaniceotto
Copy link
Member

Just waiting on #353 before reviewing this one, since this branch has the #353 branch already merged.

rocketpy/Function.py Outdated Show resolved Hide resolved
rocketpy/Function.py Outdated Show resolved Hide resolved
rocketpy/Function.py Outdated Show resolved Hide resolved
rocketpy/motors/Tank.py Outdated Show resolved Hide resolved
rocketpy/motors/TankGeometry.py Outdated Show resolved Hide resolved
rocketpy/motors/TankGeometry.py Outdated Show resolved Hide resolved
@MateusStano
Copy link
Member

I get this warning when running example_liquid.ipynb

image

@MateusStano
Copy link
Member

Btw @phmbressan you are gonna have to fix this someday heheh

image

@phmbressan
Copy link
Collaborator Author

I get this warning when running example_liquid.ipynb

@MateusStano
This is "expected" and handled in code: the invalid value occurs, but is substituted by a valid one. However the way it is currently done leave numpy warning traces of the invalid values.

This occurs due the fact that, in this notebook, the oxidizer tank gas_mass is zero. If you change it to a small value e.g. 0.1 the warning goes away. I am still thinking on a better solution, since I don't like the current approach (i.e. letting the calculations be made even if it returns an invalid value and substituting a posteriori), however for now it ensures correctness.

Copy link
Member

@giovaniceotto giovaniceotto left a comment

Choose a reason for hiding this comment

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

Great work @phmbressan. Loved how you made use of Function composition to get even the most complicated properties to carry on as array-defined Function instead of having to implement them as a function of time.

The complexity of the new motor classes is only possible thanks to great advances you and other collaborators made to the Function class. Most notably, Function composition and Function integrals solved most of our problems here.

I am very satisfied performance-wise. Made a couple of enhancement suggestions such as typo-fixes, docstring suggestions or minor optimizations. Take a quick look and ask for a new review so that I can accept this PR.

rocketpy/Function.py Outdated Show resolved Hide resolved
rocketpy/Function.py Outdated Show resolved Hide resolved
rocketpy/Function.py Outdated Show resolved Hide resolved
rocketpy/Function.py Outdated Show resolved Hide resolved
rocketpy/Function.py Outdated Show resolved Hide resolved
rocketpy/motors/TankGeometry.py Show resolved Hide resolved
rocketpy/motors/Tank.py Outdated Show resolved Hide resolved
rocketpy/motors/Tank.py Outdated Show resolved Hide resolved
rocketpy/motors/Tank.py Show resolved Hide resolved
rocketpy/motors/LiquidMotor.py Show resolved Hide resolved
@giovaniceotto
Copy link
Member

Any ideas why unrelated tests are failing?

@phmbressan
Copy link
Collaborator Author

Any ideas why unrelated tests are failing?

Please, see the comment on the original Liquid Motors PR.

@phmbressan
Copy link
Collaborator Author

I get this warning when running example_liquid.ipynb

@MateusStano

I "fixed" this on 5374a6e. The issue was that, for some reason, numpy considers 0/0 as an invalid value error and not a divide error (even though the error message is quite ambiguous).

Let me know what you think. The warning should not pop up anymore.

@MateusStano
Copy link
Member

I get this warning when running example_liquid.ipynb

@MateusStano

I "fixed" this on 5374a6e. The issue was that, for some reason, numpy considers 0/0 as an invalid value error and not a divide error (even though the error message is quite ambiguous).

Let me know what you think. The warning should not pop up anymore.

Seems all good to me now!

Copy link
Member

@MateusStano MateusStano left a comment

Choose a reason for hiding this comment

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

This one is approved by me. Just don't forget to merge beta/v1.0.0 into enh/liquid-motors before merging this one, it is currently carrying over some changes from there.

@phmbressan phmbressan force-pushed the enh/liquid-motors-optimization branch from ee7f5cc to ca18df8 Compare June 9, 2023 15:52
@phmbressan phmbressan merged commit e0c49b6 into enh/liquid-motors Jun 9, 2023
@Gui-FernandesBR Gui-FernandesBR deleted the enh/liquid-motors-optimization branch June 27, 2023 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Motors Every propulsion related issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants