|
2 | 2 | import pytest |
3 | 3 |
|
4 | 4 | from rocketpy import Flight, Function, Rocket |
| 5 | +from rocketpy.motors.point_mass_motor import PointMassMotor |
| 6 | +from rocketpy.rocket.point_mass_rocket import PointMassRocket |
5 | 7 |
|
6 | 8 |
|
7 | 9 | @pytest.fixture |
@@ -365,111 +367,99 @@ def flight_flat(example_plain_env, cesaroni_m1670): |
365 | 367 |
|
366 | 368 | # 3 DOF Flight Fixtures |
367 | 369 | # These fixtures are for testing the 3 DOF flight simulation mode |
368 | | -# They will be available when PointMassMotor and PointMassRocket are implemented |
369 | | - |
370 | | -try: |
371 | | - from rocketpy.motors.point_mass_motor import PointMassMotor |
372 | | - from rocketpy.rocket.point_mass_rocket import PointMassRocket |
373 | | - |
374 | | - THREEDOF_AVAILABLE = True |
375 | | -except ImportError: |
376 | | - THREEDOF_AVAILABLE = False |
377 | | - PointMassMotor = None |
378 | | - PointMassRocket = None |
379 | | - |
380 | | - |
381 | | -if THREEDOF_AVAILABLE: |
382 | | - |
383 | | - @pytest.fixture |
384 | | - def acceptance_point_mass_motor(): |
385 | | - """Create a realistic point mass motor for acceptance testing. |
386 | | -
|
387 | | - Returns |
388 | | - ------- |
389 | | - rocketpy.PointMassMotor |
390 | | - A point mass motor with realistic thrust and mass properties. |
391 | | - """ |
392 | | - return PointMassMotor( |
393 | | - thrust_source=1500, # 1500 N constant thrust |
394 | | - dry_mass=2.5, # 2.5 kg dry mass |
395 | | - propellant_initial_mass=3.0, # 3.0 kg propellant |
396 | | - burn_time=3.5, # 3.5 s burn time |
397 | | - ) |
398 | | - |
399 | | - @pytest.fixture |
400 | | - def acceptance_point_mass_rocket(acceptance_point_mass_motor): |
401 | | - """Create a realistic point mass rocket for acceptance testing. |
402 | | -
|
403 | | - Parameters |
404 | | - ---------- |
405 | | - acceptance_point_mass_motor : rocketpy.PointMassMotor |
406 | | - The motor to be added to the rocket. |
407 | | -
|
408 | | - Returns |
409 | | - ------- |
410 | | - rocketpy.PointMassRocket |
411 | | - A point mass rocket with realistic dimensions and properties. |
412 | | - """ |
413 | | - rocket = PointMassRocket( |
414 | | - radius=0.0635, # 127 mm diameter (5 inches) |
415 | | - mass=5.0, # 5 kg without motor |
416 | | - center_of_mass_without_motor=0.5, |
417 | | - power_off_drag=0.45, |
418 | | - power_on_drag=0.50, |
419 | | - ) |
420 | | - rocket.add_motor(acceptance_point_mass_motor, position=0) |
421 | | - return rocket |
422 | | - |
423 | | - @pytest.fixture |
424 | | - def flight_3dof_no_weathercock(example_spaceport_env, acceptance_point_mass_rocket): |
425 | | - """Create a 3 DOF flight without weathercocking. |
426 | | -
|
427 | | - Parameters |
428 | | - ---------- |
429 | | - example_spaceport_env : rocketpy.Environment |
430 | | - Environment fixture for Spaceport America. |
431 | | - acceptance_point_mass_rocket : rocketpy.PointMassRocket |
432 | | - Point mass rocket fixture. |
433 | | -
|
434 | | - Returns |
435 | | - ------- |
436 | | - rocketpy.Flight |
437 | | - A 3 DOF flight simulation with weathercock_coeff=0.0. |
438 | | - """ |
439 | | - return Flight( |
440 | | - rocket=acceptance_point_mass_rocket, |
441 | | - environment=example_spaceport_env, |
442 | | - rail_length=5.0, |
443 | | - inclination=85, # 85 degrees from horizontal (5 degrees from vertical) |
444 | | - heading=0, |
445 | | - simulation_mode="3 DOF", |
446 | | - weathercock_coeff=0.0, |
447 | | - ) |
448 | | - |
449 | | - @pytest.fixture |
450 | | - def flight_3dof_with_weathercock( |
451 | | - example_spaceport_env, acceptance_point_mass_rocket |
452 | | - ): |
453 | | - """Create a 3 DOF flight with weathercocking enabled. |
454 | | -
|
455 | | - Parameters |
456 | | - ---------- |
457 | | - example_spaceport_env : rocketpy.Environment |
458 | | - Environment fixture for Spaceport America. |
459 | | - acceptance_point_mass_rocket : rocketpy.PointMassRocket |
460 | | - Point mass rocket fixture. |
461 | | -
|
462 | | - Returns |
463 | | - ------- |
464 | | - rocketpy.Flight |
465 | | - A 3 DOF flight simulation with weathercock_coeff=1.0. |
466 | | - """ |
467 | | - return Flight( |
468 | | - rocket=acceptance_point_mass_rocket, |
469 | | - environment=example_spaceport_env, |
470 | | - rail_length=5.0, |
471 | | - inclination=85, |
472 | | - heading=0, |
473 | | - simulation_mode="3 DOF", |
474 | | - weathercock_coeff=1.0, |
475 | | - ) |
| 370 | + |
| 371 | + |
| 372 | +@pytest.fixture |
| 373 | +def acceptance_point_mass_motor(): |
| 374 | + """Create a realistic point mass motor for acceptance testing. |
| 375 | +
|
| 376 | + Returns |
| 377 | + ------- |
| 378 | + rocketpy.PointMassMotor |
| 379 | + A point mass motor with realistic thrust and mass properties. |
| 380 | + """ |
| 381 | + return PointMassMotor( |
| 382 | + thrust_source=1500, # 1500 N constant thrust |
| 383 | + dry_mass=2.5, # 2.5 kg dry mass |
| 384 | + propellant_initial_mass=3.0, # 3.0 kg propellant |
| 385 | + burn_time=3.5, # 3.5 s burn time |
| 386 | + ) |
| 387 | + |
| 388 | + |
| 389 | +@pytest.fixture |
| 390 | +def acceptance_point_mass_rocket(acceptance_point_mass_motor): |
| 391 | + """Create a realistic point mass rocket for acceptance testing. |
| 392 | +
|
| 393 | + Parameters |
| 394 | + ---------- |
| 395 | + acceptance_point_mass_motor : rocketpy.PointMassMotor |
| 396 | + The motor to be added to the rocket. |
| 397 | +
|
| 398 | + Returns |
| 399 | + ------- |
| 400 | + rocketpy.PointMassRocket |
| 401 | + A point mass rocket with realistic dimensions and properties. |
| 402 | + """ |
| 403 | + rocket = PointMassRocket( |
| 404 | + radius=0.0635, # 127 mm diameter (5 inches) |
| 405 | + mass=5.0, # 5 kg without motor |
| 406 | + center_of_mass_without_motor=0.5, |
| 407 | + power_off_drag=0.45, |
| 408 | + power_on_drag=0.50, |
| 409 | + ) |
| 410 | + rocket.add_motor(acceptance_point_mass_motor, position=0) |
| 411 | + return rocket |
| 412 | + |
| 413 | + |
| 414 | +@pytest.fixture |
| 415 | +def flight_3dof_no_weathercock(example_spaceport_env, acceptance_point_mass_rocket): |
| 416 | + """Create a 3 DOF flight without weathercocking. |
| 417 | +
|
| 418 | + Parameters |
| 419 | + ---------- |
| 420 | + example_spaceport_env : rocketpy.Environment |
| 421 | + Environment fixture for Spaceport America. |
| 422 | + acceptance_point_mass_rocket : rocketpy.PointMassRocket |
| 423 | + Point mass rocket fixture. |
| 424 | +
|
| 425 | + Returns |
| 426 | + ------- |
| 427 | + rocketpy.Flight |
| 428 | + A 3 DOF flight simulation with weathercock_coeff=0.0. |
| 429 | + """ |
| 430 | + return Flight( |
| 431 | + rocket=acceptance_point_mass_rocket, |
| 432 | + environment=example_spaceport_env, |
| 433 | + rail_length=5.0, |
| 434 | + inclination=85, # 85 degrees from horizontal (5 degrees from vertical) |
| 435 | + heading=0, |
| 436 | + simulation_mode="3 DOF", |
| 437 | + weathercock_coeff=0.0, |
| 438 | + ) |
| 439 | + |
| 440 | + |
| 441 | +@pytest.fixture |
| 442 | +def flight_3dof_with_weathercock(example_spaceport_env, acceptance_point_mass_rocket): |
| 443 | + """Create a 3 DOF flight with weathercocking enabled. |
| 444 | +
|
| 445 | + Parameters |
| 446 | + ---------- |
| 447 | + example_spaceport_env : rocketpy.Environment |
| 448 | + Environment fixture for Spaceport America. |
| 449 | + acceptance_point_mass_rocket : rocketpy.PointMassRocket |
| 450 | + Point mass rocket fixture. |
| 451 | +
|
| 452 | + Returns |
| 453 | + ------- |
| 454 | + rocketpy.Flight |
| 455 | + A 3 DOF flight simulation with weathercock_coeff=1.0. |
| 456 | + """ |
| 457 | + return Flight( |
| 458 | + rocket=acceptance_point_mass_rocket, |
| 459 | + environment=example_spaceport_env, |
| 460 | + rail_length=5.0, |
| 461 | + inclination=85, |
| 462 | + heading=0, |
| 463 | + simulation_mode="3 DOF", |
| 464 | + weathercock_coeff=1.0, |
| 465 | + ) |
0 commit comments