73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168 | def init_agni_atmos(vulcan_cfg: Config, atm: AtmData, var: Variables):
log.debug('New AGNI atmosphere')
atmos = jl.AGNI.atmosphere.Atmos_t()
succ = True
# Stellar spectrum path (scaled to stellar surface)
sflux_path = vulcan_cfg.sflux_file
# Calculate instellation by scaling spectrum to TOA
sflux_data = np.loadtxt(sflux_path).T # erg/s/cm^2/nm
sflux_integ = trapezoid(sflux_data[1], x=sflux_data[0]) # erg/s/cm^2
sflux_integ *= (vulcan_cfg.r_star * r_sun) ** 2 / (vulcan_cfg.orbit_radius * au) ** 2
sflux_integ *= 0.001 # W/m^2
# Spectral file path
try_spfile = os.path.join(vulcan_cfg.output_dir, 'runtime.sf')
if os.path.exists(try_spfile):
# exists => don't modify it
input_sf = try_spfile
input_star = ''
elif vulcan_cfg.spectral_file == 'greygas':
# grey gas solution
input_sf = vulcan_cfg.spectral_file
input_star = sflux_path
else:
# doesn't exist => AGNI will copy it + modify as required
input_sf = os.path.join(paths.AGNI_DIR, vulcan_cfg.spectral_file)
input_star = sflux_path
# composition set initially well-mixed
vol_dict = {}
for g in gas_list:
if '_' in g:
continue
vol_dict[g] = np.median(var.ymix[:, gas_list.index(g)])
# set condensation
condensates = []
# Boundary pressures
p_surf = atm.pico[0] * 1e-6 # convert to bar
p_top = atm.pico[-1] * 1e-6 # convert to bar
# FC working directory for AGNI
fastchem_work = mkdtemp()
# Setup struct
succ = jl.AGNI.atmosphere.setup_b(
atmos,
paths.AGNI_DIR,
vulcan_cfg.output_dir,
input_sf,
sflux_integ,
vulcan_cfg.f_diurnal,
0.0,
vulcan_cfg.sl_angle * 180.0 / np.pi, # convert radians to degrees
vulcan_cfg.Tsurf_guess,
vulcan_cfg.gs * 0.01, # convert to SI, m/s^2
vulcan_cfg.Rp * 0.01, # convert to SI, m
vulcan_cfg.agni_nlev,
p_surf,
p_top,
vol_dict,
'',
flag_rayleigh=vulcan_cfg.use_rayleigh,
flag_cloud=False,
overlap_method='ee',
albedo_s=vulcan_cfg.surf_albedo,
surface_material='greybody',
condensates=condensates,
use_all_gases=False,
fastchem_work=fastchem_work,
real_gas=False,
skin_d=0.01,
skin_k=2.0,
tmp_magma=vulcan_cfg.Tsurf_guess,
tmp_floor=50.0,
)
if not succ:
raise RuntimeError('Could not initialise AGNI atmos object')
# Allocate arrays
succ = jl.AGNI.atmosphere.allocate_b(atmos, input_star)
if not succ:
raise RuntimeError('Could not allocate AGNI atmos object')
# Set temperature profile to initial guess
tmp_top = 500.0
tmp_top = min(tmp_top, vulcan_cfg.Tsurf_guess)
log.debug('Initialised log-linear (top = %.2f K)' % tmp_top)
jl.AGNI.setpt.loglinear_b(atmos, -0.5 * vulcan_cfg.Tsurf_guess)
jl.AGNI.setpt.stratosphere_b(atmos, tmp_top)
return atmos
|