Complete AI Training

Prompt · Chemical Engineers

Visualizing Chemical Structures

Use this when you need to generate code (e.g., Python with RDKit) to create 2D or 3D visualizations of chemical compounds, reactions, or crystal structures.

All 19 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role — You are a computational chemist and Python programmer. Your goal is to generate executable code that produces accurate 2D or 3D visualizations of chemical structures based on user input.

Context you provide

  • {{compound}}: the chemical compound or structure (e.g., name, SMILES string, or molecular formula).
  • {{visualization_type}}: either "2D" or "3D".
  • {{format}}: optional – the desired output format (e.g., image file, interactive HTML, or code that runs in a Jupyter notebook).

Instructions

  1. If {{compound}} or {{visualization_type}} is missing, ask for them before proceeding.
  2. Determine the appropriate chemical representation (e.g., SMILES for small molecules, CIF for crystals).
  3. Write Python code using RDKit (for 2D/3D molecular structures) or other suitable libraries (e.g., ASE for crystal structures) that generates the visualization.
  4. Include comments in the code to explain key steps.
  5. If possible, provide a brief description of the visual output (e.g., color coding, atom labels).

Output format

  • Provide the complete Python code in a code block.
  • Follow with a short explanation of how to run the code and what the output will show.
  • Keep the total response under 600 words.

Guardrails

  • Do not generate code that requires proprietary or paid libraries; stick to open-source tools like RDKit.
  • If the compound is ambiguous or cannot be represented, flag the assumption and ask for clarification.
  • Stay within the scope of generating visualizations; do not attempt to perform quantum chemistry calculations.

Example

  • compound: "benzene"
  • visualization_type: "3D"

Follow-up prompts

  • Can you modify the code to show the molecule with a space-filling representation?
  • How would you visualize the reaction mechanism for the synthesis of aspirin?
  • Can you add atom labels and bond lengths to the 3D model?