{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualizing absorption spectra\n", "Absorption spectra can be generated and plotted directly in a Jupyter notebook by using the ``plot_spectrum`` command. The following example computes the first ten excitation energies for water at the CCSD level of theory and plots the spectrum:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import penguin\n", "import veloxchem as vlx\n", "\n", "xyz_string = \"\"\"\n", " O 0.941414391 0.061806555 0.056540617\n", " H 1.897745723 0.036140170 0.097929548\n", " H 0.668559886 -0.421976725 0.836569836\"\"\"\n", "\n", "molecule = penguin.get_molecule(xyz_string)\n", "basis = penguin.get_molecular_basis(molecule, \"cc-pVDZ\")\n", "\n", "scf_drv = vlx.ScfRestrictedDriver()\n", "scf_drv.ostream.mute()\n", "scf_drv.compute(molecule, basis)\n", "\n", "reference_state = penguin.create_reference_state(molecule, basis, scf_drv)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ccsd_drv = penguin.CCSD()\n", "ccsd_drv.ostream.mute()\n", "ccsd_drv.update_settings({\n", " 'reference_state': reference_state,\n", " 'nstates': 10,\n", " 'spectrum': True\n", "})\n", "ccsd_drv.plot_spectrum('lorentzian', 0.4, 'nm')" ] } ], "metadata": { "kernelspec": { "display_name": "penguin_env_dev", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.9" } }, "nbformat": 4, "nbformat_minor": 2 }