ic
RL4CRN.utils.ic
Initial-condition (IC) helpers for CRN simulations.
This module provides a lightweight IC container that stores one or more sets of
initial concentrations keyed by species names, and can project/reorder those
initial conditions to match the species ordering of a given CRN.
Typical use:
- Define ICs in a human-friendly order (by name).
- Call
get_ic(crn)to obtain NumPy vectors aligned withcrn.species_labels, ready to be passed to simulation / transient-response routines.
IC
Container for named initial conditions for CRN species.
The object stores one or multiple initial-condition vectors defined over a
fixed list of species names. When used with a CRN instance, it can reorder
each vector to match the CRN's internal species_labels ordering.
| PARAMETER | DESCRIPTION |
|---|---|
names
|
Species names corresponding to the entries in each IC vector.
TYPE:
|
values
|
One or more IC vectors. Each vector must have
length
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
names |
Species names used as the IC coordinate system.
TYPE:
|
values |
Stored IC vectors aligned with
TYPE:
|
name_to_index |
Map from species name to its index in
TYPE:
|
index_to_name |
Alias for
TYPE:
|
__init__(names, values)
Initialize an IC container.
| PARAMETER | DESCRIPTION |
|---|---|
names
|
Species names.
TYPE:
|
values
|
One or more initial condition vectors aligned with
TYPE:
|
get_ic(crn)
Reorder stored IC vectors to match a CRN's species ordering.
The CRN is expected to expose crn.species_labels (list[str]). For each
stored IC vector, this method produces a NumPy array whose entries are
ordered exactly as crn.species_labels.
| PARAMETER | DESCRIPTION |
|---|---|
crn
|
CRN-like object with attribute
|
| RETURNS | DESCRIPTION |
|---|---|
|
list[np.ndarray]: List of IC arrays, one per entry in |
|
|
each of shape |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the CRN contains a species label that is not present in |
__str__()
Return a readable string representation of the IC container.