import%20marimo%0A%0A__generated_with%20%3D%20%220.23.16%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0Aasync%20with%20app.setup(hide_code%3DTrue)%3A%0A%20%20%20%20%23%20Setup%20cell%20for%20marimo%20notebook%2C%20can%20be%20ignored%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20sys%0A%0A%20%20%20%20%23%20Import%20packages%20if%20running%20on%20marimo%20playground%0A%20%20%20%20if%20sys.executable%20%3D%3D%20%22%2Fhome%2Fpyodide%2Fthis.program%22%3A%0A%20%20%20%20%20%20%20%20import%20micropip%0A%0A%20%20%20%20%20%20%20%20await%20micropip.install(%0A%20%20%20%20%20%20%20%20%20%20%20%20%5B%22pint_pandas%3C%3D0.7%22%2C%20%22typing_extensions%3E%3D4.15.0%22%2C%20%22jablonski%3E%3D0.5.0%22%2C%20%22matplotlib%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20verbose%3DFalse%2C%0A%20%20%20%20%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%20Emission%2C%20absorption%20and%20quantum%20yield%0A%20%20%20%20Besides%20the%20populations%20of%20each%20level%2C%20Jablonski%20can%20compute%20the%20observables%20from%20spectroscopy%20experiments%3A%20emitted%20and%20absorbed%20photons%20over%20time%2C%20steady-state%20spectra%20and%20quantum%20yields.%20This%20notebook%20goes%20through%20these%20tools.%20If%20you%20are%20new%20to%20Jablonski%20start%20with%20%5BGetting%20Started%20with%20Jablonski%5D(https%3A%2F%2Fdyscolab.github.io%2Fstatic_notebooks%2Fgetting_started_with_jablonski.html).%0A%0A%20%20%20%20As%20an%20example%20system%20we%20use%20a%20simplified%20model%20of%20ruthenium%20tris(bipyridine)%20(https%3A%2F%2Fdoi.org%2F10.1016%2Fj.ccr.2020.213758)%2C%20with%20two%20absorptions%3A%20one%20into%20the%20singlet%20metal-to-ligand%20charge%20transfer%20state%20(MLCT)%2C%20and%20one%20into%20a%20higher%20ligand-centred%20state%20(LC)%2C%20which%20quickly%20relaxes%20to%20the%20MLCT.%20The%20singlet%20MLCT%20fluoresces%20weakly%20and%20crosses%20to%20the%20triplet%20MLCT%2C%20which%20phosphoresces.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20pint%0A%0A%20%20%20%20from%20jablonski%20import%20Simulator%2C%20SingletState%2C%20SpectroscopicSystem%2C%20TripletState%2C%20initial%0A%20%20%20%20from%20jablonski.plots%20import%20notebook_report%0A%20%20%20%20from%20jablonski.transitions%20import%20(%0A%20%20%20%20%20%20%20%20Absorption%2C%0A%20%20%20%20%20%20%20%20Fluorescence%2C%0A%20%20%20%20%20%20%20%20InternalConversion%2C%0A%20%20%20%20%20%20%20%20IntersystemCrossing%2C%0A%20%20%20%20%20%20%20%20Phosphorescence%2C%0A%20%20%20%20%20%20%20%20ReverseIntersystemCrossing%2C%0A%20%20%20%20)%0A%0A%20%20%20%20u%20%3D%20pint.get_application_registry()%0A%0A%20%20%20%20class%20Ruthenium(SpectroscopicSystem)%3A%0A%20%20%20%20%20%20%20%20ground%3A%20SingletState%20%3D%20initial(0%20*%20u.eV%2C%20%22singlet%22%2C%20default%3D10)%0A%20%20%20%20%20%20%20%20MLCT_3%3A%20TripletState%20%3D%20initial(2.12%20*%20u.eV%2C%20%22triplet%22%2C%20default%3D0)%0A%20%20%20%20%20%20%20%20MLCT_1%3A%20SingletState%20%3D%20initial(2.74%20*%20u.eV%2C%20default%3D0)%0A%20%20%20%20%20%20%20%20LC%3A%20SingletState%20%3D%20initial(4.3%20*%20u.eV%2C%20default%3D0)%0A%0A%20%20%20%20%20%20%20%20abs%20%3D%20Absorption(ground%3Dground%2C%20excited%3DMLCT_1%2C%20rate%3D5.6e-17%20*%20u.cm**2)%0A%20%20%20%20%20%20%20%20abs_LC%20%3D%20Absorption(ground%3Dground%2C%20excited%3DLC%2C%20rate%3D3e-16%20*%20u.cm**2)%0A%20%20%20%20%20%20%20%20ic%20%3D%20InternalConversion(high%3DLC%2C%20low%3DMLCT_1%2C%20rate%3D1%20%2F%20(100%20*%20u.fs))%0A%20%20%20%20%20%20%20%20fl%20%3D%20Fluorescence(excited%3DMLCT_1%2C%20ground%3Dground%2C%20rate%3D1e8%20%2F%20u.s)%0A%20%20%20%20%20%20%20%20isc%20%3D%20IntersystemCrossing(source%3DMLCT_1%2C%20target%3DMLCT_3%2C%20rate%3D1%20%2F%20(1%20*%20u.ps))%0A%20%20%20%20%20%20%20%20ph%20%3D%20Phosphorescence(excited%3DMLCT_3%2C%20ground%3Dground%2C%20rate%3D1%20%2F%20(0.6%20*%20u.us)%20*%200.04)%0A%20%20%20%20%20%20%20%20risc%20%3D%20ReverseIntersystemCrossing(%0A%20%20%20%20%20%20%20%20%20%20%20%20source%3DMLCT_3%2C%20target%3Dground%2C%20rate%3D1%20%2F%20(0.6%20*%20u.us)%20*%200.96%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20sim%20%3D%20Simulator(Ruthenium)%0A%20%20%20%20notebook_report(Ruthenium)%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20Absorption%2C%0A%20%20%20%20%20%20%20%20Fluorescence%2C%0A%20%20%20%20%20%20%20%20IntersystemCrossing%2C%0A%20%20%20%20%20%20%20%20Phosphorescence%2C%0A%20%20%20%20%20%20%20%20ReverseIntersystemCrossing%2C%0A%20%20%20%20%20%20%20%20Ruthenium%2C%0A%20%20%20%20%20%20%20%20Simulator%2C%0A%20%20%20%20%20%20%20%20SingletState%2C%0A%20%20%20%20%20%20%20%20SpectroscopicSystem%2C%0A%20%20%20%20%20%20%20%20TripletState%2C%0A%20%20%20%20%20%20%20%20initial%2C%0A%20%20%20%20%20%20%20%20notebook_report%2C%0A%20%20%20%20%20%20%20%20np%2C%0A%20%20%20%20%20%20%20%20plt%2C%0A%20%20%20%20%20%20%20%20sim%2C%0A%20%20%20%20%20%20%20%20u%2C%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%23%20Excitation%0A%20%20%20%20Every%20simulation%20function%20takes%20an%20excitation%3A%20how%20many%20photons%20reach%20each%20absorption.%20The%20pump%20of%20an%20absorption%20is%20a%20photon%20flux%2C%20in%20units%20of%20%241%2F(%5Ctext%7Bdistance%7D%5E2%20%5Ccdot%20%5Ctext%7Btime%7D)%24.%0A%0A%20%20%20%20Steady-state%20functions%20take%20a%20dictionary%20mapping%20each%20absorption%20to%20its%20pump%2C%20for%20continuous%20excitation%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(Ruthenium%2C%20u)%3A%0A%20%20%20%20cw%20%3D%20%7BRuthenium.abs%3A%201e23%20%2F%20(u.cm**2%20*%20u.s)%7D%0A%20%20%20%20return%20(cw%2C)%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%20Time-resolved%20functions%20take%20events%3A%20a%20dictionary%20mapping%20times%20to%20the%20pumps%20that%20change%20at%20that%20time.%20They%20are%20built%20with%20excitation%20creators%20from%20%60jablonski.simulation%60%3A%0A%0A%20%20%20%20-%20%60step_excitation(excitation%2C%20start%3D0%20s)%60%20turns%20the%20pumps%20on%20at%20%60start%60%20and%20leaves%20them%20on.%0A%20%20%20%20-%20%60pulse_excitation(excitation%2C%20width%2C%20start%3D0%20s)%60%20turns%20them%20on%20at%20%60start%60%20and%20off%20after%20%60width%60.%0A%20%20%20%20-%20%60delta_excitation(absorption%2C%20area%2C%20start%3D0%20s)%60%20approximates%20a%20%24%5Cdelta%24%20pulse%20with%20a%20total%20photon%20fluence%20%60area%60%20(photons%20per%20area)%2C%20as%20a%2050%20ps%20pulse.%0A%0A%20%20%20%20Events%20from%20different%20creators%20can%20be%20merged%20with%20%60%7C%60.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(Ruthenium%2C%20u)%3A%0A%20%20%20%20from%20jablonski.simulation%20import%20delta_excitation%2C%20pulse_excitation%2C%20step_excitation%0A%0A%20%20%20%20step%20%3D%20step_excitation(%7BRuthenium.abs%3A%201e23%20%2F%20(u.cm**2%20*%20u.s)%7D%2C%20start%3D1%20*%20u.us)%0A%20%20%20%20pulse%20%3D%20pulse_excitation(%7BRuthenium.abs%3A%201e23%20%2F%20(u.cm**2%20*%20u.s)%7D%2C%20width%3D2%20*%20u.us)%0A%20%20%20%20delta%20%3D%20delta_excitation(Ruthenium.abs%2C%20area%3D1e17%20%2F%20u.cm**2)%0A%20%20%20%20pulse%0A%20%20%20%20return%20delta%2C%20pulse%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%20Time-resolved%20simulations%0A%20%20%20%20Time-resolved%20functions%20take%20the%20times%20to%20save%20at%20from%20the%20simulator%2C%20set%20with%20%60with_times(save_at%3D...)%60%20(simulation%20times%20are%20also%20controlled%20by%20%60t_span%60%2C%20for%20the%20difference%20between%20%60save_at%60%20and%20%60t_span%60%2C%20see%20%5BSimulation%5D(https%3A%2F%2Fdyscolab.github.io%2Fstatic_notebooks%2Fsimulation.html)).%20%60piecewise(sim%2C%20events)%60%20simulates%20the%20populations%20of%20each%20level.%20It%20splits%20the%20simulation%20at%20every%20event%20and%20integrates%20from%20the%20first%20to%20the%20last%20time%20of%20%60save_at%60.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(np%2C%20plt%2C%20pulse%2C%20sim%2C%20u)%3A%0A%20%20%20%20from%20jablonski.simulation%20import%20piecewise%0A%0A%20%20%20%20timed_sim%20%3D%20sim.with_times(save_at%3Dnp.linspace(0%2C%205%2C%20200)%20*%20u.us)%0A%20%20%20%20populations%20%3D%20piecewise(timed_sim%2C%20events%3Dpulse)%0A%20%20%20%20populations%5B%5B%22MLCT_3%22%5D%5D.pint.dequantify().to_dataframe().plot()%0A%20%20%20%20plt.show()%0A%20%20%20%20return%20(timed_sim%2C)%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%20Usually%20we%20are%20interested%20in%20the%20light%20instead.%20%60spectral_time_resolved(sim%2C%20excitation)%60%20gives%20the%20photon%20rate%20of%20every%20radiative%20transition%2C%20one%20variable%20per%20line%20named%20%60emission_%3Ctransition%3E%60%20(here%20%60emission_fl%60%20and%20%60emission_ph%60).%20The%20energy%20of%20each%20line%20is%20stored%20in%20the%20attributes%20of%20the%20result.%0A%0A%20%20%20%20Results%20are%20photon%20rates%2C%20in%20photons%20per%20second.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plt%2C%20pulse%2C%20timed_sim)%3A%0A%20%20%20%20from%20jablonski.simulation%20import%20spectral_time_resolved%0A%0A%20%20%20%20lines%20%3D%20spectral_time_resolved(timed_sim%2C%20pulse)%0A%20%20%20%20lines.pint.dequantify().to_dataframe().plot()%0A%20%20%20%20plt.yscale(%22log%22)%0A%20%20%20%20plt.ylim(1%2C%20None)%0A%20%20%20%20plt.ylabel(%22Emission%20%5Bphotons%20%2F%20s%5D%22)%0A%20%20%20%20plt.show()%0A%20%20%20%20lines.attrs%0A%20%20%20%20return%20(spectral_time_resolved%2C)%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%20With%20%60join_by_energy%3DTrue%60%20lines%20with%20the%20same%20energy%20are%20summed%2C%20and%20named%20by%20their%20energy.%20%60time_resolved(sim%2C%20excitation)%60%20sums%20all%20lines%20into%20a%20single%20%60emission%60%20variable%2C%20for%20example%20the%20decay%20after%20a%20%24%5Cdelta%24%20pulse%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(delta%2C%20np%2C%20plt%2C%20sim%2C%20u)%3A%0A%20%20%20%20from%20jablonski.simulation%20import%20time_resolved%0A%0A%20%20%20%20decay_sim%20%3D%20sim.with_times(save_at%3Dnp.linspace(0%2C%203%2C%20200)%20*%20u.us)%0A%20%20%20%20decay%20%3D%20time_resolved(decay_sim%2C%20delta)%0A%20%20%20%20decay.pint.dequantify().to_dataframe().plot()%0A%20%20%20%20plt.yscale(%22log%22)%0A%20%20%20%20plt.ylabel(%22Emission%20%5Bphotons%20%2F%20s%5D%22)%0A%20%20%20%20plt.show()%0A%20%20%20%20return%20(time_resolved%2C)%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%20Steady-state%20simulations%0A%20%20%20%20Under%20continuous%20excitation%20the%20populations%20reach%20a%20steady%20state.%20%60spectral_steady_state(sim%2C%20excitation)%60%20gives%20the%20photon%20rate%20of%20each%20line%20at%20that%20point%2C%20with%20the%20same%20names%20and%20attributes%20as%20%60spectral_time_resolved%60%2C%20and%20%60steady_state(sim%2C%20excitation)%60%20gives%20the%20total.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(cw%2C%20sim)%3A%0A%20%20%20%20from%20jablonski.simulation%20import%20spectral_steady_state%2C%20steady_state%0A%0A%20%20%20%20spectral_steady_state(sim%2C%20cw)%0A%20%20%20%20return%20spectral_steady_state%2C%20steady_state%0A%0A%0A%40app.cell%0Adef%20_(cw%2C%20sim%2C%20steady_state)%3A%0A%20%20%20%20steady_state(sim%2C%20cw)%5B%22emission%22%5D.data%0A%20%20%20%20return%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%20Choosing%20what%20to%20compute%0A%20%20%20%20All%20these%20functions%20take%20a%20%60kind%60%20argument%20which%20selects%20the%20transitions%3A%0A%0A%20%20%20%20-%20%60%22emission%22%60%20(default)%3A%20every%20radiative%20transition.%0A%20%20%20%20-%20%60%22fluorescence%22%60%20or%20%60%22phosphorescence%22%60%3A%20only%20that%20process.%0A%20%20%20%20-%20%60%22absorption%22%60%3A%20the%20rate%20of%20absorbed%20photons%20of%20every%20absorption%2C%20named%20%60absorption_%3Ctransition%3E%60.%0A%20%20%20%20-%20a%20list%20of%20them%2C%20such%20as%20%60%5B%22absorption%22%2C%20%22fluorescence%22%5D%60.%0A%0A%20%20%20%20For%20example%2C%20only%20the%20phosphorescence%20over%20time%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(pulse%2C%20spectral_time_resolved%2C%20timed_sim)%3A%0A%20%20%20%20spectral_time_resolved(timed_sim%2C%20pulse%2C%20kind%3D%22phosphorescence%22)%0A%20%20%20%20return%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%20With%20%60kind%3D%22absorption%22%60%2C%20%60time_resolved%60%20and%20%60steady_state%60%20return%20the%20total%20absorbed%20photons%20as%20an%20%60absorption%60%20variable%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(plt%2C%20pulse%2C%20time_resolved%2C%20timed_sim)%3A%0A%20%20%20%20absorbed%20%3D%20time_resolved(timed_sim%2C%20pulse%2C%20kind%3D%22absorption%22)%0A%20%20%20%20absorbed.pint.dequantify().to_dataframe().plot()%0A%20%20%20%20plt.ylabel(%22Absorption%20%5Bphotons%20%2F%20s%5D%22)%0A%20%20%20%20plt.show()%0A%20%20%20%20return%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%20To%20get%20several%20kinds%20side%20by%20side%20use%20a%20list%20with%20the%20spectral%20functions%2C%20which%20keep%20each%20line%20separate%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(cw%2C%20sim%2C%20spectral_steady_state)%3A%0A%20%20%20%20spectral_steady_state(sim%2C%20cw%2C%20kind%3D%5B%22absorption%22%2C%20%22fluorescence%22%2C%20%22phosphorescence%22%5D)%0A%20%20%20%20return%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%20Spectra%0A%20%20%20%20%60spectra(sim%2C%20excitation%2C%20unit%3Du.nm)%60%20gives%20the%20steady-state%20lines%20as%20a%20spectrum%20indexed%20by%20wavelength%20(or%20any%20other%20spectroscopic%20%60unit%60%2C%20such%20as%20%60u.eV%60%20or%20%601%20%2F%20u.cm%60).%20Lines%20with%20the%20same%20energy%20are%20summed.%20Values%20are%20photon%20rates%2C%20as%20above.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(cw%2C%20sim)%3A%0A%20%20%20%20from%20jablonski.simulation%20import%20spectra%0A%0A%20%20%20%20spectra(sim%2C%20cw)%0A%20%20%20%20return%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%20Jablonski%20lines%20have%20no%20width%2C%20so%20to%20plot%20something%20closer%20to%20a%20measured%20spectrum%20%60widened_spectra%60%20broadens%20each%20line%20into%20a%20gaussian%20of%20standard%20deviation%20%60width%60%20(in%20%60unit%60)%20and%20evaluates%20it%20at%20%60samples%60.%20%60kind%60%20works%20as%20before%3B%20here%20we%20show%20fluorescence%20and%20phosphorescence%20separately.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(cw%2C%20np%2C%20plt%2C%20sim%2C%20u)%3A%0A%20%20%20%20from%20jablonski.simulation%20import%20widened_spectra%0A%0A%20%20%20%20samples%20%3D%20np.linspace(400%2C%20700%2C%201000)%20*%20u.nm%0A%20%20%20%20for%20kind%20in%20%5B%22fluorescence%22%2C%20%22phosphorescence%22%5D%3A%0A%20%20%20%20%20%20%20%20widened%20%3D%20widened_spectra(sim%2C%20cw%2C%20kind%3Dkind%2C%20samples%3Dsamples%2C%20width%3D10)%0A%20%20%20%20%20%20%20%20widened.pint.dequantify().plot(label%3Dkind)%0A%20%20%20%20plt.yscale(%22log%22)%0A%20%20%20%20plt.ylim(1e-1%2C%201e7)%0A%20%20%20%20plt.ylabel(%22Emission%20%5Bphotons%20%2F%20s%5D%22)%0A%20%20%20%20plt.legend()%0A%20%20%20%20plt.show()%0A%20%20%20%20return%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%60jablonski.plots.graph_spectra%60%20takes%20the%20same%20arguments%20and%20plots%20the%20widened%20spectrum%20as%20a%20line%20coloured%20by%20wavelength.%0A%0A%20%20%20%20%23%23%23%20Excitation%20spectra%0A%20%20%20%20%60excitation_emission_matrix(sim%2C%20height)%60%20pumps%20each%20absorption%20in%20turn%20with%20the%20photon%20flux%20%60height%60%20and%20gives%20the%20emission%20spectrum%20for%20each%2C%20one%20variable%20per%20absorption.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(sim%2C%20u)%3A%0A%20%20%20%20from%20jablonski.simulation%20import%20excitation_emission_matrix%2C%20excitation_spectra%0A%0A%20%20%20%20flux%20%3D%201e23%20%2F%20(u.cm**2%20*%20u.s)%0A%20%20%20%20excitation_emission_matrix(sim%2C%20flux)%0A%20%20%20%20return%20excitation_spectra%2C%20flux%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%60excitation_spectra(sim%2C%20emission%2C%20height)%60%20takes%20one%20emission%20wavelength%20of%20that%20matrix%20(the%20nearest%20line%20to%20%60emission%60)%2C%20giving%20the%20emission%20at%20that%20wavelength%20for%20each%20absorption.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(excitation_spectra%2C%20flux%2C%20sim%2C%20u)%3A%0A%20%20%20%20excitation_spectra(sim%2C%20emission%3D585%20*%20u.nm%2C%20height%3Dflux)%0A%20%20%20%20return%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%20Quantum%20yield%0A%20%20%20%20The%20quantum%20yield%20is%20the%20number%20of%20emitted%20photons%20per%20absorbed%20photon.%20%60quantum_yield(sim%2C%20excitation)%60%20computes%20it%20at%20steady%20state%2C%20and%20%60kind%60%20selects%20which%20emissions%20count%20(%60%22emission%22%60%2C%20%60%22fluorescence%22%60%20or%20%60%22phosphorescence%22%60).%20For%20this%20model%20the%20yield%20is%20set%20by%20the%20phosphorescence%2C%20about%204%25%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(cw%2C%20sim)%3A%0A%20%20%20%20from%20jablonski.simulation%20import%20quantum_yield%2C%20spectral_quantum_yield%0A%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20kind%3A%20quantum_yield(sim%2C%20cw%2C%20kind%3Dkind).pint.to(%22percent%22).data.item()%0A%20%20%20%20%20%20%20%20for%20kind%20in%20%5B%22emission%22%2C%20%22fluorescence%22%2C%20%22phosphorescence%22%5D%0A%20%20%20%20%7D%0A%20%20%20%20return%20(spectral_quantum_yield%2C)%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%60spectral_quantum_yield(sim%2C%20excitation)%60%20splits%20it%20by%20emission%20wavelength%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(cw%2C%20sim%2C%20spectral_quantum_yield)%3A%0A%20%20%20%20spectral_quantum_yield(sim%2C%20cw)%0A%20%20%20%20return%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%20In%20this%20model%20every%20transition%20is%20linear%20in%20the%20populations%2C%20so%20the%20quantum%20yield%20doesn't%20depend%20on%20how%20hard%20we%20pump.%20That%20is%20not%20true%20when%20two%20excited%20molecules%20interact%2C%20as%20in%20triplet-triplet%20annihilation%20upconversion.%20There%20light%20is%20absorbed%20by%20a%20sensitizer%2C%20which%20quickly%20crosses%20to%20its%20triplet%20%24T_1%24.%20The%20sensitizer%20can't%20emit%20at%20higher%20energy%20on%20its%20own%3B%20instead%20it%20hands%20its%20triplet%20to%20a%20second%20molecule%2C%20the%20annihilator%2C%20and%20returns%20to%20its%20ground%20state%3A%0A%0A%20%20%20%20%24%24%5Ctext%7Bsens.T1%7D%20%2B%20%5Ctext%7Bann.S0%7D%20%5Crightarrow%20%5Ctext%7Bsens.S0%7D%20%2B%20%5Ctext%7Bann.T1%7D.%24%24%0A%0A%20%20%20%20This%20triplet%20energy%20transfer%20is%20modelled%20with%20%60EnergyTransferUpconversion%60%2C%20which%20describes%20any%20energy%20transfer%20from%20an%20excited%20molecule%20(%60sensitizer_high%60%20%E2%86%92%20%60sensitizer_low%60)%20to%20another%20one%20(%60activator_low%60%20%E2%86%92%20%60activator_high%60)%2C%20with%20a%20rate%20proportional%20to%20%60sens.T1%20*%20ann.S0%60.%0A%0A%20%20%20%20The%20annihilator%20triplets%20are%20long-lived%2C%20so%20they%20accumulate.%20When%20two%20of%20them%20meet%20they%20annihilate%3A%20one%20goes%20back%20to%20the%20ground%20state%20and%20gives%20its%20energy%20to%20the%20other%2C%20which%20ends%20up%20in%20the%20excited%20singlet%20%24S_1%24%3A%0A%0A%20%20%20%20%24%24%5Ctext%7Bann.T1%7D%20%2B%20%5Ctext%7Bann.T1%7D%20%5Crightarrow%20%5Ctext%7Bann.S1%7D%20%2B%20%5Ctext%7Bann.S0%7D.%24%24%0A%0A%20%20%20%20This%20step%20is%20modelled%20with%20%60TripletTripletAnnihilation%60%2C%20here%20passing%20the%20same%20triplet%20twice%2C%20and%20its%20rate%20is%20proportional%20to%20%60ann.T1%20*%20ann.T1%60.%20The%20annihilator%20%24S_1%24%20(3.0%20eV)%20lies%20above%20the%20energy%20of%20the%20absorbed%20photons%20(2.3%20eV)%2C%20so%20its%20fluorescence%20is%20upconverted.%20Since%20two%20triplets%20are%20needed%20for%20each%20upconverted%20photon%2C%20the%20upconversion%20depends%20nonlinearly%20on%20the%20excitation.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20Absorption%2C%0A%20%20%20%20Fluorescence%2C%0A%20%20%20%20IntersystemCrossing%2C%0A%20%20%20%20ReverseIntersystemCrossing%2C%0A%20%20%20%20SingletState%2C%0A%20%20%20%20SpectroscopicSystem%2C%0A%20%20%20%20TripletState%2C%0A%20%20%20%20initial%2C%0A%20%20%20%20u%2C%0A)%3A%0A%20%20%20%20from%20jablonski.transitions%20import%20(%0A%20%20%20%20%20%20%20%20EnergyTransferUpconversion%2C%0A%20%20%20%20%20%20%20%20TripletTripletAnnihilation%2C%0A%20%20%20%20)%0A%0A%20%20%20%20class%20Sensitizer(SpectroscopicSystem)%3A%0A%20%20%20%20%20%20%20%20S0%3A%20SingletState%20%3D%20initial(0%20*%20u.eV%2C%20default%3D1)%0A%20%20%20%20%20%20%20%20S1%3A%20SingletState%20%3D%20initial(2.3%20*%20u.eV%2C%20default%3D0)%0A%20%20%20%20%20%20%20%20T1%3A%20TripletState%20%3D%20initial(1.9%20*%20u.eV%2C%20%22triplet%22%2C%20default%3D0)%0A%0A%20%20%20%20%20%20%20%20abs%20%3D%20Absorption(ground%3DS0%2C%20excited%3DS1%2C%20rate%3D1e-16%20*%20u.cm**2)%0A%20%20%20%20%20%20%20%20isc%20%3D%20IntersystemCrossing(source%3DS1%2C%20target%3DT1%2C%20rate%3D1e10%20%2F%20u.s)%0A%20%20%20%20%20%20%20%20decay%20%3D%20ReverseIntersystemCrossing(source%3DT1%2C%20target%3DS0%2C%20rate%3D1e4%20%2F%20u.s)%0A%0A%20%20%20%20class%20Annihilator(SpectroscopicSystem)%3A%0A%20%20%20%20%20%20%20%20S0%3A%20SingletState%20%3D%20initial(0%20*%20u.eV%2C%20default%3D10)%0A%20%20%20%20%20%20%20%20S1%3A%20SingletState%20%3D%20initial(3.0%20*%20u.eV%2C%20default%3D0)%0A%20%20%20%20%20%20%20%20T1%3A%20TripletState%20%3D%20initial(1.8%20*%20u.eV%2C%20%22triplet%22%2C%20default%3D0)%0A%0A%20%20%20%20%20%20%20%20fl%20%3D%20Fluorescence(excited%3DS1%2C%20ground%3DS0%2C%20rate%3D1e8%20%2F%20u.s)%0A%20%20%20%20%20%20%20%20decay%20%3D%20ReverseIntersystemCrossing(source%3DT1%2C%20target%3DS0%2C%20rate%3D1e3%20%2F%20u.s)%0A%0A%20%20%20%20class%20Upconversion(SpectroscopicSystem)%3A%0A%20%20%20%20%20%20%20%20sens%20%3D%20Sensitizer()%0A%20%20%20%20%20%20%20%20ann%20%3D%20Annihilator()%0A%0A%20%20%20%20%20%20%20%20%23%20Triplet%20energy%20transfer%3A%20sens.T1%20%2B%20ann.S0%20-%3E%20sens.S0%20%2B%20ann.T1%0A%20%20%20%20%20%20%20%20tet%20%3D%20EnergyTransferUpconversion(%0A%20%20%20%20%20%20%20%20%20%20%20%20sensitizer_high%3Dsens.T1%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20sensitizer_low%3Dsens.S0%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20activator_low%3Dann.S0%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20activator_high%3Dann.T1%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20rate%3D1e5%20%2F%20u.s%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%23%20Triplet-triplet%20annihilation%3A%20ann.T1%20%2B%20ann.T1%20-%3E%20ann.S1%20%2B%20ann.S0%0A%20%20%20%20%20%20%20%20tta%20%3D%20TripletTripletAnnihilation(%0A%20%20%20%20%20%20%20%20%20%20%20%20triplet_1%3Dann.T1%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20triplet_2%3Dann.T1%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20singlet_1%3Dann.S1%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20singlet_2%3Dann.S0%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20rate%3D1e4%20%2F%20u.s%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20return%20(Upconversion%2C)%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%60sweeps.sweep_quantum_yield(sim%2C%20excitations)%60%20computes%20the%20quantum%20yield%20for%20a%20list%20of%20excitations.%20If%20each%20excitation%20pumps%20a%20single%20absorption%20the%20result%20is%20indexed%20by%20the%20pump%2C%20otherwise%20pass%20%60keys%60.%20At%20low%20flux%20most%20annihilator%20triplets%20decay%20on%20their%20own%2C%20and%20the%20upconverted%20fluorescence%20grows%20with%20the%20square%20of%20the%20excitation%2C%20so%20its%20yield%20grows%20with%20the%20flux.%20At%20high%20flux%20annihilation%20dominates%20and%20the%20yield%20approaches%200.5%2C%20since%20two%20absorbed%20photons%20are%20needed%20for%20each%20upconverted%20one%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(Simulator%2C%20Upconversion%2C%20np%2C%20plt%2C%20u)%3A%0A%20%20%20%20from%20jablonski.sweeps%20import%20sweep_quantum_yield%0A%0A%20%20%20%20fluxes%20%3D%20np.logspace(15%2C%2023%2C%2030)%20%2F%20(u.cm**2%20*%20u.s)%0A%20%20%20%20yields%20%3D%20sweep_quantum_yield(%0A%20%20%20%20%20%20%20%20Simulator(Upconversion)%2C%0A%20%20%20%20%20%20%20%20excitations%3D%5B%7BUpconversion.sens.abs%3A%20flux%7D%20for%20flux%20in%20fluxes%5D%2C%0A%20%20%20%20%20%20%20%20kind%3D%22fluorescence%22%2C%0A%20%20%20%20)%0A%20%20%20%20yields.pint.dequantify().plot()%0A%20%20%20%20plt.xscale(%22log%22)%0A%20%20%20%20plt.ylabel(%22Upconversion%20quantum%20yield%22)%0A%20%20%20%20plt.show()%0A%20%20%20%20return%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%60sweeps.sweep_spectra%60%20and%20%60sweeps.sweep_spectral_steady_state%60%20sweep%20spectra%20and%20steady-state%20lines%20in%20the%20same%20way%20(see%20%5BGetting%20Started%20with%20Jablonski%5D(https%3A%2F%2Fdyscolab.github.io%2Fstatic_notebooks%2Fgetting_started_with_jablonski.html)%20for%20an%20example).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%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%20Constant%20ground%20states%0A%20%20%20%20Under%20weak%20excitation%20only%20a%20tiny%20fraction%20of%20the%20molecules%20is%20excited%20at%20any%20time%2C%20so%20the%20ground%20state%20population%20barely%20changes.%20In%20that%20case%20it%20can%20be%20modelled%20with%20%60ConstantGroundState(default%2C%20energy%3D0)%60%2C%20a%20level%20whose%20population%20stays%20constant.%20It%20is%20a%20%60Parameter%60%20with%20an%20%60energy%60%20(in%20eV%20if%20it%20is%20a%20plain%20number)%20and%20can%20replace%20a%20singlet%20or%20triplet%20state%20in%20any%20transition.%20It%20has%20no%20equation%20of%20its%20own%2C%20so%20%60ground%60%20appears%20in%20the%20parameters%20of%20the%20report%20below%2C%20not%20in%20the%20variables%2C%20and%20its%20population%20can%20be%20changed%20with%20%60with_values%60%20like%20any%20other%20parameter.%0A%0A%20%20%20%20Here%20is%20the%20ruthenium%20model%20from%20the%20beginning%20with%20a%20constant%20ground%20state%20(leaving%20out%20the%20LC%20absorption%2C%20which%20we%20didn't%20pump)%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20Absorption%2C%0A%20%20%20%20Fluorescence%2C%0A%20%20%20%20IntersystemCrossing%2C%0A%20%20%20%20Phosphorescence%2C%0A%20%20%20%20ReverseIntersystemCrossing%2C%0A%20%20%20%20SingletState%2C%0A%20%20%20%20SpectroscopicSystem%2C%0A%20%20%20%20TripletState%2C%0A%20%20%20%20initial%2C%0A%20%20%20%20notebook_report%2C%0A%20%20%20%20u%2C%0A)%3A%0A%20%20%20%20from%20jablonski%20import%20ConstantGroundState%0A%0A%20%20%20%20class%20DiluteRuthenium(SpectroscopicSystem)%3A%0A%20%20%20%20%20%20%20%20ground%20%3D%20ConstantGroundState(default%3D10)%0A%20%20%20%20%20%20%20%20MLCT_3%3A%20TripletState%20%3D%20initial(2.12%20*%20u.eV%2C%20%22triplet%22%2C%20default%3D0)%0A%20%20%20%20%20%20%20%20MLCT_1%3A%20SingletState%20%3D%20initial(2.74%20*%20u.eV%2C%20default%3D0)%0A%0A%20%20%20%20%20%20%20%20abs%20%3D%20Absorption(ground%3Dground%2C%20excited%3DMLCT_1%2C%20rate%3D5.6e-17%20*%20u.cm**2)%0A%20%20%20%20%20%20%20%20fl%20%3D%20Fluorescence(excited%3DMLCT_1%2C%20ground%3Dground%2C%20rate%3D1e8%20%2F%20u.s)%0A%20%20%20%20%20%20%20%20isc%20%3D%20IntersystemCrossing(source%3DMLCT_1%2C%20target%3DMLCT_3%2C%20rate%3D1%20%2F%20(1%20*%20u.ps))%0A%20%20%20%20%20%20%20%20ph%20%3D%20Phosphorescence(excited%3DMLCT_3%2C%20ground%3Dground%2C%20rate%3D1%20%2F%20(0.6%20*%20u.us)%20*%200.04)%0A%20%20%20%20%20%20%20%20risc%20%3D%20ReverseIntersystemCrossing(%0A%20%20%20%20%20%20%20%20%20%20%20%20source%3DMLCT_3%2C%20target%3Dground%2C%20rate%3D1%20%2F%20(0.6%20*%20u.us)%20*%200.96%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20notebook_report(DiluteRuthenium)%0A%20%20%20%20return%20(DiluteRuthenium%2C)%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%20Comparing%20the%20steady-state%20emission%20of%20both%20models%20shows%20when%20the%20approximation%20holds.%20At%20low%20flux%20they%20agree%2C%20while%20at%20high%20flux%20a%20significant%20part%20of%20the%20molecules%20sits%20in%20the%20long-lived%20triplet%2C%20the%20real%20ground%20state%20is%20depleted%20and%20the%20emission%20saturates.%20The%20constant%20ground%20state%20ignores%20this%20and%20keeps%20growing%20linearly%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(DiluteRuthenium%2C%20Ruthenium%2C%20Simulator%2C%20np%2C%20plt%2C%20steady_state%2C%20u)%3A%0A%20%20%20%20saturation_fluxes%20%3D%20np.logspace(19%2C%2024%2C%2020)%20%2F%20(u.cm**2%20*%20u.s)%0A%20%20%20%20for%20_model%20in%20%5BRuthenium%2C%20DiluteRuthenium%5D%3A%0A%20%20%20%20%20%20%20%20_sim%20%3D%20Simulator(_model)%0A%20%20%20%20%20%20%20%20_emission%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20steady_state(_sim%2C%20%7B_model.abs%3A%20flux%7D)%5B%22emission%22%5D.pint.magnitude.item()%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20flux%20in%20saturation_fluxes%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20plt.plot(saturation_fluxes.magnitude%2C%20_emission%2C%20label%3D_model.__name__)%0A%20%20%20%20plt.xscale(%22log%22)%0A%20%20%20%20plt.yscale(%22log%22)%0A%20%20%20%20plt.xlabel(%22Photon%20flux%20%5B1%20%2F%20(cm%C2%B2%20s)%5D%22)%0A%20%20%20%20plt.ylabel(%22Emission%20%5Bphotons%20%2F%20s%5D%22)%0A%20%20%20%20plt.legend()%0A%20%20%20%20plt.show()%0A%20%20%20%20return%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%20Next%20steps%0A%20%20%20%20-%20%5BFitting%20spectroscopic%20data%5D(https%3A%2F%2Fdyscolab.github.io%2Fstatic_notebooks%2Ffitting_spectroscopic_data.html)%3A%20fit%20model%20parameters%20to%20measured%20time-resolved%20emission%20and%20spectra.%0A%20%20%20%20-%20%5BStochastic%20photon%20counting%5D(https%3A%2F%2Fdyscolab.github.io%2Fstatic_notebooks%2Fstochastic_photon_counting.html)%3A%20simulate%20individual%20photon%20counts%20instead%20of%20average%20rates.%0A%20%20%20%20%22%22%22)%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
9e4a3d83e155544585dac23d7056894b