Quick Interactive Demo
In [1]:
Copied!
from t_prompts import setup_notebook
display(setup_notebook())
from t_prompts import setup_notebook
display(setup_notebook())
The output below is interactive! Click '?' on the toolbar for more help
In [2]:
Copied!
from t_prompts.widgets.demos.demo_screenshot import create_quantum_workflow_demo
create_quantum_workflow_demo()
from t_prompts.widgets.demos.demo_screenshot import create_quantum_workflow_demo
create_quantum_workflow_demo()
Out[2]:
In [3]:
Copied!
import inspect
from IPython.display import Markdown
Markdown(f"```python\n{inspect.getsource(create_quantum_workflow_demo)}\n```")
import inspect
from IPython.display import Markdown
Markdown(f"```python\n{inspect.getsource(create_quantum_workflow_demo)}\n```")
Out[3]:
def create_quantum_workflow_demo():
"""Compose the full Morse potential vibrational workflow demo."""
# Level 1 interpolation: primitive parameters
D_e = "4.5" # eV
a = "1.9" # Å⁻¹
r_e = "0.74" # Å
# Level 3: Build potential function prompt (factory for reuse)
morse_function_factory = build_morse_potential(D_e, a, r_e)
morse_function_for_solver = morse_function_factory()
# Level 4: Combine function into solver skeleton
solver_program = build_solver_program(
potential_name="morse_potential",
potential_def=morse_function_for_solver,
grid_points="500",
r_min="0.30",
r_max="3.00",
)
# Level 5: Wrap solver in a code fence
solver_code_block = code_block("python", solver_program)
# -------------------------------------------------------------------------
# Section 1: Overview
# -------------------------------------------------------------------------
overview_content = dedent(
t"""
Welcome to an ***end-to-end computational workflow*** for studying **anharmonic molecular vibrations**
with the *Morse potential*.
> “Precision in quantum chemistry emerges when theory, computation, and interpretation move in harmony.”
"""
)
overview_section = section("Overview", overview_content)
solver_configuration_table = parameters_table(
{
"Discretization": "Finite-difference second order",
"Grid points": "500 nodes across 0.30–3.00 Å",
"Boundary handling": "Dirichlet (wavefunction → 0 at edges)",
"Diagonalization": "Helper `diagonalize()` routine (SciPy backend)",
}
)
morse_equation = latex_block(
prompt(
t"""
V(r) = D_e \\left(1 - e^{{-a (r - r_e)}}\\right)^2
"""
)
)
implementation_section = section(
"Implementation",
dedent(
t"""
We assemble the solver from reusable building blocks, each captured by a prompt-friendly helper.
{solver_configuration_table:solver_configuration_table}
{morse_equation:morse_equation}
{solver_code_block:solver_code_block}
"""
),
)
# -------------------------------------------------------------------------
# Section 5: Visualization & Results
# -------------------------------------------------------------------------
from PIL import Image
image_path = Path(__file__).parent.parent.parent.parent.parent / "docs" / "assets" / "warps-and-wefts.png"
visualization_image = Image.open(image_path)
visualization_image = visualization_image.resize((300, 300))
visualization_intro = dedent(
t"""
{visualization_image:wave_visual}
"""
)
energy_comparison_table = dedent(
t"""
| Level | Analytical (eV) | Numerical (eV) |
|-------|------------------|-----------------|
| ν = 0 | 0.1180 | 0.1183 |
| ν = 1 | 0.3435 | 0.3439 |
| ν = 2 | 0.5552 | 0.5558 |
"""
)
visualization_section = section(
"Visualization & Results",
dedent(
t"""
{visualization_intro:visualization_intro}
### Computational Results
{energy_comparison_table:energy_comparison_table}
"""
),
)
# -------------------------------------------------------------------------
# Compose Final Document
# -------------------------------------------------------------------------
return dedent(
t"""
{overview_section:overview_section}
{implementation_section:implementation_section}
{visualization_section:visualization_section}
"""
)
In [ ]:
Copied!