"""Fracture-Bench Playground — interactive surrogate predictions for
phase-field fracture.
Run locally: streamlit run app.py
"""
from __future__ import annotations
import os
import time
import numpy as np
import streamlit as st
from models import registry
from utils import geometry as geo
from utils import plotting as viz
st.set_page_config(page_title="Fracture-Bench Playground",
page_icon="⚡", layout="wide")
# Pages, chosen by ?view=:
# home hero + project cards (only when run locally)
# playground datasets overview + interactive tabs
# embed the two dataset tabs only, for embedding in the github.io site
# When FRACTURE_BENCH_SITE is set (the hosted Hugging Face Space), that site is
# the home page, so the app opens on the playground and links home to the site.
SITE_URL = os.environ.get("FRACTURE_BENCH_SITE", "")
VIEW = st.query_params.get("view", "playground" if SITE_URL else "home")
if SITE_URL and VIEW not in ("playground", "embed"):
VIEW = "playground"
EMBED = VIEW == "embed"
ON_PLAYGROUND = VIEW in ("playground", "embed")
# ---------------------------------------------------------------- theme ---
NAVY, NAVY2, BLUE, MIST, WHITE = ("#0D1F45", "#16315E", "#245E94",
"#BCCBDC", "#FFFFFF")
INK, PALE, LINE = "#13294B", "#F4F8FC", "#D1DCF0"
with st.container(key="fb_toggle"):
dark_mode = st.toggle("🌙 Dark", value=False, key="theme_dark")
if dark_mode:
_css = f"""
.stApp {{ background: {NAVY}; color: {WHITE}; --fb-pg-bg:{NAVY};
--fb-pg-copy:#B9C9DE; --fb-pg-strong:#FFFFFF; }}
header[data-testid="stHeader"] {{ background: rgba(13,31,69,0.85); }}
.stApp h1, .stApp h2, .stApp h3, .stMarkdown p, label p,
[data-testid="stWidgetLabel"] p, .stRadio label p,
.stSelectbox label p {{ color: #E9F0F9 !important; }}
button[data-baseweb="tab"] p {{ color: {MIST} !important; font-weight: 600; }}
button[data-baseweb="tab"][aria-selected="true"] p {{ color: {WHITE} !important; }}
[data-testid="stAlertContainer"] {{
background: {NAVY2}; color: #E9F0F9; border-left: 4px solid {BLUE}; }}
[data-testid="stAlertContainer"] p {{ color: #E9F0F9 !important; }}
div[data-baseweb="select"] > div,
[data-testid="stNumberInputContainer"] {{
background: {NAVY2}; border-color: #2C4A7C; }}
div[data-baseweb="select"] div, div[data-baseweb="select"] span {{
color: #E9F0F9 !important; }}
div[data-baseweb="select"] svg {{ fill: #E9F0F9; }}
[data-testid="stNumberInputContainer"] input {{ color: #E9F0F9; }}
div[data-baseweb="input"], div[data-baseweb="base-input"] {{
background: {NAVY2} !important; }}
div[data-baseweb="input"] input, [data-testid="stNumberInputContainer"] input {{
color: #E9F0F9 !important;
-webkit-text-fill-color: #E9F0F9 !important;
background: {NAVY2} !important; }}
[data-testid="stNumberInputContainer"] button {{ background: {NAVY2}; }}
[data-testid="stNumberInputContainer"] button svg {{ fill: #E9F0F9; }}
hr {{ border-color: {NAVY2}; }}
.fb-eyebrow {{ color: #9AB4D4 !important; }}
.fb-sub {{ color: #B9C9DE !important; }}
.fb-chip {{ background: {NAVY2} !important; color: #D7E3F2 !important;
border-color: #2C4A7C !important; }}
div[data-baseweb="tab-list"] {{ gap: .35rem; }}
button[data-baseweb="tab"] {{
background: {NAVY2}; border: 1px solid #2C4A7C;
border-radius: 2px; padding: .6rem 1.05rem; }}
button[data-baseweb="tab"][aria-selected="true"] {{
background: {BLUE}; border-color: {BLUE}; }}
div[data-baseweb="tab-highlight"],
div[data-baseweb="tab-border"] {{ display: none; }}
"""
else:
_css = f"""
.stApp {{ background: {WHITE}; color: {NAVY}; --fb-pg-bg:#F4F8FC;
--fb-pg-copy:#446083; --fb-pg-strong:#16315E; }}
header[data-testid="stHeader"] {{ background: rgba(255,255,255,0.9); }}
button[data-baseweb="tab"] p {{ color: #5B7693; font-weight: 600; }}
button[data-baseweb="tab"][aria-selected="true"] p {{ color: {BLUE}; }}
[data-testid="stAlertContainer"] {{
background: #F4F8FC; color: #13294B; border-left: 4px solid {BLUE}; }}
.fb-eyebrow {{ color: #6E89A8; }}
.fb-sub {{ color: #446083; }}
.fb-chip {{ background: #F0F5FB; color: #2A4A74; border-color: #D6E2F0; }}
div[data-baseweb="tab-list"] {{ gap: .35rem; }}
button[data-baseweb="tab"] {{
background: #F0F5FB; border: 1px solid #C9D6E8;
border-radius: 2px; padding: .6rem 1.05rem; }}
button[data-baseweb="tab"][aria-selected="true"] {{
background: {BLUE}; border-color: {BLUE}; }}
button[data-baseweb="tab"][aria-selected="true"] p {{
color: #FFFFFF !important; }}
div[data-baseweb="tab-highlight"],
div[data-baseweb="tab-border"] {{ display: none; }}
"""
_css += f"""
[data-testid="stMainBlockContainer"] {{ padding: 0 2.5rem 3rem; max-width: 1280px; }}
[data-testid="stMainBlockContainer"] > [data-testid="stVerticalBlock"] {{ gap: 0; }}
.st-key-fb_toggle {{ position: fixed; top: .53rem; right: 2.1rem;
z-index: 9999999; width: auto; }}
.st-key-fb_toggle label p {{ font-size: .85rem;
color: #FFFFFF !important; }}
header[data-testid="stHeader"] {{ display: none; }}
"""
_css += """
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');
html, body, .stApp, .stApp p, .stApp span, .stApp label, .stApp li,
.stApp h1, .stApp h2, .stApp h3, .stApp h4,
.stApp button, .stApp input, .stMarkdown,
[data-testid="stWidgetLabel"] p {
font-family: 'Poppins', 'Lato', sans-serif;
}
[data-testid="stIconMaterial"] {
font-family: 'Material Symbols Rounded' !important;
}
/* Project-page shell, inspired by the TopoDiff hierarchy. */
.fb-fullbleed {
width: 100vw;
margin-left: calc(50% - 50vw);
}
.fb-site-nav {
background: #0D1F45;
min-height: 58px;
color: #FFFFFF;
display: flex;
align-items: center;
}
.fb-nav-inner {
width: min(1180px, calc(100% - 3rem));
margin: 0 auto;
padding-right: 7.25rem;
display: flex;
align-items: center;
justify-content: space-between;
gap: 1.5rem;
}
.fb-brand {
display: inline-flex;
align-items: center;
gap: .72rem;
color: #FFFFFF !important;
text-decoration: none !important;
font-size: .92rem;
font-weight: 700;
letter-spacing: .08em;
text-transform: uppercase;
white-space: nowrap;
}
.fb-mark {
width: 26px;
height: 26px;
display: grid;
place-items: center;
border: 1px solid rgba(255,255,255,.55);
color: #FFFFFF;
font-size: .82rem;
transform: rotate(45deg);
}
.fb-mark span { transform: rotate(-45deg); }
.fb-nav-links { display: flex; align-items: center; gap: 1.45rem; }
.fb-nav-links a {
color: #E9F0F9 !important;
text-decoration: none !important;
text-transform: uppercase;
font-size: .7rem;
font-weight: 600;
letter-spacing: .09em;
}
.fb-nav-links a:hover { color: #FFFFFF !important; }
.fb-nav-links a.fb-nav-current {
color: #FFFFFF !important;
padding-bottom: .2rem;
border-bottom: 2px solid #BCCBDC;
}
.fb-hero {
position: relative;
overflow: hidden;
background:
radial-gradient(circle at 82% 18%, rgba(188,203,220,.25), transparent 28%),
radial-gradient(circle at 65% 86%, rgba(36,94,148,.6), transparent 38%),
linear-gradient(118deg, #0D1F45 3%, #16315E 50%, #245E94 100%);
color: #FFFFFF;
min-height: 430px;
display: flex;
align-items: center;
}
.fb-hero::before,
.fb-hero::after {
content: '';
position: absolute;
pointer-events: none;
}
.fb-hero::before {
width: 560px;
height: 560px;
right: -105px;
top: -235px;
border: 1px solid rgba(255,255,255,.16);
border-radius: 50%;
box-shadow: 0 0 0 78px rgba(255,255,255,.035),
0 0 0 156px rgba(255,255,255,.025);
}
.fb-hero::after {
right: 8%;
bottom: -12%;
width: 340px;
height: 330px;
opacity: .34;
background:
linear-gradient(142deg, transparent 0 43%, #FFFFFF 43% 44%, transparent 44% 100%),
linear-gradient(34deg, transparent 0 61%, #FFFFFF 61% 62%, transparent 62% 100%),
linear-gradient(84deg, transparent 0 74%, #FFFFFF 74% 75%, transparent 75% 100%);
transform: rotate(-7deg);
}
.fb-hero-inner {
position: relative;
z-index: 1;
width: min(1180px, calc(100% - 3rem));
margin: 0 auto;
padding: 4.6rem 0 4.2rem;
}
.fb-kicker {
margin: 0 0 .9rem;
color: #BCCBDC;
text-transform: uppercase;
letter-spacing: .14em;
font-weight: 600;
font-size: .74rem;
}
.fb-hero h1 {
color: #FFFFFF !important;
font-size: clamp(2.65rem, 6vw, 5.6rem) !important;
line-height: .95 !important;
letter-spacing: -.045em !important;
margin: 0 0 1rem !important;
max-width: 880px;
}
.fb-hero-deck {
color: #FFFFFF !important;
margin: 0 0 .85rem !important;
font-size: clamp(1.05rem, 2vw, 1.45rem) !important;
font-weight: 500;
max-width: 760px;
}
.fb-hero-copy {
color: #D8E3F1 !important;
margin: 0 !important;
font-size: .9rem !important;
line-height: 1.7 !important;
max-width: 700px;
}
.fb-hero-metrics {
margin-top: 2rem;
display: flex;
flex-wrap: wrap;
gap: .6rem;
}
.fb-metric {
border-left: 2px solid #BCCBDC;
background: rgba(13,31,69,.28);
padding: .6rem 1.15rem .62rem;
min-width: 150px;
backdrop-filter: blur(6px);
}
.fb-metric strong {
display: block;
color: #FFFFFF;
font-size: 1.05rem;
}
.fb-metric span {
color: #BCCBDC;
font-size: .68rem;
text-transform: uppercase;
letter-spacing: .09em;
}
.fb-section {
padding: 4.4rem 0 3.7rem;
}
.fb-section-inner {
width: min(1180px, calc(100% - 3rem));
margin: 0 auto;
}
.fb-section-label {
color: #245E94;
font-size: .72rem;
font-weight: 700;
letter-spacing: .12em;
text-transform: uppercase;
margin-bottom: .55rem;
}
.fb-section-title {
position: relative;
display: inline-block;
color: #0D1F45;
font-size: clamp(1.45rem, 2.5vw, 2.15rem);
line-height: 1.15;
text-transform: uppercase;
letter-spacing: -.015em;
margin: 0 0 1.55rem;
padding-bottom: .52rem;
}
.fb-section-title::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 72%;
height: 2px;
background: #245E94;
}
.fb-lead {
color: #13294B;
font-size: .98rem;
line-height: 1.85;
max-width: 920px;
margin: 0;
}
.fb-lead + .fb-lead { margin-top: 1rem; }
.fb-basics {
background: #FFFFFF;
color: #13294B;
padding: 4rem 0 1.75rem;
}
.fb-basics-inner {
width: min(1180px, calc(100% - 3rem));
margin: 0 auto;
}
.stApp .fb-basics-title {
position: relative;
display: inline-block;
color: #16315E !important;
font-size: clamp(2rem, 4vw, 3rem) !important;
line-height: 1.05 !important;
font-weight: 800 !important;
letter-spacing: -.025em !important;
margin: 0 0 1.55rem !important;
padding-bottom: .65rem;
text-transform: uppercase;
}
.stApp .fb-basics-title::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 74%;
height: 4px;
background: #245E94;
}
.stApp .fb-basics-copy {
color: #172238 !important;
font-size: clamp(1.02rem, 1.65vw, 1.28rem) !important;
line-height: 1.85 !important;
max-width: 1120px;
margin: 0 !important;
}
.fb-project-grid {
width: min(1080px, 100%);
margin: 0 auto;
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 6px;
}
.fb-project-card {
position: relative;
overflow: hidden;
min-height: 305px;
display: flex;
align-items: flex-end;
justify-content: center;
padding: 1.25rem;
border: 1px solid #D1DCF0;
border-radius: 3px;
color: #FFFFFF !important;
text-decoration: none !important;
isolation: isolate;
background: #16315E;
}
.fb-project-card::after {
content: '';
position: absolute;
inset: 0;
z-index: -1;
background: linear-gradient(to top, rgba(6,16,36,.92), transparent 58%);
transition: background .2s ease;
}
.fb-project-card:hover::after {
background: linear-gradient(to top, rgba(6,16,36,.96), rgba(36,94,148,.05) 72%);
}
.fb-project-card:hover .fb-project-card-title { transform: translateY(-3px); }
.fb-project-card-title {
position: relative;
z-index: 2;
color: #FFFFFF;
font-size: 1.24rem;
font-weight: 700;
line-height: 1.2;
text-align: center;
text-shadow: 0 2px 12px rgba(0,0,0,.45);
transition: transform .2s ease;
}
.fb-placeholder-tag {
position: absolute;
z-index: 3;
top: .72rem;
left: .72rem;
padding: .28rem .48rem;
border: 1px solid rgba(255,255,255,.62);
background: rgba(13,31,69,.76);
color: #FFFFFF;
font-size: .55rem;
font-weight: 700;
letter-spacing: .1em;
text-transform: uppercase;
}
.fb-paper-card { background: #E8E9E7; }
.fb-paper-sheet {
position: absolute;
inset: 26px 34px 22px;
padding: 1.25rem 1.05rem;
background: #FEFEFC;
color: #101828;
box-shadow: 0 8px 22px rgba(13,31,69,.18);
text-align: center;
}
.fb-paper-sheet b {
display: block;
font-family: Georgia, serif;
font-size: .8rem;
line-height: 1.25;
margin-bottom: .35rem;
}
.fb-paper-sheet i {
display: block;
font-family: Georgia, serif;
font-size: .47rem;
margin-bottom: .75rem;
}
.fb-paper-lines {
height: 155px;
background:
linear-gradient(90deg, transparent 49.4%, #CDD2D8 49.4% 50.6%, transparent 50.6%),
repeating-linear-gradient(0deg, #4F5968 0 1px, transparent 1px 5px);
opacity: .72;
}
.fb-code-card { background: #121720; }
.fb-code-snippet {
position: absolute;
inset: 24px 22px 18px;
margin: 0;
color: #9DC3E9;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: .6rem;
line-height: 1.65;
white-space: pre-wrap;
opacity: .96;
}
.fb-code-snippet .kw { color: #D5A4F5; }
.fb-code-snippet .fn { color: #EBCB8B; }
.fb-code-snippet .cm { color: #6F8199; }
.fb-dataset-card {
background-image: url('https://raw.githubusercontent.com/Centrum-IntelliPhysics/Benchmark-Data--Phase-field-fracture-in-hyperelastic-material/main/animations/phase_and_disp_evolution_sample1.gif');
background-size: cover;
background-position: center;
}
.fb-files-card { background: #E8EDF3; }
.fb-file-grid {
position: absolute;
inset: 30px 24px 34px;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: .65rem;
}
.fb-file-grid i {
display: grid;
place-items: center;
min-height: 62px;
border: 1px solid #C3CEDD;
border-radius: 4px;
background: linear-gradient(#FFFFFF, #E6EBF2);
color: #5B7693;
box-shadow: 0 4px 10px rgba(13,31,69,.08);
font-style: normal;
font-size: .58rem;
font-weight: 700;
}
.fb-model-card { background: #B9C7D8; }
.fb-model-card svg {
position: absolute;
inset: 12px;
width: calc(100% - 24px);
height: calc(100% - 24px);
}
.fb-model-card line { stroke: #0D1F45; stroke-width: 5; }
.fb-model-card circle { fill: #BCCBDC; stroke: #0D1F45; stroke-width: 6; }
.fb-video-card {
background:
radial-gradient(circle at 20% 30%, rgba(188,203,220,.36), transparent 24%),
linear-gradient(138deg, #245E94, #0D1F45);
}
.fb-video-frame {
position: absolute;
inset: 32px 28px 42px;
display: grid;
place-items: center;
border: 1px solid rgba(255,255,255,.34);
background:
linear-gradient(115deg, transparent 0 41%, rgba(255,255,255,.13) 41% 42%, transparent 42%),
linear-gradient(35deg, transparent 0 61%, rgba(255,255,255,.13) 61% 62%, transparent 62%);
}
.fb-play-icon {
width: 72px;
height: 72px;
display: grid;
place-items: center;
border: 2px solid #FFFFFF;
border-radius: 50%;
color: #FFFFFF;
font-size: 1.8rem;
padding-left: .2rem;
}
.fb-poster-card {
background: #DCE5EF;
}
.fb-poster-thumb {
position: absolute;
top: 22px;
left: 22px;
width: calc(100% - 44px);
height: calc(100% - 22px - 68px);
object-fit: contain;
object-position: center top;
filter: drop-shadow(0 6px 12px rgba(13,31,69,.28));
}
.fb-band {
background: #0D1F45;
color: #FFFFFF;
}
.fb-band .fb-section-label { color: #9AB4D4; }
.fb-band .fb-section-title { color: #FFFFFF; }
.fb-band .fb-section-title::after { background: #BCCBDC; }
.fb-band .fb-lead { color: #D8E3F1; }
.fb-resource-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 2px;
margin-top: 1.75rem;
background: rgba(188,203,220,.34);
}
.fb-resource {
min-height: 225px;
position: relative;
overflow: hidden;
display: flex;
align-items: flex-end;
padding: 1.15rem;
color: #FFFFFF !important;
text-decoration: none !important;
isolation: isolate;
background-color: #16315E;
background-size: cover;
background-position: center;
}
.fb-resource::before {
content: '';
position: absolute;
inset: 0;
z-index: -1;
background: linear-gradient(to top, rgba(7,18,41,.98), rgba(13,31,69,.08) 70%);
transition: background .2s ease;
}
.fb-resource:hover::before {
background: linear-gradient(to top, rgba(7,18,41,.98), rgba(36,94,148,.18) 75%);
}
.fb-resource:hover .fb-resource-arrow { transform: translateX(4px); }
.fb-resource small {
display: block;
color: #BCCBDC;
text-transform: uppercase;
letter-spacing: .1em;
font-size: .62rem;
margin-bottom: .25rem;
}
.fb-resource strong {
color: #FFFFFF;
font-size: .95rem;
line-height: 1.35;
}
.fb-resource-arrow {
display: inline-block;
margin-left: .35rem;
transition: transform .2s ease;
}
.fb-resource-d1 {
background-image: url('https://raw.githubusercontent.com/Centrum-IntelliPhysics/Benchmark-Data--Phase-field-fracture-in-hyperelastic-material/main/animations/phase_and_disp_evolution_sample1.gif');
}
.fb-resource-d2 {
background-image: url('https://raw.githubusercontent.com/Centrum-IntelliPhysics/Benchmark_Data_Phase_field_fracture_in_fgm/main/figure/1_animation.gif');
}
.fb-resource-code {
background-image:
linear-gradient(130deg, rgba(36,94,148,.2), transparent),
repeating-linear-gradient(0deg, transparent 0 20px, rgba(188,203,220,.09) 20px 21px),
repeating-linear-gradient(90deg, transparent 0 20px, rgba(188,203,220,.09) 20px 21px);
}
.fb-resource-play {
background-image:
radial-gradient(circle at 28% 36%, rgba(188,203,220,.38) 0 3px, transparent 4px),
radial-gradient(circle at 72% 64%, rgba(188,203,220,.38) 0 3px, transparent 4px),
linear-gradient(145deg, #245E94, #0D1F45);
}
.fb-card-foot {
position: relative;
z-index: 2;
display: flex;
flex-direction: column;
align-items: center;
gap: .6rem;
}
.fb-card-links {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: .4rem;
}
.fb-card-links a {
padding: .3rem .62rem;
border: 1px solid rgba(255,255,255,.72);
border-radius: 2px;
background: rgba(13,31,69,.6);
color: #FFFFFF !important;
font-size: .68rem;
font-weight: 600;
letter-spacing: .02em;
text-decoration: none !important;
transition: background .2s ease, color .2s ease;
}
.fb-card-links a:hover { background: #FFFFFF; color: #0D1F45 !important; }
.fb-project-card:has(.fb-card-foot)::after {
background: linear-gradient(to top, rgba(6,16,36,.95) 34%, transparent 82%);
}
.fb-page-head {
background:
linear-gradient(to top, rgba(6,16,36,.95), rgba(13,31,69,.62)),
url('https://raw.githubusercontent.com/Centrum-IntelliPhysics/Benchmark-Data--Phase-field-fracture-in-hyperelastic-material/main/animations/phase_and_disp_evolution_sample1.gif') center / cover;
color: #FFFFFF;
}
.fb-page-head-inner {
width: min(1080px, calc(100% - 3rem));
margin: 0 auto;
padding: 2.6rem 0 2.1rem;
}
.fb-page-head h1 {
color: #FFFFFF !important;
font-size: clamp(1.7rem, 3.4vw, 2.6rem) !important;
line-height: 1.1 !important;
margin: 0 0 .7rem !important;
}
.fb-page-head .fb-page-sub {
color: #D8E3F1 !important;
margin: 0 !important;
font-size: .72rem !important;
font-weight: 600;
letter-spacing: .08em;
text-transform: uppercase;
}
.st-key-fb_playground_page {
width: min(1080px, 100%);
margin: 1.6rem auto 0 !important;
}
.stApp .fb-playground-copy {
color: var(--fb-pg-copy) !important;
font-size: .94rem !important;
line-height: 1.7 !important;
margin: 0 0 1rem !important;
}
.stApp .fb-playground-copy strong { color: var(--fb-pg-strong) !important; }
.st-key-fb_playground_page button[data-baseweb="tab"] {
margin-bottom: .4rem;
}
.fb-footer {
margin-top: 4.5rem;
background: #08152F;
color: #BCCBDC;
padding: 2.5rem 0;
}
.fb-footer-inner {
width: min(1180px, calc(100% - 3rem));
margin: 0 auto;
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 2rem;
}
.fb-footer strong { color: #FFFFFF; }
.fb-footer p { color: #BCCBDC !important; font-size: .76rem; margin: .25rem 0 0 !important; }
.fb-footer a { color: #FFFFFF !important; }
@media (max-width: 900px) {
[data-testid="stMainBlockContainer"] { padding-left: 1.25rem; padding-right: 1.25rem; }
.fb-nav-links { display: none; }
.fb-resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fb-project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fb-hero { min-height: 390px; }
}
@media (max-width: 600px) {
.st-key-fb_toggle { right: .8rem; }
.fb-nav-inner { width: calc(100% - 2rem); padding-right: 5.8rem; }
.fb-hero-inner, .fb-section-inner, .fb-footer-inner { width: calc(100% - 2rem); }
.fb-resource-grid { grid-template-columns: 1fr; }
.fb-project-grid { grid-template-columns: 1fr; }
.fb-project-card { min-height: 275px; }
.fb-resource { min-height: 190px; }
.fb-hero-metrics { display: grid; grid-template-columns: 1fr 1fr; }
.fb-metric { min-width: 0; }
.fb-footer-inner { display: block; }
.fb-page-head-inner { width: calc(100% - 2rem); }
}
"""
st.markdown(f"", unsafe_allow_html=True)
# ---------------------------------------------------------------- links ---
# Public links. While one is empty, its card shows a "Coming soon" tag.
PAPER_URL = "" # preprint or journal page
CODE_URL = "https://github.com/Centrum-IntelliPhysics/fracture_bench" # training code
MODELS_URL = "" # page where the trained weights can be downloaded
POSTER_URL = "app/static/Fracture-Bench_poster.pdf" # served from ./static
POSTER_THUMB = "app/static/Fracture-Bench_poster.png"
PLAYGROUND_URL = "?view=playground"
D1_DOI = "https://doi.org/10.7281/T1XFF19O"
D2_DOI = "https://doi.org/10.7281/T1RZFI3I"
D1_GITHUB = ("https://github.com/Centrum-IntelliPhysics/"
"Benchmark-Data--Phase-field-fracture-in-hyperelastic-material")
D2_GITHUB = ("https://github.com/Centrum-IntelliPhysics/"
"Benchmark_Data_Phase_field_fracture_in_fgm")
def _card_open(card_id: str, cls: str, url: str, label: str) -> str:
"""Opening tag of a home-page card: a link, or a 'Coming soon' tile."""
if url:
return (f'')
return (f'
A benchmark for scientific machine learning
Fast neural surrogates for phase-field fracture
Compare operator-learning architectures on two high-fidelity fracture datasets, then predict crack initiation and propagation in a single forward pass.
Fracture-Bench introduces neural surrogate models to phase-field fracture simulation. It compares operator-learning and generative architectures on shared data splits and evaluation metrics across two high-fidelity datasets. The playground makes these models interactive, so hours of finite-element fracture physics can be explored in a single forward pass. You can find the most up-to-date project resources below:
""" _MODELS_AND_POSTER = """\ __MODELS_OPEN__ Download trained models __MODELS_CLOSE__Fracture-Bench
Configure inputs · Compare surrogates · Inspect FEM error
Choose a dataset, configure its physical inputs, and run the available neural surrogates side by side. Held-out cases include FEM ground truth for direct pixel-wise error comparison.
""", unsafe_allow_html=True, ) _DATASET_TABS = ["Dataset 1 : Perforated plate of hyperelastic material", "Dataset 2 : Heterogeneous plate with two inclusions"] if EMBED: # the github.io page has its own overview; this container is hidden by CSS tab_d1, tab_d2 = playground_block.tabs(_DATASET_TABS) tab_ov = st.container(key="fb_hidden_overview") else: tab_ov, tab_d1, tab_d2 = playground_block.tabs(["Overview"] + _DATASET_TABS) # ====================================================================== # Overview tab # ====================================================================== _txt = "#E9F0F9" if dark_mode else "#13294B" _card_bg = "#16315E" if dark_mode else "#F4F8FC" _border = "#2C4A7C" if dark_mode else "#D1DCF0" def _dataset_card(inner_html: str, cta_intro: str, tab_prefix: str, link_text: str, height: int = 680): """Render a dataset card (content + a working tab-switch CTA) in one themed iframe, so the link runs JS yet sits inside the same box. Use the token __CTA_LI__ inside inner_html to place the CTA tick item.""" if EMBED: # overview is hidden there return lc = "#8FB7EC" if dark_mode else "#235AAA" cta_li = """Phase-field models are the method of choice for simulating fracture — crack nucleation, propagation, branching, and coalescence — within a single variational framework, but each quasi-static simulation is expensive, making ensemble workflows such as uncertainty quantification, Bayesian inference, and design optimization intractable.
Fracture-Bench is a benchmark suite that evaluates machine-learning surrogates which replace the finite-element solve with a single network forward pass. Five architectures (UNet, FNO, DeepONet, Latent DeepONet, and a conditional denoising diffusion model) are trained on identical data splits and scored with common test metrics across two high-fidelity datasets that differ in phase-field formulation, material heterogeneity, and prediction task.
Evaluation spans accuracy, computational efficiency, and generalization to load steps withheld during training. The headline result: no single architecture dominates, and prediction difficulty scales with material heterogeneity and crack-path sensitivity. All datasets, evaluation protocols, and model code are released openly.
Fracture-Bench is meant to grow as a community resource. If you would like to contribute a new surrogate architecture (or a new dataset or fracture problem) to the benchmark, we would be glad to include it — please reach out to any of us: