simjsr 0.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- simjsr/__init__.py +7 -0
- simjsr/convert.py +19 -0
- simjsr/run.py +58 -0
- simjsr-0.0.0.dist-info/METADATA +7 -0
- simjsr-0.0.0.dist-info/RECORD +6 -0
- simjsr-0.0.0.dist-info/WHEEL +4 -0
simjsr/__init__.py
ADDED
simjsr/convert.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Convert mechanism files to Cantera YAML format."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from cantera.ck2yaml import Parser
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def from_chemkin(
|
|
9
|
+
mech_file: str | Path,
|
|
10
|
+
thermo_file: str | Path | None = None,
|
|
11
|
+
out_file: str | Path | None = None,
|
|
12
|
+
) -> str:
|
|
13
|
+
"""Convert Chemkin mechanism and thermo files to Cantera YAML format."""
|
|
14
|
+
out_file = str(out_file or Path(mech_file).with_suffix(".yaml"))
|
|
15
|
+
|
|
16
|
+
Parser.convert_mech(
|
|
17
|
+
input_file=mech_file, thermo_file=thermo_file, out_name=out_file
|
|
18
|
+
)
|
|
19
|
+
return str(out_file)
|
simjsr/run.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""Reactors."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
import cantera as ct
|
|
6
|
+
from cantera import Reactor, Solution
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class Config:
|
|
11
|
+
"""Configuration for a jet-stirred reactor simulation.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
temperature: Temperature (K)
|
|
15
|
+
pressure: Pressure (atm)
|
|
16
|
+
residence_time: Residence time (s)
|
|
17
|
+
volume: Volume (cm^3)
|
|
18
|
+
concentrations: Starting concentrations
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
temperature: float
|
|
22
|
+
pressure: float
|
|
23
|
+
residence_time: float
|
|
24
|
+
concentrations: dict[str, float]
|
|
25
|
+
volume: float = 1.0
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def single(model: Solution, config: Config) -> Reactor:
|
|
29
|
+
"""Run a single jet-stirred reactor simulation.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
model: Chemical kinetics model
|
|
33
|
+
config: Configuration for the simulation
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
Reactor at steady state
|
|
37
|
+
"""
|
|
38
|
+
# Use concentrations from the previous iteration to speed up convergence
|
|
39
|
+
model.TPX = config.temperature, config.pressure * ct.one_atm, config.concentrations
|
|
40
|
+
|
|
41
|
+
# Set up JSR: inlet -> flow control -> reactor -> pressure control -> exhaust
|
|
42
|
+
volume_m3 = config.volume * (1e-2) ** 3
|
|
43
|
+
reactor = ct.IdealGasReactor(model, energy="off", volume=volume_m3, clone=True)
|
|
44
|
+
exhaust = ct.Reservoir(model, clone=True)
|
|
45
|
+
inlet = ct.Reservoir(model, clone=True)
|
|
46
|
+
ct.PressureController(
|
|
47
|
+
upstream=reactor,
|
|
48
|
+
downstream=exhaust,
|
|
49
|
+
K=1e-3,
|
|
50
|
+
primary=ct.MassFlowController(
|
|
51
|
+
upstream=inlet,
|
|
52
|
+
downstream=reactor,
|
|
53
|
+
mdot=reactor.mass / config.residence_time,
|
|
54
|
+
),
|
|
55
|
+
)
|
|
56
|
+
reactor_net = ct.ReactorNet([reactor])
|
|
57
|
+
reactor_net.advance_to_steady_state(max_steps=100000)
|
|
58
|
+
return reactor
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
simjsr/__init__.py,sha256=mh5SUqcmX7nY4lEP8IBe3H1bgJydxeY6htAHQLkv0uA,95
|
|
2
|
+
simjsr/convert.py,sha256=LnbjrYd-X_vzMPVjJkUTvl9HfuE4P1IPFq1BkmpunFY,532
|
|
3
|
+
simjsr/run.py,sha256=Ay4sQ23bS8GfvxiTm5Dt7hekH0DXu5admrHil7elUWM,1661
|
|
4
|
+
simjsr-0.0.0.dist-info/WHEEL,sha256=wXwAVsgVaOZ_pwDFqQm5Rd6PID-Fc74nkLc8X8gHiDo,81
|
|
5
|
+
simjsr-0.0.0.dist-info/METADATA,sha256=QL_jwQudJc3UvJzPs9NRYSXI4Q8JFK-qyKA_FQI9VT8,178
|
|
6
|
+
simjsr-0.0.0.dist-info/RECORD,,
|