Skip to content

Commit

Permalink
Merge pull request #77 from uclchem/develop
Browse files Browse the repository at this point in the history
We release UCLCHEM 3.4.0 with some additions to both user experience, technical improvements and new features:

    The biggest addition is a new mode where you can run UCLCHEM solely in memory, not requiring you to save and load the csv files that we relied on for long. A tutorial on how to do this, can be found in notebooks/2a_modelling_objects_on_disk.py
    We implement a new postprocessing mode, similar to what the NEATH paper does (https://fpriestley.github.io/neath/). This also allows for running much more flexible models.
    We now check whether the user specified branching ratios correctly, this means that if the total for reactions is larger than 1.0, we divide by the total. We also do it for three way split reactions, since often people write 0.33, resulting in 1% not being accounted for.
    We move to the RATE22 database as the default one, some species are renamed (https://umistdatabase.uk/)
    The tutorial notebooks have been moved to the notebooks directory and were revised a bit.
    radfield is now always a column in the output csv files, removing the need for two extra lines at the top of each uclchem csv file.
    A small chemistry network is added, this runs quickly and can be used for toy problems and code testing.

Small changes:

    The standard uv yield is now 0.03
    The magnetic field is now a parameter that can be passed for shock models
    The analysis scripts work once again in the gas phase, the grains still have some issues (see: 

Incorrect production and destruction in analysis.py #37)
We improved test coverage
We now have precommit configured to improve code quality
  • Loading branch information
GijsVermarien authored Oct 14, 2024
2 parents a74fc84 + 347b4f5 commit ddbe587
Show file tree
Hide file tree
Showing 105 changed files with 52,753 additions and 9,593 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test notebooks

on:
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11" # Specify the Python version you need

- name: Install gfortran
run: |
sudo apt-get -y update
sudo apt-get -y install gfortran
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest nbmake pytest-xdist jupyter
- name: Install package in editable mode
run: |
pip install -e .
- name: Test notebooks
run: |
pytest -n auto --nbmake --nbmake-timeout=2400 --nbmake-kernel=python3 notebooks
12 changes: 8 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run pytest
name: Test install and interface

on:
pull_request:
Expand Down Expand Up @@ -27,13 +27,17 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install pytest pytest-xdist
- name: Install package in editable mode
run: |
pip install -e .
- name: Run pytest
- name: Run pytest install test
run: |
pytest tests/ # Specify the path to your 'tests' directory
pytest tests/test_install.py
- name: Run pytest install test
run: |
pytest -n auto tests/{test_ode_conservation.py,test_run_stages.py}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ test
build
dist
*/__pycache__
.venv
conda*
.conda
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.9
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout

8 changes: 6 additions & 2 deletions Makerates/comparenetworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@

print("\nReading reactions")
reactions1, drops = read_reaction_file(reactionsFile1, speciesList, "UCL")
print(f"I found {len(reactions1)} reactions in the file {reactionsFile1}, I dropped {len(drops)} reactions.")
print(
f"I found {len(reactions1)} reactions in the file {reactionsFile1}, I dropped {len(drops)} reactions."
)
# If you need to see which reactions are dropped:
# print("\n".join([str(drop) for drop in drops]))
reactions2, drops = read_reaction_file(reactionsFile2, speciesList, "UCL")
print(f"I found {len(reactions2)} reactions in the file {reactionsFile2}, I dropped {len(drops)} reactions.")
print(
f"I found {len(reactions2)} reactions in the file {reactionsFile2}, I dropped {len(drops)} reactions."
)


print("\nReactions from file 1 not in file 2")
Expand Down
3 changes: 3 additions & 0 deletions Makerates/data/databases/dropped_from_umist22.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file contains all the reactions we dropped from UMIST2, and the reasons why we dropped them!
# Dropped because it conflicts with the default H2 Photodiss mechanism in UCLCHEM.
8268:PH:H2:PHOTON:H:H:::1:5.70e-11:0.00:4.18:10:41000:C:C:"10.1051/0004-6361/201628742":"Heays, et al. A&A, 602, A105 (2017)":
File renamed without changes.
8,767 changes: 8,767 additions & 0 deletions Makerates/data/databases/umist22.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ H2,PHOTON,,H,H,,,1,1,0,,,
#H2CO,CRP,,#HCO,#H,,,1.73E-14,0,0,,
#H2CO,CRP,,#CO,H2,,,1.73E-14,0,0,,
#CH3OH,CRP,,#CH2OH,#H,,,6.5E-15,0,0,,
#CH3OH,CRP,,#H3CO,#H,,,6.5E-15,0,0,,
#CH3OH,CRP,,#H2COH,#H,,,6.5E-15,0,0,,
#CH3OH,CRP,,#CH3,#OH,,,1.95E-14,0,0,,
#H2S,CRP,,#HS,H,,,3E-16,0,0,,
#HCOOH,CRP,,#HCOO,H,,,3E-16,0,0,,
Expand Down Expand Up @@ -66,10 +66,10 @@ H2,PHOTON,,H,H,,,1,1,0,,,
#H,#HCO,LH,#H2CO,,,,0.5,0,0,,,
#H,#HCO,LH,#CO,#H2,,,0.5,0,0,,,
#H,#H2CO,LH,#CH2OH,,,,0.33,0,5400,,,
#H,#H2CO,LH,#H3CO,,,,0.33,0,2200,,,
#H,#H2CO,LH,#H2COH,,,,0.33,0,2200,,,
#H,#H2CO,LH,#HCO,#H2,,,0.33,0,1740,,,
#H,#CH2OH,LH,#CH3OH,,,,1,0,0,,,
#H,#H3CO,LH,#CH3OH,,,,1,0,0,,,
#H,#H2COH,LH,#CH3OH,,,,1,0,0,,,
#SI,#H,LH,#SIH,,,,1.0,0,0,,,
#SIH,#H,LH,#SIH2,,,,1.0,0,0,,,
#SIH2,#H,LH,#SIH3,,,,1.0,0,0,,,
Expand Down Expand Up @@ -118,7 +118,7 @@ HOCN,H,,HNCO,H,,,1.0E-10,0,2000,,,
HONC,H,,HCNO,H,,,1.0E-10,0,2000,,,
!
#NH,#CO,LH,#HNCO,,,,1,0,4200,,,
#H3CO,#HNCO,LH,#CH3OH,#OCN,,,0,0,1200,,,
#H2COH,#HNCO,LH,#CH3OH,#OCN,,,0,0,1200,,,
#CH3,#HNCO,LH,#CH4,#OCN,,,0,0,1200,,,
#NH,#HNCO,LH,#NH2,#OCN,,,0,0,1200,,,
#NH2,#HNCO,LH,#NH3,#OCN,,,0,0,1200,,,
Expand All @@ -145,13 +145,13 @@ HONC,H,,HCNO,H,,,1.0E-10,0,2000,,,
#NH2,#H2CO,LH,#NH2CHO,H,,,0.5,0,0,,,
#NH2,#H2CO,LH,#NH3,#HCO,,,0.5,0,0,,,
H,#H2NCO,LH,#HNCO,H2,,,1.0,0,0,,,! NOBLE ET AL. 2015
NH2,H2CO,,NH2CHO,H,,,77.9E-16,-2.56,25,,,! SKOUTERIS ET AL. 2017
! NH2,H2CO,,NH2CHO,H,,,77.9E-16,-2.56,25,,,! SKOUTERIS ET AL. 2017
!
! (GARROD 2006)
!
#HCO,#H3CO,LH,#HCOOCH3,,,,1.0,0,0,,,
#HCO,#H2COH,LH,#HCOOCH3,,,,1.0,0,0,,,
#HCO,#CH2OH,LH,#HCOOCH3,,,,1.0,0,0,,,
#CH3,#H3CO,LH,#CH3OCH3,,,,1.0,0,0,,,
#CH3,#H2COH,LH,#CH3OCH3,,,,1.0,0,0,,,
#HCO,#OH,LH,#HCOOH,,,,1.0,0,0,,,
#CH3,#C2H3,LH,#CH3CHCH2,,,,1.0,0,0,,,
#CH3,#HCO,LH,#CH3CHO,,,,1.0,0,0,,,
Expand All @@ -165,7 +165,7 @@ NH2,H2CO,,NH2CHO,H,,,77.9E-16,-2.56,25,,,! SKOUTERIS ET AL. 2017
C3H5+,FREEZE,,#CH3CCH,H,,,1,1,0,,,
CH3OH2+,FREEZE,,#CH3OH,H,,,1,1,0,,,
C2N2+,FREEZE,,#NCCN,,,,1,0,0,,,
HSIS+,FREEZE,,#SIS,H,,,1,1,0,,,
SISH+,FREEZE,,#SIS,H,,,1,1,0,,,
SIH5+,FREEZE,,#SIH4,H,,,1,1,0,,,
H2CL+,FREEZE,,#HCL,H,,,1,1,0,,,
!COOCH4+,FREEZE,,#HCOOCH3,,,,1,1,0,,,
Expand All @@ -174,15 +174,15 @@ HCO2+,FREEZE,,#CO2,H,,,1,1,0,,,
CH5+,FREEZE,,#CH4,H,,,1,1,0,,,
H2NO+,FREEZE,,#HNO,H,,,1,1,0,,,
H3S+,FREEZE,,#H2S,H,,,1,1,0,,,
H3CS+,FREEZE,,#H2CS,H,,,1,1,0,,,
H2CSH+,FREEZE,,#H2CS,H,,,1,1,0,,,
HSO+,FREEZE,,#SO,H,,,1,1,0,,,
HOCS+,FREEZE,,#OCS,H,,,1,1,0,,,
OCSH+,FREEZE,,#OCS,H,,,1,1,0,,,
NH4+,FREEZE,,#NH3,H,,,1,1,0,,,
HCNH+,FREEZE,,#HCN,H,,,1,1,0,,,
N2H+,FREEZE,,#N2,H,,,1,1,0,,,
HNS+,FREEZE,,#NS,H,,,1,1,0,,,
C3+,FREEZE,,#C2,C,,,1,1,0,,,
HSO2+,FREEZE,,#SO2,H,,,1,1,0,,,
HOSO+,FREEZE,,#SO2,H,,,1,1,0,,,
SIOH+,FREEZE,,#HSIO,,,,1,1,0,,,
#HSIO,DESORB,,SIOH+,,,,1,1,0,,,
HOC+,FREEZE,,#HCO,,,,1.0,1,0,,,
Expand Down
Loading

0 comments on commit ddbe587

Please sign in to comment.