CI-script and readme updated

This commit is contained in:
Nicolas Kruse 2025-06-02 16:26:59 +02:00
parent b6ed6c0bf7
commit 6d9c029e89
2 changed files with 71 additions and 6 deletions

View File

@ -15,30 +15,29 @@ jobs:
python-version: ["3.10", 3.11, 3.12, 3.13] python-version: ["3.10", 3.11, 3.12, 3.13]
steps: steps:
# Step 1: Check out the code from the repository
- name: Check out code - name: Check out code
uses: actions/checkout@v4 uses: actions/checkout@v4
# Step 2: Set up Python
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
# Step 3: Install dependencies
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install -e .[dev] python -m pip install -e .[dev]
# Step 4: Lint with flake8 - name: Prepare data and compile thermo database
run: |
python thermo_data/combine_data.py thermo_data/combined_data.yaml thermo_data/nasa9*.yaml thermo_data/nasa9*.xml
python thermo_data/compile_to_bin.py thermo_data/combined_data.yaml src/gaspype/data/therm_data.bin
- name: Lint code with flake8 - name: Lint code with flake8
run: flake8 run: flake8
# Step 5: Check types with mypy
- name: Type checking with mypy - name: Type checking with mypy
run: mypy run: mypy
# Step 6: Run tests
- name: Run tests with pytest - name: Run tests with pytest
run: pytest run: pytest

66
thermo_data/README.md Normal file
View File

@ -0,0 +1,66 @@
# Data preparation
Gaspype uses a binary format for thermodynamic data to minimize memory usage and startup time.
## Combine and prepare data
To prepare the data from YAML and XML sources:
``` bash
python combine_data.py combined_data.yaml nasa9*.yaml nasa9*.xml
```
General Syntax is: ```python combine_data.py OUTPUT_YAML_FILE INPUT_FILE_PATTERN_1 INPUT_FILE_PATTERN_2 ...```
Example output format for a single file entry:
``` yaml
- name: HCl
composition: {Cl: 1, H: 1}
thermo:
model: NASA9
temperature-ranges: [200.0, 1000.0, 6000.0]
data:
- [20625.88287, -309.3368855, 5.27541885, -0.00482887422, 6.1957946e-06, -3.040023782e-09, 4.91679003e-13, -10677.82299, -7.309305408]
- [915774.951, -2770.550211, 5.97353979, -0.000362981006, 4.73552919e-08, 2.810262054e-12, -6.65610422e-16, 5674.95805, -16.42825822]
note: Gurvich,1989 pt1 p186 pt2 p93. [tpis89]
```
Compile ```combined_data.yaml``` to the binary gaspype format:
``` bash
python compile_to_bin.py combined_data.yaml ../src/gaspype/data/therm_data.bin
```
General syntax is: ```python compile_to_bin.py YAML_INPUT_FILE BINARY_OUTPUT_FILE```
The binary format is structured like this, it uses little-endian and IEEE 754 floats:
```
[4 Byte magic number: 'gapy']
[8 Byte: 32 Bit integer for length of all species names (NAMES_LENGTH)]
[NAMES_LENGTH Bytes: ASCII encoded string with all species names separated by space]
[Index
[For each species
[4 Bytes: 32 Bit uint with offset of species data in file]
[1 Byte: 8 Bit uint with number of elements]
[1 Byte: 8 Bit uint for polygon length, value = 9]
[1 Byte: 8 Bit uint for number of temperature supporting points (NUM_TEMPS)]
[1 Byte: 8 Bit uint for length of reference string (REF_LEN)]
]
]
[Data
[For each species
[For each species element
[2 Byte: element name in ASCII, 0x20 padded]
[1 Byte: 8 Bit uint for number of atoms]
]
[For Range(NUM_TEMPS)
[4 Byte: 32 Bit float with temperature supporting point]
]
[For Range(NUM_TEMPS - 1)
[36 Bytes: 9 x 32 Bit float with NASA9-Polynomial for a temperature interval]
]
[REF_LEN Bytes: ASCII string of the data reference]
]
]
```
## Notes
- Original source of the data compilation: https://ntrs.nasa.gov/citations/20020085330
- nasa9_*.yaml files are exported from https://cearun.grc.nasa.gov/ThermoBuild/ and
converted with ck2yaml (https://cantera.org/stable/userguide/thermobuild.html)
- nasa9polynomials.xml is from: https://github.com/guillemborrell/thermopy/tree/master/databases