Skip to content

Commit

Permalink
Python box model (#147)
Browse files Browse the repository at this point in the history
* setting up a cmake structure for c++

* python box model iniital classes

* added method for generating species config

* added relative tolerance to spec config

* added method to generate reaction config

* added generateConfig documentation and todo solve function

* added todo readfromjson function

* added params to reaction

* updated Reaction and getReactionConfig to handle A B D E and Ea paramaters

* can mostly parse json file from UI

* implemented skeleton logic for solver

* extracted concentrations and reaction rates from evolving conditions

* added initial reaction rates, need to verify

* made conversion functions to shorten code

* tested parsing with example that had every option

* added other reaction types and refactored some code

* fixed bug in species list

* fixed bug in reaction list

* generateReactionConfig accounts for the different types of reactions

* added funciton to create micm solver based on config

* added funciton to create micm solver based on config

* working towards box model test

* adds function to read config json and tests basic reaction

* fixed solve to inc by seconds

* convert time steps to seconds

* updated solve with new time units

* Changed readFromJson to readFromUIJosn

* convert_pressure converts to Pa now

* outputs results to file and creates file for initial test

* reads species name from config

* sets up test config and get analytical concentrations

* aserts concentrations

* fixed comment typo

* fixed output outputted based on output time step

* changed time in output to output step time

* added hr to time conversion:

* removed print stat

* removed print statement

* config files generatable

* initial reaction rates added to generate config

* reads species from json from camp_data

* box model pr

* handle cases without pressure and temperature in evolving conditions for UI parsing

* able to recreate test config in UI, parse it, and use in python_test_1

* reads reaction list from config json

* restructured functions

* fixed missing reaction list param in from_config_JSON

* can generate evolving_conditions.csv for config

* implemented species and rate ordering in solve

* moved where ordered arrays are computed

* updated headers to match ordered array

* fixed evolving conditions not setting attributes correctly

* fixed unit issue with pressure for setting up evolving conditions

* added reaction type prefixes in order_reaction_ratesz

* changed evolving conditions to update in a while loop in case chem time step is greater than time between evolving conditions

* updated python test 3

* creates test for chapman in python_test_3.py

* renamed tests to be more descriptive

* added test file for wall-loss

* include base values for reactions, change C back to Ea

* add species not present in initial conditions for order_species_concentration

* removed unused files

* removed unused files

* created .whl for music_box package

* make sure time in evolving conditions is float

* check reaction names correctly for evolving conditions config, ensure floats for rate constants

* added function to read from UI json string

* removing fortran things, using musica python module, creating installation suitable for pypi

* converting tests to pytest

* correcting setup python?

* adding a space

* strategy

* installing music_box in CI

* newer checkout

* pypi publish

---------

Co-authored-by: Kyle Shores <[email protected]>
Co-authored-by: Evan De la Garza <[email protected]>
Co-authored-by: Evan De la Garza <[email protected]>
  • Loading branch information
4 people authored Apr 9, 2024
1 parent 4db8a9d commit d77109b
Show file tree
Hide file tree
Showing 201 changed files with 10,989 additions and 4,530 deletions.
18 changes: 0 additions & 18 deletions .dockerignore

This file was deleted.

61 changes: 22 additions & 39 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,35 @@
name: Create and publish a Docker image
name: Publish a pypi package

on:
push:
branches: ['release']
tags:
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
release:
types: [created]

jobs:
build-and-push-image:
publish_to_pypi:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container repository
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
uses: actions/checkout@v4

- name: Build and push Docker image
uses: docker/build-push-action@v5
- name: Set up Python
uses: actions/setup-python@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build and publish package
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
pipx run build
pipx run twine check dist/*
python -m twine upload --repository pypi dist/*
35 changes: 27 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
name: build

on: [push, pull_request]
on: [push, workflow_dispatch]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ubuntu-latest

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v4
with:
submodules: recursive
- name: build Docker image
run: docker build -t music-box-test . --build-arg TAG_ID=chapman
- name: run tests in container
run: docker run --name test-container -t music-box-test bash -c 'cd /music-box/build; make test'

- uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'

- run: pip install -r requirements.txt

- name: Install this package
run: pip install -e .

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
cd tests
pytest
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ CMakeFiles/
doc/html/
doc/latex/
data/
__pycache__/
*.pyc
dist
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

35 changes: 0 additions & 35 deletions CMakeLists.txt

This file was deleted.

84 changes: 0 additions & 84 deletions Dockerfile

This file was deleted.

Loading

0 comments on commit d77109b

Please sign in to comment.