Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions chem_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
gstdev = 2.
n_tot = 566.e6 * rho_stp / rho_init
kappa = 0.61
rd_insol = 0.0
sol_frac = 1.0

# chem process toggling
chem_dsl = False
Expand Down Expand Up @@ -67,8 +67,7 @@
"CO2_a", "NH3_a", "HNO3_a"]}}'

# initial aerosol distribution
aerosol = '{"chem_aerosol": {"kappa": ' + str(kappa) + ', "rd_insol": ' + str(rd_insol) + ', "mean_r": [' + str(mean_r) + '], "gstdev": [' + str(gstdev) + '], "n_tot": [' + str(n_tot) + ']}}'

aerosol = '{"chem_aerosol": {"kappa": ' + str(kappa) + ', "sol_frac": ' + str(sol_frac) + ', "mean_r": [' + str(mean_r) + '], "gstdev": [' + str(gstdev) + '], "n_tot": [' + str(n_tot) + ']}}'
# saving parcel options as a dictionary
parcel_dict = {'dt': dt, 'z_max': z_max, 'outfreq': outfreq, 'w': w,\
'sstp_cond': sstp_cond, 'sstp_chem': sstp_chem,\
Expand Down
4 changes: 2 additions & 2 deletions long_test/test_ice_SD.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_ice_SD():
depo = True,
ice_nucl = True,
time_dep_ice_nucl = time_dep,
aerosol = '{"ammonium_sulfate": {"kappa": 0.61, "rd_insol": 0.5e-6, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [60.0e6]}}',
aerosol = '{"ammonium_sulfate": {"kappa": 0.61, "sol_frac": 0.1, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [60.0e6]}}',
outfreq = 4000,
out_bin = '{"liq": {"rght": 1, "moms": [0,3], "drwt": "wet", "nbin": 1, "lnli": "lin", "left": 5e-20}}',
outfile = outfile,
Expand All @@ -38,4 +38,4 @@ def test_ice_SD():
assert np.isclose(fnc.variables[variable][:][-1], fnc_ref.variables[variable][:][-1], rtol=1)
fnc.close()
fnc_ref.close()
subprocess.call(["rm", outfile])
subprocess.call(["rm", outfile])
4 changes: 2 additions & 2 deletions long_test/test_plot_ice_SD.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def plot_profiles(fnc, output_name):
plt.savefig(os.path.join("plots/outputs/", output_name))

def test_plot_ice_SD():
for (rd_insol, output_name) in [("0.5e-6", "ice_SD_plot_het.svg"), ("0", "ice_SD_plot_hom.svg")]:
for (sol_frac, output_name) in [("0.1", "ice_SD_plot_het.svg"), ("1.0", "ice_SD_plot_hom.svg")]:
outfile = "onesim_plot.nc"
parcel(dt=1.,w=1.,sd_conc=100,
z_max = 5000.0,
Expand All @@ -52,7 +52,7 @@ def test_plot_ice_SD():
depo = True,
ice_nucl=True,
time_dep_ice_nucl=True,
aerosol = f'{{"ammonium_sulfate": {{"kappa": 0.61, "rd_insol": {rd_insol}, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [60.0e6]}}}}',
aerosol = f'{{"ammonium_sulfate": {{"kappa": 0.61, "sol_frac": {sol_frac}, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [60.0e6]}}}}',
outfreq = 100,
out_bin= '{"liq": {"rght": 1, "moms": [0,3], "drwt": "wet", "nbin": 1, "lnli": "lin", "left": 5e-20}}',
outfile=outfile)
Expand Down
2 changes: 1 addition & 1 deletion long_test/test_plot_schemes_ice.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run_scheme(scheme, time_dep, outfile):
depo = True,
ice_nucl=True,
time_dep_ice_nucl=time_dep,
aerosol = f'{{"ammonium_sulfate": {{"kappa": 0.61, "rd_insol": 0.5e-6, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [60.0e6]}}}}',
aerosol = f'{{"ammonium_sulfate": {{"kappa": 0.61, "sol_frac": 0.1, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [60.0e6]}}}}',
outfreq = 100,
out_bin= '{"liq": {"rght": 1, "moms": [3], "drwt": "wet", "nbin": 1, "lnli": "lin", "left": 5e-20}}',
outfile=outfile)
Expand Down
2 changes: 1 addition & 1 deletion long_test/test_timestep.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def data(request):
parcel(dt=dt, outfreq = int(100/dt), outfile = outfile_nc,\
w = 1., T_0 = T_init, p_0 = p_init, r_0 = r_init, z_max = 200, \
sd_conc = 1000, \
aerosol = '{"ammonium_sulfate": {"kappa": 0.61, "rd_insol": 0.0, "mean_r": [5e-8], "gstdev": [1.5], "n_tot": [1e9]}}',
aerosol = '{"ammonium_sulfate": {"kappa": 0.61, "sol_frac": 1.0, "mean_r": [5e-8], "gstdev": [1.5], "n_tot": [1e9]}}',
out_bin = '{"radii": {"rght": 1, "moms": [0], "drwt": "wet", "nbin": 1, "lnli": "lin", "left": 1e-06}}'
)

Expand Down
2 changes: 1 addition & 1 deletion micro_lgrngn.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _micro_init(aerosol, opts, state):
lognormals = []
for i in range(len(dct["mean_r"])):
lognormals.append(lognormal(dct["mean_r"][i], dct["gstdev"][i], dct["n_tot"][i]))
dry_distros[(float(dct["kappa"]), float(dct["rd_insol"]))] = sum_of_lognormals(lognormals)
dry_distros[(float(dct["kappa"]), float(dct["sol_frac"]))] = sum_of_lognormals(lognormals)
opts_init.dry_distros = dry_distros

# better resolution for the SD tail
Expand Down
8 changes: 4 additions & 4 deletions parcel.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def parcel(dt = .1, z_max = 200., w = 1., T_0 = 300., p_0 = 101300.,
time_dep_ice_nucl = False,
depo = False,
sd_conc = 64,
aerosol = '{"ammonium_sulfate": {"kappa": 0.61, "rd_insol": 0.0, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [60.0e6]}}',
aerosol = '{"ammonium_sulfate": {"kappa": 0.61, "sol_frac": 1.0, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [60.0e6]}}',
out_bin = '{"radii": {"rght": 0.01, "moms": [0], "drwt": "wet", "nbin": 1, "lnli": "log", "left": 1e-15}}',
SO2_g = 0., O3_g = 0., H2O2_g = 0., CO2_g = 0., HNO3_g = 0., NH3_g = 0.,
chem_dsl = False, chem_dsc = False, chem_rct = False,
Expand Down Expand Up @@ -71,11 +71,11 @@ def parcel(dt = .1, z_max = 200., w = 1., T_0 = 300., p_0 = 101300.,

aerosol (Optional[json str]): dict of dicts defining aerosol distribution, e.g.:

{"ammonium_sulfate": {"kappa": 0.61, "rd_insol": 0.0, "mean_r": [0.02e-6, 0.07e-7], "gstdev": [1.4, 1.2], "n_tot": [120.0e6, 80.0e6]}
"gccn" : {"kappa": 1.28, "rd_insol": 0.0, "mean_r": [2e-6], "gstdev": [1.6], "n_tot": [1e2]}}
{"ammonium_sulfate": {"kappa": 0.61, "sol_frac": 1.0, "mean_r": [0.02e-6, 0.07e-7], "gstdev": [1.4, 1.2], "n_tot": [120.0e6, 80.0e6]}
"gccn" : {"kappa": 1.28, "sol_frac": 1.0, "mean_r": [2e-6], "gstdev": [1.6], "n_tot": [1e2]}}

where kappa - hygroscopicity parameter (see doi:10.5194/acp-7-1961-2007)
rd_insol - insoluble dry radius
sol_frac - soluble volume fraction (0-1)
mean_r - lognormal distribution mean soluble dry radius [m] (list if multimodal distribution)
Comment on lines 72 to 79
gstdev - lognormal distribution geometric standard deviation (list if multimodal distribution)
n_tot - lognormal distribution total concentration under standard
Expand Down
6 changes: 3 additions & 3 deletions parcel_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _arguments_checking(opts, spectra, aerosol, ice_switch):
for name, dct in aerosol.items():
# TODO: check if name is valid netCDF identifier
# (http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/CDM/Identifiers.html)
keys = ["kappa", "rd_insol", "mean_r", "n_tot", "gstdev"]
keys = ["kappa", "sol_frac", "mean_r", "n_tot", "gstdev"]
for key in keys:
if key not in dct:
raise Exception(">>" + key + "<< is missing in aerosol[" + name + "]")
Expand All @@ -85,8 +85,8 @@ def _arguments_checking(opts, spectra, aerosol, ice_switch):
raise Exception("invalid key >>" + key + "<< in aerosol[" + name + "]")
if dct["kappa"] <= 0:
raise Exception("kappa hygroscopicity parameter should be larger than 0 for aerosol[" + name + "]")
if dct["rd_insol"] < 0:
raise Exception("insoluble dry radius should be larger or equal to 0 for aerosol[" + name + "]")
if dct["sol_frac"] < 0 or dct["sol_frac"] > 1:
raise Exception("soluble fraction should be between 0 and 1 for aerosol[" + name + "]")
if type(dct["mean_r"]) != list:
raise Exception(">>mean_r<< key in aerosol["+ name +"] must be a list")
if type(dct["gstdev"]) != list:
Expand Down
Loading
Loading