Skip to content

Conversation

phmbressan
Copy link
Collaborator

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (make format) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

Only constant valued densities are supported by the Fluid class, which hinders the Liquid and Hybrid motor simulation accuracy.

New behavior

This PR aims to bring support for defining a Fluid with a density value that can be a function of Temperature (K) and Pressure (Pa). For instance:

>>> Fluid(name="N2O", density=lambda t, p: 44 * p / (8.314 * t))
>>> from CoolProp.CoolProp import PropsSI # external library
>>> Fluid(name="N2O", density=lambda t, p: PropsSI('D', 'T', t, 'P', p, 'N2O'))

So as to model the density evolution in time in the Tank simulation, the optional parameters temperature and pressure were added to the tank classes, which correspond to simulation/static fire data as a function of time one may have of these parameters.

Breaking change

  • Yes
  • No

Additional Information

Documentation could probably be expanded with a more throughout example of this feature and a description of the new modeling assumptions, but this does not block the review of the implementation.

@phmbressan phmbressan added this to the Release v1.X.0 milestone Sep 22, 2025
@phmbressan phmbressan self-assigned this Sep 22, 2025
@phmbressan phmbressan requested a review from a team as a code owner September 22, 2025 17:10
@phmbressan phmbressan added the Motors Every propulsion related issue or PR label Sep 22, 2025
Copy link

codecov bot commented Sep 22, 2025

Codecov Report

❌ Patch coverage is 87.59124% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.19%. Comparing base (f17893b) to head (568661d).
⚠️ Report is 24 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/motors/tank.py 90.12% 8 Missing ⚠️
rocketpy/plots/fluid_plots.py 27.27% 8 Missing ⚠️
rocketpy/motors/fluid.py 97.50% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #852      +/-   ##
===========================================
+ Coverage    80.02%   80.19%   +0.17%     
===========================================
  Files           98      103       +5     
  Lines        12004    12730     +726     
===========================================
+ Hits          9606    10209     +603     
- Misses        2398     2521     +123     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for variable density fluids in tank simulations by enabling the Fluid class to accept density as a function of temperature and pressure. Previously, only constant densities were supported, limiting simulation accuracy for liquid and hybrid motor tanks.

Key changes:

  • Enhanced the Fluid class to support density functions based on temperature and pressure
  • Added temperature and pressure parameters to tank classes for time-dependent modeling
  • Updated tank inertia and volume calculations to use variable density functions

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rocketpy/motors/fluid.py Converted Fluid from dataclass to regular class with variable density support
rocketpy/motors/tank.py Added temperature/pressure parameters and variable density calculations
rocketpy/prints/fluid_prints.py Updated print methods to handle variable density functions
rocketpy/plots/fluid_plots.py Added density function plotting capabilities
tests/ Added comprehensive test coverage for variable density functionality
docs/user/motors/tanks.rst Updated documentation with examples of variable density usage

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

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

very good PR, great addition.

I have a few minor comments.

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

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

LGTM, great addition!!

@github-project-automation github-project-automation bot moved this from Backlog to Next Version in LibDev Roadmap Sep 22, 2025
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
Status: Next Version
Development

Successfully merging this pull request may close these issues.

2 participants