Add minimal modal run to model dry deposition#211
Add minimal modal run to model dry deposition#211zdaq12 wants to merge 30 commits intocompdyn:masterfrom
Conversation
…e modal run; handle input and output for processing
… default parameters
|
closing and reopening to trigger codecov analysis |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #211 +/- ##
==========================================
- Coverage 77.45% 75.50% -1.95%
==========================================
Files 55 56 +1
Lines 9420 9713 +293
==========================================
+ Hits 7296 7334 +38
- Misses 2124 2379 +255 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Looks pretty good in my first pass.
- I think we need to add some protections to the modal model. For example, I can attempt to run with emissions/dilution (it won't complain) but they won't do anything. However these are in the spec file (they're zero for the purpose of this scenario but it leads one to think that maybe they could be changed) and they are read in (due to other PartMC subroutines). I think maybe we just add some asserts in partmc_modal to warn/error out on unsupported behavior.
- Similarly, I could also attempt to turn coagulation on. This isn't actually read anywhere. I guess what we really need is an input_format_modal similar to how we have them for input_format_particle, sectional to say what is supported.
- We do need to figure out what to do with the scenario. Honestly I'm wondering if we should consider switching this scenario to being a test case (this is what we did with the immersion freezing). This scenario already fits in pretty well with what is found in
test/loss. Making it a test would also make codecov happy. Alternatively, I think if it wants to reach scenario levels by making it interesting, we could consider running it for the particle-resolved case and/or sectional case. Just something to consider.
|
|
||
| #ifdef PMC_USE_QUADPACK | ||
| ! Do numerical integration when QUADPACK is available | ||
| print *, "***USING QUADPACK FOR DRY DEPOSITION***" |
There was a problem hiding this comment.
I don't think we need this - will print frequently.
| print *, "***USING QUADPACK FOR DRY DEPOSITION***" |
| if (ier > 0) then | ||
| call die_msg(837465, "QUADPACK integration failed (error code: " & | ||
| // trim(integer_to_string(ier))) | ||
| endif |
There was a problem hiding this comment.
Suggest that we switch to assert_msg. Test for ier = zero rather than ier > 0 (unless there is a good reason for testing >0 which would include negatives (if quadpack allows it?)). And replace number with random 9 digit number. Suggestion would look somewhat like the following (admittedly I didn't test it yet)
| if (ier > 0) then | |
| call die_msg(837465, "QUADPACK integration failed (error code: " & | |
| // trim(integer_to_string(ier))) | |
| endif | |
| call assert_msg(909106718, ier == 0, & | |
| "QUADPACK integration failed, error code: " & | |
| // trim(integer_to_string(ier))) |
| if (new_N < 1d0) then | ||
| aero_dist%mode(i_mode)%num_conc = 0d0 | ||
| aero_dist%mode(i_mode)%char_radius = 0d0 | ||
| cycle | ||
| end if |
There was a problem hiding this comment.
Is this some sort of cutoff for small number concentrations? I think a comment would help.
And is it necessary to set the char_radius to 0 or is num_conc = 0 sufficient? I can envision this could cause some issue (maybe currently only in post-processing) if char_radius = 0 is ever used in a lognormal equation.
| else if (scenario%loss_function_type == SCENARIO_LOSS_FUNCTION_CONSTANT) then | ||
| return | ||
| else if (scenario%loss_function_type == SCENARIO_LOSS_FUNCTION_DRYDEP) then | ||
| ! loss |
| !> Density for each mode. | ||
| real(kind=dp), intent(in) :: density |
There was a problem hiding this comment.
Comment says each mode but density is a scalar.
| !> Dry deposition parameters. | ||
| type(drydep_params_t), intent(inout) :: drydep_params | ||
|
|
||
| !> \page input_format_chamber Input File Format: Dry Deposition Parameters |
There was a problem hiding this comment.
Copy/pasted \page from elsewhere (chamber.F90). Should be renamed.
| do i_mode = 1,aero_dist_n_mode(aero_dist) | ||
| aero_mode = aero_dist%mode(i_mode) | ||
| N = aero_mode%num_conc | ||
|
|
||
| if (N == 0d0) then | ||
| cycle | ||
| end if | ||
|
|
||
| d_pg = aero_mode%char_radius * 2.0d0 | ||
| ln_sigma_g = aero_mode%log10_std_dev_radius / log10(exp(1.0d0)) | ||
|
|
||
| ! Integrated deposition rate for the 0-th moment (num. conc.) | ||
| m_0_rate = -1.0d0 * scenario_integrated_loss_rate_drydep(scenario, aero_mode, & | ||
| 0.0d0, density, env_state) | ||
| new_N = N * exp(m_0_rate * del_t) | ||
|
|
||
| if (new_N < 1d0) then | ||
| aero_dist%mode(i_mode)%num_conc = 0d0 | ||
| aero_dist%mode(i_mode)%char_radius = 0d0 | ||
| cycle | ||
| end if | ||
|
|
||
| aero_dist%mode(i_mode)%num_conc = new_N | ||
|
|
||
| ! Integrated deposition rate for the 3-rd moment (proportional to volume conc.) | ||
| m_3_rate = -1.0d0 * scenario_integrated_loss_rate_drydep(scenario, aero_mode, 3.0d0, & | ||
| density, env_state) | ||
| M = N * d_pg**3.0d0 * exp((3.0d0**2.0d0)/2.0d0 * (ln_sigma_g**2.0d0)) | ||
| new_M = M * exp(m_3_rate * del_t) | ||
|
|
||
| ! New geometric mean diameter | ||
| new_d_pg = (new_M / new_N * exp(-(3.0d0**2.0d0)/2.0d0 * (ln_sigma_g**2.0d0)))**(1.0d0/3.0d0) | ||
| aero_dist%mode(i_mode)%char_radius = new_d_pg / 2.0d0 | ||
| end do |
There was a problem hiding this comment.
Fix indentation on the do loop.
| @@ -0,0 +1,33 @@ | |||
| run_type modal # modal run | |||
| output_prefix data/modal_dpg_00001000000000000000_sig_2_5_emerson_grass | |||
There was a problem hiding this comment.
Suggest that you change the directory to out (consistent with other scenarios and also specified in the dockerignore)
|
|
||
| # The data should have already been generated by ./1_run_dry_dep_modal.sh | ||
|
|
||
| ../../build/drydep_modal_process |
There was a problem hiding this comment.
Complains that it needs an output prefix.
| # dens (kg/m^3) ions in soln (1) molec wght (kg/mole) kappa (1) | ||
| SO4 1800 0 96d-3 0.65 |
There was a problem hiding this comment.
Need to tack on the two new freezing parameters. Should be something like this:
| # dens (kg/m^3) ions in soln (1) molec wght (kg/mole) kappa (1) | |
| SO4 1800 0 96d-3 0.65 | |
| # dens (kg/m^3) ions in soln (1) molec wght (kg/mole) kappa (1) abifm_m (1) abifm_c (1) | |
| SO4 1800 0 96d-3 0.65 0. 0. |
| integer :: total_size, i, N | ||
|
|
There was a problem hiding this comment.
Looks like these variables tagged along from elsewhere and aren't needed here (or actually even where you probably got it from). But clean them up here only so this PR stays focused on drydep changes.
| integer :: total_size, i, N |
No description provided.