Simulations¶
machwave.simulations
¶
BallisticSimulation
¶
Bases: Simulation
Ballistic simulation class.
Attributes:
| Name | Type | Description |
|---|---|---|
rocket |
Rocket object. |
|
atmosphere |
Atmosphere object. |
|
params |
BallisticSimulationParameters
|
Simulation parameters. |
t |
Array of time values. |
|
ballistic_state |
Ballistic state object. |
Source code in machwave/simulations/ballistics.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
__init__(rocket, atmosphere, params)
¶
Initialize the BallisticSimulation instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rocket
|
Rocket
|
Rocket object. |
required |
atmosphere
|
Atmosphere
|
Atmosphere object. |
required |
params
|
BallisticSimulationParameters
|
Simulation parameters. |
required |
Source code in machwave/simulations/ballistics.py
get_propellant_mass()
¶
Compute the propellant mass at each time step.
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of propellant mass values. |
Source code in machwave/simulations/ballistics.py
print_results()
¶
Prints the results of the simulation.
Source code in machwave/simulations/ballistics.py
run()
¶
Runs the main loop of the simulation, returning the time array and the ballistic state object.
Returns:
| Type | Description |
|---|---|
tuple
|
tuple[np.array, Ballistic1DState]: A tuple containing the time |
tuple
|
array and the ballistic state object. |
Source code in machwave/simulations/ballistics.py
BallisticSimulationParameters
¶
Bases: SimulationParameters
Parameters for a ballistic simulation.
Attributes:
| Name | Type | Description |
|---|---|---|
thrust |
Array of thrust values. |
|
motor_dry_mass |
Dry mass of the motor. |
|
initial_propellant_mass |
Initial mass of the propellant. |
|
time |
Array of time values. |
|
d_t |
Time step. |
|
initial_elevation_amsl |
Initial elevation above mean sea level. |
|
rail_length |
Length of the launch rail. |
Source code in machwave/simulations/ballistics.py
InternalBallistics
¶
Bases: Simulation
Internal ballistics simulation class.
Attributes:
| Name | Type | Description |
|---|---|---|
motor |
Motor
|
Motor object. |
params |
InternalBallisticsParams
|
Simulation parameters. |
t |
ndarray
|
Array of time values. |
motor_state |
MotorState | None
|
Motor state object. |
Source code in machwave/simulations/internal_ballistics.py
get_motor_state()
¶
Returns the motor state object based on the type of the motor.
Source code in machwave/simulations/internal_ballistics.py
print_results()
¶
Prints the results of the simulation.
Source code in machwave/simulations/internal_ballistics.py
run()
¶
Runs the main loop of the simulation, returning the time array and the motor state object.
Source code in machwave/simulations/internal_ballistics.py
InternalBallisticsCoupled
¶
Bases: Simulation
Coupled internal ballistics simulation class.
Attributes:
| Name | Type | Description |
|---|---|---|
rocket |
Rocket object. |
|
params |
InternalBallisticsCoupledParams
|
Simulation parameters. |
t |
Array of time values. |
|
motor_state |
Motor state object. |
|
ballistic_state |
Ballistic state object. |
Source code in machwave/simulations/internal_balistics_coupled.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
__init__(rocket, params)
¶
Initialize the InternalBallisticsCoupled instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rocket
|
Rocket
|
Rocket object. |
required |
params
|
InternalBallisticsCoupledParams
|
Simulation parameters. |
required |
Source code in machwave/simulations/internal_balistics_coupled.py
get_motor_state()
¶
Return the motor state object based on the type of the motor.
Source code in machwave/simulations/internal_balistics_coupled.py
run()
¶
Run the main loop of the simulation.
Returns:
| Type | Description |
|---|---|
tuple
|
List containing motor state object and ballistic state object. |
Source code in machwave/simulations/internal_balistics_coupled.py
InternalBallisticsCoupledParams
¶
Bases: SimulationParameters
Parameters for a coupled internal ballistics simulation.
Attributes:
| Name | Type | Description |
|---|---|---|
atmosphere |
Atmosphere object. |
|
d_t |
Time step for the ballistic simulation. |
|
dd_t |
Time step factor for the motor simulation. |
|
initial_elevation_amsl |
Initial elevation above mean sea level. |
|
igniter_pressure |
Igniter pressure. |
|
rail_length |
Length of the launch rail. |
Source code in machwave/simulations/internal_balistics_coupled.py
InternalBallisticsParams
¶
Bases: SimulationParameters
Parameters for an internal ballistics simulation.
Attributes:
| Name | Type | Description |
|---|---|---|
d_t |
Time step. |
|
igniter_pressure |
Igniter pressure. |
|
external_pressure |
External pressure. |
Source code in machwave/simulations/internal_ballistics.py
Simulation
¶
Bases: ABC
Abstract class that represents a simulation.
Subclasses of Simulation implement specific simulation logic.
NOTE: Instances of this class should not store any simulation state. Storing and analyzing simulation data should be done only by the State class.
Attributes:
| Name | Type | Description |
|---|---|---|
params |
Object containing simulation parameters. |
Source code in machwave/simulations/base.py
__init__(params)
¶
Initialize the Simulation instance with the provided parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
SimulationParameters
|
Object containing simulation parameters. |
required |
print_results(*args, **kwargs)
abstractmethod
¶
Print the results of the simulation.
Calls the print_results method on the State instances of the simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Additional positional arguments. |
()
|
|
**kwargs
|
Additional keyword arguments. |
{}
|
Source code in machwave/simulations/base.py
run()
abstractmethod
¶
Run the simulation.
This method should be implemented by subclasses. It typically contains a loop that iterates over time or distance.
Returns:
| Type | Description |
|---|---|
tuple
|
List of State instances representing the states performed during |
tuple
|
the simulation. |
Source code in machwave/simulations/base.py
SimulationParameters
¶
Bases: ABC
Abstract class that stores simulation parameters and should be subclassed for specific simulations.
Examples of simulation parameters: - time step for a time-based iterative simulation - initial elevation in the case of a rocket launch - igniter pressure in the case of an internal ballistic simulation