Specs¶
specs
¶
op_system.specs.
RHS specification models and normalization utilities for op_system.
Design goals¶
- Domain-agnostic core: no imports from flepimop2 or other adapters.
- YAML-friendly RHS specifications that compile into a normalized representation consumable by op_engine (and other numerical backends).
- Minimal v1 implementation that demonstrates the idea without blocking future multiphysics extensions (IMEX operators, PDE terms, sources, etc.).
Current supported RHS kinds¶
1) kind: "expr" - User provides explicit expressions for d(state)/dt per state variable.
2) kind: "transitions" - User provides diagram-style transitions and per-capita hazard expressions. - Each transition contributes a flow: flow = hazard_expr * from_state and updates derivatives: d(from)/dt -= flow d(to)/dt += flow
Future-facing (not implemented, but reserved)¶
- kind: "multiphysics" or additional top-level keys such as:
- sources: explicit additive per-state terms (births/imports/forcing)
- operators: implicit operator specs/factories for IMEX (diffusion, transport)
- couplings: structured couplings across axes (space/age/traits) and fields The normalization outputs include placeholders to carry these blocks forward, so adapters/backends can extend without changing the fundamental contract.
ConstraintRule
¶
Bases: NamedTuple
Validated constraint rule produced by _normalize_constraints.
NormalizedRhs(kind, state_names, equations, aliases, param_names, all_symbols, meta)
dataclass
¶
Normalized RHS representation suitable for compilation/execution.
normalize_expr_rhs(spec)
¶
Normalize an expression-based RHS specification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
Mapping[str, Any]
|
Raw RHS specification mapping. |
required |
Returns:
| Type | Description |
|---|---|
NormalizedRhs
|
Backend-facing normalized RHS representation. |
Source code in src/op_system/specs.py
2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 | |
normalize_rhs(spec)
¶
Normalize a RHS specification dict into a backend-facing representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
Mapping[str, Any] | None
|
Raw RHS specification mapping. |
required |
Returns:
| Type | Description |
|---|---|
NormalizedRhs
|
Backend-facing normalized RHS representation. |
Source code in src/op_system/specs.py
1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 | |
normalize_transitions_rhs(spec)
¶
Normalize a transition-based RHS specification (diagram/hazard semantics).
Returns:
| Type | Description |
|---|---|
NormalizedRhs
|
Backend-facing normalized RHS representation for transitions kind. |
Source code in src/op_system/specs.py
2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 | |