models.propulsion.grain¶
machwave.models.propulsion.grain
¶
Grain
¶
Source code in machwave/models/propulsion/grain/base.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | |
segment_count
property
¶
Returns the number of segments in the grain.
:rtype: int
total_length
property
¶
Calculates total length of the grain.
Example: - 1 segment of 0.5 m length -> total length = 0.5 m - 2 segments of 0.5 m length with 0.1 m spacing -> total length = 1.1 m - 3 segments of 0.5 m length with 0.1 m spacing -> total length = 1.7 m
:rtype: float
__init__(spacing=0.0)
¶
Initialize a grain assembly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spacing
|
float
|
Distance between segments in meters. Default is 0.0 (no spacing). |
0.0
|
Source code in machwave/models/propulsion/grain/base.py
add_segment(new_segment)
¶
Adds a new segment to the grain.
:param GrainSegment new_segment: The new segment to be added :rtype: None :raises Exceptiom: If the new_segment is not valid
Source code in machwave/models/propulsion/grain/base.py
get_burn_area(web_distance)
¶
Calculates the BATES burn area given the web distance.
:param float web_distance: Instant web thickness value :return float: Instant burn area, in m^2 and in function of web :rtype: float
Source code in machwave/models/propulsion/grain/base.py
get_center_of_gravity(web_distance)
¶
Calculates the center of gravity of the grain.
Takes the mass-weighted average of all segment centers of gravity, accounting for varying density ratios and spacing between segments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_distance
|
float
|
Web distance traveled [m]. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
A 1D array of shape (3,) representing the [x, y, z] coordinates |
NDArray[float64]
|
of the center of gravity [m]. Origin is at the port of the grain |
NDArray[float64]
|
(closest to nozzle), with positive x pointing toward bulkhead. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no segments are found in the grain. |
Source code in machwave/models/propulsion/grain/base.py
get_effective_density_ratio(*, web_distance)
¶
Return an effective (burn-area weighted) density ratio.
Used for gas generation terms where $\dot{m} \propto A_b r \rho_p$.
Source code in machwave/models/propulsion/grain/base.py
get_mass_flux_per_segment(burn_rate, ideal_density, web_distance)
¶
Returns a numpy multidimensional array with the mass flux for each grain.
Source code in machwave/models/propulsion/grain/base.py
get_moment_of_inertia(ideal_density, web_distance=0.0)
¶
Combines the inertia tensors of all grain segments using the parallel axis theorem, accounting for varying density ratios and spacing between segments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ideal_density
|
float
|
Propellant ideal density [kg/m^3]. |
required |
web_distance
|
float
|
Web distance traveled [m]. |
0.0
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
A 3x3 inertia tensor [kg-m^2] at the grain's center of gravity: [[Ixx, Ixy, Ixz], [Ixy, Iyy, Iyz], [Ixz, Iyz, Izz]] |
NDArray[float64]
|
Coordinate system: Origin at grain's center of gravity, with: |
NDArray[float64]
|
|
NDArray[float64]
|
|
NDArray[float64]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no segments are found in the grain. |
Source code in machwave/models/propulsion/grain/base.py
get_propellant_mass(*, web_distance, ideal_density)
¶
Return remaining propellant mass [kg] at a given web distance.
Source code in machwave/models/propulsion/grain/base.py
get_propellant_volume(web_distance)
¶
Calculates the BATES grain volume given the web distance.
:param float web_distance: Instant web thickness value :return: Instant propellant volume, in m^3 and in function of web :rtype: float
Source code in machwave/models/propulsion/grain/base.py
get_real_density(*, web_distance, ideal_density)
¶
Return grain effective real propellant density [kg/m^3].
Source code in machwave/models/propulsion/grain/base.py
GrainSegment
¶
Bases: ABC
Class that represents a grain segment.
Source code in machwave/models/propulsion/grain/base.py
13 14 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 | |
get_burn_area(web_distance)
abstractmethod
¶
Calculates burn area in function of the web distance traveled.
:param float web_distance: Web distance traveled :return: Burn area in function of the web distance traveled :rtype: float
Source code in machwave/models/propulsion/grain/base.py
get_center_of_gravity(*args, **kwargs)
abstractmethod
¶
Calculates the center of gravity of the segment.
The coordinate system origin is at the port, closest to the nozzle, with positive x-direction pointing toward the bulkhead.
:return: The center of gravity of the segment [x, y, z] in meters :rtype: np.typing.NDArray[np.float64]
Source code in machwave/models/propulsion/grain/base.py
get_mass(web_distance, ideal_density)
¶
Calculates the mass of the segment at a given web distance.
:param float web_distance: Web distance traveled [m] :param float ideal_density: Ideal propellant density [kg/m^3] :return: Mass of the segment at the given web distance [kg] :rtype: float
Source code in machwave/models/propulsion/grain/base.py
get_moment_of_inertia(*args, **kwargs)
abstractmethod
¶
Calculates the moment of inertia tensor of the segment at its center of gravity.
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
A 3x3 array representing the inertia tensor [kg-m^2] with components: [[Ixx, Ixy, Ixz], [Iyx, Iyy, Iyz], [Izx, Izy, Izz]] |
Source code in machwave/models/propulsion/grain/base.py
get_port_area(web_distance, *args, **kwargs)
abstractmethod
¶
Calculates the port area as a function of the web distance traveled.
This method assumes a 2D or simplified model where the port area can be represented by a single scalar value at a given web distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_distance
|
float
|
Distance traveled into the grain web. |
required |
*args
|
Additional positional arguments. |
()
|
|
**kwargs
|
Additional keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
float
|
A float representing the port area. |
Source code in machwave/models/propulsion/grain/base.py
get_volume(web_distance)
abstractmethod
¶
Calculates volume in function of the web distance traveled.
:param float web_distance: Web distance traveled :return: Segment volume in function of the instant web thickness :rtype: float
Source code in machwave/models/propulsion/grain/base.py
get_web_thickness()
abstractmethod
¶
Calculates the total web thickness of the segment.
:return: The total web thickness of the segment :rtype: float
validate()
¶
Validates grain geometry. For every attribute that a child class adds, it must be validated here.
:rtype: None
Source code in machwave/models/propulsion/grain/base.py
GrainSegment2D
¶
Bases: GrainSegment, ABC
Class that represents a 2D grain segment.
A 2D grain segment is a segment that has the same cross sectional geometry throughout its length.
Some examples of 2D grain geometries: - BATES - Tubular - Pseudo-finocyl
Source code in machwave/models/propulsion/grain/base.py
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 | |
get_core_area(web_distance)
abstractmethod
¶
Calculates the core area in function of the web distance traveled.
Example: In a simple tubular geometry, the core area would be equal to the instant length of the segment times the instant core area.
Not to be confused with port area!
:param float web_distance: Web distance traveled :return: Core area in function of the web distance traveled :rtype: float
Source code in machwave/models/propulsion/grain/base.py
get_face_area(web_distance)
abstractmethod
¶
Calculates the face area in function of the web distance traveled.
Example: In a simple tubular geometry, the face area would be equal to the outer diameter area minus the instantaneous core diameter area.
:param float web_distance: Web distance traveled :return: Face area in function of the web distance traveled :rtype: float
Source code in machwave/models/propulsion/grain/base.py
GrainSegment3D
¶
Bases: GrainSegment, ABC
Class that represents a 3D grain segment.
Some examples of 3D grain geometries: - Conical - Finocyl
Source code in machwave/models/propulsion/grain/base.py
get_length(web_distance)
¶
get_port_area(web_distance, z)
abstractmethod
¶
Calculates the port area as a function of the web distance traveled and a specified height (z).
NOTE: This method is not implemented.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_distance
|
float
|
The distance traveled into the grain web. |
required |
z
|
float
|
The axial position (height) along the grain. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The port area at the given web distance and height. |