Skip to content

Commit

Permalink
MNT: add info and all_info methods to tanks.
Browse files Browse the repository at this point in the history
  • Loading branch information
phmbressan committed Nov 13, 2024
1 parent 658b60a commit d3dfbac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
11 changes: 11 additions & 0 deletions rocketpy/motors/tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,17 @@ def draw(self, filename=None):
"""
self.plots.draw(filename)

def info(self):
"""Prints out a summary of the tank properties."""
self.prints.all()

def all_info(self):
"""Prints out detailed information and plots of the tank
properties.
"""
self.prints.all()
self.plots.all()


class MassFlowRateBasedTank(Tank):
"""Class to define a tank based on mass flow rates inputs. This class
Expand Down
16 changes: 8 additions & 8 deletions rocketpy/prints/tank_prints.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def fluid_parameters(self):
-------
None
"""
print(f"Tank '{self.tank.name}' Fluid Parameters\n:")
print(f"Tank '{self.tank.name}' Fluid Parameters:")
print("\nLiquid Fluid")
self.tank.liquid.prints.all()
print("\nGas Fluid")
Expand All @@ -48,13 +48,13 @@ def mass_flux(self):
initial_time, final_time = self.tank.flux_time
print(f"\nTank '{self.tank.name}' Mass Flux Data:")
print(f"\nInitial Quantities at t = {initial_time:.2f} s:")
print(f"Initial Fluid Mass: {self.tank.fluid_mass(initial_time):.4f} kg")
print(f"Initial Liquid Volume: {self.tank.liquid_volume(initial_time):.4f} m^3")
print(f"Initial Liquid Level: {self.tank.liquid_height(initial_time):.4f} m")
print(f"Initial Fluid Mass: {self.tank.fluid_mass(initial_time):.3e} kg")
print(f"Initial Liquid Volume: {self.tank.liquid_volume(initial_time):.3e} m^3")
print(f"Initial Liquid Level: {self.tank.liquid_height(initial_time):.3e} m")
print(f"\nFinal Quantities at t = {final_time:.2f} s:")
print(f"Final Fluid Mass: {self.tank.fluid_mass(final_time):.4f} kg")
print(f"Final Liquid Volume: {self.tank.liquid_volume(final_time):.4f} m^3")
print(f"Final Liquid Level: {self.tank.liquid_height(final_time):.4f} m")
print(f"Final Fluid Mass: {self.tank.fluid_mass(final_time):.3e} kg")
print(f"Final Liquid Volume: {self.tank.liquid_volume(final_time):.3e} m^3")
print(f"Final Liquid Level: {self.tank.liquid_height(final_time):.3e} m")

def all(self):
"""Prints out all data available about the Tank.
Expand All @@ -63,7 +63,7 @@ def all(self):
-------
None
"""
print(f"Tank '{self.tank.name}' Data\n:")
print(f"\nTank '{self.tank.name}' Data:\n")
self.tank.geometry.prints.all()
self.fluid_parameters()
self.mass_flux()
4 changes: 2 additions & 2 deletions tests/integration/test_tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
def test_tank_all_info(mock_show, fixture_name, request):
tank = request.getfixturevalue(fixture_name)

assert tank.prints.all() is None
assert tank.plots.all() is None
assert tank.info() is None
assert tank.all_info() is None

assert (tank.gas_height <= tank.geometry.top).all
assert (tank.liquid_height <= tank.geometry.top).all
Expand Down

0 comments on commit d3dfbac

Please sign in to comment.