matterviz 0.4.1 → 0.4.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 -4
- package/dist/FilePicker.svelte +48 -60
- package/dist/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +2 -2
- package/dist/api/optimade.js +10 -7
- package/dist/app.css +68 -0
- package/dist/brillouin/BrillouinZone.svelte +90 -91
- package/dist/brillouin/BrillouinZone.svelte.d.ts +5 -7
- package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
- package/dist/brillouin/BrillouinZoneExportPane.svelte +18 -14
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +6 -10
- package/dist/brillouin/BrillouinZoneScene.svelte +46 -68
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/compute.js +10 -16
- package/dist/brillouin/geometry.js +2 -2
- package/dist/chempot-diagram/ChemPotDiagram.svelte +48 -50
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +61 -169
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +559 -755
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +1 -1
- package/dist/chempot-diagram/async-compute.svelte.js +13 -14
- package/dist/chempot-diagram/color.d.ts +21 -1
- package/dist/chempot-diagram/color.js +70 -1
- package/dist/chempot-diagram/compute.d.ts +7 -0
- package/dist/chempot-diagram/compute.js +85 -26
- package/dist/chempot-diagram/controls-state.svelte.js +1 -1
- package/dist/chempot-diagram/export.js +1 -6
- package/dist/chempot-diagram/temperature.js +9 -10
- package/dist/colors/index.d.ts +0 -4
- package/dist/colors/index.js +19 -20
- package/dist/composition/BarChart.svelte +30 -26
- package/dist/composition/BubbleChart.svelte +17 -17
- package/dist/composition/Composition.svelte +10 -19
- package/dist/composition/Formula.svelte +20 -27
- package/dist/composition/FormulaFilter.svelte +115 -184
- package/dist/composition/PieChart.svelte +55 -41
- package/dist/composition/format.js +7 -9
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +2 -2
- package/dist/composition/parse.js +61 -115
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +17 -26
- package/dist/convex-hull/ConvexHull.svelte +12 -15
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +93 -94
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +127 -186
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +131 -180
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +36 -40
- package/dist/convex-hull/ConvexHullControls.svelte +46 -48
- package/dist/convex-hull/ConvexHullStats.svelte +193 -195
- package/dist/convex-hull/ConvexHullTooltip.svelte +5 -12
- package/dist/convex-hull/GasPressureControls.svelte +5 -12
- package/dist/convex-hull/StructurePopup.svelte +18 -22
- package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
- package/dist/convex-hull/TemperatureSlider.svelte +4 -10
- package/dist/convex-hull/canvas-interactions.svelte.js +2 -1
- package/dist/convex-hull/gas-thermodynamics.js +21 -53
- package/dist/convex-hull/helpers.d.ts +8 -10
- package/dist/convex-hull/helpers.js +37 -43
- package/dist/convex-hull/hull-state.svelte.d.ts +1 -1
- package/dist/convex-hull/thermodynamics.js +37 -44
- package/dist/coordination/CoordinationBarPlot.svelte +49 -53
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
- package/dist/coordination/calc-coordination.d.ts +1 -1
- package/dist/coordination/calc-coordination.js +28 -25
- package/dist/element/BohrAtom.svelte +5 -9
- package/dist/element/ElementHeading.svelte +4 -1
- package/dist/element/ElementPhoto.svelte +11 -9
- package/dist/element/ElementStats.svelte +12 -10
- package/dist/element/ElementTile.svelte +44 -67
- package/dist/element/Nucleus.svelte +4 -2
- package/dist/element/data.d.ts +3 -2
- package/dist/element/data.js +5 -1
- package/dist/element/helpers.d.ts +4 -0
- package/dist/element/helpers.js +18 -0
- package/dist/element/index.d.ts +2 -5
- package/dist/element/index.js +4 -19
- package/dist/feedback/DragOverlay.svelte +5 -5
- package/dist/feedback/DragOverlay.svelte.d.ts +2 -2
- package/dist/feedback/StatusMessage.svelte +7 -4
- package/dist/fermi-surface/FermiSlice.svelte +21 -18
- package/dist/fermi-surface/FermiSurface.svelte +35 -44
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +7 -13
- package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +64 -136
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
- package/dist/fermi-surface/compute.js +25 -58
- package/dist/fermi-surface/parse.js +54 -88
- package/dist/file-viewer/JsonBrowser.svelte +1043 -0
- package/dist/file-viewer/JsonBrowser.svelte.d.ts +9 -0
- package/dist/file-viewer/PlotPanel.svelte +350 -0
- package/dist/file-viewer/PlotPanel.svelte.d.ts +9 -0
- package/dist/file-viewer/TrajectoryWithDos.svelte +30 -0
- package/dist/file-viewer/TrajectoryWithDos.svelte.d.ts +10 -0
- package/dist/file-viewer/detect.d.ts +11 -0
- package/dist/file-viewer/detect.js +381 -0
- package/dist/file-viewer/eligibility.d.ts +4 -0
- package/dist/file-viewer/eligibility.js +53 -0
- package/dist/file-viewer/host-protocol.d.ts +50 -0
- package/dist/file-viewer/host-transfer.d.ts +25 -0
- package/dist/file-viewer/host-transfer.js +42 -0
- package/dist/file-viewer/index.d.ts +5 -0
- package/dist/file-viewer/index.js +5 -0
- package/dist/file-viewer/main.d.ts +44 -0
- package/dist/file-viewer/main.js +535 -0
- package/dist/file-viewer/parse.d.ts +9 -0
- package/dist/file-viewer/parse.js +170 -0
- package/dist/file-viewer/plot-utils.d.ts +24 -0
- package/dist/file-viewer/plot-utils.js +191 -0
- package/dist/file-viewer/types.d.ts +4 -0
- package/dist/file-viewer/types.js +5 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +153 -219
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +9 -7
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +1 -1
- package/dist/heatmap-matrix/index.d.ts +5 -0
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/io/ExportPane.svelte +11 -7
- package/dist/io/decompress.d.ts +4 -1
- package/dist/io/decompress.js +24 -36
- package/dist/io/export.d.ts +11 -4
- package/dist/io/export.js +75 -19
- package/dist/io/fetch.d.ts +0 -3
- package/dist/io/fetch.js +0 -11
- package/dist/io/file-drop.js +60 -35
- package/dist/io/index.d.ts +0 -1
- package/dist/io/index.js +2 -9
- package/dist/io/is-binary.d.ts +9 -0
- package/dist/io/is-binary.js +45 -1
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +40 -40
- package/dist/isosurface/Isosurface.svelte +700 -215
- package/dist/isosurface/Isosurface.svelte.d.ts +7 -1
- package/dist/isosurface/IsosurfaceControls.svelte +590 -116
- package/dist/isosurface/IsosurfaceControls.svelte.d.ts +1 -1
- package/dist/isosurface/VolumeSlice.svelte +224 -0
- package/dist/isosurface/VolumeSlice.svelte.d.ts +28 -0
- package/dist/isosurface/coloring.d.ts +20 -0
- package/dist/isosurface/coloring.js +118 -0
- package/dist/isosurface/geometry-worker-types.d.ts +38 -0
- package/dist/isosurface/geometry.worker.d.ts +1 -0
- package/dist/isosurface/geometry.worker.js +59 -0
- package/dist/isosurface/grid.d.ts +10 -0
- package/dist/isosurface/grid.js +31 -0
- package/dist/isosurface/index.d.ts +4 -0
- package/dist/isosurface/index.js +4 -0
- package/dist/isosurface/parse-vaspwave.d.ts +3 -0
- package/dist/isosurface/parse-vaspwave.js +138 -0
- package/dist/isosurface/parse.js +6 -6
- package/dist/isosurface/profile.d.ts +12 -0
- package/dist/isosurface/profile.js +19 -0
- package/dist/isosurface/sampling.d.ts +34 -0
- package/dist/isosurface/sampling.js +408 -0
- package/dist/isosurface/slice-rendering.d.ts +13 -0
- package/dist/isosurface/slice-rendering.js +79 -0
- package/dist/isosurface/slice.d.ts +22 -2
- package/dist/isosurface/slice.js +200 -116
- package/dist/isosurface/types.d.ts +24 -1
- package/dist/isosurface/types.js +120 -8
- package/dist/json-path.d.ts +4 -0
- package/dist/json-path.js +89 -0
- package/dist/labels.d.ts +6 -2
- package/dist/labels.js +44 -14
- package/dist/layout/FullscreenButton.svelte +2 -1
- package/dist/layout/FullscreenToggle.svelte +10 -4
- package/dist/layout/InfoCard.svelte +8 -21
- package/dist/layout/InfoTag.svelte +1 -3
- package/dist/layout/NumberRangeInput.svelte +46 -0
- package/dist/layout/NumberRangeInput.svelte.d.ts +12 -0
- package/dist/layout/PropertyFilter.svelte +2 -6
- package/dist/layout/SettingsSection.svelte +57 -62
- package/dist/layout/SettingsSection.svelte.d.ts +6 -7
- package/dist/layout/SubpageGrid.svelte +3 -1
- package/dist/layout/ViewerChrome.svelte +16 -11
- package/dist/layout/ViewerChrome.svelte.d.ts +2 -1
- package/dist/layout/fullscreen.js +3 -5
- package/dist/layout/fullscreen.svelte.js +1 -2
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +22 -59
- package/dist/layout/json-tree/JsonTree.svelte +101 -172
- package/dist/layout/json-tree/JsonValue.svelte +9 -32
- package/dist/layout/json-tree/utils.d.ts +0 -3
- package/dist/layout/json-tree/utils.js +50 -188
- package/dist/marching-cubes.d.ts +8 -1
- package/dist/marching-cubes.js +115 -48
- package/dist/math.d.ts +5 -2
- package/dist/math.js +48 -38
- package/dist/overlays/ContextMenu.svelte +19 -34
- package/dist/overlays/CopyButton.svelte +11 -5
- package/dist/overlays/DragControlTab.svelte +6 -1
- package/dist/overlays/DraggablePane.svelte +110 -74
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -1
- package/dist/overlays/GlassChip.svelte +32 -0
- package/dist/overlays/GlassChip.svelte.d.ts +8 -0
- package/dist/overlays/InfoPaneCards.svelte +11 -23
- package/dist/overlays/index.d.ts +7 -0
- package/dist/overlays/index.js +26 -0
- package/dist/overlays/portal.d.ts +2 -0
- package/dist/overlays/portal.js +14 -0
- package/dist/periodic-table/PeriodicTable.svelte +113 -145
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
- package/dist/periodic-table/PeriodicTableControls.svelte +37 -115
- package/dist/periodic-table/TableInset.svelte +9 -4
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +68 -105
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
- package/dist/phase-diagram/PhaseDiagramControls.svelte +70 -94
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +12 -12
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
- package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
- package/dist/phase-diagram/build-diagram.js +4 -9
- package/dist/phase-diagram/diagram-input.d.ts +1 -2
- package/dist/phase-diagram/parse.js +15 -15
- package/dist/phase-diagram/svg-to-diagram.js +28 -27
- package/dist/phase-diagram/utils.js +2 -3
- package/dist/plot/bar/BarPlot.svelte +461 -426
- package/dist/plot/bar/BarPlot.svelte.d.ts +2 -0
- package/dist/plot/bar/BarPlotControls.svelte +1 -3
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +4 -6
- package/dist/plot/bar/SpacegroupBarPlot.svelte +46 -77
- package/dist/plot/bar/data.d.ts +5 -4
- package/dist/plot/bar/data.js +2 -1
- package/dist/plot/box/BoxPlot.svelte +322 -226
- package/dist/plot/box/BoxPlot.svelte.d.ts +2 -0
- package/dist/plot/box/Violin.svelte.d.ts +1 -0
- package/dist/plot/box/box-plot.js +1 -1
- package/dist/plot/core/auto-place.d.ts +1 -1
- package/dist/plot/core/auto-place.js +2 -2
- package/dist/plot/core/axis-utils.d.ts +12 -7
- package/dist/plot/core/axis-utils.js +48 -48
- package/dist/plot/core/components/AxisLabel.svelte +82 -20
- package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
- package/dist/plot/core/components/ColorBar.svelte +101 -106
- package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
- package/dist/plot/core/components/FillArea.svelte +10 -17
- package/dist/plot/core/components/HierarchyControls.svelte +249 -0
- package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
- package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
- package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/core/components/Line.svelte +18 -9
- package/dist/plot/core/components/Line.svelte.d.ts +2 -0
- package/dist/plot/core/components/PlotAxis.svelte +40 -17
- package/dist/plot/core/components/PlotControls.svelte +65 -41
- package/dist/plot/core/components/PlotLegend.svelte +31 -35
- package/dist/plot/core/components/PlotMarginals.svelte +616 -0
- package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
- package/dist/plot/core/components/PlotTooltip.svelte +1 -1
- package/dist/plot/core/components/PortalSelect.svelte +4 -8
- package/dist/plot/core/components/ReferenceLine.svelte +27 -24
- package/dist/plot/core/components/ReferenceLine3D.svelte +54 -57
- package/dist/plot/core/components/ReferencePlane.svelte +7 -8
- package/dist/plot/core/components/ZeroLines.svelte +4 -8
- package/dist/plot/core/components/ZoomRect.svelte +1 -2
- package/dist/plot/core/components/index.d.ts +1 -0
- package/dist/plot/core/components/index.js +1 -0
- package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
- package/dist/plot/core/data-cleaning-signal.js +467 -0
- package/dist/plot/core/data-cleaning.d.ts +2 -42
- package/dist/plot/core/data-cleaning.js +27 -474
- package/dist/plot/core/data-transform.d.ts +1 -2
- package/dist/plot/core/data-transform.js +9 -15
- package/dist/plot/core/fill-utils.d.ts +3 -1
- package/dist/plot/core/fill-utils.js +28 -6
- package/dist/plot/core/index.d.ts +1 -0
- package/dist/plot/core/index.js +1 -0
- package/dist/plot/core/interactions.js +0 -2
- package/dist/plot/core/layout.d.ts +15 -6
- package/dist/plot/core/layout.js +57 -38
- package/dist/plot/core/marginals.d.ts +170 -0
- package/dist/plot/core/marginals.js +436 -0
- package/dist/plot/core/pan-zoom.svelte.d.ts +2 -4
- package/dist/plot/core/pan-zoom.svelte.js +34 -17
- package/dist/plot/core/placed-tween.svelte.d.ts +3 -0
- package/dist/plot/core/placed-tween.svelte.js +68 -21
- package/dist/plot/core/reference-line.js +1 -1
- package/dist/plot/core/scales.d.ts +23 -0
- package/dist/plot/core/scales.js +39 -13
- package/dist/plot/core/svg.js +0 -1
- package/dist/plot/core/types/fills.d.ts +101 -0
- package/dist/plot/core/types/fills.js +15 -0
- package/dist/plot/core/types/plot-3d.d.ts +87 -0
- package/dist/plot/core/types/plot-3d.js +4 -0
- package/dist/plot/core/types/reference-lines.d.ts +140 -0
- package/dist/plot/core/types/reference-lines.js +9 -0
- package/dist/plot/core/types.d.ts +29 -324
- package/dist/plot/core/types.js +23 -20
- package/dist/plot/core/utils/hierarchy-chart.d.ts +52 -0
- package/dist/plot/core/utils/hierarchy-chart.js +191 -0
- package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
- package/dist/plot/core/utils/hierarchy-labels.js +100 -0
- package/dist/plot/core/utils/label-placement.js +2 -2
- package/dist/plot/histogram/Histogram.svelte +314 -340
- package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
- package/dist/plot/histogram/HistogramControls.svelte +30 -28
- package/dist/plot/histogram/histogram.d.ts +31 -0
- package/dist/plot/histogram/histogram.js +70 -0
- package/dist/plot/histogram/index.d.ts +1 -0
- package/dist/plot/histogram/index.js +1 -0
- package/dist/plot/index.d.ts +1 -0
- package/dist/plot/index.js +1 -0
- package/dist/plot/sankey/Sankey.svelte +78 -69
- package/dist/plot/sankey/Sankey.svelte.d.ts +2 -2
- package/dist/plot/sankey/SankeyControls.svelte +22 -16
- package/dist/plot/sankey/sankey.js +13 -9
- package/dist/plot/scatter/BinnedScatterPlot.svelte +311 -141
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +7 -0
- package/dist/plot/scatter/ElementScatter.svelte +4 -1
- package/dist/plot/scatter/ScatterPlot.svelte +517 -410
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +2 -0
- package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
- package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/scatter/ScatterPoint.svelte +16 -9
- package/dist/plot/scatter/adaptive-density.d.ts +1 -1
- package/dist/plot/scatter/adaptive-density.js +36 -20
- package/dist/plot/scatter/binned-scatter-types.d.ts +3 -2
- package/dist/plot/scatter/binned-scatter-types.js +6 -1
- package/dist/plot/scatter/scatter-data.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.js +8 -7
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte +25 -34
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +8 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +113 -116
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/scatter-3d/Surface3D.svelte +4 -13
- package/dist/plot/sunburst/Sunburst.svelte +269 -347
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +2 -2
- package/dist/plot/sunburst/index.d.ts +1 -1
- package/dist/plot/sunburst/index.js +2 -1
- package/dist/plot/sunburst/render.d.ts +2 -2
- package/dist/plot/sunburst/render.js +47 -22
- package/dist/plot/sunburst/sunburst.d.ts +5 -1
- package/dist/plot/sunburst/sunburst.js +10 -3
- package/dist/plot/treemap/Treemap.svelte +1022 -0
- package/dist/plot/treemap/Treemap.svelte.d.ts +90 -0
- package/dist/plot/treemap/index.d.ts +4 -0
- package/dist/plot/treemap/index.js +4 -0
- package/dist/plot/treemap/labels.d.ts +38 -0
- package/dist/plot/treemap/labels.js +80 -0
- package/dist/plot/treemap/treemap.d.ts +28 -0
- package/dist/plot/treemap/treemap.js +102 -0
- package/dist/rdf/RdfPlot.svelte +37 -59
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/calc-rdf.js +63 -52
- package/dist/rdf/index.d.ts +0 -1
- package/dist/sanitize.js +85 -27
- package/dist/scene/SceneCamera.svelte +1 -1
- package/dist/scene/SceneCamera.svelte.d.ts +1 -1
- package/dist/scene/bind-renderer.svelte.js +14 -6
- package/dist/scene/index.d.ts +1 -2
- package/dist/scene/index.js +1 -1
- package/dist/scene/{props.js → props.svelte.js} +15 -1
- package/dist/settings.d.ts +19 -9
- package/dist/settings.js +229 -525
- package/dist/spectral/Bands.svelte +207 -221
- package/dist/spectral/BandsAndDos.svelte +11 -9
- package/dist/spectral/BrillouinBandsDos.svelte +19 -42
- package/dist/spectral/Dos.svelte +92 -93
- package/dist/spectral/helpers.d.ts +3 -3
- package/dist/spectral/helpers.js +65 -140
- package/dist/state.svelte.js +5 -18
- package/dist/structure/Arrow.svelte +5 -18
- package/dist/structure/ArrowInstances.svelte +160 -0
- package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
- package/dist/structure/AtomLegend.svelte +120 -85
- package/dist/structure/AtomLegend.svelte.d.ts +2 -3
- package/dist/structure/Bond.svelte +31 -23
- package/dist/structure/CanvasTooltip.svelte +15 -3
- package/dist/structure/CellSelect.svelte +45 -35
- package/dist/structure/Cylinder.svelte +24 -40
- package/dist/structure/InstancedAtoms.svelte +114 -0
- package/dist/structure/InstancedAtoms.svelte.d.ts +15 -0
- package/dist/structure/Lattice.svelte +85 -149
- package/dist/structure/SiteLabels.svelte +122 -0
- package/dist/structure/SiteLabels.svelte.d.ts +18 -0
- package/dist/structure/Structure.svelte +636 -504
- package/dist/structure/Structure.svelte.d.ts +4 -2
- package/dist/structure/StructureCarousel.svelte +637 -0
- package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
- package/dist/structure/StructureControls.svelte +165 -425
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +17 -21
- package/dist/structure/StructureInfoPane.svelte +128 -133
- package/dist/structure/StructureInfoPane.svelte.d.ts +1 -1
- package/dist/structure/StructureScene.svelte +535 -578
- package/dist/structure/StructureScene.svelte.d.ts +6 -2
- package/dist/structure/StructureViewport.svelte +451 -0
- package/dist/structure/StructureViewport.svelte.d.ts +65 -0
- package/dist/structure/atom-label-placement.d.ts +16 -12
- package/dist/structure/atom-label-placement.js +70 -37
- package/dist/structure/atom-properties.d.ts +2 -0
- package/dist/structure/atom-properties.js +105 -38
- package/dist/structure/bond-order-perception.js +3 -8
- package/dist/structure/bonding.d.ts +9 -3
- package/dist/structure/bonding.js +95 -46
- package/dist/structure/edit-history.d.ts +6 -0
- package/dist/structure/edit-history.js +27 -0
- package/dist/structure/export.d.ts +1 -0
- package/dist/structure/export.js +89 -105
- package/dist/structure/format-detect.d.ts +1 -0
- package/dist/structure/format-detect.js +20 -0
- package/dist/structure/geometry.d.ts +9 -0
- package/dist/structure/geometry.js +27 -0
- package/dist/structure/index.d.ts +16 -1
- package/dist/structure/index.js +15 -10
- package/dist/structure/measure.d.ts +1 -1
- package/dist/structure/measure.js +6 -12
- package/dist/structure/parse.d.ts +2 -1
- package/dist/structure/parse.js +272 -313
- package/dist/structure/partial-occupancy.js +10 -5
- package/dist/structure/pbc.js +85 -107
- package/dist/structure/polyhedra.d.ts +0 -1
- package/dist/structure/polyhedra.js +7 -21
- package/dist/structure/prop-groups.d.ts +85 -0
- package/dist/structure/prop-groups.js +18 -0
- package/dist/structure/supercell.d.ts +1 -2
- package/dist/structure/supercell.js +7 -13
- package/dist/symmetry/SymmetryElements.svelte +11 -15
- package/dist/symmetry/SymmetryStats.svelte +55 -71
- package/dist/symmetry/WyckoffTable.svelte +10 -28
- package/dist/symmetry/cell-transform.js +6 -14
- package/dist/symmetry/index.d.ts +1 -0
- package/dist/symmetry/index.js +13 -10
- package/dist/symmetry/spacegroups.js +3 -2
- package/dist/table/HeatmapTable.svelte +1142 -447
- package/dist/table/HeatmapTable.svelte.d.ts +12 -2
- package/dist/table/ToggleMenu.svelte +168 -53
- package/dist/table/ToggleMenu.svelte.d.ts +1 -1
- package/dist/table/index.d.ts +21 -6
- package/dist/table/index.js +34 -21
- package/dist/theme/ThemeControl.svelte +16 -8
- package/dist/theme/embedded.d.ts +18 -0
- package/dist/theme/embedded.js +206 -0
- package/dist/theme/index.d.ts +5 -5
- package/dist/theme/index.js +5 -12
- package/dist/theme/themes.mjs +44 -66
- package/dist/tooltip/KCoords.svelte +4 -1
- package/dist/tooltip/TooltipContent.svelte +3 -6
- package/dist/tooltip/TooltipContent.svelte.d.ts +1 -1
- package/dist/tooltip/index.d.ts +8 -1
- package/dist/trajectory/Trajectory.svelte +613 -386
- package/dist/trajectory/Trajectory.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryError.svelte +12 -74
- package/dist/trajectory/TrajectoryExportPane.svelte +14 -32
- package/dist/trajectory/TrajectoryInfoPane.svelte +127 -164
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +2 -1
- package/dist/trajectory/extract.js +61 -49
- package/dist/trajectory/format-detect.d.ts +2 -0
- package/dist/trajectory/format-detect.js +17 -13
- package/dist/trajectory/frame-reader.d.ts +2 -0
- package/dist/trajectory/frame-reader.js +35 -32
- package/dist/trajectory/helpers.d.ts +2 -0
- package/dist/trajectory/helpers.js +34 -56
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +5 -8
- package/dist/trajectory/parse/ase.js +1 -1
- package/dist/trajectory/parse/h5-utils.d.ts +13 -0
- package/dist/trajectory/parse/h5-utils.js +109 -0
- package/dist/trajectory/parse/hdf5.d.ts +1 -1
- package/dist/trajectory/parse/hdf5.js +116 -106
- package/dist/trajectory/parse/index.d.ts +6 -6
- package/dist/trajectory/parse/index.js +25 -33
- package/dist/trajectory/parse/lammps.js +8 -12
- package/dist/trajectory/parse/vasp.js +10 -7
- package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
- package/dist/trajectory/parse/vaspout-electronic.js +207 -0
- package/dist/trajectory/parse/vaspout-h5.d.ts +4 -0
- package/dist/trajectory/parse/vaspout-h5.js +281 -0
- package/dist/trajectory/parse/xyz.js +59 -9
- package/dist/trajectory/plotting.d.ts +8 -9
- package/dist/trajectory/plotting.js +113 -64
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +7 -0
- package/dist/xrd/XrdPlot.svelte +79 -118
- package/dist/xrd/broadening.js +2 -1
- package/dist/xrd/calc-xrd.js +24 -62
- package/dist/xrd/parse.d.ts +0 -1
- package/dist/xrd/parse.js +69 -95
- package/package.json +94 -34
- package/readme.md +6 -5
- package/dist/api/mp.d.ts +0 -6
- package/dist/api/mp.js +0 -22
- package/dist/plot/sunburst/SunburstControls.svelte +0 -200
- package/dist/scene/types.d.ts +0 -26
- package/dist/tooltip/types.d.ts +0 -8
- package/dist/trajectory/constants.d.ts +0 -6
- package/dist/trajectory/constants.js +0 -11
- /package/dist/{scene/types.js → file-viewer/host-protocol.js} +0 -0
- /package/dist/{tooltip/types.js → isosurface/geometry-worker-types.js} +0 -0
|
@@ -17,6 +17,6 @@ type $$ComponentProps = {
|
|
|
17
17
|
controls_open?: boolean;
|
|
18
18
|
export_pane_open?: boolean;
|
|
19
19
|
};
|
|
20
|
-
declare const ChemPotDiagram3D: import("svelte").Component<$$ComponentProps, {}, "height" | "width" | "
|
|
20
|
+
declare const ChemPotDiagram3D: import("svelte").Component<$$ComponentProps, {}, "height" | "width" | "fullscreen" | "wrapper" | "controls_open" | "export_pane_open" | "temperature" | "hover_info">;
|
|
21
21
|
type ChemPotDiagram3D = ReturnType<typeof ChemPotDiagram3D>;
|
|
22
22
|
export default ChemPotDiagram3D;
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
// Async wrapper for compute_chempot_diagram via Web Worker.
|
|
2
2
|
// Falls back to synchronous main-thread computation during SSR.
|
|
3
|
-
import { compute_chempot_diagram,
|
|
3
|
+
import { compute_chempot_diagram, entry_fingerprint } from './compute';
|
|
4
4
|
import { to_error } from '../utils';
|
|
5
5
|
let worker = null;
|
|
6
6
|
let next_id = 0;
|
|
7
7
|
const pending = new Map();
|
|
8
8
|
const pending_by_key = new Map();
|
|
9
9
|
function make_compute_request_key(entries, config) {
|
|
10
|
-
|
|
11
|
-
.map((entry) => [
|
|
12
|
-
formula_key_from_composition(entry.composition),
|
|
13
|
-
entry.energy,
|
|
14
|
-
entry.energy_per_atom ?? ``,
|
|
15
|
-
entry.e_form_per_atom ?? ``,
|
|
16
|
-
entry.is_stable ?? ``,
|
|
17
|
-
entry.e_above_hull ?? ``,
|
|
18
|
-
entry.exclude_from_hull ?? ``,
|
|
19
|
-
].join(`:`))
|
|
20
|
-
.sort();
|
|
21
|
-
return `${keyed_entries.join(`,`)}|${JSON.stringify(config)}`;
|
|
10
|
+
return `${entries.map(entry_fingerprint).sort().join(`,`)}|${JSON.stringify(config)}`;
|
|
22
11
|
}
|
|
23
12
|
function track_pending(request_key, promise) {
|
|
24
13
|
pending_by_key.set(request_key, promise);
|
|
@@ -53,6 +42,16 @@ function get_worker() {
|
|
|
53
42
|
return worker;
|
|
54
43
|
}
|
|
55
44
|
export function compute_chempot_async(entries, config = {}) {
|
|
45
|
+
// Never throw synchronously: callers handle errors via .catch() only, so key
|
|
46
|
+
// construction or Worker instantiation failures (e.g. CSP) must reject instead
|
|
47
|
+
try {
|
|
48
|
+
return compute_chempot_async_unsafe(entries, config);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
return Promise.reject(to_error(err));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function compute_chempot_async_unsafe(entries, config) {
|
|
56
55
|
const request_key = make_compute_request_key(entries, config);
|
|
57
56
|
const existing = pending_by_key.get(request_key);
|
|
58
57
|
if (existing)
|
|
@@ -68,7 +67,7 @@ export function compute_chempot_async(entries, config = {}) {
|
|
|
68
67
|
pending.set(id, { resolve, reject });
|
|
69
68
|
try {
|
|
70
69
|
// $state.snapshot strips Svelte $state proxies (not structured-cloneable)
|
|
71
|
-
//
|
|
70
|
+
// oxlint-disable-next-line unicorn/require-post-message-target-origin
|
|
72
71
|
wkr.postMessage($state.snapshot({ id, entries, config }));
|
|
73
72
|
}
|
|
74
73
|
catch (err) {
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import { type D3InterpolateName } from '../colors';
|
|
2
|
+
import type { PhaseData } from '../convex-hull/types';
|
|
2
3
|
import type { Vec2 } from '../math';
|
|
3
|
-
|
|
4
|
+
import { type FormulaEnergyStats } from './compute';
|
|
5
|
+
import type { ChemPotColorMode } from './types';
|
|
6
|
+
export declare const ARITY_COLORS: readonly ["#3498db", "#2ecc71", "#e67e22", "#9b59b6"];
|
|
4
7
|
export declare function get_chempot_color_bar_config(color_scale: D3InterpolateName, reverse: boolean): {
|
|
5
8
|
color_scale_fn: (frac: number) => string;
|
|
6
9
|
color_scale_domain: Vec2;
|
|
7
10
|
};
|
|
11
|
+
export interface ChemPotDomainColorData {
|
|
12
|
+
colors: Map<string, string>;
|
|
13
|
+
color_range: {
|
|
14
|
+
min: number;
|
|
15
|
+
max: number;
|
|
16
|
+
label: string;
|
|
17
|
+
} | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function get_domain_color_data(opts: {
|
|
20
|
+
formulas: string[];
|
|
21
|
+
color_mode: ChemPotColorMode;
|
|
22
|
+
color_scale: D3InterpolateName;
|
|
23
|
+
reverse_color_scale: boolean;
|
|
24
|
+
entries: PhaseData[];
|
|
25
|
+
el_refs: Record<string, PhaseData>;
|
|
26
|
+
energy_stats: Map<string, FormulaEnergyStats>;
|
|
27
|
+
}): ChemPotDomainColorData;
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { get_d3_interpolator } from '../colors';
|
|
2
|
+
import { extract_formula_elements } from '../composition/parse';
|
|
3
|
+
import { group } from 'd3-array';
|
|
2
4
|
import { scaleSequential } from 'd3-scale';
|
|
5
|
+
import { best_form_energy_for_formula as best_form_energy, formula_key_from_composition, } from './compute';
|
|
6
|
+
// Categorical palette for arity mode (element count)
|
|
7
|
+
export const ARITY_COLORS = [`#3498db`, `#2ecc71`, `#e67e22`, `#9b59b6`];
|
|
8
|
+
// Exhaustively typed over the numeric color modes so adding a new mode
|
|
9
|
+
// fails compilation here instead of rendering an undefined colorbar title
|
|
10
|
+
const COLOR_MODE_LABELS = {
|
|
11
|
+
energy: `Energy per atom (eV)`,
|
|
12
|
+
formation_energy: `Formation energy (eV/atom)`,
|
|
13
|
+
entries: `Entry count`,
|
|
14
|
+
};
|
|
3
15
|
// Resolve D3 interpolator with optional reverse for chempot color scales.
|
|
4
16
|
function get_chempot_interpolator(name, reverse) {
|
|
5
17
|
const raw = get_d3_interpolator(name);
|
|
6
18
|
return reverse ? (frac) => raw(1 - frac) : raw;
|
|
7
19
|
}
|
|
8
20
|
// Build sequential color scale from values and D3 interpolator name.
|
|
9
|
-
|
|
21
|
+
function make_chempot_color_scale(values, interpolator_name, reverse) {
|
|
10
22
|
const finite_values = values.filter(Number.isFinite);
|
|
11
23
|
if (finite_values.length === 0)
|
|
12
24
|
return null;
|
|
@@ -30,3 +42,60 @@ export function get_chempot_color_bar_config(color_scale, reverse) {
|
|
|
30
42
|
color_scale_domain: [0, 1],
|
|
31
43
|
};
|
|
32
44
|
}
|
|
45
|
+
// Per-formula domain colors plus color-bar range for the active color mode.
|
|
46
|
+
// Shared by ChemPotDiagram2D and ChemPotDiagram3D.
|
|
47
|
+
export function get_domain_color_data(opts) {
|
|
48
|
+
const { formulas, color_mode, entries, el_refs, energy_stats } = opts;
|
|
49
|
+
const colors = new Map();
|
|
50
|
+
if (color_mode === `none`)
|
|
51
|
+
return { colors, color_range: null };
|
|
52
|
+
if (color_mode === `arity`) {
|
|
53
|
+
for (const formula of formulas) {
|
|
54
|
+
const n_elements = extract_formula_elements(formula).length;
|
|
55
|
+
const color_idx = Math.min(n_elements, ARITY_COLORS.length) - 1;
|
|
56
|
+
colors.set(formula, ARITY_COLORS[Math.max(0, color_idx)]);
|
|
57
|
+
}
|
|
58
|
+
return { colors, color_range: null };
|
|
59
|
+
}
|
|
60
|
+
const entries_by_formula = color_mode === `formation_energy`
|
|
61
|
+
? group(entries, (entry) => formula_key_from_composition(entry.composition))
|
|
62
|
+
: new Map();
|
|
63
|
+
const get_value = (formula) => {
|
|
64
|
+
if (color_mode === `energy`)
|
|
65
|
+
return energy_stats.get(formula)?.min_energy_per_atom ?? null;
|
|
66
|
+
if (color_mode === `formation_energy`) {
|
|
67
|
+
return best_form_energy(entries_by_formula.get(formula) ?? [], formula, el_refs) ?? null;
|
|
68
|
+
}
|
|
69
|
+
return energy_stats.get(formula)?.matching_entry_count ?? 0;
|
|
70
|
+
};
|
|
71
|
+
const value_by_formula = new Map();
|
|
72
|
+
for (const formula of formulas) {
|
|
73
|
+
const value = get_value(formula);
|
|
74
|
+
if (value == null || !Number.isFinite(value))
|
|
75
|
+
continue;
|
|
76
|
+
value_by_formula.set(formula, value);
|
|
77
|
+
}
|
|
78
|
+
const values = [...value_by_formula.values()];
|
|
79
|
+
const scale = make_chempot_color_scale(values, opts.color_scale, opts.reverse_color_scale);
|
|
80
|
+
for (const formula of formulas) {
|
|
81
|
+
const value = value_by_formula.get(formula);
|
|
82
|
+
colors.set(formula, value != null && scale ? scale(value) : `#999`);
|
|
83
|
+
}
|
|
84
|
+
if (values.length === 0)
|
|
85
|
+
return { colors, color_range: null };
|
|
86
|
+
let [min_val, max_val] = [values[0], values[0]];
|
|
87
|
+
for (const value of values) {
|
|
88
|
+
if (value < min_val)
|
|
89
|
+
min_val = value;
|
|
90
|
+
if (value > max_val)
|
|
91
|
+
max_val = value;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
colors,
|
|
95
|
+
color_range: {
|
|
96
|
+
min: min_val,
|
|
97
|
+
max: Math.max(max_val, min_val + 1e-6),
|
|
98
|
+
label: COLOR_MODE_LABELS[color_mode],
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -8,6 +8,12 @@ export declare function get_min_entries_and_el_refs(entries: PhaseData[]): {
|
|
|
8
8
|
el_refs: Record<string, PhaseData>;
|
|
9
9
|
};
|
|
10
10
|
export declare function best_form_energy_for_formula(entries: PhaseData[], formula: string, el_refs: Record<string, PhaseData>): number | undefined;
|
|
11
|
+
export interface FormulaEnergyStats {
|
|
12
|
+
matching_entry_count: number;
|
|
13
|
+
min_energy_per_atom: number | null;
|
|
14
|
+
max_energy_per_atom: number | null;
|
|
15
|
+
}
|
|
16
|
+
export declare function get_energy_stats_by_formula(entries: PhaseData[]): Map<string, FormulaEnergyStats>;
|
|
11
17
|
export declare const renormalize_entries: (entries: PhaseData[], el_refs: Record<string, PhaseData>, elements: string[]) => PhaseData[];
|
|
12
18
|
export declare function build_hyperplanes(min_entries: PhaseData[], el_refs: Record<string, PhaseData>, elements: string[]): {
|
|
13
19
|
hyperplanes: number[][];
|
|
@@ -44,5 +50,6 @@ export interface VisibleDomainLabel {
|
|
|
44
50
|
}
|
|
45
51
|
export declare function get_visible_domain_labels(face_positions: ArrayLike<number>, face_domain_map: string[], label_font_size_by_formula: ReadonlyMap<string, number>, pinned_labels?: VisibleDomainLabel[]): VisibleDomainLabel[];
|
|
46
52
|
export declare function get_ternary_combinations(elements: string[]): string[][];
|
|
53
|
+
export declare function entry_fingerprint(entry: PhaseData): string;
|
|
47
54
|
export declare function make_nd_cache_key(entries: PhaseData[], formal_chempots: boolean, default_min_limit: number, limits: ChemPotDiagramConfig[`limits`]): string;
|
|
48
55
|
export declare function compute_chempot_diagram(entries: PhaseData[], config?: ChemPotDiagramConfig): ChemPotDiagramData;
|
|
@@ -34,16 +34,28 @@ const get_reduced_formula = (composition) => {
|
|
|
34
34
|
.map(([elem, amt]) => [elem, Math.round(amt * factor)]));
|
|
35
35
|
};
|
|
36
36
|
// === Entry Helpers ===
|
|
37
|
-
//
|
|
37
|
+
// Energy per atom; NaN for invalid/non-finite so UI can skip without throwing.
|
|
38
38
|
export function get_energy_per_atom(entry) {
|
|
39
|
-
if (typeof entry.energy_per_atom === `number`)
|
|
40
|
-
return entry.energy_per_atom;
|
|
41
|
-
const atoms = count_atoms_in_composition(entry.composition);
|
|
42
|
-
if (atoms <= 0) {
|
|
43
|
-
throw new Error(`Invalid composition with non-positive atom count: ${JSON.stringify(entry.composition)}`);
|
|
39
|
+
if (typeof entry.energy_per_atom === `number`) {
|
|
40
|
+
return Number.isFinite(entry.energy_per_atom) ? entry.energy_per_atom : Number.NaN;
|
|
44
41
|
}
|
|
42
|
+
const atoms = count_atoms_in_composition(entry.composition);
|
|
43
|
+
if (atoms <= 0 || !Number.isFinite(entry.energy))
|
|
44
|
+
return Number.NaN;
|
|
45
45
|
return entry.energy / atoms;
|
|
46
46
|
}
|
|
47
|
+
// Same-formula EPA total order (keep aligned with make_nd_cache_key / entry_fingerprint).
|
|
48
|
+
function prefer_min_entry(candidate, candidate_epa, existing, existing_epa) {
|
|
49
|
+
if (candidate_epa !== existing_epa)
|
|
50
|
+
return candidate_epa < existing_epa;
|
|
51
|
+
if (Boolean(candidate.exclude_from_hull) !== Boolean(existing.exclude_from_hull)) {
|
|
52
|
+
return !candidate.exclude_from_hull;
|
|
53
|
+
}
|
|
54
|
+
if ((candidate.is_stable === true) !== (existing.is_stable === true)) {
|
|
55
|
+
return candidate.is_stable === true;
|
|
56
|
+
}
|
|
57
|
+
return (candidate.e_above_hull ?? Infinity) < (existing.e_above_hull ?? Infinity);
|
|
58
|
+
}
|
|
47
59
|
// Cache for reduced formula strings -- avoids recomputing get_reduced_formula
|
|
48
60
|
// in hot loops. Key is object identity (WeakMap), value is the formula string.
|
|
49
61
|
const formula_cache = new WeakMap();
|
|
@@ -69,8 +81,10 @@ export function get_min_entries_and_el_refs(entries) {
|
|
|
69
81
|
for (const entry of entries) {
|
|
70
82
|
const key = formula_key_from_composition(entry.composition);
|
|
71
83
|
const epa = get_energy_per_atom(entry);
|
|
84
|
+
if (!Number.isFinite(epa))
|
|
85
|
+
continue;
|
|
72
86
|
const existing = by_formula.get(key);
|
|
73
|
-
if (!existing || epa
|
|
87
|
+
if (!existing || prefer_min_entry(entry, epa, existing.entry, existing.epa)) {
|
|
74
88
|
by_formula.set(key, { entry, epa });
|
|
75
89
|
}
|
|
76
90
|
}
|
|
@@ -89,14 +103,20 @@ export function get_min_entries_and_el_refs(entries) {
|
|
|
89
103
|
function compute_form_energy_per_atom(entry, el_refs) {
|
|
90
104
|
const atom_count = count_atoms_in_composition(entry.composition);
|
|
91
105
|
const energy_per_atom = get_energy_per_atom(entry);
|
|
106
|
+
if (!(atom_count > 0) || !Number.isFinite(energy_per_atom))
|
|
107
|
+
return Number.NaN;
|
|
92
108
|
let ref_energy = 0;
|
|
93
109
|
for (const [element, amount] of Object.entries(entry.composition)) {
|
|
94
110
|
if (amount <= 0)
|
|
95
111
|
continue;
|
|
96
112
|
const fraction = amount / atom_count;
|
|
97
113
|
const ref_entry = el_refs[element];
|
|
98
|
-
if (ref_entry)
|
|
99
|
-
|
|
114
|
+
if (ref_entry) {
|
|
115
|
+
const ref_epa = get_energy_per_atom(ref_entry);
|
|
116
|
+
if (!Number.isFinite(ref_epa))
|
|
117
|
+
return Number.NaN;
|
|
118
|
+
ref_energy += fraction * ref_epa;
|
|
119
|
+
}
|
|
100
120
|
}
|
|
101
121
|
return energy_per_atom - ref_energy;
|
|
102
122
|
}
|
|
@@ -107,23 +127,57 @@ export function best_form_energy_for_formula(entries, formula, el_refs) {
|
|
|
107
127
|
if (formula_key_from_composition(entry.composition) !== formula)
|
|
108
128
|
continue;
|
|
109
129
|
const e_form = entry.e_form_per_atom ?? compute_form_energy_per_atom(entry, el_refs);
|
|
130
|
+
if (!Number.isFinite(e_form))
|
|
131
|
+
continue;
|
|
110
132
|
if (best_value === undefined || e_form < best_value)
|
|
111
133
|
best_value = e_form;
|
|
112
134
|
}
|
|
113
135
|
return best_value;
|
|
114
136
|
}
|
|
137
|
+
// Aggregate per-formula entry count and min/max energy per atom (used for
|
|
138
|
+
// region coloring and hover tooltips in the 2D/3D diagram components).
|
|
139
|
+
export function get_energy_stats_by_formula(entries) {
|
|
140
|
+
const stats = new Map();
|
|
141
|
+
for (const entry of entries) {
|
|
142
|
+
const energy_per_atom = get_energy_per_atom(entry);
|
|
143
|
+
if (!Number.isFinite(energy_per_atom))
|
|
144
|
+
continue;
|
|
145
|
+
const formula_key = formula_key_from_composition(entry.composition);
|
|
146
|
+
const existing = stats.get(formula_key);
|
|
147
|
+
if (existing) {
|
|
148
|
+
existing.matching_entry_count += 1;
|
|
149
|
+
existing.min_energy_per_atom = Math.min(existing.min_energy_per_atom ?? energy_per_atom, energy_per_atom);
|
|
150
|
+
existing.max_energy_per_atom = Math.max(existing.max_energy_per_atom ?? energy_per_atom, energy_per_atom);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
stats.set(formula_key, {
|
|
154
|
+
matching_entry_count: 1,
|
|
155
|
+
min_energy_per_atom: energy_per_atom,
|
|
156
|
+
max_energy_per_atom: energy_per_atom,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return stats;
|
|
161
|
+
}
|
|
115
162
|
// Renormalize entry energies to be relative to elemental references (formal chemical potentials).
|
|
116
163
|
// For each entry, subtracts sum(x_i * E_ref_i) from its energy per atom.
|
|
117
164
|
export const renormalize_entries = (entries, el_refs, elements) => entries.map((entry) => {
|
|
118
165
|
const atoms = count_atoms_in_composition(entry.composition);
|
|
166
|
+
const base_epa = get_energy_per_atom(entry);
|
|
167
|
+
if (!(atoms > 0) || !Number.isFinite(base_epa))
|
|
168
|
+
return entry;
|
|
119
169
|
let renorm_energy = 0;
|
|
120
170
|
for (const el of elements) {
|
|
121
|
-
const frac =
|
|
171
|
+
const frac = (entry.composition[el] ?? 0) / atoms;
|
|
122
172
|
const ref = el_refs[el];
|
|
123
|
-
if (ref)
|
|
124
|
-
|
|
173
|
+
if (!ref)
|
|
174
|
+
continue;
|
|
175
|
+
const ref_epa = get_energy_per_atom(ref);
|
|
176
|
+
if (!Number.isFinite(ref_epa))
|
|
177
|
+
return entry;
|
|
178
|
+
renorm_energy += frac * ref_epa;
|
|
125
179
|
}
|
|
126
|
-
const new_energy_per_atom =
|
|
180
|
+
const new_energy_per_atom = base_epa - renorm_energy;
|
|
127
181
|
return {
|
|
128
182
|
...entry,
|
|
129
183
|
energy: new_energy_per_atom * atoms,
|
|
@@ -137,7 +191,10 @@ export function build_hyperplanes(min_entries, el_refs, elements) {
|
|
|
137
191
|
const n_elems = elements.length;
|
|
138
192
|
const element_ref_energies = elements.map((element) => {
|
|
139
193
|
const ref_entry = el_refs[element];
|
|
140
|
-
|
|
194
|
+
if (!ref_entry)
|
|
195
|
+
return 0;
|
|
196
|
+
const epa = get_energy_per_atom(ref_entry);
|
|
197
|
+
return Number.isFinite(epa) ? epa : 0;
|
|
141
198
|
});
|
|
142
199
|
const always_include = new Set(Object.values(el_refs));
|
|
143
200
|
const tol = 1e-6; // PhaseDiagram.formation_energy_tol
|
|
@@ -148,6 +205,8 @@ export function build_hyperplanes(min_entries, el_refs, elements) {
|
|
|
148
205
|
const atom_count = count_atoms_in_composition(entry.composition);
|
|
149
206
|
const composition = entry.composition;
|
|
150
207
|
const energy_per_atom = get_energy_per_atom(entry);
|
|
208
|
+
if (!(atom_count > 0) || !Number.isFinite(energy_per_atom))
|
|
209
|
+
continue;
|
|
151
210
|
const row = Array(n_elems + 1).fill(0);
|
|
152
211
|
let ref_energy = 0;
|
|
153
212
|
for (let elem_idx = 0; elem_idx < n_elems; elem_idx++) {
|
|
@@ -670,19 +729,19 @@ export function get_ternary_combinations(elements) {
|
|
|
670
729
|
return combos;
|
|
671
730
|
}
|
|
672
731
|
let nd_cache = null;
|
|
673
|
-
//
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
.map((entry) => [
|
|
732
|
+
// Fingerprint for N-D / async-compute cache keys (computed EPA; NaN → null).
|
|
733
|
+
export function entry_fingerprint(entry) {
|
|
734
|
+
const epa = get_energy_per_atom(entry);
|
|
735
|
+
return JSON.stringify([
|
|
678
736
|
formula_key_from_composition(entry.composition),
|
|
679
|
-
|
|
680
|
-
entry.is_stable ??
|
|
681
|
-
entry.e_above_hull ??
|
|
682
|
-
entry.exclude_from_hull ??
|
|
683
|
-
]
|
|
684
|
-
|
|
685
|
-
|
|
737
|
+
Number.isFinite(epa) ? epa : null,
|
|
738
|
+
entry.is_stable ?? null,
|
|
739
|
+
entry.e_above_hull ?? null,
|
|
740
|
+
entry.exclude_from_hull ?? null,
|
|
741
|
+
]);
|
|
742
|
+
}
|
|
743
|
+
export function make_nd_cache_key(entries, formal_chempots, default_min_limit, limits) {
|
|
744
|
+
return `${entries.map(entry_fingerprint).sort().join(`,`)}|${formal_chempots}|${default_min_limit}|${JSON.stringify(limits ?? {})}`;
|
|
686
745
|
}
|
|
687
746
|
// === Main Pipeline ===
|
|
688
747
|
// Compute the full chemical potential diagram from entries and config.
|
|
@@ -13,7 +13,7 @@ export function create_chempot_overrides(config, keys, custom_defaults = {}) {
|
|
|
13
13
|
}));
|
|
14
14
|
let overrides = $state({});
|
|
15
15
|
return {
|
|
16
|
-
resolve: (key) =>
|
|
16
|
+
resolve: (key) => overrides[key] ?? config()[key] ?? defaults[key],
|
|
17
17
|
set: (key, value) => {
|
|
18
18
|
overrides[key] = value;
|
|
19
19
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Export helpers for chemical potential diagrams (shared between 2D and 3D views).
|
|
2
2
|
import { dpi_to_scale } from '../io/export';
|
|
3
3
|
import { download } from '../io/fetch';
|
|
4
|
+
import { escape_html as xml_escape } from '../utils';
|
|
4
5
|
import * as THREE from 'three';
|
|
5
6
|
import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js';
|
|
6
7
|
export const get_json_string = (payload) => JSON.stringify(payload, null, 2);
|
|
@@ -77,12 +78,6 @@ export function export_png_file(wrapper, basename, png_dpi) {
|
|
|
77
78
|
download(blob, `${basename}.png`, `image/png`);
|
|
78
79
|
}, `image/png`);
|
|
79
80
|
}
|
|
80
|
-
const xml_escape = (text) => text
|
|
81
|
-
.replaceAll(`&`, `&`)
|
|
82
|
-
.replaceAll(`<`, `<`)
|
|
83
|
-
.replaceAll(`>`, `>`)
|
|
84
|
-
.replaceAll(`"`, `"`)
|
|
85
|
-
.replaceAll(`'`, `'`);
|
|
86
81
|
// SVG snapshot: rasterized canvas as embedded image + overlay labels as real text nodes
|
|
87
82
|
export function export_svg_file(wrapper, basename, view_settings) {
|
|
88
83
|
const gl_canvas = get_gl_canvas(wrapper);
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { analyze_temperature_data, filter_entries_at_temperature, } from '../convex-hull/helpers';
|
|
2
2
|
import { CHEMPOT_DEFAULTS } from './types';
|
|
3
3
|
export const get_projection_source_entries = (entries, temp_filtered_entries) => (temp_filtered_entries.length > 0 ? temp_filtered_entries : entries);
|
|
4
|
-
const resolve_temp_filter_options = (config, props) => ({
|
|
5
|
-
interpolate: config.interpolate_temperature ??
|
|
6
|
-
props.interpolate_temperature ??
|
|
7
|
-
CHEMPOT_DEFAULTS.interpolate_temperature,
|
|
8
|
-
max_interpolation_gap: config.max_interpolation_gap ??
|
|
9
|
-
props.max_interpolation_gap ??
|
|
10
|
-
CHEMPOT_DEFAULTS.max_interpolation_gap,
|
|
11
|
-
});
|
|
12
4
|
export function get_temp_filter_payload(entries, temperature, config, props) {
|
|
13
5
|
const { has_temp_data, available_temperatures } = analyze_temperature_data(entries);
|
|
14
6
|
if (!has_temp_data || temperature === undefined) {
|
|
15
7
|
return { has_temp_data, available_temperatures, temp_filtered_entries: entries };
|
|
16
8
|
}
|
|
17
|
-
|
|
18
|
-
const temp_filtered_entries = filter_entries_at_temperature(entries, temperature,
|
|
9
|
+
// Option resolution order: config beats props beats defaults
|
|
10
|
+
const temp_filtered_entries = filter_entries_at_temperature(entries, temperature, {
|
|
11
|
+
interpolate: config.interpolate_temperature ??
|
|
12
|
+
props.interpolate_temperature ??
|
|
13
|
+
CHEMPOT_DEFAULTS.interpolate_temperature,
|
|
14
|
+
max_interpolation_gap: config.max_interpolation_gap ??
|
|
15
|
+
props.max_interpolation_gap ??
|
|
16
|
+
CHEMPOT_DEFAULTS.max_interpolation_gap,
|
|
17
|
+
});
|
|
19
18
|
return { has_temp_data, available_temperatures, temp_filtered_entries };
|
|
20
19
|
}
|
|
21
20
|
export function get_valid_temperature(temperature, has_temp_data, available_temperatures) {
|
package/dist/colors/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as d3_sc from 'd3-scale-chromatic';
|
|
2
|
-
import type { Vec3 } from '../math';
|
|
3
|
-
import type { ELEM_SYMBOLS } from '../labels';
|
|
4
2
|
export type D3InterpolateName = keyof typeof d3_sc & `interpolate${string}`;
|
|
5
3
|
export type D3ColorSchemeName = D3InterpolateName extends `interpolate${infer Name}` ? Name : never;
|
|
6
4
|
export declare const get_d3_interpolator: (name: D3InterpolateName) => ((t: number) => string);
|
|
@@ -9,8 +7,6 @@ export type ColorScaleType = (typeof COLOR_SCALE_TYPES)[number];
|
|
|
9
7
|
export declare const DEFAULT_CATEGORY_COLORS: Record<string, string>;
|
|
10
8
|
export declare const AXIS_COLORS: readonly [readonly ["x", "#d75555", "#e66666"], readonly ["y", "#55b855", "#66c966"], readonly ["z", "#5555d7", "#6666e6"]];
|
|
11
9
|
export declare const NEG_AXIS_COLORS: readonly [readonly ["nx", "#b84444", "#cc5555"], readonly ["ny", "#44a044", "#55b155"], readonly ["nz", "#4444b8", "#5555c9"]];
|
|
12
|
-
export type RGBColor = Vec3;
|
|
13
|
-
export type ElementColorScheme = Record<(typeof ELEM_SYMBOLS)[number], RGBColor>;
|
|
14
10
|
export declare const vesta_hex: Record<string, string>;
|
|
15
11
|
export declare const jmol_hex: Record<string, string>;
|
|
16
12
|
export declare const alloy_hex: Record<string, string>;
|
package/dist/colors/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { color as d3_color, rgb } from 'd3-color';
|
|
2
2
|
import * as d3_sc from 'd3-scale-chromatic';
|
|
3
|
+
import { COLOR_THEMES, get_system_mode, get_theme_preference, is_valid_theme_name, resolve_theme_mode, THEME_STORAGE_KEY, THEME_TYPE, } from '../theme';
|
|
4
|
+
import { clamp01 } from '../utils';
|
|
3
5
|
import alloy_colors from './alloy-colors.json' with { type: 'json' };
|
|
4
6
|
import dark_mode_colors from './dark-mode-colors.json' with { type: 'json' };
|
|
5
7
|
import jmol_colors from './jmol-colors.json' with { type: 'json' };
|
|
@@ -82,16 +84,17 @@ export function luminance(clr) {
|
|
|
82
84
|
const { r: red, g: green, b: blue } = rgb(clr);
|
|
83
85
|
return (0.299 * red + 0.587 * green + 0.114 * blue) / 255; // https://stackoverflow.com/a/596243
|
|
84
86
|
}
|
|
87
|
+
// CSS color string for a fully transparent background
|
|
88
|
+
const NO_BG = `rgba(0, 0, 0, 0)`;
|
|
85
89
|
// get background color of passed DOM node, or recurse up the DOM tree if current node is transparent
|
|
86
90
|
export function get_bg_color(elem, bg_color = null) {
|
|
87
91
|
if (bg_color)
|
|
88
92
|
return bg_color;
|
|
89
93
|
// recurse up the DOM tree to find the first non-transparent background color
|
|
90
|
-
const transparent = `rgba(0, 0, 0, 0)`;
|
|
91
94
|
if (!elem)
|
|
92
|
-
return
|
|
95
|
+
return NO_BG; // if no DOM node, return transparent
|
|
93
96
|
const bg = getComputedStyle(elem).backgroundColor; // get node background color
|
|
94
|
-
if (bg !==
|
|
97
|
+
if (bg !== NO_BG)
|
|
95
98
|
return bg; // if not transparent, return it
|
|
96
99
|
return get_bg_color(elem.parentElement); // otherwise recurse up the DOM tree
|
|
97
100
|
}
|
|
@@ -104,7 +107,7 @@ export function pick_contrast_color(options = {}) {
|
|
|
104
107
|
export const contrast_color = (options = {}) => (node) => {
|
|
105
108
|
node.style.color = pick_contrast_color({ ...options, bg_color: get_bg_color(node) });
|
|
106
109
|
};
|
|
107
|
-
const is_valid_bg = (bg) => bg !== `` && bg !==
|
|
110
|
+
const is_valid_bg = (bg) => bg !== `` && bg !== NO_BG && bg !== `transparent`;
|
|
108
111
|
// Detect and return the page background color from html/body elements or user preferences
|
|
109
112
|
export function get_page_background(fallback_dark = `#1a1a1a`, fallback_light = `#ffffff`) {
|
|
110
113
|
if (typeof window === `undefined`)
|
|
@@ -119,25 +122,21 @@ export function get_page_background(fallback_dark = `#1a1a1a`, fallback_light =
|
|
|
119
122
|
if (is_valid_bg(html_bg))
|
|
120
123
|
return html_bg;
|
|
121
124
|
// Fall back to prefers-color-scheme
|
|
122
|
-
const prefers_dark = globalThis.matchMedia(`(prefers-color-scheme: dark)`)
|
|
125
|
+
const prefers_dark = globalThis.matchMedia?.(`(prefers-color-scheme: dark)`)?.matches;
|
|
123
126
|
return prefers_dark ? fallback_dark : fallback_light;
|
|
124
127
|
}
|
|
125
|
-
// Detect dark mode: checks data-theme attribute,
|
|
128
|
+
// Detect dark mode: checks data-theme attribute, then the persisted theme
|
|
129
|
+
// preference (resolving `auto` against the OS), then falls back to OS preference.
|
|
126
130
|
export function is_dark_mode() {
|
|
127
131
|
if (typeof document === `undefined`)
|
|
128
132
|
return false;
|
|
133
|
+
// Prefer the resolved theme name on data-theme (light/dark/white/black), else
|
|
134
|
+
// fall back to the persisted preference (resolving `auto` against the OS)
|
|
129
135
|
const data_theme = document.documentElement.dataset.theme;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (stored === `dark` || stored === `light`)
|
|
135
|
-
return stored === `dark`;
|
|
136
|
-
}
|
|
137
|
-
catch {
|
|
138
|
-
/* localStorage throws in private browsing mode */
|
|
139
|
-
}
|
|
140
|
-
return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches ?? false;
|
|
136
|
+
const theme_name = data_theme && is_valid_theme_name(data_theme)
|
|
137
|
+
? data_theme
|
|
138
|
+
: resolve_theme_mode(get_theme_preference(), get_system_mode());
|
|
139
|
+
return THEME_TYPE[theme_name] === COLOR_THEMES.dark;
|
|
141
140
|
}
|
|
142
141
|
// Watch for dark mode changes and call callback on each change. Returns cleanup function.
|
|
143
142
|
export function watch_dark_mode(on_change) {
|
|
@@ -149,8 +148,8 @@ export function watch_dark_mode(on_change) {
|
|
|
149
148
|
attributes: true,
|
|
150
149
|
attributeFilter: [`data-theme`],
|
|
151
150
|
});
|
|
152
|
-
const on_storage = (
|
|
153
|
-
if (
|
|
151
|
+
const on_storage = (event) => {
|
|
152
|
+
if (event.key === THEME_STORAGE_KEY)
|
|
154
153
|
notify();
|
|
155
154
|
};
|
|
156
155
|
globalThis.addEventListener(`storage`, on_storage);
|
|
@@ -178,7 +177,7 @@ export function css_color_to_hex(color, fallback) {
|
|
|
178
177
|
// Returns the color in rgba() format, or the original color if format is unsupported.
|
|
179
178
|
export function add_alpha(color, alpha) {
|
|
180
179
|
// Clamp alpha to valid CSS range [0, 1]
|
|
181
|
-
const clamped_alpha =
|
|
180
|
+
const clamped_alpha = clamp01(alpha);
|
|
182
181
|
// Handle hex colors (#rgb, #rgba, #rrggbb, #rrggbbaa)
|
|
183
182
|
if (color.startsWith(`#`)) {
|
|
184
183
|
const hex = color.slice(1);
|