import numpy as np
from matplotlib import pyplot as plt
from PhotochemPy import PhotochemPy


# Load input files
pc = PhotochemPy('../../input/templates/Archean+haze/species.dat', \
                 '../../input/templates/Archean+haze/reactions.rx', \
                 '../../input/templates/Archean+haze/planet.dat', \
                 '../../input/templates/Archean+haze/input_photchem.dat', \
                 '../../input/templates/Archean+haze/atmosphere.txt', \
                 '../../input/templates/Archean+haze/Sun_2.7Ga.txt')

# integrate to photochemical equilibirum
pc.integrate(nsteps=1000)

# plot
input = pc.in_dict()
out = pc.out_dict()
plt.rcParams.update({'font.size': 15})
fig,ax = plt.subplots(1,1,figsize=[9,5])
species = ['H2','CO','CH4','SO2','H2S']
colors = ['C0','C1','C2','C3','C4']
for i,sp in enumerate(species):
    ax.plot(out[sp],out['alt'],colors[i]+'-',label=sp)
    ax.plot(input[sp],input['alt'],colors[i]+'--')
ax.set_xscale('log')
ax.legend()
ax.set_ylabel('Altitude (km)')
ax.set_xlabel('Mixing Ratio')
ax.set_title('Solid lines = PhotochemPy\nDashed lines = old Atmos Photochem')
Exemple #2
0
import numpy as np
from PhotochemPy import PhotochemPy
import time
import os

template = '../../input/templates/Hadean+HCN'
star = 'Sun_4.0Ga.txt'

pc = PhotochemPy(template+'/species.dat', \
                 template+'/reactions.rx', \
                 template+'/planet.dat', \
                 template+'/input_photchem.dat', \
                 template+'/atmosphere.txt', \
                 template+'/'+star)

# integrate to photochemical equilibirum
start = time.time()
pc.integrate(nsteps=50)
end = time.time()

t = end - start

threads = os.getenv('OMP_NUM_THREADS')

fil = open('times.txt', 'a')
fil.write(threads + ' ' + '%.4e' % t + '\n')
fil.close()
Exemple #3
0
import numpy as np
from matplotlib import pyplot as plt
from PhotochemPy import PhotochemPy

# Load input files
pc = PhotochemPy('../input/templates/Archean+haze/species.dat', \
                 '../input/templates/Archean+haze/reactions.rx', \
                 '../input/templates/Archean+haze/settings.yaml', \
                 '../input/templates/Archean+haze/atmosphere.txt', \
                 '../input/templates/Archean+haze/Sun_2.7Ga.txt')

# integrate to photochemical equilibirum
pc.integrate(nsteps=1000)

# Plot
plot = True
if plot:
    out = pc.out_dict()
    plt.rcParams.update({'font.size': 15})
    fig, ax = plt.subplots(1, 1, figsize=[9, 5])
    specs = ['CH4', 'CO', 'O2', 'H2']
    for sp in specs:
        ax.plot(out[sp], out['alt'], label=sp)
    ax.set_xscale('log')
    ax.legend()
    ax.set_ylabel('Altitude (km)')
    ax.set_xlabel('Mixing Ratio')
    plt.show()
Exemple #4
0
import numpy as np
from PhotochemPy import PhotochemPy
import time
import os

template = '../../input/templates/Hadean+HCN'
star = 'Sun_4.0Ga.txt'

pc = PhotochemPy(template+'/species.dat', \
                 template+'/reactions.rx', \
                 template+'/settings.yaml', \
                 template+'/atmosphere.txt', \
                 template+'/'+star)

# integrate to photochemical equilibirum
start = time.time()
pc.integrate(nsteps=50)
end = time.time()

t = end-start

threads = os.getenv('OMP_NUM_THREADS')

fil = open('times.txt','a')
fil.write(threads+' '+'%.4e'%t+'\n')
fil.close()
import numpy as np
from matplotlib import pyplot as plt
from PhotochemPy import PhotochemPy

# Load input files
pc = PhotochemPy('../../input/templates/Hadean+HCN/species.dat', \
                 '../../input/templates/Hadean+HCN/reactions.rx', \
                 '../../input/templates/Hadean+HCN/planet.dat', \
                 '../../input/templates/Hadean+HCN/input_photchem.dat', \
                 '../../input/templates/Hadean+HCN/atmosphere.txt', \
                 '../../input/templates/Hadean+HCN/Sun_4.0Ga.txt')

# integrate to photochemical equilibirum
pc.integrate(nsteps=1000)

# plot
input = pc.in_dict()
out = pc.out_dict()
plt.rcParams.update({'font.size': 15})
fig, ax = plt.subplots(1, 1, figsize=[9, 5])
species = ['H2', 'CO', 'CH4', 'SO2', 'H2S']
colors = ['C0', 'C1', 'C2', 'C3', 'C4']
for i, sp in enumerate(species):
    ax.plot(out[sp], out['alt'], colors[i] + '-', label=sp)
    ax.plot(input[sp], input['alt'], colors[i] + '--')
ax.set_xscale('log')
ax.legend()
ax.set_ylabel('Altitude (km)')
ax.set_xlabel('Mixing Ratio')
ax.set_title('Solid lines = PhotochemPy\nDashed lines = old Atmos Photochem')
plt.savefig("Hadean+HCN_validation.pdf", bbox_inches='tight')
import numpy as np
from PhotochemPy import PhotochemPy

###############################
##### ModernEarth #####
###############################
template = '../input/templates/ModernEarth'
star = 'Sun_now.txt'
pc = PhotochemPy(template+'/species.dat', \
                 template+'/reactions.rx', \
                 template+'/settings.yaml', \
                 template+'/atmosphere.txt', \
                 template+'/'+star)
pc.integrate(method='Backward_Euler')
pc.integrate(method='CVODE_BDF')

###############################
##### Archean2Proterozoic #####
###############################
template = '../input/templates/Archean2Proterozoic'
star = 'Sun_2.7Ga.txt'
pc = PhotochemPy(template+'/species.dat', \
                 template+'/reactions.rx', \
                 template+'/settings.yaml', \
                 template+'/atmosphere.txt', \
                 template+'/'+star)
pc.integrate(method='Backward_Euler')
pc.integrate(method='CVODE_BDF')

########################
##### Archean+Haze #####
Exemple #7
0
from PhotochemPy import PhotochemPy

pc = PhotochemPy('input/templates/Archean+haze/species.dat', \
              'input/templates/Archean+haze/reactions.rx', \
              'input/templates/Archean+haze/PLANET.dat', \
              'input/templates/Archean+haze/input_photchem.dat', \
              'input/templates/Archean+haze/atmosphere.txt', \
              'input/templates/Archean+haze/Sun_2.7Ga.txt')





converged = pc.integrate()
import numpy as np
from matplotlib import pyplot as plt
from PhotochemPy import PhotochemPy

# Load input files
pc = PhotochemPy('../../input/templates/ModernEarth/species.dat', \
                 '../../input/templates/ModernEarth/reactions.rx', \
                 '../../input/templates/ModernEarth/planet.dat', \
                 '../../input/templates/ModernEarth/input_photchem.dat', \
                 '../../input/templates/ModernEarth/atmosphere.txt', \
                 '../../input/templates/ModernEarth/Sun_now.txt')

# integrate to photochemical equilibirum
pc.integrate(nsteps=1000)

# plot
input = pc.in_dict()
out = pc.out_dict()
plt.rcParams.update({'font.size': 15})
fig, ax = plt.subplots(1, 1, figsize=[9, 5])
species = ['H2', 'CO', 'CH4', 'SO2', 'H2S', 'O3']
colors = ['C0', 'C1', 'C2', 'C3', 'C4', 'C5']
for i, sp in enumerate(species):
    ax.plot(out[sp], out['alt'], colors[i] + '-', label=sp)
    ax.plot(input[sp], input['alt'], colors[i] + '--')
ax.set_xscale('log')
ax.legend()
ax.set_ylabel('Altitude (km)')
ax.set_xlabel('Mixing Ratio')
ax.set_title('Solid lines = PhotochemPy\nDashed lines = old Atmos Photochem')
plt.savefig("ModernEarth_validation.pdf", bbox_inches='tight')
Exemple #9
0
import numpy as np
from pathos.multiprocessing import ProcessingPool as Pool
from PhotochemPy import PhotochemPy
import sys
import time
import os

pc = PhotochemPy(None, None, None, None, None)

method = 'Backward_Euler'
rtol = 1e-3
atol = 1e-27


def wrapper(inpt):
    move_ind, init_ind, solutions, aersol_props, params, param_space, nsteps = inpt
    pc.vars.usol_init = solutions[init_ind]
    pc.vars.rpar_init = aersol_props[init_ind][0]
    pc.vars.wfall_init = aersol_props[init_ind][1]
    pc.vars.aersol_init = aersol_props[init_ind][2]
    for i, key in enumerate(params.keys()):
        pc.set_mr(key, 10**param_space[i][move_ind])
    converged = pc.integrate(method=method,
                             nsteps=nsteps,
                             rtol=rtol,
                             atol=atol)
    # converged = True
    if not converged:
        return [converged, np.nan, np.nan, np.nan, np.nan]
    if converged:
        aersol_props_converged = [pc.wrk.rpar, pc.wrk.wfall, pc.wrk.aersol]
from PhotochemPy import PhotochemPy

#######################
##### ModernEarth #####
#######################
template = '../input/templates/ModernEarth'
star = 'Sun_now.txt'
pc = PhotochemPy(template+'/species.dat', \
                 template+'/reactions.rx', \
                 template+'/settings.yaml', \
                 template+'/atmosphere.txt', \
                 template+'/'+star)
pc.integrate(method='Backward_Euler')
pc.integrate(method='CVODE_BDF')

###############################
##### Archean2Proterozoic #####
###############################
template = '../input/templates/Archean2Proterozoic'
star = 'Sun_2.7Ga.txt'
pc = PhotochemPy(template+'/species.dat', \
                 template+'/reactions.rx', \
                 template+'/settings.yaml', \
                 template+'/atmosphere.txt', \
                 template+'/'+star)
pc.integrate(method='Backward_Euler')
pc.integrate(method='CVODE_BDF')

########################
##### Archean+Haze #####
########################
Exemple #11
0
from PhotochemPy import PhotochemPy

template = 'Archean2Proterozoic'
sun = 'Sun_2.7Ga.txt'

pc = PhotochemPy('input/templates/'+template+'/species.dat', \
                 'input/templates/'+template+'/reactions.rx', \
                 'input/templates/'+template+'/settings.yaml', \
                 'input/templates/'+template+'/atmosphere.txt', \
                 'input/templates/'+template+'/'+sun)

converged = pc.integrate(method='Backward_Euler')
converged = pc.integrate(method='CVODE_BDF')