Skip to content

feature/SOF-7957 Feat: dielectric Tensor NB#348

Open
VsevolodX wants to merge 2 commits into
mainfrom
feature/SOF-7957
Open

feature/SOF-7957 Feat: dielectric Tensor NB#348
VsevolodX wants to merge 2 commits into
mainfrom
feature/SOF-7957

Conversation

@VsevolodX

@VsevolodX VsevolodX commented Jul 17, 2026

Copy link
Copy Markdown
Member
  • update: return ZPE NB
  • feat: add dielectric tensor NB

Summary by CodeRabbit

  • New Features
    • Added a guided notebook workflow for computing and visualizing the frequency-dependent optical dielectric function.
    • Lets you configure material inputs, DFT settings, pseudopotentials, k-point grids, plane-wave cutoffs, and the dielectric energy range.
    • Automates job submission, progress monitoring, result retrieval, and visualization.
  • Documentation
    • Updated the introduction to link directly to the new dielectric tensor workflow.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c9499aa9-8c4e-47ff-b8b8-55201e62ec04

📥 Commits

Reviewing files that changed from the base of the PR and between 270eabd and 76dd9cf.

📒 Files selected for processing (1)
  • other/materials_designer/workflows/dielectric_tensor.ipynb
🚧 Files skipped from review as they are similar to previous changes (1)
  • other/materials_designer/workflows/dielectric_tensor.ipynb

📝 Walkthrough

Walkthrough

Adds a Jupyter notebook that configures and submits a Quantum ESPRESSO dielectric tensor workflow through the Mat3ra API, waits for completion, and visualizes results. The introduction notebook now links to it.

Changes

Dielectric tensor workflow

Layer / File(s) Summary
Setup and workflow inputs
other/materials_designer/workflows/dielectric_tensor.ipynb
Documents notebook usage, defines material, workflow, compute, and dielectric tensor parameters, and initializes account/project access.
Material and workflow configuration
other/materials_designer/workflows/dielectric_tensor.ipynb
Loads and saves a material, configures the DFT workflow and model, patches k-grids, cutoffs, and epsilon settings, and saves the workflow.
Compute and job execution
other/materials_designer/workflows/dielectric_tensor.ipynb
Selects compute resources, creates and submits a job, and polls for completion.
Results and notebook discoverability
other/materials_designer/workflows/dielectric_tensor.ipynb, other/materials_designer/workflows/Introduction.ipynb
Retrieves and visualizes dielectric tensor results and links the new notebook from the introduction.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant APIClient
  participant Material
  participant Workflow
  participant Job
  participant Results
  User->>APIClient: Authenticate and select project
  APIClient->>Material: Load and save material
  APIClient->>Workflow: Configure and save dielectric workflow
  APIClient->>Job: Create and submit job
  APIClient->>Job: Poll until completion
  APIClient->>Results: Retrieve dielectric tensor
  Results-->>User: Visualize dielectric tensor
Loading

Possibly related PRs

Suggested reviewers: timurbazhirov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clearly related to the main change: adding a dielectric tensor notebook.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/SOF-7957

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@other/materials_designer/workflows/dielectric_tensor.ipynb`:
- Around line 513-540: Update the cluster selection before constructing Compute
so it handles an empty clusters list and requires exactly one explicit match for
CLUSTER_NAME, rather than defaulting to clusters[0] or using partial matching.
Fail fast when zero or multiple clusters match, and only create Compute after a
unique cluster has been selected.
- Around line 233-235: Validate the result of client.projects.list before
accessing projects[0] in the project selection flow. If no default project
matches, raise a clear error or require explicit project selection; only derive
project_id and print the project details after confirming a project exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e2db4bc9-12a3-4e82-b77e-a075d2785d04

📥 Commits

Reviewing files that changed from the base of the PR and between 6a6518d and 270eabd.

📒 Files selected for processing (2)
  • other/materials_designer/workflows/Introduction.ipynb
  • other/materials_designer/workflows/dielectric_tensor.ipynb

Comment on lines +233 to +235
"projects = client.projects.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})\n",
"project_id = projects[0][\"_id\"]\n",
"print(f\"✅ Using project: {projects[0]['name']} ({project_id})\")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

python3 - <<'PY'
import json, pathlib
nb_path = pathlib.Path('other/materials_designer/workflows/dielectric_tensor.ipynb')
nb = json.loads(nb_path.read_text())

for i, cell in enumerate(nb.get('cells', [])):
    src = ''.join(cell.get('source', []))
    if 'client.projects.list({"isDefault": True, "owner._id": ACCOUNT_ID})' in src or 'project_id = projects[0]["_id"]' in src:
        print(f"\nCELL {i} [{cell.get('cell_type')}]")
        print(src)
PY

Repository: mat3ra/api-examples

Length of output: 347


Handle empty default-project results.
client.projects.list(...) can return no matches here, and projects[0] will raise IndexError. Raise a clear error or require an explicit project selection before indexing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@other/materials_designer/workflows/dielectric_tensor.ipynb` around lines 233
- 235, Validate the result of client.projects.list before accessing projects[0]
in the project selection flow. If no default project matches, raise a clear
error or require explicit project selection; only derive project_id and print
the project details after confirming a project exists.

Comment on lines +513 to +540
"clusters = client.clusters.list()\n",
"print(f\"Available clusters: {[c['hostname'] for c in clusters]}\")"
]
},
{
"cell_type": "markdown",
"id": "36",
"metadata": {},
"source": [
"### 5.2. Create compute configuration"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "37",
"metadata": {},
"outputs": [],
"source": [
"from mat3ra.ide.compute import Compute\n",
"\n",
"if CLUSTER_NAME:\n",
" cluster = next((c for c in clusters if CLUSTER_NAME in c[\"hostname\"]), None)\n",
"else:\n",
" cluster = clusters[0]\n",
"\n",
"compute = Compute(cluster=cluster, queue=QUEUE_NAME, ppn=PPN)\n",
"print(f\"Using cluster: {compute.cluster.hostname}, queue: {QUEUE_NAME}, ppn: {PPN}\")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

python3 - <<'PY'
import json, pathlib

path = pathlib.Path('other/materials_designer/workflows/dielectric_tensor.ipynb')
nb = json.loads(path.read_text())

for i, cell in enumerate(nb.get('cells', [])):
    src = ''.join(cell.get('source', []))
    if 'clusters = client.clusters.list()' in src or 'CLUSTER_NAME' in src or 'Compute(cluster=cluster' in src:
        print(f"\n--- cell {i} ({cell.get('cell_type')}) ---")
        print(src)
PY

Repository: mat3ra/api-examples

Length of output: 1372


Require a single, explicit cluster match before creating Compute. clusters[0] will fail when no clusters are available, and the partial-name lookup can silently select the wrong cluster if multiple entries match. Fail fast unless exactly one cluster matches CLUSTER_NAME, and handle the empty list case.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@other/materials_designer/workflows/dielectric_tensor.ipynb` around lines 513
- 540, Update the cluster selection before constructing Compute so it handles an
empty clusters list and requires exactly one explicit match for CLUSTER_NAME,
rather than defaulting to clusters[0] or using partial matching. Fail fast when
zero or multiple clusters match, and only create Compute after a unique cluster
has been selected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant