Configuration for the SPECTRUM software suite, enabling C++-native, compile-time full codebase parameterization.
Project description
Config-SPECTRUM
⚠️ DISCLAIMER: This project is currently under active pre-alpha development.
Config-SPECTRUM is a configuration assistant for SPECTRUM, facilitating C++-native compile-time configuration and parameter management.
Quick Start 🥚
The script is accessed via a command line entry point config-spectrum.
Compile-time constants (parameters) may be set at the command line.
The tool will also resolve a set of contingent defaults.
For example:
config-spectrum . -b Dipole -t Lorentz -d None
This will generate a config file with a default name (config.hh) in the current directory (.).
This file will inject the default values for a Lorentz particle trajectory in a Dipole background,
with no Diffusion model applied. The path argument is usually (.), but it can be modified.
To change the name of the file, use the -o flag. As in:
config-spectrum ./my_path -b Dipole -t Lorentz -d None -o my_first_test
Now the generated file is in a local subdirectory, and is named my_first_test.config.hh.
Config files are C++ header files. By convention, suffixed with config.hh instead of the
usual .hh for a C++ header file.
For more information, use the help flag config-spectrum -h or config-spectrum --help.
Guide for Developers 💾
Except for the frontend in main.py, the implementation is in the
submodule _impl, and should not need to be frequently modified.
The files config_parameters.py and config_physical.py in config-spectrum,
and the file common/compiletime_lists.hh are
the "source of truth" for all of SPECTRUM.
-
compiletime_lists.hh. This file and included header files determine fundamental structure is exposed at compile-time. In particular, it determines what Backgrounds, Trajectories, and Diffusion classes are recognized byconfig-spectrum. The enum classes there may be edited when the source code is changed, to reflect changes to the SPECTRUM object model. For example, a new Background implemented inbackground_silly.hh/background_silly.cccan be registered incompiletime_lists.hhby addingSillyto the list of backgrounds. -
config_parameters.py. Contains a specification of all (hyper)parameters for the SPECTRUM test particle trajectory solver. It provides type information, possible ranges, a docstring, and a globally-defined fallthrough default value. Modifications of this file should be made in tandem with review and possible modifications ofcompiletime_lists.hh. -
config_physical.py. Contains
This leads to the following general heuristic for developers:
- Modifications of
compiletime_lists.hhshould be made in tandem with review and possible modifications ofconfig_parameters.py, and vice versa. - Modifications of
config_physical.pycan be freely made.
Whenever changes to either of the .py files are made,
the .config.hh files that appear in /src/ need to be updated.
This process has been automated. You only need to run:
config-spectrum . --mkdefaults
To proceed cautiously, it is recommended to run this first in testing mode:
config-spectrum . --mkdefaults --test
Setting default values in config_physical.py
The dict of dicts in conig_physical.py defines a "reasonable" default
for the particular trajectory/background/diffusion type.
This file is the unique location in the code where
these default values are defined.
There is no inheritance mechanism, so each class repeats parameters defined in base classes. In some cases, this is indicated by commented-out dividers.
The dicts are used on an "as-needed" basis, so the definitions here
are not brittle. config-spectrum will automatically check that
every case has a default value.
The formatting of values of key-value pairs
is performed by the value method in _impl/configdata.py.
Each parameter (say, a floating point parameter) has its type resolved
via the dictionaries in config.parameters.py. If this type is float,
then the value is set as a float. If this type is string (for example,
a file name), then this value is set as a string. Default values of strings can
be set using an ordinary double-quote "..." string.
If the type is type (a C++ type), then the type is set here
inside of a double-quote string. Brace-initializer expressions can be
used for default values.
The dict of dicts physical_defaults has the following structure:
physical_defaults = {
'Background': ..., # dict of backgrounds
'Trajectory': ..., # dict of trajectories
'Diffusion': ..., # dict of diffusions
}
Notes
- It is not possible to do what
config-spectrumdoes using compile-time language features of C++20, the version used by SPECTRUM. Therefore a custom-built solution is needed, and this is one possibility (among many) which takes advantage of the well-developed Python ecosystem. Experience withconfig-spectrum
Last Updated
Lucius Schoenbaum May 31, 2026
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file config_spectrum-0.2.0.tar.gz.
File metadata
- Download URL: config_spectrum-0.2.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
143192829bce25d57ebf6ecbeb66f992d9bcf381efb2ed4674cbbcd0c573032f
|
|
| MD5 |
1aa154ae19e7957e41d2dc37acd03974
|
|
| BLAKE2b-256 |
99f158c57fd726bb864604a256b8bf8a07ed609c209651b4ee895469418d610a
|
File details
Details for the file config_spectrum-0.2.0-py3-none-any.whl.
File metadata
- Download URL: config_spectrum-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fff82073c7b25cb7cb6c6dfa7cd83ae6bfc8cdfd1ffde7479e452c619890322
|
|
| MD5 |
8517cb0448528af3b8a841daadc6f426
|
|
| BLAKE2b-256 |
c1be6964d7579b61fec43ec69b806f23a8fb65263972339b2ec4ea78dcb6d112
|