Skip to content

Commit 7b964a1

Browse files
Merge pull request #5 from LIBRA-project/ci
CI
2 parents 24f8630 + 64938ba commit 7b964a1

13 files changed

Lines changed: 291 additions & 121 deletions

File tree

.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

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
```

main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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
66

77

88
ANIMATE = True

pyproject.toml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "libra_sparging"
7+
version = "0.1.0"
8+
description = "A finite element model for sparging processes"
9+
readme = "README.md"
10+
requires-python = ">=3.10"
11+
license = {text = "LICENSE"}
12+
authors = [
13+
{name = "Author Name", email = "author@example.com"},
14+
]
15+
keywords = ["FEM", "sparging", "dolfinx"]
16+
classifiers = [
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
"License :: OSI Approved :: MIT License",
22+
"Development Status :: 3 - Alpha",
23+
]
24+
25+
dependencies = [
26+
"fenics-dolfinx",
27+
"matplotlib",
28+
"pyvista",
29+
"pyyaml",
30+
"numpy",
31+
"scipy",
32+
"pandas",
33+
"pint",
34+
]
35+
36+
[project.optional-dependencies]
37+
dev = [
38+
"pytest>=7.0",
39+
"pytest-cov",
40+
]
41+
42+
[project.urls]
43+
Repository = "https://github.com/libra_project/libra_sparging"
44+
45+
[tool.setuptools]
46+
packages = ["sparging"]
47+
package-dir = {"" = "src"}
48+
49+
[tool.pytest.ini_options]
50+
testpaths = ["test"]
51+
python_files = "test_*.py"
52+
addopts = "-v"
53+
54+
[tool.setuptools.package-data]
55+
sparging = ["*.yaml", "*.yml"]

src/sparging/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
libra_sparging: A finite element model for sparging processes using FEniCSx/DOLFINX.
3+
"""
4+
5+
from .config import ureg, const_R, const_g, VERBOSE
6+
from .model import SimulationResults
7+
from .animation import ConcentrationAnimator
8+
from .helpers import *
9+
from .correlations import *
10+
11+
__all__ = [
12+
"SimulationInput",
13+
"SimulationResults",
14+
"ConcentrationAnimator",
15+
"ureg",
16+
"const_R",
17+
"const_g",
18+
"VERBOSE",
19+
]

animation.py renamed to src/sparging/animation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import matplotlib.pyplot as plt
33
from matplotlib import gridspec
44
from matplotlib.widgets import Slider, Button
5-
from model import SimulationResults
5+
from sparging.model import SimulationResults
66

77
molar_mass_T2 = 3.016 * 2 # g/mol T2
88
specific_activity_tritium = 3.57e14 # Bq/g
File renamed without changes.
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from __future__ import annotations
2-
from config import *
2+
from sparging.config import ureg, const_R, const_g, VERBOSE
3+
from typing import TYPE_CHECKING
4+
5+
if TYPE_CHECKING:
6+
from sparging.model import SimulationInput
37
import numpy as np
48
import scipy.constants as const
59
import warnings
@@ -77,7 +81,7 @@ def get_d_b(flow_g_vol: float, nozzle_diameter: float, nb_nozzle: int) -> float:
7781
)
7882

7983

80-
def get_Re(input: SimulationInput) -> float:
84+
def get_Re(input: "SimulationInput") -> float:
8185
try:
8286
u = input.u_g0
8387
Re_old = input.Re
@@ -97,7 +101,7 @@ def get_Re(input: SimulationInput) -> float:
97101
return Re.to("dimensionless")
98102

99103

100-
def get_u_g0(input: SimulationInput) -> float: # TODO move inside class ?
104+
def get_u_g0(input: "SimulationInput") -> float: # TODO move inside class ?
101105
"""
102106
bubble initial velocity [m/s], correlation for terminal velocity from Clift 1978
103107
"""
@@ -121,7 +125,7 @@ def get_u_g0(input: SimulationInput) -> float: # TODO move inside class ?
121125
return u_g0
122126

123127

124-
def get_eps_g(input: SimulationInput) -> float:
128+
def get_eps_g(input: "SimulationInput") -> float:
125129
"""computes gas void fraction from ideal gas law and Young-Laplace pressure in the bubbles (neglecting hydrostatic pressure variation)"""
126130
eps_g = (
127131
const_R
@@ -142,7 +146,7 @@ def get_eps_g(input: SimulationInput) -> float:
142146
def get_h_higbie(D_l: float, u_g: float, d_b: float) -> float:
143147
"""mass transfer coefficient [m/s] for tritium in liquid FLiBe using Higbie penetration model"""
144148
h_l = (
145-
(D_l * u_g) / (ufl.pi * d_b)
149+
(D_l * u_g) / (const.pi * d_b)
146150
) ** 0.5 # mass transport coefficient Higbie penetration model
147151
return h_l
148152

helpers.py renamed to src/sparging/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import yaml
22
import numpy as np
3-
from config import *
3+
from sparging.config import *
44

55

66
# TODO this could be a dataclass?
77
# see issue #3
8-
def get_input(yaml_input_path):
8+
def get_input(yaml_input_path) -> dict:
99
with open(yaml_input_path, "r") as file:
1010
params = yaml.safe_load(file)
1111
if "input" in params:

0 commit comments

Comments
 (0)