Simulation¶
Main entry point for running internal ballistics simulations. InternalBallisticsSimulation takes a motor model and simulation parameters (time step, igniter pressure, external pressure), then marches through time using an RK4 solver.
run() returns a frozen SimulationResult (subclassed per motor type — SolidSimulationResult, BiliquidSimulationResult) carrying the full time-series data (thrust, chamber pressure, propellant mass, efficiency losses, …) along with derived scalars (total impulse, specific impulse, burn time). Each result class provides a report() method to print a human-readable summary and a summary() method that returns the scalar metrics as a dict.
The per-step accumulator state used by the integrator (MotorState and its subclasses SolidMotorState, BiliquidEngineState) lives in this same package — it is rarely consumed directly outside the simulation loop. Alongside it, the abstract TimestepConditions and its per-engine subclasses SolidTimestepConditions, BiliquidTimestepConditions snapshot the operating quantities of one timestep and are handed to the nozzle loss model.
machwave.simulation
¶
InternalBallisticsSimulation
¶
Internal ballistics simulation class.
Attributes:
| Name | Type | Description |
|---|---|---|
motor |
Motor
|
Motor object. |
params |
InternalBallisticsSimulationParams
|
Simulation parameters. |
Source code in machwave/simulation/base.py
__init__(motor, params)
¶
Initialize an internal ballistics simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
motor
|
Motor
|
Motor model to simulate. |
required |
params
|
InternalBallisticsSimulationParams
|
Simulation parameters. |
required |
Source code in machwave/simulation/base.py
run()
¶
Run the simulation to thrust termination and return its result.
Source code in machwave/simulation/base.py
InternalBallisticsSimulationParams
dataclass
¶
Parameters for an internal ballistics simulation.
Attributes:
| Name | Type | Description |
|---|---|---|
d_t |
float
|
Time step. |
igniter_pressure |
float
|
Igniter pressure. |
external_pressure |
float
|
External pressure. |
Source code in machwave/simulation/base.py
MotorState
¶
Bases: ABC
Defines the states and iteration step for a motor operation.
Source code in machwave/simulation/states.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
burn_time
property
¶
Return the burn time [s].
Raises:
| Type | Description |
|---|---|
ValueError
|
If the simulation has not yet completed. |
initial_propellant_mass
property
¶
Return the initial propellant mass [kg].
thrust_time
property
¶
Return the thrust time [s].
Raises:
| Type | Description |
|---|---|
ValueError
|
If the simulation has not yet completed. |
__init__(motor, igniter_pressure, external_pressure)
¶
Initialize a motor state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
motor
|
Motor
|
Motor to track. |
required |
igniter_pressure
|
float
|
Initial chamber pressure from the igniter [Pa]. |
required |
external_pressure
|
float
|
Ambient pressure [Pa]. |
required |
Source code in machwave/simulation/states.py
build_result()
¶
SimulationResult
dataclass
¶
Bases: ABC, Generic[StateT]
Results of a finished internal ballistics simulation.
Source code in machwave/simulation/results.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 | |
from_state(state)
classmethod
¶
Build a SimulationResult from a finished motor state.
report(file=sys.stdout)
¶
Print a human-readable report of the simulation result.
summary()
¶
Return a mapping of headline scalar metrics for this result.
Source code in machwave/simulation/results.py
base
¶
InternalBallisticsSimulation
¶
Internal ballistics simulation class.
Attributes:
| Name | Type | Description |
|---|---|---|
motor |
Motor
|
Motor object. |
params |
InternalBallisticsSimulationParams
|
Simulation parameters. |
Source code in machwave/simulation/base.py
__init__(motor, params)
¶
Initialize an internal ballistics simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
motor
|
Motor
|
Motor model to simulate. |
required |
params
|
InternalBallisticsSimulationParams
|
Simulation parameters. |
required |
Source code in machwave/simulation/base.py
run()
¶
Run the simulation to thrust termination and return its result.
Source code in machwave/simulation/base.py
InternalBallisticsSimulationParams
dataclass
¶
Parameters for an internal ballistics simulation.
Attributes:
| Name | Type | Description |
|---|---|---|
d_t |
float
|
Time step. |
igniter_pressure |
float
|
Igniter pressure. |
external_pressure |
float
|
External pressure. |
Source code in machwave/simulation/base.py
biliquid
¶
BiliquidEngineState
¶
Bases: MotorState
State for a biliquid rocket engine.
Source code in machwave/simulation/biliquid/states.py
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
__init__(motor, igniter_pressure, external_pressure)
¶
Initialize a biliquid engine state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
motor
|
BiliquidEngine
|
Biliquid engine to track. |
required |
igniter_pressure
|
float
|
Initial chamber pressure from the igniter [Pa]. |
required |
external_pressure
|
float
|
Ambient pressure [Pa]. |
required |
Source code in machwave/simulation/biliquid/states.py
run_timestep(d_t, external_pressure)
¶
Iterate the engine operation by calculating operational parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d_t
|
float
|
Time increment [s]. |
required |
external_pressure
|
float
|
External pressure [Pa]. |
required |
Source code in machwave/simulation/biliquid/states.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
BiliquidSimulationResult
dataclass
¶
Bases: SimulationResult['biliquid_states.BiliquidEngineState']
Simulation result for a biliquid engine run.
Source code in machwave/simulation/biliquid/results.py
results
¶
BiliquidSimulationResult
dataclass
¶
Bases: SimulationResult['biliquid_states.BiliquidEngineState']
Simulation result for a biliquid engine run.
Source code in machwave/simulation/biliquid/results.py
states
¶
BiliquidEngineState
¶
Bases: MotorState
State for a biliquid rocket engine.
Source code in machwave/simulation/biliquid/states.py
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
__init__(motor, igniter_pressure, external_pressure)
¶
Initialize a biliquid engine state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
motor
|
BiliquidEngine
|
Biliquid engine to track. |
required |
igniter_pressure
|
float
|
Initial chamber pressure from the igniter [Pa]. |
required |
external_pressure
|
float
|
Ambient pressure [Pa]. |
required |
Source code in machwave/simulation/biliquid/states.py
run_timestep(d_t, external_pressure)
¶
Iterate the engine operation by calculating operational parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d_t
|
float
|
Time increment [s]. |
required |
external_pressure
|
float
|
External pressure [Pa]. |
required |
Source code in machwave/simulation/biliquid/states.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
BiliquidTimestepConditions
dataclass
¶
Bases: TimestepConditions
Timestep conditions for a biliquid engine.
Source code in machwave/simulation/biliquid/states.py
get_injector_mass_flows(chamber_pressure, *, feed_system, injector, fuel_mass, oxidizer_mass, fuel_tank_pressure, oxidizer_tank_pressure, is_feeding, d_t)
¶
Fuel and oxidizer injector flows at the given chamber pressure [kg/s].
Source code in machwave/simulation/biliquid/states.py
get_total_injector_mass_flow(chamber_pressure, *, injector_flows)
¶
Total injector mass flow (fuel + oxidizer) at the given pressure [kg/s].
Source code in machwave/simulation/biliquid/states.py
results
¶
SimulationResult
dataclass
¶
Bases: ABC, Generic[StateT]
Results of a finished internal ballistics simulation.
Source code in machwave/simulation/results.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 | |
from_state(state)
classmethod
¶
Build a SimulationResult from a finished motor state.
report(file=sys.stdout)
¶
Print a human-readable report of the simulation result.
summary()
¶
Return a mapping of headline scalar metrics for this result.
Source code in machwave/simulation/results.py
solid
¶
SolidMotorState
¶
Bases: MotorState
State for a Solid Rocket Motor.
Source code in machwave/simulation/solid/states.py
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
__init__(motor, igniter_pressure, external_pressure)
¶
Initialize a solid motor state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
motor
|
SolidMotor
|
Solid motor to track. |
required |
igniter_pressure
|
float
|
Initial chamber pressure from the igniter [Pa]. |
required |
external_pressure
|
float
|
Ambient pressure [Pa]. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the motor's propellant has no thermochemical properties. Solid propellant properties are fixed for the entire run, so a missing value is a configuration error and the simulation refuses to start. |
Source code in machwave/simulation/solid/states.py
run_timestep(d_t, external_pressure)
¶
Iterate the motor operation by calculating operational parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d_t
|
float
|
Time increment [s]. |
required |
external_pressure
|
float
|
External pressure [Pa]. |
required |
Source code in machwave/simulation/solid/states.py
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
SolidSimulationResult
dataclass
¶
Bases: SimulationResult['solid_states.SolidMotorState']
Simulation result for a solid motor run.
Source code in machwave/simulation/solid/results.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
results
¶
SolidSimulationResult
dataclass
¶
Bases: SimulationResult['solid_states.SolidMotorState']
Simulation result for a solid motor run.
Source code in machwave/simulation/solid/results.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
states
¶
SolidMotorState
¶
Bases: MotorState
State for a Solid Rocket Motor.
Source code in machwave/simulation/solid/states.py
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
__init__(motor, igniter_pressure, external_pressure)
¶
Initialize a solid motor state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
motor
|
SolidMotor
|
Solid motor to track. |
required |
igniter_pressure
|
float
|
Initial chamber pressure from the igniter [Pa]. |
required |
external_pressure
|
float
|
Ambient pressure [Pa]. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the motor's propellant has no thermochemical properties. Solid propellant properties are fixed for the entire run, so a missing value is a configuration error and the simulation refuses to start. |
Source code in machwave/simulation/solid/states.py
run_timestep(d_t, external_pressure)
¶
Iterate the motor operation by calculating operational parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d_t
|
float
|
Time increment [s]. |
required |
external_pressure
|
float
|
External pressure [Pa]. |
required |
Source code in machwave/simulation/solid/states.py
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
SolidTimestepConditions
dataclass
¶
Bases: TimestepConditions
Timestep conditions for a solid motor.
Source code in machwave/simulation/solid/states.py
get_free_chamber_volume_rate(chamber_pressure, *, propellant, burn_area)
¶
Free chamber volume growth rate at the given chamber pressure [m^3/s].
Source code in machwave/simulation/solid/states.py
get_grain_mass_flow(chamber_pressure, *, mass_flow_per_segment)
¶
Total grain mass generation rate at the given chamber pressure [kg/s].
Source code in machwave/simulation/solid/states.py
get_grain_mass_flow_per_segment(chamber_pressure, *, propellant, burn_area_per_segment, segment_density_ratios)
¶
Per-segment grain mass generation rate at the given chamber pressure [kg/s].
Source code in machwave/simulation/solid/states.py
states
¶
MotorState
¶
Bases: ABC
Defines the states and iteration step for a motor operation.
Source code in machwave/simulation/states.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
burn_time
property
¶
Return the burn time [s].
Raises:
| Type | Description |
|---|---|
ValueError
|
If the simulation has not yet completed. |
initial_propellant_mass
property
¶
Return the initial propellant mass [kg].
thrust_time
property
¶
Return the thrust time [s].
Raises:
| Type | Description |
|---|---|
ValueError
|
If the simulation has not yet completed. |
__init__(motor, igniter_pressure, external_pressure)
¶
Initialize a motor state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
motor
|
Motor
|
Motor to track. |
required |
igniter_pressure
|
float
|
Initial chamber pressure from the igniter [Pa]. |
required |
external_pressure
|
float
|
Ambient pressure [Pa]. |
required |
Source code in machwave/simulation/states.py
build_result()
¶
TimestepConditions
dataclass
¶
Engine conditions at one simulation timestep, in SI units.
Holds the scalar operating quantities every engine/motor type computes for the step, except the performance-related ones (thrust, thrust coefficient, nozzle efficiency).