diff --git a/chem_conditions.py b/chem_conditions.py index ac2c214..4bc2c3b 100644 --- a/chem_conditions.py +++ b/chem_conditions.py @@ -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 @@ -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,\ diff --git a/long_test/test_ice_SD.py b/long_test/test_ice_SD.py index 0eff584..ce34ba1 100644 --- a/long_test/test_ice_SD.py +++ b/long_test/test_ice_SD.py @@ -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, @@ -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]) \ No newline at end of file + subprocess.call(["rm", outfile]) diff --git a/long_test/test_plot_ice_SD.py b/long_test/test_plot_ice_SD.py index 5625595..9a58481 100644 --- a/long_test/test_plot_ice_SD.py +++ b/long_test/test_plot_ice_SD.py @@ -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, @@ -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) diff --git a/long_test/test_plot_schemes_ice.py b/long_test/test_plot_schemes_ice.py index 154ef05..f687dc1 100644 --- a/long_test/test_plot_schemes_ice.py +++ b/long_test/test_plot_schemes_ice.py @@ -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) diff --git a/long_test/test_timestep.py b/long_test/test_timestep.py index 5fed365..7ad6d90 100644 --- a/long_test/test_timestep.py +++ b/long_test/test_timestep.py @@ -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}}' ) diff --git a/micro_lgrngn.py b/micro_lgrngn.py index 5efd25d..92ace09 100644 --- a/micro_lgrngn.py +++ b/micro_lgrngn.py @@ -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 diff --git a/parcel.py b/parcel.py index 996984d..e8f66c0 100755 --- a/parcel.py +++ b/parcel.py @@ -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, @@ -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) gstdev - lognormal distribution geometric standard deviation (list if multimodal distribution) n_tot - lognormal distribution total concentration under standard diff --git a/parcel_common.py b/parcel_common.py index ba8d12e..d7e0d49 100644 --- a/parcel_common.py +++ b/parcel_common.py @@ -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 + "]") @@ -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: diff --git a/plots/outputs/plot_schemes_ice.svg b/plots/outputs/plot_schemes_ice.svg deleted file mode 100644 index b9ebe4b..0000000 --- a/plots/outputs/plot_schemes_ice.svg +++ /dev/null @@ -1,2641 +0,0 @@ - - - - - - - - 2026-04-14T14:57:25.200045 - image/svg+xml - - - Matplotlib v3.10.8, https://matplotlib.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/unit_test/test_RH.py b/unit_test/test_RH.py index 6c9d927..349d48a 100644 --- a/unit_test/test_RH.py +++ b/unit_test/test_RH.py @@ -11,7 +11,7 @@ def test_RH_gt1(tmpdir, kappa): (i.e. cloud is created) """ str_f = str(tmpdir.join("test_pcl.nc")) - pc.parcel(outfile=str_f, outfreq=1, aerosol='{"ammonium_sulfate": {"kappa": ' + str(kappa) + ', "rd_insol":0.0, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [60.0e6]}}') + pc.parcel(outfile=str_f, outfreq=1, aerosol='{"ammonium_sulfate": {"kappa": ' + str(kappa) + ', "sol_frac":1.0, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [60.0e6]}}') f_out = netcdf.netcdf_file(str_f, "r") assert f_out.variables["RH"][-1] >= .99 diff --git a/unit_test/test_chem_henry.py b/unit_test/test_chem_henry.py index 55e62f9..4ad678f 100644 --- a/unit_test/test_chem_henry.py +++ b/unit_test/test_chem_henry.py @@ -55,7 +55,7 @@ def data(request): outfile = outfile,\ chem_dsl = True, chem_dsc = True, chem_rct = False,\ aerosol = \ - '{"test": {"kappa": 0.5, "rd_insol":0.0, "mean_r": [' + str(mean_r) + '], "gstdev": [' + str(gstdev) + '], "n_tot": [' + str(n_tot) + ']}}',\ + '{"test": {"kappa": 0.5, "sol_frac":1.0, "mean_r": [' + str(mean_r) + '], "gstdev": [' + str(gstdev) + '], "n_tot": [' + str(n_tot) + ']}}',\ sd_conc = sd_conc,\ out_bin = \ '{"radii": {"rght": 1.0, "left": 0.0, "drwt": "wet", "lnli": "lin", "nbin": 1, "moms": [0, 3]},\ diff --git a/unit_test/test_init.py b/unit_test/test_init.py index 172b10c..4e81a97 100644 --- a/unit_test/test_init.py +++ b/unit_test/test_init.py @@ -19,8 +19,8 @@ def test_supersat(tmpdir): @pytest.mark.parametrize("arg",[{"T_0" : 255}, {"RH_0": 1.00001}, {"w" : -1}, - {"aerosol" : '{"zero_kappa": {"kappa" : 0., "rd_insol":0.0, "mean_r": [2e-8], "gstdev": [1.2], "n_tot": [60e6]}}'}, - {"aerosol" : '{"unity_gstdev": {"kappa" : 0.61, "rd_insol":0.0, "mean_r": [2e-8], "gstdev": [1.], "n_tot": [60e6]}}'}, + {"aerosol" : '{"zero_kappa": {"kappa" : 0., "sol_frac":1.0, "mean_r": [2e-8], "gstdev": [1.2], "n_tot": [60e6]}}'}, + {"aerosol" : '{"unity_gstdev": {"kappa" : 0.61, "sol_frac":1.0, "mean_r": [2e-8], "gstdev": [1.], "n_tot": [60e6]}}'}, {"out_bin" : '{"radii": {"moms": [0], "drwt": "wet", "nbin": 26, "lnli": "log", "left": 1e-09}}'}, {"out_bin" : '{"radii": {"aqq": 1, "rght": 0.0001, "moms": [0], "drwt": "wet", "nbin": 26, "lnli": "log", "left": 1e-09}}'}, {"out_bin" : '{"radii": {"rght": "aqq", "moms": [0], "drwt": "wet", "nbin": 26, "lnli": "log", "left": 1e-09}}'}, diff --git a/unit_test/test_moments.py b/unit_test/test_moments.py index 6ea2f23..1991193 100644 --- a/unit_test/test_moments.py +++ b/unit_test/test_moments.py @@ -32,7 +32,7 @@ def data(request): p_dict['wait'] = 0 # initial aerosol: 1-mode ammonium sulfate lognormal - p_dict['aerosol'] = '{"ammonium_sulfate": {"kappa": 0.61, "rd_insol":0.0, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [100e6]}}' + p_dict['aerosol'] = '{"ammonium_sulfate": {"kappa": 0.61, "sol_frac":1.0, "mean_r": [0.02e-6], "gstdev": [1.4], "n_tot": [100e6]}}' # output for size distribution moments p_dict['out_bin'] = '{\