More on Berton 2023 replication
Please create a notebook (notebooks/replicate-basic-solutions.ipynb) to replicate the plots in Section 3 of the paper. Please also add some logging (using tqdm: you can add it as a dependency) in the simulation function in the main code, so that I can see progress as the simulations run.
Implemented.
Changes:
- Added
tqdmdependency inpyproject.tomland updateduv.lock. - Added
tqdm.auto.tqdmprogress reporting tocloud_rom.berton2023.simulate(...). - New args:
progress=True,progress_desc="simulate". - Created notebook:
notebooks/replicate-basic-solutions.ipynb- Reproduces Section 3 Case 0 basic solution plots:
- non-oscillatory mode: Figures 7–15 analogues
Show remaining 5 lines
- oscillatory mode: Figures 16–24 analogues
Validation:
uv run pytest -q→6 passed- Notebook JSON/code cells parse successfully.
Let's concentrate on the steady-state solution in the notebook. I've run the simulation, but it stopped before the full time and the results look a little odd. I've saved the results into notebooks/df_steady.csv. It appears that the initial part of the trajectory has been dropped somehow: most of the plots look reasonable but seem to show only the later part of the trajectory (after maybe 3-3.5 hours?).
I inspected notebooks/df_steady.csv. Two things are happening:
- The initial part is not actually missing
The CSV starts at t = 0 second, x = 2 kilometer, z = 10 kilometer.
- The raw CSV has mixed unit strings
The first row has x = 2 kilometer, but later rows have x = ... meter; same for z. If reloaded/parsed naively, that can make the early trajectory look wrong or effectively disappear.
- The run stopped early because mass is approaching zero
Your saved steady run ends at about 7836 s ≈ 2.18 h, not 5 h. The last sampled mass is still positive, but the simulator likely stops shortly after because stop_on_nonpositive_mass=True.
Show remaining 17 lines
I made these changes:
- Updated
initial_state_for_case()andcase0_initial_state()so initialx, zare stored internally as meters, avoiding mixed-unit CSV output. - Reworked
notebooks/replicate-basic-solutions.ipynbto focus only on the steady Case 0 solution. - Added notebook diagnostics showing:
- requested duration vs actual last sampled time
- early-stop warning
- first rows, to confirm the beginning is present
- Added zoomed trajectory plots for the first 1.5 h so the early hook/head isn’t visually compressed by the later trail.
- Added export of a clean numeric CSV:
notebooks/df_steady_magnitudes.csv
Validation:
uv run pytest -q→6 passed
One remaining issue: the model currently sublimates the steady crystal too fast compared with the paper’s stated 5 h lifetime. That looks like a model/parameter discrepancy, not a notebook plotting/drop issue.
Something is definitely not right: based on Figure 11a in the paper, the particle mass should increase for about 3.5 hours, reaching a maximum of more than 1.2 μg. It's also very clear that the first part of the trajectory is not simulated correctly: there is no "hook", and the abscissa increases monotically, while according to Figure 8a in the paper, it should decrease for the first 3.5 hours (during the "hook" phase). My guess would be that there is a sign error somewhere causing the initial forcing to be in the wrong direction. I'll see if I can find anything, but could you also investigate and see if you can find any other potential causes for this problem?
I just noticed something: the Coriolis term is not being set to zero. I included the Coriolis force in the model for later investigation, but in the paper it's always neglected, so we should do the same for the verification exercise. I also noticed that the timestep used in the notebook is 0.04 seconds, while in the paper, Δt = 0.02s. However, some experimentation indicates that neither of those things is the cause of this problem. I've updated the notebook to disable the Coriolis effect and reduce the timestep to 0.02 s, but the simulation is still incorrect and the hook part of the trajectory doesn't happen.
You are trying to do some very long simulations. I don't think that's the way to go here. Something is going wrong right at the beginning of the simulations: the mass growth rate quickly falls to zero, there is no hook, etc. Concentrate on the beginning of the simulation.
I think it's the definition of the Reynolds number and the drag coefficient that are the problem. Take a look at their values at the first timestep and the second timestep. First, the drag coefficient has a value of O(10^13) at t=0 when it should be between 11 and 12, and Re is approximately 1, when it should be about 2.
You were right to focus on Re/C_D.
I found two related issues:
- Wrong default Reynolds length convention
- The code defaulted to
reynolds_length="radius". - But the paper text before Sect. 3 says it uses
r_i = D_iin Eq. (4) for the retained numerical convention. - Using radius halves
Re, raisesC_D, increases damping, and kills the early lift/hook behavior.
- Singular initial zero-slip state
Show remaining 32 lines
- Table 2 has
w0 = W_a = 0.6 m/s, so the literal relative speed in Eq. (4) is exactly zero att=0. - That made
Re≈1e-12andC_D≈2e13. - The paper’s plotted branch is clearly the physical terminal/low-Re branch, with
Re≈2,C_D≈11.
I changed src/cloud_rom/berton2023.py to:
- Default
SimulationConfig.reynolds_length = "diameter". - Add a
terminal_reynolds_number(...)fallback for the zero-slip initial state, solving Eqs. (3), (5), and (9) self-consistently. - Use that fallback only when instantaneous slip is effectively zero.
Now Case 0 initial diagnostics are:
Re = 2.0788
C_D = 11.3261
k = 17.54 1/s
And after 20 min with dt=0.02, no Coriolis:
t=0 min x=2.000 km z=10.000 km m=0.936 µg
t=10 min x=1.965 km z=10.023 km m=0.955 µg
t=20 min x=1.868 km z=10.041 km m=0.972 µg
So the early trajectory now moves left and upward, and mass grows.
Validation:
uv run pytest -q→7 passed
If your notebook explicitly sets reynolds_length="radius", remove that override or set it to "diameter".
OK, that works perfectly now. The initial condition was tricky, but everything looks good now.
Great — glad that fixed it.
The key fixes were:
- using the paper’s retained
Reconvention (D_i, notD_i/2); - handling the zero-slip initial condition via the terminal low-Re branch instead of letting
C_Dblow up.
That explains why the early hook and mass-growth phase were missing before.
Now, please rename the notebook for the steady state to reflect that it's for the steady state and make an equivalent notebook for replicating the oscillatory state. Factor out any common setup and plotting code into a separate module.
Done.
Changes:
- Renamed/replaced notebook:
notebooks/replicate-steady-state.ipynb- Added oscillatory notebook:
notebooks/replicate-oscillatory-state.ipynb- Removed old:
notebooks/replicate-basic-solutions.ipynb- Factored shared notebook utilities into:
Show remaining 13 lines
src/cloud_rom/berton2023_plots.py
The new helper module includes:
- Case 0 runner
- Pint-to-magnitude conversion
- numeric CSV export
- run summaries
- shared plotting functions for trajectory/hodograph, x/z, microphysics drivers, size state, and drag/damping diagnostics
Validation:
- Notebook code cells parse successfully.
uv run python -m py_compile src/cloud_rom/berton2023_plots.pyuv run pytest -q→7 passed
OK, that all looks good. Can you please commit the changes so far.
Committed changes.
Commit:
6b6b39e Implement Berton 2023 parcel model notebooks
Working tree is clean.