Skip to content

Commit

Permalink
moving to new photolysis cross sections
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholaswogan committed Sep 26, 2024
1 parent 0ca9109 commit afc1246
Show file tree
Hide file tree
Showing 21 changed files with 615 additions and 456 deletions.
20 changes: 1 addition & 19 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,8 @@
.ipynb_checkpoints
__pycache__
*.so
*.o
Photo.run
*.mod
data
build
*.a
a.out
test.run
*.dSYM
.vscode


src/Stringifor
build_dir
src/dependencies/lib
src/dependencies/include
src/dependencies/examples
src/dependencies/cmake
src/dependencies/modules

julia_wrap_photochem.ipynb
random.ipynb


4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION "3.14")
cmake_policy(SET CMP0148 OLD)
project(Photochem LANGUAGES Fortran C VERSION "0.5.6")

project(Photochem LANGUAGES Fortran C VERSION "0.6.0")
set(PHOTOCHEM_CLIMA_DATA_VERSION "0.2.0")

include(FortranCInterface)
FortranCInterface_VERIFY()
Expand Down
4 changes: 2 additions & 2 deletions photochem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
os.environ['OMP_NUM_THREADS'] = '1'

from ._photochem import EvoAtmosphere, Atmosphere, PhotoException, __version__
from photochem_clima_data import DATA_DIR

zahnle_earth = os.path.dirname(os.path.realpath(__file__))+ \
'/data/reaction_mechanisms/zahnle_earth.yaml'
zahnle_earth = DATA_DIR+'/reaction_mechanisms/zahnle_earth.yaml'
2 changes: 1 addition & 1 deletion photochem/cython/Atmosphere.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cdef class Atmosphere:
self._init_called = True

if data_dir == None:
data_dir_ = os.path.dirname(os.path.realpath(__file__))+'/data'
data_dir_ = photochem_clima_data.DATA_DIR
else:
data_dir_ = data_dir

Expand Down
2 changes: 1 addition & 1 deletion photochem/cython/EvoAtmosphere.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ cdef class EvoAtmosphere:
self._init_called = True

if data_dir == None:
data_dir_ = os.path.dirname(os.path.realpath(__file__))+'/data'
data_dir_ = photochem_clima_data.DATA_DIR
else:
data_dir_ = data_dir

Expand Down
1 change: 1 addition & 0 deletions photochem/cython/_photochem.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from cpython.object cimport PyObject_GenericSetAttr
import numpy as np
import ctypes as ct
import os
import photochem_clima_data

DEF S_STR_LEN = 20;
DEF M_STR_LEN = 100;
Expand Down
4 changes: 2 additions & 2 deletions photochem/equilibrate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ._equilibrate import ChemEquiAnalysis, EquilibrateException
from ._equilibrate import __version__
from .utils._format import FormatReactions_main, yaml, Loader, MyDumper
import os
from photochem_clima_data import DATA_DIR

def generate_zahnle_earth_thermo(outfile='zahnle_earth_thermo.yaml'):
"""Generates a thermodynamic file for equilibrium solving that includes
Expand All @@ -13,7 +13,7 @@ def generate_zahnle_earth_thermo(outfile='zahnle_earth_thermo.yaml'):
Name of the output file, by default 'zahnle_earth_thermo.yaml'
"""

rx_folder = os.path.dirname(os.path.realpath(__file__))+'/data/reaction_mechanisms/'
rx_folder = DATA_DIR+'/reaction_mechanisms/'

with open(rx_folder+'zahnle_earth.yaml','r') as f:
dat = yaml.load(f, Loader=Loader)
Expand Down
8 changes: 4 additions & 4 deletions src/dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

CPMAddPackage(
NAME futils
VERSION 0.1.11
VERSION 0.1.14
GITHUB_REPOSITORY "Nicholaswogan/futils"
GIT_TAG "v0.1.11"
GIT_TAG "v0.1.14"
EXCLUDE_FROM_ALL ON
)

Expand Down Expand Up @@ -49,15 +49,15 @@ CPMAddPackage(

CPMAddPackage(
NAME clima
VERSION 0.4.6
VERSION 0.5.0
OPTIONS
"BUILD_EXECUTABLE OFF"
"BUILD_WITH_OPENMP ${BUILD_WITH_OPENMP}"
"SKBUILD ${SKBUILD}"
"BUILD_PYTHON_CLIMA ${BUILD_PYTHON_PHOTOCHEM}"
"PYTHON_CLIMA_DESTINATION photochem"
GITHUB_REPOSITORY "Nicholaswogan/clima"
GIT_TAG "v0.4.6"
GIT_TAG "v0.5.0"
EXCLUDE_FROM_ALL OFF
)

Expand Down
2 changes: 1 addition & 1 deletion src/evoatmosphere/photochem_evoatmosphere_rhs_climate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function equilibrium_climate_equation(self, d, err) result(F_in)
if (allocated(err)) return

! do raditative transfer
call self%rad%radiate(d%T_surf, d%T, d%P, d%densities, self%var%dz, d%pdensities, d%radii, err)
call self%rad%radiate(d%T_surf, d%T, d%P, d%densities, self%var%dz, d%pdensities, d%radii, err=err)
if (allocated(err)) return

! compute the energy going into the atmosphere
Expand Down
19 changes: 3 additions & 16 deletions src/input/photochem_input_after_read.f90
Original file line number Diff line number Diff line change
Expand Up @@ -221,25 +221,12 @@ module subroutine interp2xsdata(dat, var, err)

character(:), allocatable, intent(out) :: err

integer :: i, j, k
real(dp) :: val(1), T_temp(1)
integer :: i, k

! No temperature dependence, so we just copy over
do k = 1, dat%nw
do i = 1,dat%kj
if (dat%xs_data(i)%n_temps > 1) then
do j = 1,var%nz
T_temp(1) = var%temperature(j)

call interp(1, dat%xs_data(i)%n_temps, T_temp, dat%xs_data(i)%xs_temps, &
log10(abs(dat%xs_data(i)%xs(:,k))+smaller_real), val)

var%xs_x_qy(j,i,k) = 10.0_dp**val(1)
enddo
else
do j = 1,var%nz
var%xs_x_qy(j,i,k) = abs(dat%xs_data(i)%xs(1,k))+smaller_real
enddo
endif
var%xs_x_qy(:,i,k) = abs(dat%photolysis_xs(i,k))+smaller_real
enddo
enddo

Expand Down
Loading

0 comments on commit afc1246

Please sign in to comment.