Configuration
The configuration layer maps a TOML (or YAML) file onto a tree of validated Pydantic models. StellarConfig is the root; each section of the config file maps to one of its sub-models.
Model hierarchy
StellarConfig
├── model → ModelConfig
├── chemistry → ChemistryConfig
├── grid → GridConfig
├── parameters → ParameterConfig
└── plot → PlotConfig
StellarConfig
StellarConfig
pydantic-model
Bases: BaseModel
Top-level configuration for stellar evolution
Fields:
-
model(ModelConfig) -
chemistry(ChemistryConfig) -
grid(GridConfig) -
parameters(ParameterConfig) -
plot(PlotConfig) -
output_dir(Optional[str | Path])
Validators:
-
validate_all
Source code in src/keppy/models.py
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 | |
lane_emden
cached
property
The Lane-Emden grid for this config, built once on first access.
Pure function of model.mass, chemistry.mu and the grid
overrides, so it is (re)built lazily after override()/reload rather
than eagerly during validation. massunit is excluded from the grid
kwargs (it is a post-grid scaling applied when emitting cards).
override
Return a new, fully re-validated config with section fields changed.
Intended for a "load a template, then tweak it" workflow::
cfg = load_config("template.toml")
cfg = cfg.override(
model={"mass": 5.0, "metallicity": 0.001},
chemistry={"preset": "sollo09"},
)
Each keyword names a config section (model, chemistry,
grid, parameters, plot) and maps to a dict of field
overrides that are shallow-merged over the existing values. Scalar
top-level fields (e.g. output_dir) may be passed directly.
The whole validation pipeline re-runs on the merged data, so the Lane-Emden grid is rebuilt and the composition re-scaled. The original config is left untouched; a new instance is returned.
Notes
presetandcustomare mutually exclusive: supplying one clears the other.- Changing
preset/custom/nameresetsburngen(unless you override it explicitly) so it is regenerated for the new composition.
Source code in src/keppy/models.py
to_toml
Serialise this config back to TOML, round-tripping load_config.
Only input-level fields are emitted (e.g. mass, preset,
scale_to_Z, initial_Y, parameter overrides). Derived values --
the resolved composition, the computed plot parameters, the Lane-Emden
grid -- are not written; they are reproduced when the file is reloaded.
Parameters
path: If given, the TOML is also written to this path.
Returns
str The TOML document text.
Source code in src/keppy/models.py
ModelConfig
ModelConfig
pydantic-model
Bases: BaseModel
Basic (higher) star configuration.
Example: ``` [model] mass: 4 metallicity: 0.014 rotation: 0.9 force_hstat: true
Fields:
-
mass(float) -
metallicity(float) -
rotation(float) -
rotation_version(int) -
force_hstat(bool) -
u(float)
Validators:
-
validate_mass→mass
Source code in src/keppy/models.py
rotation
pydantic-field
Rotation rate parameter. >1e6: we use value directly. 0 < val < 1e6: scale with max rotation. val<0: use Z=0 fits.
rotation_version
pydantic-field
Algorithm to determine spin. 1: Heger 1998, 2: Woosley & Heger 2012
force_hstat
pydantic-field
Whether to force the initial configuration into hydrostatic equilibrium. Can lead to noise.
ChemistryConfig
ChemistryConfig
pydantic-model
Bases: BaseModel
Chemistry (network and materials) config
Example:
Fields:
-
name(Literal['solcomp', 'zero', 'mycomp']) -
preset(Optional[str]) -
custom(Optional[dict[str, float]]) -
scale_to_Z(bool) -
initial_Y(Optional[float]) -
num(Literal[1]) -
isenet(bool) -
coprocess(bool) -
use_burn(bool) -
burngen(Optional[str]) -
adaptive(bool) -
network_z_max(int)
Validators:
Source code in src/keppy/models.py
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 | |
preset
pydantic-field
Name of preset composition (exclusive with custom). Requires $KEPLER_DATA to be set.
custom
pydantic-field
Custom ion abundances (exclusive with preset)
scale_to_Z
pydantic-field
Whether to scale the composition to the given metallicity. Setting with a preset will scale all mass fractions to this metallicity
initial_Y
pydantic-field
Optional target initial helium mass fraction Y. When set, the composition is scaled to this Y by drawing from (or adding to) hydrogen while preserving metals, instead of using the raw preset value. Independent of and applied after scale_to_Z.
coprocess
pydantic-field
Whether to enable BURN coprocessing (mapburn only). Default OFF because use_burn is generally on.
burngen
pydantic-field
BURN generator filepath. Automatically set to name of preset if preset is used.
network_z_max
pydantic-field
Maximum mass number of elements to be allowed in the network.
validate_preset
pydantic-validator
Check that preset name is valid
Source code in src/keppy/models.py
validate_burngen
pydantic-validator
Auto-set burngen name if not explicitly specified.
Source code in src/keppy/models.py
validate_exclusive
pydantic-validator
Ensure either preset or custom is specified, not both or neither
Source code in src/keppy/models.py
init_composition
pydantic-validator
Initializes composition object
Source code in src/keppy/models.py
GridConfig
GridConfig
pydantic-model
Bases: BaseModel
Grid setup overrides to Lane Emden solver
Fields:
-
massunit(float) -
cutoff(Optional[float]) -
ngrid(Optional[int]) -
rho_c(Optional[float]) -
n(Optional[float]) -
Omega(Optional[float])
Source code in src/keppy/models.py
ParameterConfig
ParameterConfig
pydantic-model
Bases: BaseModel
Controls for Kepler's adjustable runtime parameters.
Example
[parameters]
dtmax: 3e12 # 10^5yrs in seconds
iwinsize: 10240750 # XXXX by YYYY
tnmin: 1e4 # minimum temperature for which rezoning is considered
dnmin: 1e-4 # minimum density for which rezoning is considered
Config:
extra:allow
Fields:
-
parameters(dict[str, float | int | str])
Source code in src/keppy/models.py
model_post_init
Capture all parameters and verify
Source code in src/keppy/models.py
get_output_parameters
PlotConfig
PlotConfig
pydantic-model
Bases: BaseModel
Mongo plotting configuration.
Example: ``` [plot] window_width: 1024 window_height: 720 plot1: plot2:
Fields:
-
window_width(int) -
window_height(int) -
interval(int) -
xaxis(int) -
plot1(PlotMode) -
plot2(Optional[PlotMode]) -
plot3(Optional[PlotMode]) -
plot4(Optional[PlotMode]) -
isotopes(Optional[list[str]])
Source code in src/keppy/models.py
get_integer_mapping
Map a plot mode (int code or named alias) to its integer code string.