Skip to content

Feature/lecture readiness improvements#21

Open
jslim93 wants to merge 14 commits intomainfrom
feature/lecture-readiness-improvements
Open

Feature/lecture readiness improvements#21
jslim93 wants to merge 14 commits intomainfrom
feature/lecture-readiness-improvements

Conversation

@jslim93
Copy link
Copy Markdown
Owner

@jslim93 jslim93 commented Feb 11, 2026

No description provided.

Document outlines approaches for extending LEM to handle:
- Sedimentation: particles falling through S' field
- Ice particle statistics: low multiplicity problem
- Phase coupling: WBF process and S' fluctuations

Five approaches analyzed with pros/cons:
A) Phase-Separated LEM
B) Spatial LEM (Fortran research code style)
C) Lagrangian S' History (recommended)
D) Conditional Statistics
E) Hybrid approach

Includes research questions and suggested starting point.
- collision.py: Remove hardcoded V_parcel=1.0 and rho_parcel=1.0,
  use actual parcel density/volume (collision rates were ~82x too high)
- collision.py: Fix E_H80 interpolation to convert radius to microns
  (missing *1.0E6 disabled interpolation entirely)
- collision.py: Fix kappa sequential mutation bug in same_weights_update
  and rewrite mass logic to match Fortran reference pattern
- collision.py: Remove unnecessary hardcoded constants that shadowed
  function parameters
- parameters.py: Fix N_l trailing comma that made it a tuple
- parcel.py: Fix temperature sign logic for sine/oscillation modes
  (use T -= dz*g/cp unconditionally instead of checking w_parcel sign)
- condensation.py: Fix dead wrong V_parcel formula (was 100/P/(R*T))
- analysis.py: Guard division by zero when no cloud droplets exist
- widget.py: nt_widget uses BoundedIntText (min=1, max=100000)
- widget.py: sigma min 0.0→0.01, mu min 0.0→0.001 to prevent div-by-zero
- print_plot.py: jet→viridis colormap (perceptually uniform)
- print_plot.py: fix "Evaporaton" typo
- print_plot.py: move deepcopy outside DSD loop (was re-copying every iteration)
- print_plot.py: fig.show()→plt.show() for Jupyter compatibility
- timestep_routine.py: add tqdm progress bar
- timestep_routine.py: move time_array outside loop (was recomputed every step)
- timestep_routine.py: remove unused pylab import
- animation.py: Replace clear_output()+fig.show() loop pattern with
  FigureWidget + batch_update for in-place updates (no memory leak)
- animation.py: Only slice data up to current timestep (was sending full arrays)
- aero_init.py: Remove unused scipy.stats.lognorm import
Presets (widget.py):
- Maritime/Continental/Arctic dropdown auto-fills aerosol grid
- Maritime: few hygroscopic CCN → fast rain onset
- Continental: many small CCN → suppressed rain
- Arctic: ultra-clean → extreme drizzle behavior

Ablation Lab (widget.py + physics modules):
- Kelvin (curvature) effect toggle: afactor=0 when off
- Raoult (solute) effect toggle: bfactor=0 when off
- Constant collision efficiency (E=1) vs Hall (1980)
- Simplified terminal velocity (Stokes) vs Beard (1976)
- ws_drops_stokes() added for pure Stokes drag comparison
- All switches threaded through timestep_routine → physics modules

Performance (@jit):
- radius_liquid_euler: 0.2 µs/call with numba nopython
- esatw: 0.1 µs/call with numba nopython
- sigma_air_liq: JIT-compiled with cache
- Removed unused scipy.optimize import
Port turbulent collision kernel (Ayala et al. 2008, NJP; Wang &
Grabowski 2009, QJRMS) from SAM-LCM micro_coll.f90:
- phi_w(), zhi_func(): helper functions for Ayala analytical model
- gck(): general collection kernel with turbulent radial relative
  velocity and radial distribution function
- E_turb(): turbulent enhancement factor lookup tables at
  epsilon = 100 and 400 cm^2/s^3 with bilinear interpolation
- Ablation Lab toggle + epsilon widget in notebook
- Fix ZeroDivisionError when particles have M=0 or Ns=0 after collision
  (skip degenerate particles in condensation loop)
- Add safety floor in Newton-Raphson solver for r_aero=0 and r_eul_old=0
- Add adaptive condensation substep option (Arnason & Brown 1971):
  dt_sub = min(2*tau_phase, dt) where tau_phase = 1/(4*pi*D_v*sum(A*r)/V)
- New widget toggle in Ablation Lab + threaded through notebook
Fix Nc/Nr unit convention: multiply PyLCM values by rho to convert
from /kg/1e6 to proper /cm3, matching Fortran output convention.
When p_crit > 1 in LSM, gamma = NINT(p_crit) collisions occur per pair
instead of just 1. Includes limiter to prevent over-collection.
Reduces PyLCM peak Nr from ~20 to ~6 /cm3 (Fortran: 2.2 /cm3).
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant