RocketPy-Team / RocketPy

Next generation High-Power Rocketry 6-DOF Trajectory Simulation
https://docs.rocketpy.org/
MIT License
610 stars 144 forks source link

BUG: the rocket does not take off the rail #411

Open Gui-FernandesBR opened 1 year ago

Gui-FernandesBR commented 1 year ago

Describe the bug

To Reproduce

Try to follow the code block below. You're gonna see that the rocket never leaves the position (0, 0, 0).

liquid_motor = LiquidMotor(
        thrust_source="data/SEBLM/test124_Thrust_Curve.csv",
        burn_time=(8, 20), # this is important to reproduce the error!
        dry_mass=10,
        dry_inertia=(5, 5, 0.2),
        center_of_dry_mass_position=0,
        nozzle_position=-1.364,
        nozzle_radius=0.069 / 2,
    )
liquid_motor.add_tank(pressurant_tank, position=2.007)
liquid_motor.add_tank(fuel_tank, position=-1.048)
liquid_motor.add_tank(oxidizer_tank, position=0.711)

calisto_liquid_modded= Rocket(
        radius=0.0635,
        mass=14.426,
        inertia=(6.321, 6.321, 0.034),
        power_off_drag="data/calisto/powerOffDragCurve.csv",
        power_on_drag="data/calisto/powerOnDragCurve.csv",
        center_of_mass_without_motor=0,
        coordinate_system_orientation="tail_to_nose",
    )
calisto_liquid_modded.add_motor(liquid_motor, position=-1.373)

test_flight = Flight(
        rocket=calisto_liquid_modded,
        environment=Environment(),
        rail_length=5,
        inclination=85,
        heading=0,
        max_time_step=np.inf # this is important to reproduce the error!
)

test_flight.all_info()

Expected behavior

A description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Some warning are also generated due to this BUG, for example:

tests/test_flight.py::test_liquid_motor_flight
  RocketPy\rocketpy\plots\flight_plots.py:107: UserWarning: Attempting to set identical low and high zlims makes transformation singular; automatically expanding.
    ax1.set_zlim3d([0, max_z])

tests/test_flight.py::test_liquid_motor_flight
  RocketPy\rocketpy\plots\flight_plots.py:108: UserWarning: Attempting to set identical low and high ylims makes transformation singular; automatically expanding.
    ax1.set_ylim3d([min_xy, max_xy])

tests/test_flight.py::test_liquid_motor_flight
  RocketPy\rocketpy\plots\flight_plots.py:109: UserWarning: Attempting to set identical low and high xlims makes transformation singular; automatically expanding.
    ax1.set_xlim3d([min_xy, max_xy])

Possible solutions:

While discussing this internally, we came up with some suggestions:

Gui-FernandesBR commented 1 year ago

I think it's not a good idea to start the simulation with a initial_time different of t=0. Otherwise, we would lose some insights in the flight, for example, the "apogee_time" would become the flight time plus the time until ignition starts. This would be a bit confusing I guess.

It's better to adjust the thrust curve to always start at 0, probably.

I'm open to discussions anyway

williambrenner commented 1 year ago

This bug happens to me frequently even when the thrust curve starts with 0. The way I fix it is the same as suggested (changing the maxTimeStep to 0.1) as shown in the screenshot

image

The simulations of this screenshot had a thrust curve that starts like this

image

In Monte Carlo simulations this also happens sometimes, usually when the standard deviation of the burn time is too high. To correct the dispersion analysis, I have to reduce the standard deviation.