Skip to content

Commit

Permalink
Newly created tanks_fixtures.py and modified modules conftest and liq…
Browse files Browse the repository at this point in the history
…uid_fixtures.
  • Loading branch information
lucasfourier committed Feb 18, 2024
1 parent c215e9f commit f5cf265
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 144 deletions.
10 changes: 3 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import pytest


# Pytest configuration

pytest_plugins = [
"tests.fixtures.environment.environment_fixtures",
"tests.fixtures.flight.flight_fixtures",
"tests.fixtures.function.function_fixtures",
"tests.fixtures.motor.liquid_fixtures",
"tests.fixtures.motor.hybrid_fixtures",
"tests.fixtures.motor.solid_motor_fixtures",
"tests.fixtures.motor.liquid_fixtures",
"tests.fixtures.motor.tanks_fixtures",
"tests.fixtures.motor.generic_motor_fixtures",
"tests.fixtures.parachutes.parachute_fixtures",
"tests.fixtures.rockets.rocket_fixtures",
"tests.fixtures.surfaces.surface_fixtures",
"tests.fixtures.units.numerical_fixtures",
"tests.fixtures.units.numerical_fixtures"
]

#


def pytest_addoption(parser):
"""Add option to run slow tests. This is used to skip slow tests by default.
Expand Down
138 changes: 1 addition & 137 deletions tests/fixtures/motor/liquid_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import numpy as np
import pytest

from rocketpy import (
CylindricalTank,
Fluid,
Function,
LevelBasedTank,
LiquidMotor,
MassBasedTank,
SphericalTank,
UllageBasedTank,
)
from rocketpy import Fluid, LiquidMotor


@pytest.fixture
Expand Down Expand Up @@ -78,102 +68,6 @@ def oxidizer_fluid():
return Fluid(name="O2", density=1000)


@pytest.fixture
def pressurant_tank(pressurant_fluid):
"""An example of a pressurant cylindrical tank with spherical
caps.
Parameters
----------
pressurant_fluid : rocketpy.Fluid
Pressurizing fluid. This is a pytest fixture.
Returns
-------
rocketpy.MassBasedTank
An object of the CylindricalTank class.
"""
geometry = CylindricalTank(0.135 / 2, 0.981, spherical_caps=True)
pressurant_tank = MassBasedTank(
name="Pressure Tank",
geometry=geometry,
liquid_mass=0,
flux_time=(8, 20),
gas_mass="data/SEBLM/pressurantMassFiltered.csv",
gas=pressurant_fluid,
liquid=pressurant_fluid,
)

return pressurant_tank


@pytest.fixture
def fuel_tank(fuel_fluid, fuel_pressurant):
"""An example of a fuel cylindrical tank with spherical
caps.
Parameters
----------
fuel_fluid : rocketpy.Fluid
Fuel fluid of the tank. This is a pytest fixture.
fuel_pressurant : rocketpy.Fluid
Pressurizing fluid of the fuel tank. This is a pytest
fixture.
Returns
-------
rocketpy.UllageBasedTank
"""
geometry = CylindricalTank(0.0744, 0.8068, spherical_caps=True)
ullage = (
-Function("data/SEBLM/test124_Propane_Volume.csv") * 1e-3
+ geometry.total_volume
)
fuel_tank = UllageBasedTank(
name="Propane Tank",
flux_time=(8, 20),
geometry=geometry,
liquid=fuel_fluid,
gas=fuel_pressurant,
ullage=ullage,
)

return fuel_tank


@pytest.fixture
def oxidizer_tank(oxidizer_fluid, oxidizer_pressurant):
"""An example of a oxidizer cylindrical tank with spherical
caps.
Parameters
----------
oxidizer_fluid : rocketpy.Fluid
Oxidizer fluid of the tank. This is a pytest fixture.
oxidizer_pressurant : rocketpy.Fluid
Pressurizing fluid of the oxidizer tank. This is a pytest
fixture.
Returns
-------
rocketpy.UllageBasedTank
"""
geometry = CylindricalTank(0.0744, 0.8068, spherical_caps=True)
ullage = (
-Function("data/SEBLM/test124_Lox_Volume.csv") * 1e-3 + geometry.total_volume
)
oxidizer_tank = UllageBasedTank(
name="Lox Tank",
flux_time=(8, 20),
geometry=geometry,
liquid=oxidizer_fluid,
gas=oxidizer_pressurant,
ullage=ullage,
)

return oxidizer_tank


@pytest.fixture
def liquid_motor(pressurant_tank, fuel_tank, oxidizer_tank):
"""An example of a liquid motor with pressurant, fuel and oxidizer tanks.
Expand Down Expand Up @@ -205,33 +99,3 @@ def liquid_motor(pressurant_tank, fuel_tank, oxidizer_tank):
liquid_motor.add_tank(oxidizer_tank, position=0.711)

return liquid_motor


@pytest.fixture
def spherical_oxidizer_tank(oxidizer_fluid, oxidizer_pressurant):
"""An example of a oxidizer spherical tank.
Parameters
----------
oxidizer_fluid : rocketpy.Fluid
Oxidizer fluid of the tank. This is a pytest fixture.
oxidizer_pressurant : rocketpy.Fluid
Pressurizing fluid of the oxidizer tank. This is a pytest
fixture.
Returns
-------
rocketpy.UllageBasedTank
"""
geometry = SphericalTank(0.05)
liquid_level = Function(lambda t: 0.1 * np.exp(-t / 2) - 0.05)
oxidizer_tank = LevelBasedTank(
name="Lox Tank",
flux_time=10,
geometry=geometry,
liquid=oxidizer_fluid,
gas=oxidizer_pressurant,
liquid_height=liquid_level,
)

return oxidizer_tank
137 changes: 137 additions & 0 deletions tests/fixtures/motor/tanks_fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import numpy as np
import pytest

from rocketpy import (
CylindricalTank,
Function,
LevelBasedTank,
MassBasedTank,
SphericalTank,
UllageBasedTank,
)


@pytest.fixture
def pressurant_tank(pressurant_fluid):
"""An example of a pressurant cylindrical tank with spherical
caps.
Parameters
----------
pressurant_fluid : rocketpy.Fluid
Pressurizing fluid. This is a pytest fixture.
Returns
-------
rocketpy.MassBasedTank
An object of the CylindricalTank class.
"""
geometry = CylindricalTank(0.135 / 2, 0.981, spherical_caps=True)
pressurant_tank = MassBasedTank(
name="Pressure Tank",
geometry=geometry,
liquid_mass=0,
flux_time=(8, 20),
gas_mass="data/SEBLM/pressurantMassFiltered.csv",
gas=pressurant_fluid,
liquid=pressurant_fluid,
)

return pressurant_tank


@pytest.fixture
def fuel_tank(fuel_fluid, fuel_pressurant):
"""An example of a fuel cylindrical tank with spherical
caps.
Parameters
----------
fuel_fluid : rocketpy.Fluid
Fuel fluid of the tank. This is a pytest fixture.
fuel_pressurant : rocketpy.Fluid
Pressurizing fluid of the fuel tank. This is a pytest
fixture.
Returns
-------
rocketpy.UllageBasedTank
"""
geometry = CylindricalTank(0.0744, 0.8068, spherical_caps=True)
ullage = (
-Function("data/SEBLM/test124_Propane_Volume.csv") * 1e-3
+ geometry.total_volume
)
fuel_tank = UllageBasedTank(
name="Propane Tank",
flux_time=(8, 20),
geometry=geometry,
liquid=fuel_fluid,
gas=fuel_pressurant,
ullage=ullage,
)

return fuel_tank


@pytest.fixture
def oxidizer_tank(oxidizer_fluid, oxidizer_pressurant):
"""An example of a oxidizer cylindrical tank with spherical
caps.
Parameters
----------
oxidizer_fluid : rocketpy.Fluid
Oxidizer fluid of the tank. This is a pytest fixture.
oxidizer_pressurant : rocketpy.Fluid
Pressurizing fluid of the oxidizer tank. This is a pytest
fixture.
Returns
-------
rocketpy.UllageBasedTank
"""
geometry = CylindricalTank(0.0744, 0.8068, spherical_caps=True)
ullage = (
-Function("data/SEBLM/test124_Lox_Volume.csv") * 1e-3 + geometry.total_volume
)
oxidizer_tank = UllageBasedTank(
name="Lox Tank",
flux_time=(8, 20),
geometry=geometry,
liquid=oxidizer_fluid,
gas=oxidizer_pressurant,
ullage=ullage,
)

return oxidizer_tank


@pytest.fixture
def spherical_oxidizer_tank(oxidizer_fluid, oxidizer_pressurant):
"""An example of a oxidizer spherical tank.
Parameters
----------
oxidizer_fluid : rocketpy.Fluid
Oxidizer fluid of the tank. This is a pytest fixture.
oxidizer_pressurant : rocketpy.Fluid
Pressurizing fluid of the oxidizer tank. This is a pytest
fixture.
Returns
-------
rocketpy.UllageBasedTank
"""
geometry = SphericalTank(0.05)
liquid_level = Function(lambda t: 0.1 * np.exp(-t / 2) - 0.05)
oxidizer_tank = LevelBasedTank(
name="Lox Tank",
flux_time=10,
geometry=geometry,
liquid=oxidizer_fluid,
gas=oxidizer_pressurant,
liquid_height=liquid_level,
)

return oxidizer_tank

0 comments on commit f5cf265

Please sign in to comment.