Skip to content

Reverse pourbaix component#530

Draft
zccalka wants to merge 15 commits intomaterialsproject:mainfrom
zccalka:reverse_pourbaix
Draft

Reverse pourbaix component#530
zccalka wants to merge 15 commits intomaterialsproject:mainfrom
zccalka:reverse_pourbaix

Conversation

@zccalka
Copy link
Copy Markdown

@zccalka zccalka commented May 4, 2026

Summary

Adds a reverse Pourbaix component and example app for demoing the new feature.

Context

This is a demo branch for the reverse pourbaix app. This is che component used for the web implimentation.

Changes

  • New ReversePourbaix component (crystal_toolkit/components/reverse_pourbaix.py)
  • Example app (crystal_toolkit/apps/examples/reverse_pourbaix_example.py)
  • Pre-computed heatmap data (reverse_pourbaix_heatmap.json)
  • Component registered in components/__init__.py

Precomputed heatmap data is included in commit. Will be updated with up-to-date data later.

Status

Demo/draft. I will make a PR on web for the web implementation that makes this component.

How to view

python crystal_toolkit/apps/examples/reverse_pourbaix_example.py

Full example should be accessed form web.

@minhsueh please take look when you have a chance.

return float(value)


def _snap_to_grid(ph: float, v: float) -> tuple[int, float]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It seems like _resolve_cutoff and _snap_to_grid are closely related to ReversePourbaixDiagramComponent. Is there a reason not to put them in the ReversePourbaixDiagramComponent as static methods like _format_cutoff_key?

CUTOFF_STEP = 0.1


def _resolve_cutoff(value) -> float:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It would be better to have a specific input type, either float or List[float]. I would prefer float, since if the input is a list, we only take the first element; we should handle this logic in the calling place.

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.

2 participants