models.grain.fmm¶
Fast Marching Method (FMM) base classes for grain geometries whose cross-section cannot be described analytically. The burning surface at any web distance is read off a single distance map of the initial port (solved with scikit-fmm), instead of re-meshing the geometry at every regression step.
FMMGrainSegment— Shared regression logic: builds the distance map and derives web thickness, the regressed face map, and port and burn area from it.FMMGrainSegment2D— Constant cross-section geometries (Star, D-grain, wagon-wheel, multi-port, rod-and-tube). Burn area is the core perimeter (a single contour of the distance map) times the grain length, plus any exposed end faces.FMMGrainSegment3D— Axially varying cross-section geometries (Conical, Finocyl). The port is a stack of axial slices through a 3D distance map; burn area is the marching-cubes area of the regressing iso-surface, and port area is read from a chosen slice.FMMSTLGrainSegment— Arbitrary grain geometry imported from an STL mesh file.
Used internally by the concrete geometry classes in geometries.
machwave.models.grain.fmm
¶
Fast Marching Method (FMM) grain geometry models.
Supports both 2D and 3D geometries, as well as STL meshes.
References
https://math.berkeley.edu/~sethian/2006/Explanations/fast_marching_explain.html
FMMGrainSegment
¶
Bases: GrainSegment, ABC
Fast Marching Method (FMM) implementation of a grain segment.
Source code in machwave/models/grain/fmm/base.py
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 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 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 | |
has_cross_section_regression
property
¶
Return whether the cross-section has any burning surface.
__init__(length, outer_diameter, inhibited_surfaces=None, grid_resolution=DEFAULT_GRID_RESOLUTION, density_ratio=1.0)
¶
Initialize an FMM grain segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Segment length [m]. |
required |
outer_diameter
|
float
|
Outer diameter [m]. |
required |
inhibited_surfaces
|
InhibitedSurfaces | None
|
Surfaces inhibited from burning. |
None
|
grid_resolution
|
int
|
Resolution of the face map, x and y axes. |
DEFAULT_GRID_RESOLUTION
|
density_ratio
|
float
|
Ratio of real to ideal propellant density. |
1.0
|
Source code in machwave/models/grain/fmm/base.py
cells_to_meters(value)
¶
Convert a pixel-distance value to [m].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float | NDArray[float64]
|
Distance in pixel units. |
required |
Returns:
| Type | Description |
|---|---|
float | NDArray[float64]
|
Distance [m]. |
Source code in machwave/models/grain/fmm/base.py
cells_to_square_meters(value)
¶
Convert a pixel-area value to [m^2].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float | NDArray[float64]
|
Area in pixel units. |
required |
Returns:
| Type | Description |
|---|---|
float | NDArray[float64]
|
Area [m^2]. |
Source code in machwave/models/grain/fmm/base.py
denormalize(value)
¶
Convert a normalized input back into a dimensional value [m].
generate_initial_face_map()
abstractmethod
¶
Generate the initial face map for the geometry (1 = propellant, 0 = void).
get_contours(web_distance, *args, **kwargs)
abstractmethod
¶
Return the contours of the regression map for a given web distance.
Must be implemented by a subclass to compute the contour data based on the given web distance and any additional parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_distance
|
float
|
Depth of regression into the grain web [m]. |
required |
*args
|
Any
|
Additional positional arguments. |
()
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
list[NDArray[float64]]
|
An array representing the computed contours of the grain regression. |
Source code in machwave/models/grain/fmm/base.py
get_coordinate_grids()
abstractmethod
¶
get_empty_face_map()
¶
get_face_map(web_distance)
¶
Returns a matrix representing the grain face based on the given web distance.
The returned array can contain: -1 for masked or invalid points, 0 for points below the threshold, 1 for points above the threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_distance
|
float
|
The distance traveled into the grain web. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int64]
|
A NumPy array with -1, 0, or 1 indicating the grain face at the specified web distance. |
Source code in machwave/models/grain/fmm/base.py
get_masked_face()
¶
Return a masked representation of the face map.
Source code in machwave/models/grain/fmm/base.py
get_normalized_spacing()
¶
get_outer_diameter_mask()
abstractmethod
¶
get_regression_map()
¶
Return the distance map for grain regression.
Uses the fast marching method (scikit-fmm) on the masked face. Each value is the distance from the initial face along the cross-section. With no burning surface (end burner), returns a static map set to the axial burnout web, so the grain regresses along its length, not a cell.
Source code in machwave/models/grain/fmm/base.py
get_web_thickness()
¶
Return the maximum web thickness of the grain [m].
Derived from the distance map as the largest normalized distance, converted back into real units.
Source code in machwave/models/grain/fmm/base.py
normalize(value)
¶
Convert a dimensional value to a fraction of the outer radius.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int | float
|
Dimensional value (e.g., length) to normalize [m]. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Value expressed as a fraction of the outer radius. |
Source code in machwave/models/grain/fmm/base.py
validate()
¶
Validate the internal geometry of the grain.
Raises:
| Type | Description |
|---|---|
GrainGeometryError
|
If the grid resolution is below the valid threshold. |
Source code in machwave/models/grain/fmm/base.py
FMMGrainSegment2D
¶
Bases: FMMGrainSegment, GrainSegment2D, ABC
Fast Marching Method (FMM) implementation for 2D grain segment.
Source code in machwave/models/grain/fmm/_2d.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 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 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 | |
get_burn_area(web_distance)
¶
Return burn area [m^2] at a given web distance.
Source code in machwave/models/grain/fmm/_2d.py
get_burn_area_interpolator()
¶
Return a cached interpolator for burn area [m^2] vs normalized web.
Source code in machwave/models/grain/fmm/_2d.py
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 | |
get_center_of_gravity(web_distance)
¶
Return the center of gravity of a 2D FMM grain segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_distance
|
float
|
Web distance traveled [m]. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
Center of gravity as |
Source code in machwave/models/grain/fmm/_2d.py
get_contours(web_distance)
¶
Return contour arrays for the given web distance.
Each contour is typically an (N, 2) array of (row, col) points.
Source code in machwave/models/grain/fmm/_2d.py
get_coordinate_grids()
¶
Return the coordinate grids (map_x, map_y).
Each array has shape (grid_resolution, grid_resolution) and ranges from -1 to 1.
Source code in machwave/models/grain/fmm/_2d.py
get_core_area(web_distance)
¶
Return the core (internal) area [m^2] at the given web distance.
Computed as perimeter * length (2D approximation).
Source code in machwave/models/grain/fmm/_2d.py
get_core_perimeter(web_distance)
¶
Return the perimeter of the open core at the given web distance.
Source code in machwave/models/grain/fmm/_2d.py
get_face_area(web_distance)
¶
Return the face area at the given web distance.
get_face_area_interpolator()
¶
Return an interpolator mapping normalized web distance to face area [m^2].
Source code in machwave/models/grain/fmm/_2d.py
get_moment_of_inertia(ideal_density, web_distance=0.0)
¶
Calculate the moment of inertia tensor at the segment's its center of gravity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_distance
|
float
|
Web distance traveled [m]. |
0.0
|
ideal_density
|
float
|
Propellant ideal density [kg/m^3]. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
A 3x3 inertia tensor [kg-m^2]. |
Source code in machwave/models/grain/fmm/_2d.py
get_outer_diameter_mask()
¶
Return a boolean mask indicating which points lie outside the unit circle.
Source code in machwave/models/grain/fmm/_2d.py
get_port_area(web_distance)
¶
Return the open cross-sectional port area [m^2].
FMMGrainSegment3D
¶
Bases: FMMGrainSegment, GrainSegment3D, ABC
Fast Marching Method (FMM) implementation for 3D grain segment.
Source code in machwave/models/grain/fmm/_3d.py
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 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 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 | |
get_burn_area_interpolator()
¶
Return a cached interpolator for burn area [m^2] vs web distance [m].
Source code in machwave/models/grain/fmm/_3d.py
get_center_of_gravity(web_distance)
¶
Return the center of gravity of a 3D FMM grain segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_distance
|
float
|
Web distance traveled [m]. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
Center of gravity [z, x, y] in meters from the port of the segment. |
Raises:
| Type | Description |
|---|---|
GrainGeometryError
|
If web distance exceeds the web thickness, or if no active material is found. |
Source code in machwave/models/grain/fmm/_3d.py
get_moment_of_inertia(ideal_density, web_distance=0.0)
¶
Calculate the moment of inertia tensor at the segment's its center of gravity.
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]. |
Raises:
| Type | Description |
|---|---|
GrainGeometryError
|
If web distance exceeds web thickness or if no active material is found. |
Source code in machwave/models/grain/fmm/_3d.py
get_port_area(web_distance, z=0.0)
¶
Calculates the port area at a given web distance and axial height z.
This method extracts a single 2D slice from the 3D face map by converting the physical height z into an integer index, and then computes the port area for that slice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_distance
|
float
|
The distance traveled into the grain web. |
required |
z
|
float
|
Axial position along the grain [m], measured from the aft (nozzle) end. Defaults to nozzle end. |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
A float representing the port area at the specified z slice, in m^2. |
Source code in machwave/models/grain/fmm/_3d.py
FMMSTLGrainSegment
¶
Bases: FMMGrainSegment3D, ABC
FMM grain segment loaded from an STL mesh.
Source code in machwave/models/grain/fmm/stl.py
__init__(file_path, outer_diameter, length, inhibited_surfaces=None, grid_resolution=grain_fmm.DEFAULT_GRID_RESOLUTION)
¶
Initialize an STL-backed FMM grain segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to a watertight STL mesh of the grain. |
required |
outer_diameter
|
float
|
Outer diameter [m]. |
required |
length
|
float
|
Segment length [m]. |
required |
inhibited_surfaces
|
InhibitedSurfaces | None
|
Surfaces inhibited from burning. |
None
|
grid_resolution
|
int
|
Grid points per axis of the cross-section. |
DEFAULT_GRID_RESOLUTION
|
Source code in machwave/models/grain/fmm/stl.py
generate_initial_face_map()
¶
Generate the initial face map by voxelizing an STL mesh.
The trimesh voxel grid does not line up with the FMM grid, so it is
resampled onto the canonical (normalized_length, grid_resolution, grid_resolution)
shape the rest of the 3D machinery expects.
Source code in machwave/models/grain/fmm/stl.py
get_grid_spacing()
¶
validate()
¶
Validate STL grain segment geometry.