Skip to content

Commit

Permalink
MNT: renaming to stochastic
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusStano committed Feb 8, 2024
1 parent b16e329 commit 1bae4b6
Show file tree
Hide file tree
Showing 10 changed files with 358 additions and 358 deletions.
14 changes: 14 additions & 0 deletions rocketpy/stochastic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from .stochastic_model import StochasticModel
from .stochastic_aero_surfaces import (
StochasticEllipticalFins,
StochasticNoseCone,
StochasticRailButtons,
StochasticTail,
StochasticTrapezoidalFins,
)
from .stochastic_environment import StochasticEnvironment
from .stochastic_flight import StochasticFlight
from .stochastic_parachute import StochasticParachute
from .stochastic_rocket import StochasticRocket
from .stochastic_solid_motor import StochasticSolidMotor
from .stochastic_generic_motor import StochasticGenericMotor

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from rocketpy.environment import Environment

from .dispersion_model import DispersionModel
from .stochastic_model import StochasticModel


class McEnvironment(DispersionModel):
"""A Monte Carlo Environment class that inherits from MonteCarloModel. This
class StochasticEnvironment(StochasticModel):
"""A Stochastic Environment class that inherits from StochasticModel. This
class is used to receive a Environment object and information about the
dispersion of its parameters and generate a random environment object based
on the provided information.
Expand All @@ -15,16 +15,16 @@ class is used to receive a Environment object and information about the
Environment object to be used for validation.
elevation : tuple, list, int, float
Elevation of the launch site in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
gravity : tuple, list, int, float
Gravitational acceleration in meters per second squared. Follows the
standard input format of Dispersion Models.
standard input format of Stochastic Models.
latitude : tuple, list, int, float
Latitude of the launch site in degrees. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
longitude : tuple, list, int, float
Longitude of the launch site in degrees. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
ensemble_member : list
List of integers representing the ensemble member to be selected.
wind_velocity_x_factor : tuple, list, int, float
Expand All @@ -51,12 +51,12 @@ def __init__(
wind_velocity_x_factor=(1, 0),
wind_velocity_y_factor=(1, 0),
):
"""Initializes the Monte Carlo Environment class.
"""Initializes the Stochastic Environment class.
See Also
--------
This should link to somewhere that explains how inputs works in
dispersion models.
Stochastic models.
Parameters
----------
Expand All @@ -67,26 +67,26 @@ def __init__(
(year, month, day, hour).
elevation : int, float, tuple, list, optional
Elevation of the launch site in meters. Follows the standard
input format of Dispersion Models.
input format of Stochastic Models.
gravity : int, float, tuple, list, optional
Gravitational acceleration in meters per second squared. Follows
the standard input format of Dispersion Models.
the standard input format of Stochastic Models.
latitude : int, float, tuple, list, optional
Latitude of the launch site in degrees. Follows the standard
input format of Dispersion Models.
input format of Stochastic Models.
longitude : int, float, tuple, list, optional
Longitude of the launch site in degrees. Follows the standard
input format of Dispersion Models.
input format of Stochastic Models.
ensemble_member : list, optional
List of integers representing the ensemble member to be selected.
wind_velocity_x_factor : int, float, tuple, list, optional
Factor to be multiplied by the wind velocity in the x direction.
Follows the factor input format of Dispersion Models.
Follows the factor input format of Stochastic Models.
wind_velocity_y_factor : int, float, tuple, list, optional
Factor to be multiplied by the wind velocity in the y direction.
Follows the factor input format of Dispersion Models.
Follows the factor input format of Stochastic Models.
"""
# Validate in DispersionModel
# Validate in StochasticModel
super().__init__(
environment,
date=None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
from rocketpy.simulation import Flight

from .dispersion_model import DispersionModel
from .stochastic_model import StochasticModel


class McFlight(DispersionModel):
"""A Monte Carlo Flight class that inherits from MonteCarloModel. This
class StochasticFlight(StochasticModel):
"""A Stochastic Flight class that inherits from StochasticModel. This
class is used to receive a Flight object and information about the
dispersion of its parameters and generate a random flight object based on
the provided information.
Attributes
----------
flight : Flight
The Flight object to be used as a base for the Monte Carlo flight.
The Flight object to be used as a base for the Stochastic flight.
rail_length : int, float, tuple, list, optional
The rail length of the flight. Follows the standard input format of
Dispersion Models.
Stochastic Models.
inclination : int, float, tuple, list, optional
The inclination of the flight. Follows the standard input format of
Dispersion Models.
Stochastic Models.
heading : int, float, tuple, list, optional
The heading of the flight. Follows the standard input format of
Dispersion Models.
Stochastic Models.
initial_solution : tuple, list, optional
The initial solution of the flight. This is a tuple of 14 elements that
represent the initial conditions of the flight. This attribute can not
Expand All @@ -40,26 +40,26 @@ def __init__(
initial_solution=None,
terminate_on_apogee=None,
):
"""Initializes the Monte Carlo Flight class.
"""Initializes the Stochastic Flight class.
See Also
--------
This should link to somewhere that explains how inputs works in
dispersion models.
Stochastic models.
Parameters
----------
flight : Flight
The Flight object to be used as a base for the Monte Carlo flight.
The Flight object to be used as a base for the Stochastic flight.
rail_length : int, float, tuple, list, optional
The rail length of the flight. Follows the standard input format of
Dispersion Models.
Stochastic Models.
inclination : int, float, tuple, list, optional
The inclination of the flight. Follows the standard input format of
Dispersion Models.
Stochastic Models.
heading : int, float, tuple, list, optional
The heading of the flight. Follows the standard input format of
Dispersion Models.
Stochastic Models.
initial_solution : tuple, list, optional
The initial solution of the flight. This is a tuple of 14 elements
that represent the initial conditions of the flight. This attribute
Expand Down Expand Up @@ -100,21 +100,21 @@ def _validate_initial_solution(self, initial_solution):
# TODO: these call dict_generator a lot of times unecessaryly
def _randomize_rail_length(self):
"""Randomizes the rail length of the flight. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
"""
generated_dict = next(self.dict_generator())
return generated_dict["rail_length"]

def _randomize_inclination(self):
"""Randomizes the inclination of the flight. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
"""
generated_dict = next(self.dict_generator())
return generated_dict["inclination"]

def _randomize_heading(self):
"""Randomizes the heading of the flight. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
"""
generated_dict = next(self.dict_generator())
return generated_dict["heading"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from rocketpy.motors import GenericMotor

from .motor_dispersion_model import MotorDispersionModel
from .stochastic_motor_model import StochasticMotorModel


class McGenericMotor(MotorDispersionModel):
"""A Monte Carlo Generic Motor class that inherits from MonteCarloModel.
class StochasticGenericMotor(StochasticMotorModel):
"""A Stochastic Generic Motor class that inherits from StochasticModel.
This class is used to receive a GenericMotor object and information about
the dispersion of its parameters and generate a random generic motor object
based on the provided information.
Expand All @@ -17,52 +17,52 @@ class McGenericMotor(MotorDispersionModel):
List of strings representing the thrust source to be selected.
total_impulse : int, float, tuple, list
Total impulse of the motor in newton seconds. Follows the standard
input format of Dispersion Models.
input format of Stochastic Models.
burn_start_time : int, float, tuple, list
Burn start time of the motor in seconds. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
burn_out_time : int, float, tuple, list
Burn out time of the motor in seconds. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
dry_mass : int, float, tuple, list
Dry mass of the motor in kilograms. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
dry_I_11 : int, float, tuple, list
Dry inertia of the motor in kilograms times meters squared. Follows the
standard input format of Dispersion Models.
standard input format of Stochastic Models.
dry_I_22 : int, float, tuple, list
Dry inertia of the motor in kilograms times meters squared. Follows the
standard input format of Dispersion Models.
standard input format of Stochastic Models.
dry_I_33 : int, float, tuple, list
Dry inertia of the motor in kilograms times meters squared. Follows the
standard input format of Dispersion Models.
standard input format of Stochastic Models.
dry_I_12 : int, float, tuple, list
Dry inertia of the motor in kilograms times meters squared. Follows the
standard input format of Dispersion Models.
standard input format of Stochastic Models.
dry_I_13 : int, float, tuple, list
Dry inertia of the motor in kilograms times meters squared. Follows the
standard input format of Dispersion Models.
standard input format of Stochastic Models.
dry_I_23 : int, float, tuple, list
Dry inertia of the motor in kilograms times meters squared. Follows the
standard input format of Dispersion Models.
standard input format of Stochastic Models.
chamber_radius : int, float, tuple, list
Chamber radius of the motor in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
chamber_height : int, float, tuple, list
Chamber height of the motor in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
chamber_position : int, float, tuple, list
Chamber position of the motor in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
nozzle_radius : int, float, tuple, list
Nozzle radius of the motor in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
nozzle_position : int, float, tuple, list
Nozzle position of the motor in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
center_of_dry_mass_position : int, float, tuple, list
Center of dry mass position of the motor in meters. Follows the
standard input format of Dispersion Models.
standard input format of Stochastic Models.
interpolation_method : str, optional
Interpolation method to be used. This attribute can not be randomized.
coordinate_system_orientation : str, optional
Expand Down Expand Up @@ -92,68 +92,68 @@ def __init__(
nozzle_position=None,
center_of_dry_mass_position=None,
):
"""Initializes the Monte Carlo Generic Motor class.
"""Initializes the Stochastic Generic Motor class.
See Also
--------
This should link to somewhere that explains how inputs works in
dispersion models.
Stochastic Models.
Parameters
----------
generic_motor : GenericMotor
GenericMotor object to be used for validation.
thrust_source : list, optional
List of strings representing the thrust source to be selected.
Follows the 1d array like input format of Dispersion Models.
Follows the 1d array like input format of Stochastic Models.
total_impulse : int, float, tuple, list, optional
Total impulse of the motor in newton seconds. Follows the standard
input format of Dispersion Models.
input format of Stochastic Models.
burn_start_time : int, float, tuple, list, optional
Burn start time of the motor in seconds. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
burn_out_time : int, float, tuple, list, optional
Burn out time of the motor in seconds. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
dry_mass : int, float, tuple, list, optional
Dry mass of the motor in kilograms. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
dry_I_11 : int, float, tuple, list, optional
Dry inertia of the motor in kilograms times meters squared. Follows
the standard input format of Dispersion Models.
the standard input format of Stochastic Models.
dry_I_22 : int, float, tuple, list, optional
Dry inertia of the motor in kilograms times meters squared. Follows
the standard input format of Dispersion Models.
the standard input format of Stochastic Models.
dry_I_33 : int, float, tuple, list, optional
Dry inertia of the motor in kilograms times meters squared. Follows
the standard input format of Dispersion Models.
the standard input format of Stochastic Models.
dry_I_12 : int, float, tuple, list, optional
Dry inertia of the motor in kilograms times meters squared. Follows
the standard input format of Dispersion Models.
the standard input format of Stochastic Models.
dry_I_13 : int, float, tuple, list, optional
Dry inertia of the motor in kilograms times meters squared. Follows
the standard input format of Dispersion Models.
the standard input format of Stochastic Models.
dry_I_23 : int, float, tuple, list, optional
Dry inertia of the motor in kilograms times meters squared. Follows
the standard input format of Dispersion Models.
the standard input format of Stochastic Models.
chamber_radius : int, float, tuple, list, optional
Chamber radius of the motor in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
chamber_height : int, float, tuple, list, optional
Chamber height of the motor in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
chamber_position : int, float, tuple, list, optional
Chamber position of the motor in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
nozzle_radius : int, float, tuple, list, optional
Nozzle radius of the motor in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
nozzle_position : int, float, tuple, list, optional
Nozzle position of the motor in meters. Follows the standard input
format of Dispersion Models.
format of Stochastic Models.
center_of_dry_mass_position : int, float, tuple, list, optional
Center of dry mass position of the motor in meters. Follows the
standard input format of Dispersion Models.
standard input format of Stochastic Models.
"""
super().__init__(
generic_motor,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from random import choice

import numpy as np

from rocketpy.mathutils.function import Function

from ..tools import get_distribution


class DispersionModel:
"""Base class for all Monte Carlo classes. This class is used to validate
class StochasticModel:
"""Base class for all Stochastic classes. This class is used to validate
the input arguments of the child classes. The input arguments are validated
and saved as attributes of the class in the correct format. The attributes
are then used to generate a dictionary with the randomly generated input
Expand All @@ -24,7 +23,7 @@ class DispersionModel:
]

def __init__(self, object, **kwargs):
"""Initialize the DispersionModel class with validated input arguments.
"""Initialize the StochasticModel class with validated input arguments.
Parameters
----------
Expand Down
Loading

0 comments on commit 1bae4b6

Please sign in to comment.