Skip to content

Commit eb2a429

Browse files
Merge pull request #4 from LIBRA-project/pint
Pint support
2 parents 545c82c + 93b9913 commit eb2a429

18 files changed

Lines changed: 1021 additions & 743 deletions

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
on: [pull_request, push]
3+
4+
jobs:
5+
run-tests:
6+
name: run-tests
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v5
12+
13+
- name: Set up Conda
14+
uses: conda-incubator/setup-miniconda@v3
15+
with:
16+
activate-environment: libra_sparging
17+
environment-file: environment.yml
18+
miniforge-version: latest
19+
use-mamba: false
20+
channels: conda-forge
21+
22+
- name: Install package
23+
shell: bash -l {0}
24+
run: |
25+
python -m pip install -e .[dev]
26+
27+
- name: Run tests
28+
shell: bash -l {0}
29+
run: |
30+
python -m pytest test
31+
32+
# - name: Upload to codecov
33+
# uses: codecov/codecov-action@v4
34+
# with:
35+
# token: ${{ secrets.CODECOV_TOKEN }}
36+
# files: ./coverage.xml

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,6 @@ __marimo__/
210210
*.yaml
211211
*.csv
212212
mwe.py
213+
*.json
214+
*.ipynb
215+
*.code-workspace

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ conda env create -f environment.yml
1515
conda activate libra_sparging
1616
```
1717

18+
```
19+
python -m pip install -e .[dev]
20+
```
21+
22+
## How to run tests
1823

1924
```
20-
python model.py
25+
python -m pytest test
2126
```

environment.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ name: libra_sparging
22
channels:
33
- conda-forge
44
dependencies:
5+
- python>=3.12
56
- fenics-dolfinx
67
- matplotlib
78
- pyvista
89
- pyyaml
910
- numpy
1011
- scipy
11-
- pandas
12+
- pandas
13+
- pint

helpers.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

main.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,38 @@
1-
import model
1+
import src.sparging.model as model
22
import sys
33
import os
4-
from animation import create_animation
5-
from helpers import get_input
4+
from sparging.animation import create_animation
5+
from sparging.helpers import get_input
6+
67

78
ANIMATE = True
89
SHOW_ACTIVITY = True
9-
INPUT_PATH = os.path.join(os.getcwd(), sys.argv[1])
10-
OUTPUT_PATH = os.path.join(
11-
os.getcwd(), sys.argv[1] + "_out" if len(sys.argv) < 3 else sys.argv[2]
10+
YAML_INPUT_PATH = os.path.join(os.getcwd(), sys.argv[1])
11+
OUTPUT_FOLDER = os.path.join(
12+
os.getcwd(), sys.argv[1].split(".")[0].replace("_input", "")
1213
)
1314

14-
1515
if __name__ == "__main__":
16-
params = get_input(INPUT_PATH + ".yaml")
17-
properties = model.compute_properties(params)
16+
params = get_input(YAML_INPUT_PATH)
17+
sim_input = model.SimulationInput(params)
1818

19-
# breakpoint()
20-
merged_dict = {}
21-
merged_dict.update(params)
22-
merged_dict.update(properties)
23-
24-
t_sparging_hr = [0, 1e20] # time interval when sparger is ON
19+
# TODO integrate to input file
20+
t_sparging_hr = [24, 1e20] # time interval when sparger is ON
2521
t_irr_hr = [0, 96] # time interval when irradiation is ON
26-
t_final = 10 * model.days_to_seconds
22+
t_final = 6 * model.days_to_seconds
2723

2824
results = model.solve(
29-
merged_dict,
25+
sim_input,
3026
t_final=t_final,
3127
t_irr=[t * model.hours_to_seconds for t in t_irr_hr],
3228
t_sparging=[t * model.hours_to_seconds for t in t_sparging_hr],
3329
)
34-
# save_to_csv(c_T_volume)
3530

36-
results.to_yaml(OUTPUT_PATH + ".yaml", inputs=params, properties=properties)
37-
results.to_json(OUTPUT_PATH + ".json", inputs=params, properties=properties)
38-
results.profiles_to_csv(OUTPUT_PATH + "_profiles")
39-
# breakpoint()
31+
os.makedirs(OUTPUT_FOLDER, exist_ok=True)
32+
results.to_yaml(os.path.join(OUTPUT_FOLDER, "restart.yaml"))
33+
results.to_json(os.path.join(OUTPUT_FOLDER, "output.json"))
34+
# results.profiles_to_csv(os.path.join(OUTPUT_FOLDER, "profiles"))
35+
4036
if ANIMATE is True:
4137
# Create interactive animation
4238
try:

0 commit comments

Comments
 (0)