matterviz 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EmptyState.svelte +10 -2
- package/dist/FilePicker.svelte +154 -96
- package/dist/Icon.svelte +20 -14
- package/dist/MillerIndexInput.svelte +27 -21
- package/dist/api/optimade.js +6 -6
- package/dist/app.css +216 -178
- package/dist/brillouin/BrillouinZone.svelte +299 -198
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
- package/dist/brillouin/BrillouinZoneExportPane.svelte +74 -55
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
- package/dist/brillouin/BrillouinZoneScene.svelte +277 -165
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneTooltip.svelte +17 -7
- package/dist/brillouin/compute.js +11 -6
- package/dist/chempot-diagram/ChemPotDiagram.svelte +327 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +847 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +3194 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +11 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
- package/dist/chempot-diagram/async-compute.svelte.js +77 -0
- package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
- package/dist/chempot-diagram/chempot-worker.js +11 -0
- package/dist/chempot-diagram/color.d.ts +10 -0
- package/dist/chempot-diagram/color.js +32 -0
- package/dist/chempot-diagram/compute.d.ts +48 -0
- package/dist/chempot-diagram/compute.js +812 -0
- package/dist/chempot-diagram/index.d.ts +6 -0
- package/dist/chempot-diagram/index.js +6 -0
- package/dist/chempot-diagram/pointer.d.ts +16 -0
- package/dist/chempot-diagram/pointer.js +40 -0
- package/dist/chempot-diagram/temperature.d.ts +15 -0
- package/dist/chempot-diagram/temperature.js +36 -0
- package/dist/chempot-diagram/types.d.ts +86 -0
- package/dist/chempot-diagram/types.js +28 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +9 -3
- package/dist/composition/BarChart.svelte +141 -77
- package/dist/composition/BubbleChart.svelte +107 -52
- package/dist/composition/Composition.svelte +100 -79
- package/dist/composition/Formula.svelte +108 -62
- package/dist/composition/FormulaFilter.svelte +973 -353
- package/dist/composition/FormulaFilter.svelte.d.ts +35 -1
- package/dist/composition/PieChart.svelte +199 -99
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- package/dist/composition/format.d.ts +5 -0
- package/dist/composition/format.js +20 -3
- package/dist/composition/parse.js +14 -9
- package/dist/convex-hull/ConvexHull.svelte +93 -38
- package/dist/convex-hull/ConvexHull2D.svelte +551 -393
- package/dist/convex-hull/ConvexHull3D.svelte +1303 -825
- package/dist/convex-hull/ConvexHull4D.svelte +1012 -686
- package/dist/convex-hull/ConvexHullControls.svelte +115 -28
- package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
- package/dist/convex-hull/ConvexHullStats.svelte +821 -249
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +41 -16
- package/dist/convex-hull/GasPressureControls.svelte +104 -61
- package/dist/convex-hull/StructurePopup.svelte +25 -4
- package/dist/convex-hull/TemperatureSlider.svelte +45 -25
- package/dist/convex-hull/barycentric-coords.js +13 -7
- package/dist/convex-hull/demo-temperature.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +40 -0
- package/dist/convex-hull/gas-thermodynamics.js +17 -12
- package/dist/convex-hull/helpers.d.ts +10 -1
- package/dist/convex-hull/helpers.js +79 -38
- package/dist/convex-hull/index.d.ts +1 -0
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +163 -69
- package/dist/convex-hull/types.d.ts +12 -12
- package/dist/convex-hull/types.js +0 -12
- package/dist/coordination/CoordinationBarPlot.svelte +232 -176
- package/dist/element/BohrAtom.svelte +56 -13
- package/dist/element/ElementHeading.svelte +7 -2
- package/dist/element/ElementPhoto.svelte +15 -9
- package/dist/element/ElementStats.svelte +10 -4
- package/dist/element/ElementTile.svelte +137 -73
- package/dist/element/Nucleus.svelte +39 -11
- package/dist/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/types.d.ts +1 -0
- package/dist/feedback/ClickFeedback.svelte +16 -5
- package/dist/feedback/DragOverlay.svelte +10 -2
- package/dist/feedback/Spinner.svelte +4 -2
- package/dist/feedback/StatusMessage.svelte +8 -2
- package/dist/fermi-surface/FermiSlice.svelte +118 -88
- package/dist/fermi-surface/FermiSurface.svelte +336 -239
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
- package/dist/fermi-surface/FermiSurfaceScene.svelte +536 -343
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
- package/dist/fermi-surface/compute.js +16 -20
- package/dist/fermi-surface/parse.js +37 -33
- package/dist/fermi-surface/symmetry.js +2 -7
- package/dist/fermi-surface/types.d.ts +3 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1527 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +30 -0
- package/dist/heatmap-matrix/index.d.ts +53 -0
- package/dist/heatmap-matrix/index.js +100 -0
- package/dist/heatmap-matrix/shared.d.ts +2 -0
- package/dist/heatmap-matrix/shared.js +4 -0
- package/dist/icons.d.ts +111 -0
- package/dist/icons.js +158 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.d.ts +3 -0
- package/dist/io/export.js +138 -140
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +43 -0
- package/dist/io/index.d.ts +2 -2
- package/dist/io/index.js +2 -112
- package/dist/io/is-binary.js +2 -3
- package/dist/io/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +117 -0
- package/dist/isosurface/Isosurface.svelte +220 -110
- package/dist/isosurface/IsosurfaceControls.svelte +65 -28
- package/dist/isosurface/parse.js +104 -56
- package/dist/isosurface/slice.d.ts +2 -1
- package/dist/isosurface/slice.js +8 -13
- package/dist/isosurface/types.d.ts +14 -1
- package/dist/isosurface/types.js +152 -5
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +12 -8
- package/dist/layout/FullscreenToggle.svelte +11 -2
- package/dist/layout/InfoCard.svelte +38 -6
- package/dist/layout/InfoTag.svelte +125 -94
- package/dist/layout/PropertyFilter.svelte +82 -37
- package/dist/layout/SettingsSection.svelte +85 -55
- package/dist/layout/SubpageGrid.svelte +82 -0
- package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +266 -223
- package/dist/layout/json-tree/JsonTree.svelte +516 -429
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +281 -173
- package/dist/layout/json-tree/types.d.ts +10 -2
- package/dist/layout/json-tree/utils.d.ts +2 -0
- package/dist/layout/json-tree/utils.js +37 -2
- package/dist/marching-cubes.js +25 -2
- package/dist/math.d.ts +20 -17
- package/dist/math.js +474 -57
- package/dist/overlays/ContextMenu.svelte +66 -40
- package/dist/overlays/DraggablePane.svelte +331 -154
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- package/dist/periodic-table/PeriodicTable.svelte +278 -145
- package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
- package/dist/periodic-table/PropertySelect.svelte +25 -7
- package/dist/periodic-table/TableInset.svelte +8 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +559 -267
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +131 -51
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +160 -110
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +8 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +217 -86
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
- package/dist/phase-diagram/build-diagram.js +9 -9
- package/dist/phase-diagram/colors.js +1 -3
- package/dist/phase-diagram/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/parse.js +10 -9
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +869 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +8 -4
- package/dist/phase-diagram/utils.js +219 -74
- package/dist/plot/AxisLabel.svelte +51 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +1461 -768
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +33 -6
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +533 -383
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ColorScaleSelect.svelte +28 -7
- package/dist/plot/ElementScatter.svelte +38 -16
- package/dist/plot/FillArea.svelte +152 -92
- package/dist/plot/Histogram.svelte +1162 -709
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +81 -18
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- package/dist/plot/InteractiveAxisLabel.svelte +34 -11
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/Line.svelte +63 -28
- package/dist/plot/PlotControls.svelte +221 -96
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +174 -91
- package/dist/plot/PlotTooltip.svelte +45 -6
- package/dist/plot/PortalSelect.svelte +175 -146
- package/dist/plot/ReferenceLine.svelte +77 -22
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferenceLine3D.svelte +132 -107
- package/dist/plot/ReferencePlane.svelte +146 -123
- package/dist/plot/ScatterPlot.svelte +1880 -1156
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte +256 -131
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +300 -297
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot3DScene.svelte +608 -406
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +150 -70
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ScatterPoint.svelte +98 -26
- package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
- package/dist/plot/SpacegroupBarPlot.svelte +142 -85
- package/dist/plot/Surface3D.svelte +159 -108
- package/dist/plot/ZeroLines.svelte +96 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +23 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- package/dist/plot/axis-utils.js +1 -3
- package/dist/plot/data-cleaning.js +12 -28
- package/dist/plot/data-transform.js +2 -1
- package/dist/plot/fill-utils.js +2 -0
- package/dist/plot/index.d.ts +6 -2
- package/dist/plot/index.js +6 -2
- package/dist/plot/interactions.d.ts +8 -10
- package/dist/plot/interactions.js +2 -3
- package/dist/plot/layout.d.ts +11 -2
- package/dist/plot/layout.js +44 -17
- package/dist/plot/reference-line.d.ts +5 -22
- package/dist/plot/reference-line.js +12 -84
- package/dist/plot/scales.js +24 -36
- package/dist/plot/types.d.ts +53 -40
- package/dist/plot/types.js +12 -7
- package/dist/plot/utils/label-placement.d.ts +32 -15
- package/dist/plot/utils/label-placement.js +227 -63
- package/dist/plot/utils/series-visibility.js +2 -3
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +173 -132
- package/dist/rdf/calc-rdf.js +4 -5
- package/dist/sanitize.d.ts +4 -0
- package/dist/sanitize.js +107 -0
- package/dist/settings.d.ts +21 -6
- package/dist/settings.js +63 -19
- package/dist/spectral/Bands.svelte +963 -412
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- package/dist/spectral/BandsAndDos.svelte +90 -49
- package/dist/spectral/BrillouinBandsDos.svelte +151 -93
- package/dist/spectral/Dos.svelte +389 -258
- package/dist/spectral/helpers.d.ts +23 -1
- package/dist/spectral/helpers.js +119 -51
- package/dist/spectral/types.d.ts +2 -0
- package/dist/state.svelte.d.ts +1 -1
- package/dist/state.svelte.js +3 -2
- package/dist/structure/Arrow.svelte +59 -20
- package/dist/structure/AtomLegend.svelte +231 -129
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +73 -47
- package/dist/structure/CanvasTooltip.svelte +10 -2
- package/dist/structure/CellSelect.svelte +148 -51
- package/dist/structure/Cylinder.svelte +33 -17
- package/dist/structure/Lattice.svelte +88 -33
- package/dist/structure/Structure.svelte +1077 -821
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureControls.svelte +373 -139
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +124 -89
- package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +304 -231
- package/dist/structure/StructureScene.svelte +919 -445
- package/dist/structure/StructureScene.svelte.d.ts +16 -7
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +42 -29
- package/dist/structure/bonding.js +6 -7
- package/dist/structure/export.js +22 -34
- package/dist/structure/ferrox-wasm-types.d.ts +3 -2
- package/dist/structure/ferrox-wasm-types.js +0 -3
- package/dist/structure/ferrox-wasm.d.ts +3 -2
- package/dist/structure/ferrox-wasm.js +2 -3
- package/dist/structure/index.d.ts +16 -0
- package/dist/structure/index.js +88 -6
- package/dist/structure/measure.d.ts +2 -2
- package/dist/structure/measure.js +4 -44
- package/dist/structure/parse.js +130 -155
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +99 -0
- package/dist/structure/pbc.d.ts +1 -0
- package/dist/structure/pbc.js +16 -6
- package/dist/structure/supercell.d.ts +2 -2
- package/dist/structure/supercell.js +12 -22
- package/dist/structure/validation.js +5 -3
- package/dist/symmetry/SymmetryStats.svelte +94 -37
- package/dist/symmetry/WyckoffTable.svelte +42 -14
- package/dist/symmetry/cell-transform.js +5 -3
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +87 -21
- package/dist/symmetry/spacegroups.js +148 -148
- package/dist/table/HeatmapTable.svelte +1112 -516
- package/dist/table/HeatmapTable.svelte.d.ts +12 -1
- package/dist/table/ToggleMenu.svelte +125 -90
- package/dist/table/index.d.ts +2 -0
- package/dist/table/index.js +2 -4
- package/dist/theme/ThemeControl.svelte +21 -12
- package/dist/time.js +4 -1
- package/dist/tooltip/TooltipContent.svelte +33 -8
- package/dist/trajectory/Trajectory.svelte +889 -687
- package/dist/trajectory/TrajectoryError.svelte +14 -3
- package/dist/trajectory/TrajectoryExportPane.svelte +148 -90
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +13 -31
- package/dist/trajectory/format-detect.d.ts +9 -0
- package/dist/trajectory/format-detect.js +76 -0
- package/dist/trajectory/frame-reader.d.ts +17 -0
- package/dist/trajectory/frame-reader.js +332 -0
- package/dist/trajectory/helpers.d.ts +14 -0
- package/dist/trajectory/helpers.js +172 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +23 -14
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +77 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +129 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +299 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +179 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +68 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +110 -0
- package/dist/trajectory/plotting.js +13 -8
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +17 -0
- package/dist/xrd/XrdPlot.svelte +337 -245
- package/dist/xrd/broadening.js +14 -9
- package/dist/xrd/calc-xrd.js +12 -19
- package/dist/xrd/parse.d.ts +1 -1
- package/dist/xrd/parse.js +17 -17
- package/package.json +103 -101
- package/readme.md +4 -4
- package/dist/trajectory/parse.d.ts +0 -42
- package/dist/trajectory/parse.js +0 -1267
- /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
- /package/dist/theme/{themes.js → themes.mjs} +0 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { get_electro_neg_formula } from '../composition/format';
|
|
3
|
+
import type { PhaseData } from '../convex-hull/types';
|
|
4
|
+
import Spinner from '../feedback/Spinner.svelte';
|
|
5
|
+
import { format_num } from '../labels';
|
|
6
|
+
import { constrain_tooltip_position } from '../plot/layout';
|
|
7
|
+
import { sanitize_html } from '../sanitize';
|
|
8
|
+
import { compute_chempot_async } from './async-compute.svelte';
|
|
9
|
+
import ChemPotDiagram2D from './ChemPotDiagram2D.svelte';
|
|
10
|
+
import ChemPotDiagram3D from './ChemPotDiagram3D.svelte';
|
|
11
|
+
import { get_ternary_combinations } from './compute';
|
|
12
|
+
import type {
|
|
13
|
+
ChemPotDiagramConfig,
|
|
14
|
+
ChemPotHoverInfo,
|
|
15
|
+
ChemPotHoverInfo3D,
|
|
16
|
+
} from './types';
|
|
17
|
+
import { CHEMPOT_DEFAULTS } from './types';
|
|
18
|
+
|
|
19
|
+
let {
|
|
20
|
+
entries = [],
|
|
21
|
+
config = {},
|
|
22
|
+
width = $bindable(600),
|
|
23
|
+
height = $bindable(600),
|
|
24
|
+
// Bound temperature may be auto-corrected by 2D/3D child components.
|
|
25
|
+
temperature = $bindable(),
|
|
26
|
+
hover_info = $bindable<ChemPotHoverInfo | null>(null),
|
|
27
|
+
}: {
|
|
28
|
+
entries: PhaseData[]
|
|
29
|
+
config?: ChemPotDiagramConfig
|
|
30
|
+
width?: number
|
|
31
|
+
height?: number
|
|
32
|
+
temperature?: number
|
|
33
|
+
hover_info?: ChemPotHoverInfo | null
|
|
34
|
+
} = $props()
|
|
35
|
+
|
|
36
|
+
// Extract unique elements from all entries (composition keys are element symbols)
|
|
37
|
+
const all_elements = $derived(
|
|
38
|
+
[
|
|
39
|
+
...new Set(entries.flatMap((entry) =>
|
|
40
|
+
Object.entries(entry.composition)
|
|
41
|
+
.filter(([, amount]) => amount > 0)
|
|
42
|
+
.map(([element]) => element)
|
|
43
|
+
)),
|
|
44
|
+
].toSorted(),
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
// How many display axes (2 = binary/2D, 3+ = ternary/3D)
|
|
48
|
+
const display_elements = $derived(config.elements ?? all_elements)
|
|
49
|
+
const n_display = $derived(display_elements.length)
|
|
50
|
+
const show_tooltip = $derived(
|
|
51
|
+
config.show_tooltip ?? CHEMPOT_DEFAULTS.show_tooltip,
|
|
52
|
+
)
|
|
53
|
+
const tooltip_detail_level = $derived(
|
|
54
|
+
config.tooltip_detail_level ?? CHEMPOT_DEFAULTS.tooltip_detail_level,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
const projection_mode = $derived(
|
|
58
|
+
config.projection_mode ?? CHEMPOT_DEFAULTS.projection_mode,
|
|
59
|
+
)
|
|
60
|
+
// For quaternary+ in grid mode, generate all C(n,3) ternary projections
|
|
61
|
+
// Uses display_elements (not all_elements) so config.elements scopes the grid
|
|
62
|
+
const ternary_combos = $derived(
|
|
63
|
+
n_display > 3 && projection_mode === `grid`
|
|
64
|
+
? get_ternary_combinations(display_elements)
|
|
65
|
+
: [],
|
|
66
|
+
)
|
|
67
|
+
const show_grid = $derived(ternary_combos.length > 0 && ternary_combos.length <= 12)
|
|
68
|
+
// Scale down sub-diagrams in grid mode
|
|
69
|
+
const grid_width = $derived(Math.max(280, Math.round(width * 0.48)))
|
|
70
|
+
const grid_height = $derived(Math.max(240, Math.round(height * 0.48)))
|
|
71
|
+
|
|
72
|
+
// Pre-warm the worker's N-D computation cache before mounting heavy 3D
|
|
73
|
+
// children. Fires one async call with the first projection — subsequent
|
|
74
|
+
// child calls for different element triples hit the cached N-D result.
|
|
75
|
+
let grid_cache_ready = $state(false)
|
|
76
|
+
let grid_error = $state<string | null>(null)
|
|
77
|
+
$effect(() => {
|
|
78
|
+
grid_cache_ready = false
|
|
79
|
+
grid_error = null
|
|
80
|
+
if (!show_grid) return
|
|
81
|
+
let cancelled = false
|
|
82
|
+
compute_chempot_async(entries, { ...config, elements: ternary_combos[0] })
|
|
83
|
+
.then(() => { if (!cancelled) grid_cache_ready = true })
|
|
84
|
+
.catch((err) => {
|
|
85
|
+
if (cancelled) return
|
|
86
|
+
console.error(`Grid precompute failed:`, err)
|
|
87
|
+
grid_error = err instanceof Error ? err.message : String(err)
|
|
88
|
+
})
|
|
89
|
+
return () => { cancelled = true }
|
|
90
|
+
})
|
|
91
|
+
const is_hover_info_3d = (value: ChemPotHoverInfo | null): value is ChemPotHoverInfo3D => value?.view === `3d`
|
|
92
|
+
|
|
93
|
+
let tooltip_el = $state<HTMLElement>()
|
|
94
|
+
const tooltip_pos = $derived.by(() => {
|
|
95
|
+
const pointer = hover_info?.pointer
|
|
96
|
+
if (!pointer) return { x: 4, y: 4 }
|
|
97
|
+
return constrain_tooltip_position(
|
|
98
|
+
pointer.x, pointer.y,
|
|
99
|
+
tooltip_el?.offsetWidth ?? 200,
|
|
100
|
+
tooltip_el?.offsetHeight ?? 100,
|
|
101
|
+
width, height,
|
|
102
|
+
{ offset: 0 },
|
|
103
|
+
)
|
|
104
|
+
})
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<div class="chempot-diagram-wrapper">
|
|
108
|
+
{#if n_display < 2}
|
|
109
|
+
<div
|
|
110
|
+
class="chempot-error"
|
|
111
|
+
role="alert"
|
|
112
|
+
aria-live="polite"
|
|
113
|
+
style:width="{width}px"
|
|
114
|
+
style:height="{height}px"
|
|
115
|
+
>
|
|
116
|
+
<div>
|
|
117
|
+
<h3 id="unsupported-chemical-system">Unsupported Chemical System</h3>
|
|
118
|
+
<p>
|
|
119
|
+
Chemical potential diagrams require at least 2 elements. Found {n_display}
|
|
120
|
+
element{n_display === 1 ? `` : `s`}:
|
|
121
|
+
{display_elements.join(`, `) || `none`}
|
|
122
|
+
</p>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
{:else if n_display === 2}
|
|
126
|
+
<ChemPotDiagram2D
|
|
127
|
+
{entries}
|
|
128
|
+
{config}
|
|
129
|
+
bind:width
|
|
130
|
+
bind:height
|
|
131
|
+
bind:temperature
|
|
132
|
+
bind:hover_info
|
|
133
|
+
render_local_tooltip={false}
|
|
134
|
+
/>
|
|
135
|
+
{:else if n_display === 3 || !show_grid}
|
|
136
|
+
<ChemPotDiagram3D
|
|
137
|
+
{entries}
|
|
138
|
+
{config}
|
|
139
|
+
bind:width
|
|
140
|
+
bind:height
|
|
141
|
+
bind:temperature
|
|
142
|
+
bind:hover_info
|
|
143
|
+
render_local_tooltip={false}
|
|
144
|
+
/>
|
|
145
|
+
{:else}
|
|
146
|
+
<p class="projection-info">
|
|
147
|
+
Showing all {ternary_combos.length} ternary projections of the
|
|
148
|
+
{display_elements.length}-element system ({display_elements.join(`-`)})
|
|
149
|
+
</p>
|
|
150
|
+
{#if grid_error}
|
|
151
|
+
<div class="chempot-error" role="alert">
|
|
152
|
+
<div>
|
|
153
|
+
<h3 id="grid-computation-failed">Grid computation failed</h3>
|
|
154
|
+
<p>{grid_error}</p>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
{:else if !grid_cache_ready}
|
|
158
|
+
<Spinner
|
|
159
|
+
text="Computing {display_elements.length}-element chemical potential domains..."
|
|
160
|
+
style="--spinner-size: 1.2em"
|
|
161
|
+
/>
|
|
162
|
+
{:else}
|
|
163
|
+
<div class="projection-grid">
|
|
164
|
+
{#each ternary_combos as combo (combo.join(`|`))}
|
|
165
|
+
<div class="projection-cell">
|
|
166
|
+
<h4 id="projection" class="projection-label">{combo.join(`-`)} projection</h4>
|
|
167
|
+
<ChemPotDiagram3D
|
|
168
|
+
{entries}
|
|
169
|
+
config={{ ...config, elements: combo }}
|
|
170
|
+
width={grid_width}
|
|
171
|
+
height={grid_height}
|
|
172
|
+
bind:temperature
|
|
173
|
+
/>
|
|
174
|
+
</div>
|
|
175
|
+
{/each}
|
|
176
|
+
</div>
|
|
177
|
+
{/if}
|
|
178
|
+
{/if}
|
|
179
|
+
{#if show_tooltip && hover_info}
|
|
180
|
+
<aside
|
|
181
|
+
bind:this={tooltip_el}
|
|
182
|
+
class="chempot-tooltip"
|
|
183
|
+
style:left="{tooltip_pos.x}px"
|
|
184
|
+
style:top="{tooltip_pos.y}px"
|
|
185
|
+
>
|
|
186
|
+
<h4>{@html sanitize_html(get_electro_neg_formula(hover_info.formula, false, ``, `.3~s`))}</h4>
|
|
187
|
+
{#if hover_info.view === `2d`}
|
|
188
|
+
<p>2D domain · Points: {hover_info.n_points}</p>
|
|
189
|
+
{#if tooltip_detail_level === `detailed`}
|
|
190
|
+
<h5 id="axis-ranges">Axis ranges</h5>
|
|
191
|
+
{#each hover_info.axis_ranges as axis_range (axis_range.element)}
|
|
192
|
+
<p>
|
|
193
|
+
{axis_range.element}: {format_num(axis_range.min_val, `.4~g`)} to
|
|
194
|
+
{format_num(axis_range.max_val, `.4~g`)} eV
|
|
195
|
+
</p>
|
|
196
|
+
{/each}
|
|
197
|
+
{/if}
|
|
198
|
+
{:else if is_hover_info_3d(hover_info)}
|
|
199
|
+
<p>
|
|
200
|
+
{hover_info.is_elemental ? `Elemental phase` : `Compound phase`}
|
|
201
|
+
{#if hover_info.is_draw_formula}
|
|
202
|
+
<span> · Overlay target</span>
|
|
203
|
+
{/if}
|
|
204
|
+
</p>
|
|
205
|
+
<p>
|
|
206
|
+
Vertices: {hover_info.n_vertices} · Edges: {hover_info.n_edges} · Points:
|
|
207
|
+
{hover_info.n_points}
|
|
208
|
+
</p>
|
|
209
|
+
<p>
|
|
210
|
+
Entries: {hover_info.matching_entry_count}
|
|
211
|
+
{#if hover_info.min_energy_per_atom !== null &&
|
|
212
|
+
hover_info.max_energy_per_atom !== null}
|
|
213
|
+
· E/atom: {format_num(hover_info.min_energy_per_atom, `.4~g`)}
|
|
214
|
+
to {format_num(hover_info.max_energy_per_atom, `.4~g`)} eV
|
|
215
|
+
{/if}
|
|
216
|
+
</p>
|
|
217
|
+
{#if tooltip_detail_level === `detailed`}
|
|
218
|
+
<h5 id="axis-ranges-1">Axis ranges</h5>
|
|
219
|
+
{#each hover_info.axis_ranges as axis_range (axis_range.element)}
|
|
220
|
+
<p>
|
|
221
|
+
{axis_range.element}: {format_num(axis_range.min_val, `.4~g`)} to
|
|
222
|
+
{format_num(axis_range.max_val, `.4~g`)} eV
|
|
223
|
+
</p>
|
|
224
|
+
{/each}
|
|
225
|
+
<p>
|
|
226
|
+
Centroid: ({
|
|
227
|
+
hover_info.ann_loc.map((value) => format_num(value, `.3~g`)).join(
|
|
228
|
+
`, `,
|
|
229
|
+
)
|
|
230
|
+
})
|
|
231
|
+
</p>
|
|
232
|
+
{#if hover_info.neighbors.length > 0}
|
|
233
|
+
<h5 id="neighbors">Neighbors ({hover_info.neighbors.length})</h5>
|
|
234
|
+
<p>
|
|
235
|
+
{
|
|
236
|
+
hover_info.neighbors.map((f) => get_electro_neg_formula(f, true, ``, `.3~s`)).join(
|
|
237
|
+
`, `,
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
</p>
|
|
241
|
+
{/if}
|
|
242
|
+
{#if hover_info.touches_limits.length > 0}
|
|
243
|
+
<h5 id="touches-bounds">Touches bounds</h5>
|
|
244
|
+
<p>{hover_info.touches_limits.join(`, `)}</p>
|
|
245
|
+
{/if}
|
|
246
|
+
{/if}
|
|
247
|
+
{/if}
|
|
248
|
+
</aside>
|
|
249
|
+
{/if}
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
<style>
|
|
253
|
+
.chempot-diagram-wrapper {
|
|
254
|
+
position: relative;
|
|
255
|
+
}
|
|
256
|
+
.projection-info {
|
|
257
|
+
margin: 0 0 0.5em;
|
|
258
|
+
font-size: 0.9em;
|
|
259
|
+
color: var(--text-color-secondary, #666);
|
|
260
|
+
}
|
|
261
|
+
.projection-grid {
|
|
262
|
+
display: grid;
|
|
263
|
+
grid-template-columns: repeat(2, 1fr);
|
|
264
|
+
gap: 0.4em;
|
|
265
|
+
}
|
|
266
|
+
.projection-cell {
|
|
267
|
+
min-width: 0;
|
|
268
|
+
}
|
|
269
|
+
.projection-label {
|
|
270
|
+
margin: 0 0 0.3em;
|
|
271
|
+
font-size: 0.85em;
|
|
272
|
+
font-weight: 400;
|
|
273
|
+
text-align: center;
|
|
274
|
+
}
|
|
275
|
+
.chempot-error {
|
|
276
|
+
display: flex;
|
|
277
|
+
align-items: center;
|
|
278
|
+
justify-content: center;
|
|
279
|
+
border: 1px solid var(--border-color, #ccc);
|
|
280
|
+
border-radius: var(--border-radius, 3pt);
|
|
281
|
+
background: var(--bg-color, transparent);
|
|
282
|
+
}
|
|
283
|
+
.chempot-error > div {
|
|
284
|
+
text-align: center;
|
|
285
|
+
padding: 2em;
|
|
286
|
+
color: var(--text-color, #666);
|
|
287
|
+
}
|
|
288
|
+
.chempot-error h3 {
|
|
289
|
+
margin: 0 0 1em;
|
|
290
|
+
}
|
|
291
|
+
.chempot-error p {
|
|
292
|
+
margin: 0;
|
|
293
|
+
}
|
|
294
|
+
.chempot-tooltip {
|
|
295
|
+
position: absolute;
|
|
296
|
+
max-width: min(32rem, 92vw);
|
|
297
|
+
background: var(
|
|
298
|
+
--tooltip-bg,
|
|
299
|
+
light-dark(rgba(255, 255, 255, 0.95), rgba(0, 0, 0, 0.9))
|
|
300
|
+
);
|
|
301
|
+
color: var(--tooltip-text, var(--text-color, #222));
|
|
302
|
+
border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
|
|
303
|
+
border-radius: 6px;
|
|
304
|
+
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
|
|
305
|
+
padding: 8px 10px;
|
|
306
|
+
font-size: 12px;
|
|
307
|
+
line-height: 1.35;
|
|
308
|
+
pointer-events: none;
|
|
309
|
+
z-index: 40;
|
|
310
|
+
}
|
|
311
|
+
.chempot-tooltip h4 {
|
|
312
|
+
margin: 0 0 4px;
|
|
313
|
+
font-size: 13px;
|
|
314
|
+
}
|
|
315
|
+
.chempot-tooltip p {
|
|
316
|
+
margin: 1px 0;
|
|
317
|
+
white-space: nowrap;
|
|
318
|
+
overflow: hidden;
|
|
319
|
+
text-overflow: ellipsis;
|
|
320
|
+
}
|
|
321
|
+
.chempot-tooltip h5 {
|
|
322
|
+
margin-top: 6px;
|
|
323
|
+
margin-bottom: 0;
|
|
324
|
+
font-size: 12px;
|
|
325
|
+
font-weight: 600;
|
|
326
|
+
}
|
|
327
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PhaseData } from '../convex-hull/types';
|
|
2
|
+
import type { ChemPotDiagramConfig, ChemPotHoverInfo } from './types';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
entries: PhaseData[];
|
|
5
|
+
config?: ChemPotDiagramConfig;
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
temperature?: number;
|
|
9
|
+
hover_info?: ChemPotHoverInfo | null;
|
|
10
|
+
};
|
|
11
|
+
declare const ChemPotDiagram: import("svelte").Component<$$ComponentProps, {}, "temperature" | "height" | "width" | "hover_info">;
|
|
12
|
+
type ChemPotDiagram = ReturnType<typeof ChemPotDiagram>;
|
|
13
|
+
export default ChemPotDiagram;
|