Skip to content

Enh/liquid-motors-linear-algebra - #364

Merged
MateusStano merged 25 commits into
enh/liquid-motorsfrom
enh/liquid-motors-linear-algebra
Jun 25, 2023
Merged

MateusStano merged 25 commits into
enh/liquid-motorsfrom
enh/liquid-motors-linear-algebra

Conversation

@giovaniceotto

Copy link
Copy Markdown
Member

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:

  • ReadMe, Docs and GitHub maintenance:

    • Spelling has been verified
    • Code docs are working correctly
  • Code base maintenance (refactoring, formatting, renaming):

    • 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
  • 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?

Enter text here...

What is the new behavior?

Enter text here...

Does this introduce a breaking change?

  • Yes
  • No

Other information

Enter text here...

@Gui-FernandesBR Gui-FernandesBR added this to the Release v1.0.0 milestone May 29, 2023
@giovaniceotto
giovaniceotto marked this pull request as ready for review May 30, 2023 11:29
@giovaniceotto
giovaniceotto requested a review from phmbressan May 30, 2023 11:29

@phmbressan phmbressan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall great enhancements, really straight to the point code to speed up simple linear algebra operations vs numpy. I still have some testing to do and left some comments, I will approve it after it.

Comment thread rocketpy/Flight.py
Comment thread rocketpy/tools.py Outdated
Comment thread rocketpy/tools.py
Comment thread rocketpy/tools.py Outdated
Comment thread rocketpy/tools.py Outdated
Comment thread rocketpy/tools.py
Comment thread rocketpy/tools.py Outdated
@Gui-FernandesBR Gui-FernandesBR added Enhancement New feature or request, including adjustments in current codes Flight Flight Class related features labels Jun 1, 2023
@MateusStano
MateusStano self-requested a review June 1, 2023 23:29
@giovaniceotto
giovaniceotto requested a review from phmbressan June 2, 2023 16:11

@MateusStano MateusStano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey, so tried to debug the new EOM to find where the the difference was coming from.

What I did was I ran two debugs in the getting_started.ipynb (without wind) in two different VScodes simultaneously. I compared the results of "standard" uDot and the "NumpyFree" uDot vector in the first step of the uDot phase. The results of uDotRail1 were the same in both cases (as expected).

Here is what I found:

  • I_11_dot (from uDotVariableMassNumpyFree) is different from TiDot (from standard uDot). From what I understand, these two should be the same, or am I wrong?

  • The resulting uDot from "standard" is:

    • [0.0, 2.248419533601745, 25.699552867618234, 0.0, 8.656902256438004, 89.14219557097906, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  • The resulting uDot from "NumpyFree" is:

    • [0.0, 2.248419533601745, 25.699552867618234, 0.0, 8.59772619988504, 89.14312454809829, 0.0, 0.0, 0.0, 0.0, 0.48555730861286195, 0.0, 0.0]
  • The differences are in ay, az, and specially in w1

    • w1's differences come from: I_CM, T20 and T21
      • It seems that the biggest factors for difference (on both T20 and T21) come from weightB and r_CM involving factors.

Overall I'd recommend to check weightB, r_CM and all the T's. Seems the difference is deriving from there one way or another

Comment thread rocketpy/Flight.py
@giovaniceotto

Copy link
Copy Markdown
Member Author

Great debugging work @MateusStano. I'll attempt to use your observations to fix the trajectory difference and get back to you ASAP.

I'll first review the motor mass PR and then get back to this.

Comment thread rocketpy/Flight.py
@giovaniceotto

giovaniceotto commented Jun 20, 2023

Copy link
Copy Markdown
Member Author

Pending TO-DOs:

  • Remove unnecessary implementations.
  • Create a toggle to use older equations of motion.
  • Merge beta/v1 to this branch.
  • Review equations of motion based Stano's feedback.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@giovaniceotto

giovaniceotto commented Jun 22, 2023

Copy link
Copy Markdown
Member Author
  • I_11_dot (from uDotVariableMassNumpyFree) is different from TiDot (from standard uDot). From what I understand, these two should be the same, or am I wrong?

For a moment, I agreed with your hypothesis. But it is not true because I_11_dot and TiDot are relative to different origins. Since there is the m*d² term when translating inertia components, and both the mass and the distance are time varying functions, the relationship between I_11_dot and TiDot is non-trivial.

Is the multiplication and division of * self.rocket.motor.mass / total_mass correct here? It seems that this was done to simplify the expression of v_dot, but I am not sure if the other expressions that use r_CM_z were also changed.

Also r_CM_z is meant to be the CM position relative to CDM in the body frame. This multiplication and division makes it so r_CM_z represents something else, or am I wrong?

I have verified that the implementation is in fact correct. The logic is:

$r_{CM} \cdot m_{CM} = r_{CDM} \cdot m_{CDM} + r_{CPM} \cdot m_{CPM}$

where $CM$ is for Center of Mass, $CDM$ is for Center of Dry Mass and $CPM$ is for Center of Propellant Mass. Keep in mind that $m_{CDM}$ is the total dry mass (constant) and $m_{CPM}$ is the propellant mass (time-varying).

Since, for the equations of motion, the origin is fixed back to the $CDM$, then $r_{CDM} = 0$. This simplifies the equation to:

$r_{CM} = r_{CPM} \cdot m_{CPM} / m_{CM} $

I believe this settle the debate about the weird mass multiplication and division in the code.


With all EOMs doubts addressed, @MateusStano, feel free to review my last commits and merge.

@MateusStano MateusStano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey! Seems we have a lot of issues with the tests. Some are broken due to the Inertia changes, but there are many problems with tests that have asserted value.

@giovaniceotto

Copy link
Copy Markdown
Member Author

Seems like I had an issue before with the beta v1 merge (user error). Just merged it again, and the liquid motor branch as well. Everything working perfectly now, with all tests passing. No code changes, in the scope of this PR, were needed.

@MateusStano, please skim through and merge when you feel ready. Let me know if you have any questions. For reviewing porpuses, I would recommend reviewing each commit individually.

@MateusStano
MateusStano merged commit 2f09814 into enh/liquid-motors Jun 25, 2023
@Gui-FernandesBR
Gui-FernandesBR deleted the enh/liquid-motors-linear-algebra 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

Enhancement New feature or request, including adjustments in current codes Flight Flight Class related features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants