%23%20%2F%2F%2F%20script%0A%23%20requires-python%20%3D%20%22%3E%3D3.12%22%0A%23%20dependencies%20%3D%20%5B%0A%23%20%20%20%20%20%22diffrax%3D%3D0.7.0%22%2C%0A%23%20%20%20%20%20%22jax%3D%3D0.8.1%22%2C%0A%23%20%20%20%20%20%22marimo%22%2C%0A%23%20%20%20%20%20%22matplotlib%3D%3D3.10.8%22%2C%0A%23%20%20%20%20%20%22numpy%3D%3D2.3.5%22%2C%0A%23%20%20%20%20%20%22numpyro%3D%3D0.19.0%22%2C%0A%23%20%20%20%20%20%22pandas%3D%3D2.3.3%22%2C%0A%23%20%20%20%20%20%22seaborn%3D%3D0.13.2%22%2C%0A%23%20%5D%0A%23%20%2F%2F%2F%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.19.4%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22%2C%20auto_download%3D%5B%22html%22%5D)%0A%0Awith%20app.setup(hide_code%3DTrue)%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20from%20numpyro%20import%20distributions%20as%20dist%2C%20handlers%0A%20%20%20%20from%20numpyro%20import%20sample%2C%20param%2C%20deterministic%0A%20%20%20%20from%20numpyro.infer%20import%20MCMC%2C%20NUTS%2C%20SVI%2C%20Trace_ELBO%2C%20reparam%2C%20autoguide%0A%20%20%20%20import%20pandas%20as%20pd%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20from%20numpyro.optim%20import%20Adam%0A%20%20%20%20from%20jax.random%20import%20PRNGKey%0A%20%20%20%20from%20jax%20import%20numpy%20as%20jnp%2C%20lax%0A%20%20%20%20import%20seaborn%20as%20sns%0A%20%20%20%20from%20matplotlib%20import%20pyplot%20as%20plt%0A%0A%20%20%20%20from%20diffrax%20import%20diffeqsolve%2C%20ODETerm%2C%20Dopri5%2C%20SaveAt%0A%0A%20%20%20%20sns.set_theme(%0A%20%20%20%20%20%20%20%20%22talk%22%2C%20%22ticks%22%2C%20font%3D%22Arial%22%2C%20font_scale%3D1.0%2C%20rc%3D%7B%22svg.fonttype%22%3A%20%22none%22%7D%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Thinking%20about%20aerosols%20probabilistically%20%E2%80%94%20Part%201%3A%20Evaporation%0A%0A%20%20%20%20Experiments%20with%20anything%20small%20and%20hard%20to%20observe%20directly%20%E2%80%94%20and%20especially%20something%20as%20mercurial%20and%20stochastic%20as%20an%20aerosol%20%E2%80%94%20inevitably%20include%20%22dark%22%20areas%2C%20where%20there%20is%20incomplete%20information%20about%20what%20is%20going%20on.%0A%20%20%20%20Recently%2C%20we%20have%20been%20analysing%20the%20effect%20of%20solvent%20vapour%20pressure%20on%20reactive%20aerosols.%20Intuitively%2C%20one%20would%20expect%20that%20the%20evaporation%20of%20solvent%20would%20boost%20reactivity%20within%20the%20droplets%2C%20but%20is%20this%20acceleration%20detectable%20experimentally%2C%20and%20to%20what%20specific%20effect%20can%20we%20attribute%20any%20observed%20acceleration%3F%0A%0A%20%20%20%20Here's%20a%20simplified%20description%20of%20the%20experiment%3A%0A%0A%20%20%20%20*%20Solvent%20vapour%20pressure%20within%20the%20reactor%20is%20adjusted%20to%20the%20desired%20initial%20level%20%24P_0%24.%0A%20%20%20%20*%20Two%20jets%20of%20reactive%20aerosols%20(let's%20call%20them%20%24A%24%20and%20%24B%24%2C%20each%20dissolved%20in%20the%20same%20solvent)%20are%20released%20simultaneously%20into%20our%20reactor%20and%20allowed%20to%20mix.%0A%20%20%20%20*%20After%20a%20specified%20resting%20period%20%24t_r%24%2C%20the%20contents%20are%20transfered%20to%20a%20mass%20spectrometer%20for%20analysis.%0A%0A%20%20%20%20In%20%5Bprevious%20work%5D(https%3A%2F%2Fdoi.org%2F10.26434%2Fchemrxiv-2025-g4hcg)%20(where%20we%20didn't%20control%20solvent%20vapour%20pressure%20or%20care%20about%20its%20impact)%20it%20was%20sufficient%20to%20think%20about%20the%20average%20behaviour%3A%20combined%20reagent%20aerosols%20were%20sent%20to%20the%20MS%20for%20analysis%2C%20product%20peaks%20were%20observed%2C%20there%20was%20a%20dependence%20on%20reaction%20time%2C%20stoichiometry%2C%20etc..%0A%0A%20%20%20%20The%20question%20is%20how%20to%20think%20about%20all%20the%20different%20ways%20in%20which%20differing%20initial%20solvent%20vapour%20pressure%20affects%20what%20happens%20during%20the%20experiment.%20The%20most%20obvious%20is%20the%20equilibrium%20size%20distribution%20of%20the%20released%20droplets.%20When%20droplets%20shrink%20under%20the%20effect%20of%20solvent%20evaporation%2C%20there%20is%0A%0A%20%20%20%201.%20A%20boost%20in%20the%20concentration%20of%20(non-volatile)%20reagents%2C%20so%20if%20the%20reaction%20is%20first-order%20w.r.t.%20%24A%24%2C%20a%20linear%20acceleration%20would%20be%20expected%20as%20%24%5BA%5D%24%20rises.%0A%20%20%20%202.%20A%20radius-dependent%20change%20in%20chemical%20potential%20irrespective%20of%20concentration%3A%20%24(%5Cfrac%7B%5Cpartial%20%5Cmu%7D%7B%5Cpartial%20r%7D)_%7B%5BA%5D%7D%24%2C%0A%20%20%20%203.%20Observed%20changes%20in%20product%20distribution%20may%20be%20due%20to%20a%20change%20in%20droplet%20coalescence%20kinetics.%20In%20a%20dry%20reactor%2C%20droplets%20rapidly%20shrink%20due%20to%20evaporation%20and%20their%20motion%20becomes%20more%20%22fluid-like%22%20as%20a%20result%2C%20so%20coalescence%20events%20may%20become%20less%20likely.%20Higher%20initial%20solvent%20vapour%20pressure%20limits%20the%20loss%20of%20solvent%20from%20the%20droplets%2C%20so%20there%20are%20is%20a%20higher%20probability%20of%20droplet%20collisions.%0A%0A%20%20%20%20In%20this%20notebook%20series%2C%20my%20aim%20is%20to%20explore%20a%20series%20of%20increasingly%20accurate%2Felaborate%20models%20exploring%20the%20evolution%20of%20droplets%20in%20this%20setting.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.function(hide_code%3DTrue)%0Adef%20infer(model%2C%20args)%3A%0A%20%20%20%20mcmc%20%3D%20MCMC(%0A%20%20%20%20%20%20%20%20NUTS(model)%2C%20num_warmup%3D2000%2C%20num_samples%3D250%2C%20progress_bar%3DFalse%0A%20%20%20%20)%0A%20%20%20%20mcmc.run(PRNGKey(0)%2C%20*args)%0A%20%20%20%20mcmc_samples%20%3D%20mcmc.get_samples()%0A%0A%20%20%20%20guide%20%3D%20autoguide.AutoNormal(model)%0A%20%20%20%20svi%20%3D%20SVI(model%2C%20guide%2C%20Adam(0.01)%2C%20Trace_ELBO())%0A%20%20%20%20svi_result%20%3D%20svi.run(PRNGKey(1)%2C%2010000%2C%20*args%2C%20progress_bar%3DFalse)%0A%20%20%20%20svi_samples%20%3D%20guide.sample_posterior(%0A%20%20%20%20%20%20%20%20PRNGKey(0)%2C%20svi_result.params%2C%20sample_shape%3D(100%2C)%0A%20%20%20%20)%0A%20%20%20%20return%20locals()%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Model%201%3A%20Hard%20minimum%20droplet%20size%2C%20evaporation%20rate%20controlled%20by%20unsaturation%0A%0A%20%20%20%20To%20get%20started%2C%20let's%20consider%20a%20very%20basic%2C%20if%20somewhat%20na%C3%AFve%20model.%0A%0A%20%20%20%20*%20Inputs%20are%20initial%20radii%20%24r_0%24%20and%20relative%20humidity%20%24%5Cmathrm%7Brh%7D_0%24%20(relative%20vapour%20pressure%20between%200.0%20and%201.0)%0A%20%20%20%20*%20Unsaturation%20%24u%24%20%3D%20%241%20-%20%5Cmathrm%7Brh%7D%24%0A%20%20%20%20*%20%24%5Cfrac%7Bdr%7D%7Bdt%7D%20%3D%20-u%20k_r%5Cmax(%5Cfrac%7Br%20-%20r_%5Ctext%7Bmin%7D%7D%7Br%7D%2C%200)%24%20The%20max%20term%20is%20there%20to%20prevent%20the%20droplet%20shrinking%20below%20its%20minimum%20radius.%20This%20is%20a%20somewhat%20artificial%20constraint%20and%20is%20removed%20in%20later%20models%20so%20that%20droplets%20can%20also%20grow.%0A%20%20%20%20*%20Relative%20humidity%20rises%20according%20to%20simple%201st%20order%20dynamics%20%24%5Cfrac%7Bd%20%5Ctext%7Brh%7D%7D%7Bdt%7D%20%3D%20u%20k_%7B%5Ctext%7Brh%7D%7D%24%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.function%0Adef%20diffeq1(t%2C%20y%2C%20args)%3A%0A%20%20%20%20k_r%2C%20k_rh%2C%20r_min%20%3D%20args%5B%22k_r%22%5D%2C%20args%5B%22k_rh%22%5D%2C%20args%5B%22r_min%22%5D%0A%20%20%20%20r%2C%20rh%20%3D%20y%0A%20%20%20%20unsaturation%20%3D%201.0%20-%20rh%0A%20%20%20%20dr%20%3D%20-jnp.maximum(k_r%20*%20(r%20-%20r_min)%20%2F%20r%2C%200.0)%20*%20unsaturation%0A%20%20%20%20drh%20%3D%20unsaturation%20*%20k_rh%0A%20%20%20%20return%20(dr%2C%20drh)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Model%202%3A%20Non-volatile%20component%20instead%20of%20hard%20minimum%20radius%0A%0A%20%20%20%20The%20idea%20of%20a%20fixed%20minimum%20droplet%20radius%20seems%20rigid%20and%20a%20bit%20silly.%20What%20really%20limits%20the%20complete%20evaporation%20of%20each%20microdroplet%20is%20its%20non-volatile%20content%20so%20let's%20use%20Raoult's%20law%20to%20approximate%20the%20drop%20in%20droplet%20vapour%20pressure%20as%20solvent%20evaporates.%20Also%2C%20the%20contribution%20to%20overall%20relative%20humidty%20can%20be%20calculated%20explicitly%20based%20on%0A%0A%20%20%20%20*%20Droplets%20start%20with%20an%20initial%20mole%20fraction%20%24x_0%24%20of%20non-volatile%20solute%0A%20%20%20%20*%20As%20solvent%20evaporates%20this%20fraction%20rises%20until%20it%20reaches%20the%20relative%20humidity%2C%20_e.g._%20if%20%24x%24%20is%200.7%20then%20droplet%20is%20at%20equilibrium%20with%20vapour%20at%2070%25%20relative%20humidity.%0A%20%20%20%20*%20Relative%20humidty%20rise%20is%20commensurate%20to%20the%20volume%20of%20liquid%20lost%20from%20droplets%3A%20%24%5Cfrac%7Bd%5Ctext%7Brh%7D%7D%7Bdt%7D%20%3D%20-%5Cfrac%7Bdr%7D%7Bdt%7D%20r%5E2%20N%24%20where%20N%20is%20the%20number%20density%20of%20droplets.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.function%0A%23%20Instead%20of%20a%20minimum%20radius%20specify%20initial%20non-volatile%20component%20mole%20fraction%0Adef%20diffeq2(t%2C%20y%2C%20args)%3A%0A%20%20%20%20r0%2C%20x0%2C%20k_r%2C%20N%20%3D%20(%0A%20%20%20%20%20%20%20%20args%5B%22r0%22%5D%2C%0A%20%20%20%20%20%20%20%20args%5B%22x0%22%5D%2C%0A%20%20%20%20%20%20%20%20args%5B%22k_r%22%5D%2C%0A%20%20%20%20%20%20%20%20args%5B%22N%22%5D%2C%0A%20%20%20%20)%0A%20%20%20%20r%2C%20rh%20%3D%20y%0A%20%20%20%20concentration_enrichment%20%3D%20(r%20%2F%20r0)%20**%203%0A%20%20%20%20X%20%3D%20(1.0%20-%20x0)%20*%20concentration_enrichment%0A%20%20%20%20X%20%3D%20X%20%2F%20(X%20%2B%20x0)%0A%20%20%20%20unsaturation%20%3D%20X%20-%20rh%0A%20%20%20%20dr%20%3D%20-k_r%20*%20unsaturation%0A%20%20%20%20drh%20%3D%20-(dr%20*%20r**2).sum()%20*%20N%0A%20%20%20%20return%20(dr%2C%20drh)%0A%0A%0A%40app.function%0A%23%20Add%20Ostwald%20ripening%0Adef%20diffeq3(t%2C%20y%2C%20args)%3A%0A%20%20%20%20r0%2C%20x0%2C%20p_eq%2C%20k_r%2C%20N%20%3D%20(%0A%20%20%20%20%20%20%20%20args%5B%22r0%22%5D%2C%20%20%23%20initial%20radii%0A%20%20%20%20%20%20%20%20args%5B%22x0%22%5D%2C%20%20%23%20initial%20mole%20fraction%20of%20solute%0A%20%20%20%20%20%20%20%20args%5B%22p_eq%22%5D%2C%20%20%23%20equilibrium%20vapour%20pressure%0A%20%20%20%20%20%20%20%20args%5B%22k_r%22%5D%2C%20%20%23%20evaporation%20rate%0A%20%20%20%20%20%20%20%20args%5B%22N%22%5D%2C%20%20%23%20droplet%20number%20density%0A%20%20%20%20)%0A%20%20%20%20r%2C%20p%20%3D%20y%0A%20%20%20%20concentration_enrichment%20%3D%20(r%20%2F%20r0)%20**%203%0A%20%20%20%20X%20%3D%20(1.0%20-%20x0)%20*%20concentration_enrichment%0A%20%20%20%20X%20%3D%20X%20%2F%20(X%20%2B%20x0)%0A%20%20%20%20p_eq%20%3D%20p_eq%20*%20X%20*%20jnp.minimum(jnp.exp(1%20%2F%20r)%2C%2010.0)%0A%20%20%20%20dr%20%3D%20-k_r%20*%20(p_eq%20-%20p)%0A%20%20%20%20dp%20%3D%20-jnp.sum(dr%20*%20r**2%20*%20N)%0A%20%20%20%20return%20(dr%2C%20dp)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20t0%20%3D%200.0%0A%20%20%20%20t1%20%3D%20200.0%0A%20%20%20%20n_points%20%3D%201000%0A%20%20%20%20n_droplets%20%3D%2050%0A%20%20%20%20dt0%20%3D%20(t1%20-%20t0)%20%2F%20n_points%0A%20%20%20%20ts%20%3D%20jnp.linspace(t0%2C%20t1%2C%20n_points)%0A%0A%20%20%20%20default_params%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22rh0%22%3A%200.1%2C%0A%20%20%20%20%20%20%20%20%22r0%22%3A%20jnp.logspace(-0.4%2C%200.25%2C%20n_droplets)%2C%0A%20%20%20%20%20%20%20%20%22r_min%22%3A%200.01%2C%0A%20%20%20%20%20%20%20%20%22p0%22%3A%200.01%2C%0A%20%20%20%20%20%20%20%20%22x0%22%3A%200.01%2C%0A%20%20%20%20%20%20%20%20%22p_eq%22%3A%200.03%2C%0A%20%20%20%20%20%20%20%20%22k_r%22%3A%200.1%2C%0A%20%20%20%20%20%20%20%20%22k_rh%22%3A%200.1%2C%0A%20%20%20%20%20%20%20%20%22N%22%3A%200.01%2C%0A%20%20%20%20%7D%0A%0A%20%20%20%20models%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22model1%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22eq%22%3A%20diffeq1%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22y%22%3A%20%5B%22r0%22%2C%20%22rh0%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22args%22%3A%20%5B%22k_r%22%2C%20%22k_rh%22%2C%20%22r_min%22%5D%2C%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22model2%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22eq%22%3A%20diffeq2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22y%22%3A%20%5B%22r0%22%2C%20%22rh0%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22args%22%3A%20%5B%22r0%22%2C%20%22rh0%22%2C%20%22x0%22%2C%20%22k_r%22%2C%20%22N%22%5D%2C%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22model3%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22eq%22%3A%20diffeq3%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22y%22%3A%20%5B%22r0%22%2C%20%22p0%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22args%22%3A%20%5B%22r0%22%2C%20%22x0%22%2C%20%22p_eq%22%2C%20%22k_r%22%2C%20%22N%22%5D%2C%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%7D%0A%20%20%20%20return%20default_params%2C%20dt0%2C%20models%2C%20n_points%2C%20t0%2C%20t1%2C%20ts%0A%0A%0A%40app.cell%0Adef%20_(models)%3A%0A%20%20%20%20model_picker%20%3D%20mo.ui.dropdown(models.keys()%2C%20value%3D%22model1%22)%0A%20%20%20%20return%20(model_picker%2C)%0A%0A%0A%40app.cell%0Adef%20_(model_picker%2C%20models)%3A%0A%20%20%20%20configuration%20%3D%20models%5Bmodel_picker.value%5D%0A%20%20%20%20term%20%3D%20ODETerm(configuration%5B%22eq%22%5D)%0A%20%20%20%20model_picker%0A%20%20%20%20return%20configuration%2C%20term%0A%0A%0A%40app.cell%0Adef%20_(configuration%2C%20default_params%2C%20dt0%2C%20t0%2C%20t1%2C%20term%2C%20ts)%3A%0A%20%20%20%20%23%20default_params%20%3D%20%7B'r0'%3A%20jnp.logspace(-1.0%2C%200.0%2C%20n_droplets)%2C%20'rh0'%3A%20jnp.full((n_droplets%2C)%2C%200.1)%2C%20'x0'%3A%200.01%2C%20'k_r'%3A%200.1%2C%20'N'%3A%202.0%7D%0A%0A%20%20%20%20solution%20%3D%20diffeqsolve(%0A%20%20%20%20%20%20%20%20term%2C%0A%20%20%20%20%20%20%20%20Dopri5()%2C%0A%20%20%20%20%20%20%20%20t0%3Dt0%2C%0A%20%20%20%20%20%20%20%20dt0%3Ddt0%2C%0A%20%20%20%20%20%20%20%20saveat%3DSaveAt(ts%3Dts)%2C%0A%20%20%20%20%20%20%20%20t1%3Dt1%2C%0A%20%20%20%20%20%20%20%20y0%3Dtuple(default_params%5Bk%5D%20for%20k%20in%20configuration%5B%22y%22%5D)%2C%0A%20%20%20%20%20%20%20%20args%3Ddefault_params%2C%0A%20%20%20%20)%0A%20%20%20%20return%20(solution%2C)%0A%0A%0A%40app.cell%0Adef%20_(solution%2C%20ts)%3A%0A%20%20%20%20plt.plot(ts%2C%20solution.ys%5B0%5D%2C%20c%3D%22b%22%2C%20alpha%3D0.2)%5B0%5D.set_label(%22Radius%22)%0A%20%20%20%20plt.plot(ts%2C%20solution.ys%5B1%5D%2C%20c%3D%22r%22%2C%20label%3D%22Vapour%20pressure%22)%0A%20%20%20%20plt.legend()%0A%20%20%20%20plt.gca().set(xlabel%3D%22Time%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20rdists%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22Unimodal%22%3A%20dist.LogNormal(scale%3D0.5)%2C%0A%20%20%20%20%20%20%20%20%22Bimodal%22%3A%20dist.MixtureSameFamily(%0A%20%20%20%20%20%20%20%20%20%20%20%20component_distribution%3Ddist.LogNormal(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20scale%3Djnp.array(%5B0.25%2C%200.1%5D)%2C%20loc%3Djnp.array(%5B0.0%2C%201.5%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mixing_distribution%3Ddist.Categorical(probs%3Djnp.array(%5B0.8%2C%200.2%5D))%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%7D%0A%0A%20%20%20%20rdist_select%20%3D%20mo.ui.dropdown(rdists%2C%20value%3D%22Unimodal%22%2C%20label%3D%22Initial%20droplet%20distribution%22)%0A%20%20%20%20rdist_select%0A%20%20%20%20return%20(rdist_select%2C)%0A%0A%0A%40app.cell%0Adef%20_(default_params%2C%20dt0%2C%20rdist_select%2C%20t0%2C%20t1%2C%20term%2C%20ts)%3A%0A%20%20%20%20def%20model(n_droplets%3D30)%3A%0A%20%20%20%20%20%20%20%20r0%20%3D%20sample(%22r0%22%2C%20rdist_select.value%2C%20sample_shape%3D(n_droplets%2C))%0A%20%20%20%20%20%20%20%20p0%20%3D%20default_params%5B%22p0%22%5D%0A%0A%20%20%20%20%20%20%20%20r%2C%20p%20%3D%20diffeqsolve(%0A%20%20%20%20%20%20%20%20%20%20%20%20term%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20Dopri5()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20t0%3Dt0%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20dt0%3Ddt0%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20saveat%3DSaveAt(ts%3Dts)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20t1%3Dt1%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y0%3D(r0%2C%20p0)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20args%3D%7B**default_params%2C%20%22r0%22%3A%20r0%7D%2C%0A%20%20%20%20%20%20%20%20).ys%0A%20%20%20%20%20%20%20%20deterministic(%22r%22%2C%20r)%0A%20%20%20%20%20%20%20%20deterministic(%22p%22%2C%20p)%0A%20%20%20%20return%20(model%2C)%0A%0A%0A%40app.cell%0Adef%20_(model)%3A%0A%20%20%20%20result%20%3D%20infer(model%2C%20())%0A%20%20%20%20return%20(result%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(n_points%2C%20result)%3A%0A%20%20%20%20result_type%20%3D%20mo.ui.dropdown(%0A%20%20%20%20%20%20%20%20%7B%22MCMC%22%3A%20%22mcmc_samples%22%2C%20%22SVI%22%3A%20%22svi_samples%22%7D%2C%0A%20%20%20%20%20%20%20%20value%3D%22MCMC%22%2C%0A%20%20%20%20%20%20%20%20label%3D%22Result%20type%22%2C%0A%20%20%20%20)%0A%0A%20%20%20%20sample_no%20%3D%20mo.ui.slider(%0A%20%20%20%20%20%20%20%20start%3D0%2C%20stop%3Dresult%5B%22mcmc_samples%22%5D%5B%22r%22%5D.shape%5B0%5D%2C%20label%3D%22Sample%20number%22%0A%20%20%20%20)%0A%0A%20%20%20%20t_slider%20%3D%20mo.ui.slider(%0A%20%20%20%20%20%20%20%200%2C%20n_points%20-%201%2C%20debounce%3DTrue%2C%20label%3D%22Time%20step%22%2C%20value%3Dn_points%20%2F%2F%202%0A%20%20%20%20)%0A%0A%20%20%20%20result_type%0A%20%20%20%20return%20result_type%2C%20sample_no%2C%20t_slider%0A%0A%0A%40app.cell%0Adef%20_(result%2C%20result_type%2C%20sample_no%2C%20ts)%3A%0A%20%20%20%20res%20%3D%20result%5Bresult_type.value%5D%0A%0A%20%20%20%20plt.plot(ts%2C%20res%5B%22r%22%5D%5Bsample_no.value%5D%2C%20c%3D%22b%22%2C%20alpha%3D0.2)%5B%0A%20%20%20%20%20%20%20%200%0A%20%20%20%20%5D.set_label(%22Radius%22)%0A%20%20%20%20plt.plot(%0A%20%20%20%20%20%20%20%20ts%2C%0A%20%20%20%20%20%20%20%20res%5B%22p%22%5D%5Bsample_no.value%5D%2C%0A%20%20%20%20%20%20%20%20c%3D%22r%22%2C%0A%20%20%20%20%20%20%20%20label%3D%22Vapour%20pressure%22%2C%0A%20%20%20%20)%0A%20%20%20%20plt.legend()%0A%20%20%20%20mo.vstack(%5Bsample_no%2C%20plt.gcf()%5D)%0A%20%20%20%20return%20(res%2C)%0A%0A%0A%40app.cell%0Adef%20_(res%2C%20t_slider)%3A%0A%20%20%20%20sns.kdeplot(res%5B%22r%22%5D%5B%3A%2C%20t_slider.value%2C%20%3A%5D.ravel()%2C%20fill%3DTrue%2C%20log_scale%3DTrue)%0A%20%20%20%20plt.gca().set(xlabel%3D%22Droplet%20radius%22)%0A%20%20%20%20mo.vstack(%5Bt_slider%2C%20plt.gcf()%5D)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
70c0e2260cf8cc1179e1c957048bd1dc