Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
89e11c6
Update existing Pourbaix components, stylistic updates just for practice
zccalka Apr 22, 2026
e166e74
Add reverse Pourbaix components for demo
zccalka Apr 22, 2026
14d055d
small changes to reverse_pourbaix, added reverse pourbiax to init
zccalka Apr 24, 2026
b644096
addition of dummy stability cutoff slider
zccalka Apr 24, 2026
593a3c3
reverse pourbaix with eV cutoff now, heatmap updates at selected cutoff
zccalka Apr 27, 2026
8459956
working demo of full list of mp_ids in each heatmap region displayed …
zccalka Apr 27, 2026
5adf13f
stylistic changes to reverse pourbaix app, added comment to pourbaix …
zccalka Apr 29, 2026
b346737
small stylistic changes to reverse pourbaix app
zccalka Apr 30, 2026
47b1ad6
small refactor of code, functionality looks the same
zccalka May 1, 2026
f8e2b2f
updated examples and data
zccalka May 1, 2026
3ae396a
updated comments
zccalka May 4, 2026
8c596a2
Revert unrelated changes for demo branch
zccalka May 4, 2026
9c215e6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 4, 2026
fba1e9f
Merge remote-tracking branch 'origin/main' into reverse_pourbaix
zccalka May 4, 2026
9daafe7
Merge branch 'reverse_pourbaix' of https://github.com/zccalka/crystal…
zccalka May 4, 2026
b0bce4f
fixes fersponding to PR comments
zccalka May 7, 2026
6c43a1b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 7, 2026
b81e001
test with dummy options for solid filter and ion conc.
zccalka May 20, 2026
ca2ea36
test with dummy options for solid filter and ion conc.
zccalka May 20, 2026
ce9a150
functionality to allow acceptance of composition from reverse_pourbai…
zccalka May 22, 2026
ec4dbdf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 22, 2026
dd74d90
Merge branch 'main' into reverse_pourbaix
zccalka May 22, 2026
abb9c3f
updated json for example
zccalka May 22, 2026
d27f1cd
small layout changes
zccalka May 28, 2026
b0126ee
updated formatting
zccalka May 28, 2026
0306082
updated formatting, fixed plotly issue
zccalka Jun 3, 2026
5ea1f78
small updates to comment and removal of dummy filters, also updated j…
zccalka Jun 8, 2026
59ef6b8
Merge branch 'main' of https://github.com/materialsproject/crystaltoo…
zccalka Jun 9, 2026
46148db
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 9, 2026
e5d9ff8
added preprocessing so component can handle .parquet instead of .json…
zccalka Jun 17, 2026
d6eb3ab
changes to handle S3 instead of local files
zccalka Jun 18, 2026
9dd9198
moved path and some preprocessing out of component so component accep…
zccalka Jun 22, 2026
665e36b
ran pre-commit
zccalka Jun 22, 2026
c6bee46
removed dead code, get_stable_mp_ids was replaced by _build_active_ro…
zccalka Jul 2, 2026
ad04675
removed list as type form resolve cutoff
zccalka Jul 2, 2026
f083259
extract stability_cutoff from get_slider_input output list
minhsueh Jul 7, 2026
c6c3829
_resolve_cutoff handles the output of MPComponent's get_slider_input …
minhsueh Jul 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions crystal_toolkit/apps/examples/reverse_pourbaix_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Example app for the Reverse Pourbaix Diagram Component.

Renders the heatmap statically using the component's `get_heatmap_figure`
staticmethod. No interactivity. See the Materials Project web integration.
"""

from __future__ import annotations

import dash
import pyarrow.parquet as pq
from dash import dcc, html

import crystal_toolkit.components as ctc
from crystal_toolkit.components.reverse_pourbaix import ReversePourbaixDiagramComponent
from crystal_toolkit.settings import SETTINGS

app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH)

# Load pre-computed heatmap data from the versioned, hive-partitioned S3
# dataset; filter to one version so multiple versions in the bucket don't
# get mixed together.
DATA_PATH = "s3://materialsproject-build/collections/reverse-pourbaix-heatmap/"
DATA_FILTERS = [("version", "=", "2026-04-13")]

heatmap_df = pq.read_table(DATA_PATH, filters=DATA_FILTERS).to_pandas()
heatmap_data = ReversePourbaixDiagramComponent.load_heatmap_data(heatmap_df)

# Build the heatmap figure directly — no component, no callbacks.
figure = ReversePourbaixDiagramComponent.get_heatmap_figure(heatmap_data)

layout = html.Div(
[
html.H1("Reverse Pourbaix Diagram"),
html.P(
"Number of thermodynamically stable materials at each pH/potential "
"combination (decomposition energy < 0.2 eV/atom)."
),
dcc.Graph(
figure=figure,
config={"displayModeBar": False, "displaylogo": False},
),
],
style=dict(maxWidth="900px", margin="2em auto"),
)

ctc.register_crystal_toolkit(app=app, layout=layout)

if __name__ == "__main__":
app.run(debug=True, port=8050)
1 change: 1 addition & 0 deletions crystal_toolkit/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
PhononBandstructureAndDosPanelComponent,
)
from crystal_toolkit.components.pourbaix import PourbaixDiagramComponent
from crystal_toolkit.components.reverse_pourbaix import ReversePourbaixDiagramComponent
from crystal_toolkit.components.search import SearchComponent
from crystal_toolkit.components.structure import StructureMoleculeComponent

Expand Down
25 changes: 20 additions & 5 deletions crystal_toolkit/components/pourbaix.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,15 @@ def update_heatmap_choices(entries, mat_detials, filter_solids):
Output(self.id("comp-conc-btn"), "children"),
Output(self.id("comp-conc-btn"), "style"),
Input(self.id(), "data"),
# Optional: prefilled ratio from a parent app linking via
# `links={"prefill-ratio": parent_app.id("prefill-ratio")}`.
# If not linked, falls back to equal ratios.
State(self.id("prefill-ratio"), "data"),
prevent_initial_call=True,
)
def update_element_specific_sliders(
entries,
prefill_ratio,
):
"""
When pourbaix entries input, add concentration and composition options
Expand All @@ -711,7 +716,7 @@ def update_element_specific_sliders(

conc_inputs = []

for element in sorted(elements):
for element in sorted(elements, key=lambda e: e.symbol):
conc_input = PourbaixDiagramComponent.create_centered_object(
self.get_numerical_input(
f"conc-{element}",
Expand Down Expand Up @@ -760,10 +765,20 @@ def update_element_specific_sliders(
}

# elements store
elements = [element.symbol for element in elements]

# default_comp
default_comp = ":".join(["1" for _ in elements])
# Sort alphabetically for deterministic ordering across page loads.
# This order is the contract between the composition title display,
# the comp-text positional parsing in make_figure, and any URL-based
# ratio prefill from the reverse-Pourbaix app.
elements = sorted(element.symbol for element in elements)

# default_comp — use prefilled ratio from URL if supplied and length
# matches the resolved element list, otherwise fall back to all-equal.
if prefill_ratio and len(prefill_ratio) == len(elements):
default_comp = ":".join(
str(int(r)) if r == int(r) else str(r) for r in prefill_ratio
)
else:
default_comp = ":".join(["1" for _ in elements])

# composition title
title = "💡 Composition of " + ":".join(elements)
Expand Down
Loading
Loading