ndiffusion.make_medium_map¶
- ndiffusion.make_medium_map(regions, total_cells=None, edges=None)[source]¶
Build a flat medium_map list from a compact region specification.
Four calling conventions are supported:
List of
(mat_id, n_cells)tuples:make_medium_map([(0, 61), (1, 39)])
List of int cell counts (mat IDs are assigned 0, 1, 2, …):
make_medium_map([61, 39])
List of widths (float or int) with total_cells - cells are distributed proportionally; the last region absorbs any rounding remainder:
make_medium_map([R1, R2], total_cells=100)
List of physical lengths in cm with edges - each cell is assigned by its center position relative to cumulative region boundaries. Also accepts
(mat_id, length_cm)tuples for explicit material IDs:make_medium_map([R1, R2], edges=edges) make_medium_map([(0, R1), (1, R2)], edges=edges)
- Parameters:
regions (list) – Region sizes as int cell counts, float physical lengths (cm), or
(mat_id, size)tuples.total_cells (int or None) – Total number of spatial cells. Required for convention 3.
edges (array-like or None) – Cell-edge positions (cm), length
n_cells + 1. Required for convention 4. When provided, cell assignment is determined by each cell’s center position, giving exact results on non-uniform meshes.
- Returns:
Flat medium_map of length equal to the total cell count.
- Return type:
- Raises:
ValueError – If a float region size is passed without total_cells or edges.