matterviz 0.3.6 → 0.3.7
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.d.ts +9 -0
- package/dist/FilePicker.svelte +360 -0
- package/dist/FilePicker.svelte.d.ts +17 -0
- package/dist/Icon.svelte.d.ts +13 -0
- package/dist/MillerIndexInput.svelte +66 -0
- package/dist/MillerIndexInput.svelte.d.ts +7 -0
- package/dist/api/mp.d.ts +6 -0
- package/dist/api/mp.js +22 -0
- package/dist/api/optimade.d.ts +45 -0
- package/dist/api/optimade.js +135 -0
- package/dist/brillouin/BrillouinZone.svelte +549 -0
- package/dist/brillouin/BrillouinZone.svelte.d.ts +83 -0
- package/dist/brillouin/BrillouinZoneControls.svelte +144 -0
- package/dist/brillouin/BrillouinZoneControls.svelte.d.ts +17 -0
- package/dist/brillouin/BrillouinZoneExportPane.svelte +146 -0
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +15 -0
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +146 -0
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +13 -0
- package/dist/brillouin/BrillouinZoneScene.svelte +476 -0
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +48 -0
- package/dist/brillouin/BrillouinZoneTooltip.svelte +92 -0
- package/dist/brillouin/BrillouinZoneTooltip.svelte.d.ts +8 -0
- package/dist/brillouin/compute.d.ts +17 -0
- package/dist/brillouin/compute.js +426 -0
- package/dist/brillouin/index.d.ts +8 -0
- package/dist/brillouin/index.js +7 -0
- package/dist/brillouin/types.d.ts +43 -0
- package/dist/brillouin/types.js +1 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte +327 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +846 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +3193 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -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 +78 -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 +806 -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 +34 -0
- package/dist/chempot-diagram/types.d.ts +81 -0
- package/dist/chempot-diagram/types.js +28 -0
- package/dist/colors/index.d.ts +47 -0
- package/dist/colors/index.js +203 -0
- package/dist/composition/BarChart.svelte +297 -0
- package/dist/composition/BarChart.svelte.d.ts +39 -0
- package/dist/composition/BubbleChart.svelte +218 -0
- package/dist/composition/BubbleChart.svelte.d.ts +28 -0
- package/dist/composition/Composition.svelte +165 -0
- package/dist/composition/Composition.svelte.d.ts +15 -0
- package/dist/composition/Formula.svelte +268 -0
- package/dist/composition/Formula.svelte.d.ts +19 -0
- package/dist/composition/FormulaFilter.svelte +1257 -0
- package/dist/composition/FormulaFilter.svelte.d.ts +51 -0
- package/dist/composition/PieChart.svelte +323 -0
- package/dist/composition/PieChart.svelte.d.ts +37 -0
- package/dist/composition/format.d.ts +15 -0
- package/dist/composition/format.js +109 -0
- package/dist/composition/index.d.ts +20 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +56 -0
- package/dist/composition/parse.js +474 -0
- package/dist/constants.d.ts +29 -0
- package/dist/constants.js +99 -0
- package/dist/controls.d.ts +14 -0
- package/dist/controls.js +30 -0
- package/dist/convex-hull/ConvexHull.svelte +157 -0
- package/dist/convex-hull/ConvexHull.svelte.d.ts +13 -0
- package/dist/convex-hull/ConvexHull2D.svelte +825 -0
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +11 -0
- package/dist/convex-hull/ConvexHull3D.svelte +1801 -0
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +8 -0
- package/dist/convex-hull/ConvexHull4D.svelte +1398 -0
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +8 -0
- package/dist/convex-hull/ConvexHullControls.svelte +535 -0
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +48 -0
- package/dist/convex-hull/ConvexHullInfoPane.svelte +125 -0
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +20 -0
- package/dist/convex-hull/ConvexHullStats.svelte +929 -0
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +17 -0
- package/dist/convex-hull/ConvexHullTooltip.svelte +131 -0
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +33 -0
- package/dist/convex-hull/GasPressureControls.svelte +247 -0
- package/dist/convex-hull/GasPressureControls.svelte.d.ts +11 -0
- package/dist/convex-hull/StructurePopup.svelte +151 -0
- package/dist/convex-hull/StructurePopup.svelte.d.ts +18 -0
- package/dist/convex-hull/TemperatureSlider.svelte.d.ts +8 -0
- package/dist/convex-hull/barycentric-coords.d.ts +18 -0
- package/dist/convex-hull/barycentric-coords.js +182 -0
- 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.d.ts +16 -0
- package/dist/convex-hull/gas-thermodynamics.js +314 -0
- package/dist/convex-hull/helpers.d.ts +114 -0
- package/dist/convex-hull/helpers.js +710 -0
- package/dist/convex-hull/index.d.ts +119 -0
- package/dist/convex-hull/index.js +58 -0
- package/dist/convex-hull/thermodynamics.d.ts +67 -0
- package/dist/convex-hull/thermodynamics.js +1752 -0
- package/dist/convex-hull/types.d.ts +162 -0
- package/dist/convex-hull/types.js +36 -0
- package/dist/coordination/CoordinationBarPlot.svelte +311 -0
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +30 -0
- package/dist/coordination/calc-coordination.d.ts +15 -0
- package/dist/coordination/calc-coordination.js +63 -0
- package/dist/coordination/index.d.ts +8 -0
- package/dist/coordination/index.js +7 -0
- package/dist/effects.svelte.d.ts +12 -0
- package/dist/effects.svelte.js +37 -0
- package/dist/element/BohrAtom.svelte.d.ts +20 -0
- package/dist/element/ElementHeading.svelte +26 -0
- package/dist/element/ElementHeading.svelte.d.ts +8 -0
- package/dist/element/ElementPhoto.svelte +57 -0
- package/dist/element/ElementPhoto.svelte.d.ts +9 -0
- package/dist/element/ElementStats.svelte +80 -0
- package/dist/element/ElementStats.svelte.d.ts +8 -0
- package/dist/element/ElementTile.svelte +484 -0
- package/dist/element/ElementTile.svelte.d.ts +29 -0
- package/dist/element/Nucleus.svelte.d.ts +17 -0
- package/dist/element/data.d.ts +2 -0
- package/dist/element/data.js +2 -0
- package/dist/element/index.d.ts +8 -0
- package/dist/element/index.js +7 -0
- package/dist/element/types.d.ts +57 -0
- package/dist/element/types.js +1 -0
- package/dist/feedback/ClickFeedback.svelte +58 -0
- package/dist/feedback/ClickFeedback.svelte.d.ts +12 -0
- package/dist/feedback/DragOverlay.svelte +42 -0
- package/dist/feedback/DragOverlay.svelte.d.ts +7 -0
- package/dist/feedback/Spinner.svelte.d.ts +7 -0
- package/dist/feedback/StatusMessage.svelte.d.ts +9 -0
- package/dist/feedback/index.d.ts +4 -0
- package/dist/feedback/index.js +4 -0
- package/dist/fermi-surface/FermiSlice.svelte +189 -0
- package/dist/fermi-surface/FermiSlice.svelte.d.ts +24 -0
- package/dist/fermi-surface/FermiSurface.svelte +600 -0
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +83 -0
- package/dist/fermi-surface/FermiSurfaceControls.svelte +448 -0
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +35 -0
- package/dist/fermi-surface/FermiSurfaceScene.svelte +794 -0
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +50 -0
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +111 -0
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte.d.ts +8 -0
- package/dist/fermi-surface/compute.d.ts +5 -0
- package/dist/fermi-surface/compute.js +538 -0
- package/dist/fermi-surface/constants.d.ts +9 -0
- package/dist/fermi-surface/constants.js +27 -0
- package/dist/fermi-surface/export.d.ts +5 -0
- package/dist/fermi-surface/export.js +50 -0
- package/dist/fermi-surface/index.d.ts +12 -0
- package/dist/fermi-surface/index.js +13 -0
- package/dist/fermi-surface/marching-cubes.d.ts +2 -0
- package/dist/fermi-surface/marching-cubes.js +2 -0
- package/dist/fermi-surface/parse.d.ts +2 -0
- package/dist/fermi-surface/parse.js +491 -0
- package/dist/fermi-surface/symmetry.d.ts +3 -0
- package/dist/fermi-surface/symmetry.js +46 -0
- package/dist/fermi-surface/types.d.ts +110 -0
- package/dist/fermi-surface/types.js +4 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1545 -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 +569 -0
- package/dist/icons.js +648 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +39 -0
- package/dist/io/decompress.d.ts +11 -0
- package/dist/io/decompress.js +74 -0
- package/dist/io/export.d.ts +16 -0
- package/dist/io/export.js +316 -0
- package/dist/io/fetch.d.ts +5 -0
- package/dist/io/fetch.js +39 -0
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +43 -0
- package/dist/io/index.d.ts +7 -0
- package/dist/io/index.js +6 -0
- package/dist/io/is-binary.d.ts +1 -0
- package/dist/io/is-binary.js +20 -0
- package/dist/io/types.d.ts +8 -0
- package/dist/io/types.js +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +123 -0
- package/dist/isosurface/Isosurface.svelte +285 -0
- package/dist/isosurface/Isosurface.svelte.d.ts +8 -0
- package/dist/isosurface/IsosurfaceControls.svelte +277 -0
- package/dist/isosurface/IsosurfaceControls.svelte.d.ts +9 -0
- package/dist/isosurface/index.d.ts +5 -0
- package/dist/isosurface/index.js +6 -0
- package/dist/isosurface/parse.d.ts +6 -0
- package/dist/isosurface/parse.js +553 -0
- package/dist/isosurface/slice.d.ts +11 -0
- package/dist/isosurface/slice.js +140 -0
- package/dist/isosurface/types.d.ts +56 -0
- package/dist/isosurface/types.js +227 -0
- package/dist/labels.d.ts +53 -0
- package/dist/labels.js +277 -0
- package/dist/layout/FullscreenToggle.svelte +50 -0
- package/dist/layout/FullscreenToggle.svelte.d.ts +7 -0
- package/dist/layout/InfoCard.svelte +120 -0
- package/dist/layout/InfoCard.svelte.d.ts +21 -0
- package/dist/layout/InfoTag.svelte +185 -0
- package/dist/layout/InfoTag.svelte.d.ts +19 -0
- package/dist/layout/PropertyFilter.svelte +246 -0
- package/dist/layout/PropertyFilter.svelte.d.ts +24 -0
- package/dist/layout/SettingsSection.svelte +148 -0
- package/dist/layout/SettingsSection.svelte.d.ts +17 -0
- package/dist/layout/SubpageGrid.svelte +82 -0
- package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
- package/dist/layout/fullscreen.d.ts +9 -0
- package/dist/layout/fullscreen.js +53 -0
- package/dist/layout/index.d.ts +10 -0
- package/dist/layout/index.js +8 -0
- package/dist/layout/json-tree/JsonNode.svelte +548 -0
- package/dist/layout/json-tree/JsonNode.svelte.d.ts +11 -0
- package/dist/layout/json-tree/JsonTree.svelte +1230 -0
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +6 -0
- package/dist/layout/json-tree/JsonValue.svelte.d.ts +9 -0
- package/dist/layout/json-tree/index.d.ts +3 -0
- package/dist/layout/json-tree/index.js +3 -0
- package/dist/layout/json-tree/types.d.ts +74 -0
- package/dist/layout/json-tree/types.js +2 -0
- package/dist/layout/json-tree/utils.d.ts +29 -0
- package/dist/layout/json-tree/utils.js +641 -0
- package/dist/marching-cubes.d.ts +14 -0
- package/dist/marching-cubes.js +540 -0
- package/dist/math.d.ts +101 -0
- package/dist/math.js +905 -0
- package/dist/overlays/ContextMenu.svelte +162 -0
- package/dist/overlays/ContextMenu.svelte.d.ts +25 -0
- package/dist/overlays/CopyButton.svelte +45 -0
- package/dist/overlays/CopyButton.svelte.d.ts +8 -0
- package/dist/overlays/DragControlTab.svelte +98 -0
- package/dist/overlays/DragControlTab.svelte.d.ts +8 -0
- package/dist/overlays/DraggablePane.svelte +487 -0
- package/dist/overlays/DraggablePane.svelte.d.ts +36 -0
- package/dist/overlays/InfoPaneCards.svelte +149 -0
- package/dist/overlays/InfoPaneCards.svelte.d.ts +22 -0
- package/dist/overlays/index.d.ts +3 -0
- package/dist/overlays/index.js +3 -0
- package/dist/periodic-table/PeriodicTable.svelte +469 -0
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +55 -0
- package/dist/periodic-table/PeriodicTableControls.svelte +557 -0
- package/dist/periodic-table/PeriodicTableControls.svelte.d.ts +24 -0
- package/dist/periodic-table/PropertySelect.svelte +37 -0
- package/dist/periodic-table/PropertySelect.svelte.d.ts +13 -0
- package/dist/periodic-table/TableInset.svelte.d.ts +9 -0
- package/dist/periodic-table/index.d.ts +10 -0
- package/dist/periodic-table/index.js +4 -0
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +1086 -0
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +44 -0
- package/dist/phase-diagram/PhaseDiagramControls.svelte +444 -0
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +30 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +184 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +19 -0
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +391 -0
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +16 -0
- package/dist/phase-diagram/TdbInfoPanel.svelte +203 -0
- package/dist/phase-diagram/TdbInfoPanel.svelte.d.ts +12 -0
- package/dist/phase-diagram/build-diagram.d.ts +11 -0
- package/dist/phase-diagram/build-diagram.js +160 -0
- package/dist/phase-diagram/colors.d.ts +35 -0
- package/dist/phase-diagram/colors.js +51 -0
- package/dist/phase-diagram/diagram-input.d.ts +29 -0
- package/dist/phase-diagram/diagram-input.js +3 -0
- package/dist/phase-diagram/index.d.ts +13 -0
- package/dist/phase-diagram/index.js +11 -0
- package/dist/phase-diagram/parse.d.ts +55 -0
- package/dist/phase-diagram/parse.js +272 -0
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +867 -0
- package/dist/phase-diagram/types.d.ts +93 -0
- package/dist/phase-diagram/types.js +1 -0
- package/dist/phase-diagram/utils.d.ts +118 -0
- package/dist/phase-diagram/utils.js +604 -0
- package/dist/plot/AxisLabel.svelte +51 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +2113 -0
- package/dist/plot/BarPlot.svelte.d.ts +84 -0
- package/dist/plot/BarPlotControls.svelte +66 -0
- package/dist/plot/BarPlotControls.svelte.d.ts +18 -0
- package/dist/plot/BinnedScatterPlot.svelte +1114 -0
- package/dist/plot/BinnedScatterPlot.svelte.d.ts +66 -0
- package/dist/plot/ColorBar.svelte +721 -0
- package/dist/plot/ColorBar.svelte.d.ts +31 -0
- package/dist/plot/ColorScaleSelect.svelte +54 -0
- package/dist/plot/ColorScaleSelect.svelte.d.ts +15 -0
- package/dist/plot/ElementScatter.svelte +63 -0
- package/dist/plot/ElementScatter.svelte.d.ts +14 -0
- package/dist/plot/FillArea.svelte.d.ts +21 -0
- package/dist/plot/Histogram.svelte +1558 -0
- package/dist/plot/Histogram.svelte.d.ts +50 -0
- package/dist/plot/HistogramControls.svelte +212 -0
- package/dist/plot/HistogramControls.svelte.d.ts +22 -0
- package/dist/plot/InteractiveAxisLabel.svelte +96 -0
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +14 -0
- package/dist/plot/Line.svelte +84 -0
- package/dist/plot/Line.svelte.d.ts +15 -0
- package/dist/plot/PlotAxis.svelte +169 -0
- package/dist/plot/PlotAxis.svelte.d.ts +24 -0
- package/dist/plot/PlotControls.svelte +537 -0
- package/dist/plot/PlotControls.svelte.d.ts +4 -0
- package/dist/plot/PlotLegend.svelte +569 -0
- package/dist/plot/PlotLegend.svelte.d.ts +29 -0
- package/dist/plot/PlotTooltip.svelte +67 -0
- package/dist/plot/PlotTooltip.svelte.d.ts +17 -0
- package/dist/plot/PortalSelect.svelte +253 -0
- package/dist/plot/PortalSelect.svelte.d.ts +16 -0
- package/dist/plot/ReferenceLine.svelte.d.ts +20 -0
- package/dist/plot/ReferenceLine3D.svelte +156 -0
- package/dist/plot/ReferenceLine3D.svelte.d.ts +14 -0
- package/dist/plot/ReferencePlane.svelte +175 -0
- package/dist/plot/ReferencePlane.svelte.d.ts +14 -0
- package/dist/plot/ScatterPlot.svelte +2778 -0
- package/dist/plot/ScatterPlot.svelte.d.ts +96 -0
- package/dist/plot/ScatterPlot3D.svelte +529 -0
- package/dist/plot/ScatterPlot3D.svelte.d.ts +95 -0
- package/dist/plot/ScatterPlot3DControls.svelte +437 -0
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +20 -0
- package/dist/plot/ScatterPlot3DScene.svelte +912 -0
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +74 -0
- package/dist/plot/ScatterPlotControls.svelte +306 -0
- package/dist/plot/ScatterPlotControls.svelte.d.ts +17 -0
- package/dist/plot/ScatterPoint.svelte +182 -0
- package/dist/plot/ScatterPoint.svelte.d.ts +22 -0
- package/dist/plot/SpacegroupBarPlot.svelte +293 -0
- package/dist/plot/SpacegroupBarPlot.svelte.d.ts +9 -0
- package/dist/plot/Surface3D.svelte +197 -0
- package/dist/plot/Surface3D.svelte.d.ts +13 -0
- package/dist/plot/ZeroLines.svelte +97 -0
- package/dist/plot/ZeroLines.svelte.d.ts +33 -0
- package/dist/plot/ZoomRect.svelte +23 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/adaptive-density.d.ts +69 -0
- package/dist/plot/adaptive-density.js +191 -0
- package/dist/plot/auto-place.d.ts +43 -0
- package/dist/plot/auto-place.js +122 -0
- package/dist/plot/axis-utils.d.ts +19 -0
- package/dist/plot/axis-utils.js +78 -0
- package/dist/plot/binned-scatter-types.d.ts +59 -0
- package/dist/plot/binned-scatter-types.js +1 -0
- package/dist/plot/data-cleaning.d.ts +37 -0
- package/dist/plot/data-cleaning.js +855 -0
- package/dist/plot/data-transform.d.ts +16 -0
- package/dist/plot/data-transform.js +45 -0
- package/dist/plot/defaults.d.ts +19 -0
- package/dist/plot/defaults.js +9 -0
- package/dist/plot/fill-utils.d.ts +46 -0
- package/dist/plot/fill-utils.js +322 -0
- package/dist/plot/hover-lock.svelte.d.ts +14 -0
- package/dist/plot/hover-lock.svelte.js +46 -0
- package/dist/plot/index.d.ts +41 -0
- package/dist/plot/index.js +39 -0
- package/dist/plot/interactions.d.ts +12 -0
- package/dist/plot/interactions.js +101 -0
- package/dist/plot/layout.d.ts +78 -0
- package/dist/plot/layout.js +273 -0
- package/dist/plot/reference-line.d.ts +60 -0
- package/dist/plot/reference-line.js +314 -0
- package/dist/plot/scales.d.ts +48 -0
- package/dist/plot/scales.js +481 -0
- package/dist/plot/svg.d.ts +1 -0
- package/dist/plot/svg.js +11 -0
- package/dist/plot/types.d.ts +831 -0
- package/dist/plot/types.js +99 -0
- package/dist/plot/utils/label-placement.d.ts +68 -0
- package/dist/plot/utils/label-placement.js +326 -0
- package/dist/plot/utils/series-visibility.d.ts +15 -0
- package/dist/plot/utils/series-visibility.js +85 -0
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +247 -0
- package/dist/rdf/RdfPlot.svelte.d.ts +27 -0
- package/dist/rdf/calc-rdf.d.ts +4 -0
- package/dist/rdf/calc-rdf.js +111 -0
- package/dist/rdf/index.d.ts +23 -0
- package/dist/rdf/index.js +2 -0
- package/dist/sanitize.d.ts +6 -0
- package/dist/sanitize.js +116 -0
- package/dist/settings.d.ts +255 -0
- package/dist/settings.js +1132 -0
- package/dist/spectral/Bands.svelte +1040 -0
- package/dist/spectral/Bands.svelte.d.ts +40 -0
- package/dist/spectral/BandsAndDos.svelte +134 -0
- package/dist/spectral/BandsAndDos.svelte.d.ts +18 -0
- package/dist/spectral/BrillouinBandsDos.svelte +252 -0
- package/dist/spectral/BrillouinBandsDos.svelte.d.ts +20 -0
- package/dist/spectral/Dos.svelte +697 -0
- package/dist/spectral/Dos.svelte.d.ts +29 -0
- package/dist/spectral/helpers.d.ts +119 -0
- package/dist/spectral/helpers.js +1032 -0
- package/dist/spectral/index.d.ts +6 -0
- package/dist/spectral/index.js +6 -0
- package/dist/spectral/types.d.ts +84 -0
- package/dist/spectral/types.js +2 -0
- package/dist/state.svelte.d.ts +25 -0
- package/dist/state.svelte.js +45 -0
- package/dist/structure/Arrow.svelte +72 -0
- package/dist/structure/Arrow.svelte.d.ts +15 -0
- package/dist/structure/AtomLegend.svelte +815 -0
- package/dist/structure/AtomLegend.svelte.d.ts +35 -0
- package/dist/structure/Bond.svelte +140 -0
- package/dist/structure/Bond.svelte.d.ts +9 -0
- package/dist/structure/CanvasTooltip.svelte +33 -0
- package/dist/structure/CanvasTooltip.svelte.d.ts +12 -0
- package/dist/structure/CellSelect.svelte +349 -0
- package/dist/structure/CellSelect.svelte.d.ts +13 -0
- package/dist/structure/Cylinder.svelte +45 -0
- package/dist/structure/Cylinder.svelte.d.ts +10 -0
- package/dist/structure/Lattice.svelte +196 -0
- package/dist/structure/Lattice.svelte.d.ts +17 -0
- package/dist/structure/Structure.svelte +2248 -0
- package/dist/structure/Structure.svelte.d.ts +89 -0
- package/dist/structure/StructureControls.svelte +1273 -0
- package/dist/structure/StructureControls.svelte.d.ts +31 -0
- package/dist/structure/StructureExportPane.svelte +252 -0
- package/dist/structure/StructureExportPane.svelte.d.ts +17 -0
- package/dist/structure/StructureInfoPane.svelte +737 -0
- package/dist/structure/StructureInfoPane.svelte.d.ts +19 -0
- package/dist/structure/StructureScene.svelte +2255 -0
- package/dist/structure/StructureScene.svelte.d.ts +111 -0
- package/dist/structure/atom-properties.d.ts +37 -0
- package/dist/structure/atom-properties.js +200 -0
- package/dist/structure/bond-order-perception.d.ts +13 -0
- package/dist/structure/bond-order-perception.js +384 -0
- package/dist/structure/bonding.d.ts +68 -0
- package/dist/structure/bonding.js +696 -0
- package/dist/structure/export.d.ts +20 -0
- package/dist/structure/export.js +727 -0
- package/dist/structure/index.d.ts +126 -0
- package/dist/structure/index.js +169 -0
- package/dist/structure/label-placement.d.ts +14 -0
- package/dist/structure/label-placement.js +72 -0
- package/dist/structure/measure.d.ts +6 -0
- package/dist/structure/measure.js +29 -0
- package/dist/structure/parse.d.ts +66 -0
- package/dist/structure/parse.js +1392 -0
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +99 -0
- package/dist/structure/pbc.d.ts +9 -0
- package/dist/structure/pbc.js +123 -0
- package/dist/structure/supercell.d.ts +8 -0
- package/dist/structure/supercell.js +170 -0
- package/dist/structure/validation.d.ts +2 -0
- package/dist/structure/validation.js +10 -0
- package/dist/symmetry/SymmetryStats.svelte +226 -0
- package/dist/symmetry/SymmetryStats.svelte.d.ts +21 -0
- package/dist/symmetry/WyckoffTable.svelte +120 -0
- package/dist/symmetry/WyckoffTable.svelte.d.ts +11 -0
- package/dist/symmetry/cell-transform.d.ts +12 -0
- package/dist/symmetry/cell-transform.js +91 -0
- package/dist/symmetry/index.d.ts +43 -0
- package/dist/symmetry/index.js +228 -0
- package/dist/symmetry/spacegroups.d.ts +9 -0
- package/dist/symmetry/spacegroups.js +394 -0
- package/dist/table/HeatmapTable.svelte +1833 -0
- package/dist/table/HeatmapTable.svelte.d.ts +49 -0
- package/dist/table/ToggleMenu.svelte +385 -0
- package/dist/table/ToggleMenu.svelte.d.ts +11 -0
- package/dist/table/index.d.ts +74 -0
- package/dist/table/index.js +38 -0
- package/dist/theme/ThemeControl.svelte +53 -0
- package/dist/theme/ThemeControl.svelte.d.ts +9 -0
- package/dist/theme/index.d.ts +29 -0
- package/dist/theme/index.js +79 -0
- package/dist/time.d.ts +4 -0
- package/dist/time.js +70 -0
- package/dist/tooltip/TooltipContent.svelte +58 -0
- package/dist/tooltip/TooltipContent.svelte.d.ts +31 -0
- package/dist/tooltip/index.d.ts +2 -0
- package/dist/tooltip/index.js +1 -0
- package/dist/tooltip/types.d.ts +8 -0
- package/dist/tooltip/types.js +1 -0
- package/dist/trajectory/Trajectory.svelte +1545 -0
- package/dist/trajectory/Trajectory.svelte.d.ts +77 -0
- package/dist/trajectory/TrajectoryError.svelte +128 -0
- package/dist/trajectory/TrajectoryError.svelte.d.ts +13 -0
- package/dist/trajectory/TrajectoryExportPane.svelte +357 -0
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +17 -0
- package/dist/trajectory/TrajectoryInfoPane.svelte +313 -0
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +17 -0
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.d.ts +5 -0
- package/dist/trajectory/extract.js +162 -0
- 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 +15 -0
- package/dist/trajectory/helpers.js +164 -0
- package/dist/trajectory/index.d.ts +63 -0
- package/dist/trajectory/index.js +126 -0
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +73 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +127 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +298 -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.d.ts +28 -0
- package/dist/trajectory/plotting.js +423 -0
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +45 -0
- package/dist/xrd/XrdPlot.svelte +615 -0
- package/dist/xrd/XrdPlot.svelte.d.ts +28 -0
- package/dist/xrd/broadening.d.ts +20 -0
- package/dist/xrd/broadening.js +97 -0
- package/dist/xrd/calc-xrd.d.ts +37 -0
- package/dist/xrd/calc-xrd.js +336 -0
- package/dist/xrd/index.d.ts +37 -0
- package/dist/xrd/index.js +4 -0
- package/dist/xrd/parse.d.ts +13 -0
- package/dist/xrd/parse.js +749 -0
- package/license +1 -1
- package/package.json +232 -1457
- package/readme.md +98 -171
- package/.vscode/launch.json +0 -13
- package/.vscodeignore +0 -7
- package/dist/assets/STLExporter-BpTH3YHE.js +0 -8
- package/dist/assets/browser-DdDecX_W.js +0 -1
- package/dist/assets/export-qgn-H9y6.js +0 -2
- package/dist/assets/main-DiKYzti2.css +0 -1
- package/dist/assets/moyo_wasm_bg-0ocwg7xY.wasm +0 -0
- package/dist/extension.js +0 -31293
- package/dist/src/lib/FilePicker.svelte +0 -360
- package/dist/src/lib/MillerIndexInput.svelte +0 -66
- package/dist/src/lib/api/mp.ts +0 -26
- package/dist/src/lib/api/optimade.ts +0 -204
- package/dist/src/lib/brillouin/BrillouinZone.svelte +0 -549
- package/dist/src/lib/brillouin/BrillouinZoneControls.svelte +0 -144
- package/dist/src/lib/brillouin/BrillouinZoneExportPane.svelte +0 -146
- package/dist/src/lib/brillouin/BrillouinZoneInfoPane.svelte +0 -146
- package/dist/src/lib/brillouin/BrillouinZoneScene.svelte +0 -476
- package/dist/src/lib/brillouin/BrillouinZoneTooltip.svelte +0 -92
- package/dist/src/lib/brillouin/compute.ts +0 -529
- package/dist/src/lib/brillouin/index.ts +0 -8
- package/dist/src/lib/brillouin/types.ts +0 -51
- package/dist/src/lib/chempot-diagram/ChemPotDiagram.svelte +0 -327
- package/dist/src/lib/chempot-diagram/ChemPotDiagram2D.svelte +0 -846
- package/dist/src/lib/chempot-diagram/ChemPotDiagram3D.svelte +0 -3193
- package/dist/src/lib/chempot-diagram/async-compute.svelte.ts +0 -94
- package/dist/src/lib/chempot-diagram/chempot-worker.ts +0 -11
- package/dist/src/lib/chempot-diagram/color.ts +0 -42
- package/dist/src/lib/chempot-diagram/compute.ts +0 -1014
- package/dist/src/lib/chempot-diagram/index.ts +0 -6
- package/dist/src/lib/chempot-diagram/pointer.ts +0 -56
- package/dist/src/lib/chempot-diagram/temperature.ts +0 -77
- package/dist/src/lib/chempot-diagram/types.ts +0 -130
- package/dist/src/lib/colors/index.ts +0 -249
- package/dist/src/lib/composition/BarChart.svelte +0 -297
- package/dist/src/lib/composition/BubbleChart.svelte +0 -218
- package/dist/src/lib/composition/Composition.svelte +0 -165
- package/dist/src/lib/composition/Formula.svelte +0 -268
- package/dist/src/lib/composition/FormulaFilter.svelte +0 -1257
- package/dist/src/lib/composition/PieChart.svelte +0 -323
- package/dist/src/lib/composition/format.ts +0 -155
- package/dist/src/lib/composition/index.ts +0 -37
- package/dist/src/lib/composition/parse.ts +0 -605
- package/dist/src/lib/constants.ts +0 -134
- package/dist/src/lib/controls.ts +0 -42
- package/dist/src/lib/convex-hull/ConvexHull.svelte +0 -157
- package/dist/src/lib/convex-hull/ConvexHull2D.svelte +0 -825
- package/dist/src/lib/convex-hull/ConvexHull3D.svelte +0 -1801
- package/dist/src/lib/convex-hull/ConvexHull4D.svelte +0 -1398
- package/dist/src/lib/convex-hull/ConvexHullControls.svelte +0 -535
- package/dist/src/lib/convex-hull/ConvexHullInfoPane.svelte +0 -125
- package/dist/src/lib/convex-hull/ConvexHullStats.svelte +0 -929
- package/dist/src/lib/convex-hull/ConvexHullTooltip.svelte +0 -131
- package/dist/src/lib/convex-hull/GasPressureControls.svelte +0 -247
- package/dist/src/lib/convex-hull/StructurePopup.svelte +0 -151
- package/dist/src/lib/convex-hull/barycentric-coords.ts +0 -246
- package/dist/src/lib/convex-hull/demo-temperature.ts +0 -63
- package/dist/src/lib/convex-hull/gas-thermodynamics.ts +0 -405
- package/dist/src/lib/convex-hull/helpers.ts +0 -932
- package/dist/src/lib/convex-hull/index.ts +0 -202
- package/dist/src/lib/convex-hull/thermodynamics.ts +0 -2192
- package/dist/src/lib/convex-hull/types.ts +0 -267
- package/dist/src/lib/coordination/CoordinationBarPlot.svelte +0 -311
- package/dist/src/lib/coordination/calc-coordination.ts +0 -93
- package/dist/src/lib/coordination/index.ts +0 -9
- package/dist/src/lib/effects.svelte.ts +0 -48
- package/dist/src/lib/element/ElementHeading.svelte +0 -26
- package/dist/src/lib/element/ElementPhoto.svelte +0 -57
- package/dist/src/lib/element/ElementStats.svelte +0 -80
- package/dist/src/lib/element/ElementTile.svelte +0 -484
- package/dist/src/lib/element/data.ts +0 -14
- package/dist/src/lib/element/index.ts +0 -8
- package/dist/src/lib/element/types.ts +0 -62
- package/dist/src/lib/feedback/ClickFeedback.svelte +0 -58
- package/dist/src/lib/feedback/DragOverlay.svelte +0 -42
- package/dist/src/lib/feedback/index.ts +0 -4
- package/dist/src/lib/fermi-surface/FermiSlice.svelte +0 -189
- package/dist/src/lib/fermi-surface/FermiSurface.svelte +0 -600
- package/dist/src/lib/fermi-surface/FermiSurfaceControls.svelte +0 -448
- package/dist/src/lib/fermi-surface/FermiSurfaceScene.svelte +0 -794
- package/dist/src/lib/fermi-surface/FermiSurfaceTooltip.svelte +0 -111
- package/dist/src/lib/fermi-surface/compute.ts +0 -728
- package/dist/src/lib/fermi-surface/constants.ts +0 -32
- package/dist/src/lib/fermi-surface/export.ts +0 -64
- package/dist/src/lib/fermi-surface/index.ts +0 -14
- package/dist/src/lib/fermi-surface/marching-cubes.ts +0 -3
- package/dist/src/lib/fermi-surface/parse.ts +0 -574
- package/dist/src/lib/fermi-surface/symmetry.ts +0 -56
- package/dist/src/lib/fermi-surface/types.ts +0 -159
- package/dist/src/lib/heatmap-matrix/HeatmapMatrix.svelte +0 -1545
- package/dist/src/lib/heatmap-matrix/HeatmapMatrixControls.svelte +0 -225
- package/dist/src/lib/heatmap-matrix/index.ts +0 -167
- package/dist/src/lib/heatmap-matrix/shared.ts +0 -7
- package/dist/src/lib/icons.ts +0 -650
- package/dist/src/lib/index.ts +0 -61
- package/dist/src/lib/io/decompress.ts +0 -92
- package/dist/src/lib/io/export.ts +0 -385
- package/dist/src/lib/io/fetch.ts +0 -46
- package/dist/src/lib/io/file-drop.ts +0 -51
- package/dist/src/lib/io/index.ts +0 -7
- package/dist/src/lib/io/is-binary.ts +0 -24
- package/dist/src/lib/io/types.ts +0 -8
- package/dist/src/lib/io/url-drop.ts +0 -141
- package/dist/src/lib/isosurface/Isosurface.svelte +0 -285
- package/dist/src/lib/isosurface/IsosurfaceControls.svelte +0 -277
- package/dist/src/lib/isosurface/index.ts +0 -7
- package/dist/src/lib/isosurface/parse.ts +0 -656
- package/dist/src/lib/isosurface/slice.ts +0 -175
- package/dist/src/lib/isosurface/types.ts +0 -309
- package/dist/src/lib/labels.ts +0 -320
- package/dist/src/lib/layout/FullscreenToggle.svelte +0 -50
- package/dist/src/lib/layout/InfoCard.svelte +0 -120
- package/dist/src/lib/layout/InfoTag.svelte +0 -185
- package/dist/src/lib/layout/PropertyFilter.svelte +0 -246
- package/dist/src/lib/layout/SettingsSection.svelte +0 -148
- package/dist/src/lib/layout/SubpageGrid.svelte +0 -82
- package/dist/src/lib/layout/fullscreen.ts +0 -65
- package/dist/src/lib/layout/index.ts +0 -11
- package/dist/src/lib/layout/json-tree/JsonNode.svelte +0 -548
- package/dist/src/lib/layout/json-tree/JsonTree.svelte +0 -1230
- package/dist/src/lib/layout/json-tree/index.ts +0 -3
- package/dist/src/lib/layout/json-tree/types.ts +0 -126
- package/dist/src/lib/layout/json-tree/utils.ts +0 -682
- package/dist/src/lib/marching-cubes.ts +0 -614
- package/dist/src/lib/math.ts +0 -1081
- package/dist/src/lib/overlays/ContextMenu.svelte +0 -162
- package/dist/src/lib/overlays/CopyButton.svelte +0 -45
- package/dist/src/lib/overlays/DragControlTab.svelte +0 -98
- package/dist/src/lib/overlays/DraggablePane.svelte +0 -487
- package/dist/src/lib/overlays/InfoPaneCards.svelte +0 -149
- package/dist/src/lib/overlays/index.ts +0 -3
- package/dist/src/lib/periodic-table/PeriodicTable.svelte +0 -469
- package/dist/src/lib/periodic-table/PeriodicTableControls.svelte +0 -557
- package/dist/src/lib/periodic-table/PropertySelect.svelte +0 -37
- package/dist/src/lib/periodic-table/index.ts +0 -12
- package/dist/src/lib/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +0 -1086
- package/dist/src/lib/phase-diagram/PhaseDiagramControls.svelte +0 -444
- package/dist/src/lib/phase-diagram/PhaseDiagramEditorPane.svelte +0 -126
- package/dist/src/lib/phase-diagram/PhaseDiagramExportPane.svelte +0 -184
- package/dist/src/lib/phase-diagram/PhaseDiagramTooltip.svelte +0 -391
- package/dist/src/lib/phase-diagram/TdbInfoPanel.svelte +0 -203
- package/dist/src/lib/phase-diagram/build-diagram.ts +0 -186
- package/dist/src/lib/phase-diagram/colors.ts +0 -58
- package/dist/src/lib/phase-diagram/diagram-input.ts +0 -40
- package/dist/src/lib/phase-diagram/index.ts +0 -13
- package/dist/src/lib/phase-diagram/parse.ts +0 -348
- package/dist/src/lib/phase-diagram/svg-to-diagram.ts +0 -1023
- package/dist/src/lib/phase-diagram/types.ts +0 -144
- package/dist/src/lib/phase-diagram/utils.ts +0 -775
- package/dist/src/lib/plot/AxisLabel.svelte +0 -51
- package/dist/src/lib/plot/BarPlot.svelte +0 -2113
- package/dist/src/lib/plot/BarPlotControls.svelte +0 -66
- package/dist/src/lib/plot/BinnedScatterPlot.svelte +0 -1114
- package/dist/src/lib/plot/ColorBar.svelte +0 -721
- package/dist/src/lib/plot/ColorScaleSelect.svelte +0 -54
- package/dist/src/lib/plot/ElementScatter.svelte +0 -63
- package/dist/src/lib/plot/Histogram.svelte +0 -1558
- package/dist/src/lib/plot/HistogramControls.svelte +0 -212
- package/dist/src/lib/plot/InteractiveAxisLabel.svelte +0 -96
- package/dist/src/lib/plot/Line.svelte +0 -84
- package/dist/src/lib/plot/PlotAxis.svelte +0 -169
- package/dist/src/lib/plot/PlotControls.svelte +0 -537
- package/dist/src/lib/plot/PlotLegend.svelte +0 -569
- package/dist/src/lib/plot/PlotTooltip.svelte +0 -67
- package/dist/src/lib/plot/PortalSelect.svelte +0 -253
- package/dist/src/lib/plot/ReferenceLine3D.svelte +0 -156
- package/dist/src/lib/plot/ReferencePlane.svelte +0 -175
- package/dist/src/lib/plot/ScatterPlot.svelte +0 -2778
- package/dist/src/lib/plot/ScatterPlot3D.svelte +0 -529
- package/dist/src/lib/plot/ScatterPlot3DControls.svelte +0 -437
- package/dist/src/lib/plot/ScatterPlot3DScene.svelte +0 -912
- package/dist/src/lib/plot/ScatterPlotControls.svelte +0 -306
- package/dist/src/lib/plot/ScatterPoint.svelte +0 -182
- package/dist/src/lib/plot/SpacegroupBarPlot.svelte +0 -293
- package/dist/src/lib/plot/Surface3D.svelte +0 -197
- package/dist/src/lib/plot/ZeroLines.svelte +0 -97
- package/dist/src/lib/plot/ZoomRect.svelte +0 -23
- package/dist/src/lib/plot/adaptive-density.ts +0 -316
- package/dist/src/lib/plot/auto-place.ts +0 -184
- package/dist/src/lib/plot/axis-utils.ts +0 -122
- package/dist/src/lib/plot/binned-scatter-types.ts +0 -83
- package/dist/src/lib/plot/data-cleaning.ts +0 -1069
- package/dist/src/lib/plot/data-transform.ts +0 -69
- package/dist/src/lib/plot/defaults.ts +0 -9
- package/dist/src/lib/plot/fill-utils.ts +0 -494
- package/dist/src/lib/plot/hover-lock.svelte.ts +0 -60
- package/dist/src/lib/plot/index.ts +0 -53
- package/dist/src/lib/plot/interactions.ts +0 -119
- package/dist/src/lib/plot/layout.ts +0 -425
- package/dist/src/lib/plot/reference-line.ts +0 -426
- package/dist/src/lib/plot/scales.ts +0 -654
- package/dist/src/lib/plot/svg.ts +0 -23
- package/dist/src/lib/plot/types.ts +0 -1144
- package/dist/src/lib/plot/utils/label-placement.ts +0 -541
- package/dist/src/lib/plot/utils/series-visibility.ts +0 -140
- package/dist/src/lib/plot/utils.ts +0 -11
- package/dist/src/lib/rdf/RdfPlot.svelte +0 -247
- package/dist/src/lib/rdf/calc-rdf.ts +0 -167
- package/dist/src/lib/rdf/index.ts +0 -27
- package/dist/src/lib/sanitize.ts +0 -126
- package/dist/src/lib/settings.ts +0 -1479
- package/dist/src/lib/spectral/Bands.svelte +0 -1040
- package/dist/src/lib/spectral/BandsAndDos.svelte +0 -134
- package/dist/src/lib/spectral/BrillouinBandsDos.svelte +0 -252
- package/dist/src/lib/spectral/Dos.svelte +0 -697
- package/dist/src/lib/spectral/helpers.ts +0 -1381
- package/dist/src/lib/spectral/index.ts +0 -8
- package/dist/src/lib/spectral/types.ts +0 -112
- package/dist/src/lib/state.svelte.ts +0 -64
- package/dist/src/lib/structure/Arrow.svelte +0 -72
- package/dist/src/lib/structure/AtomLegend.svelte +0 -815
- package/dist/src/lib/structure/Bond.svelte +0 -140
- package/dist/src/lib/structure/CanvasTooltip.svelte +0 -33
- package/dist/src/lib/structure/CellSelect.svelte +0 -349
- package/dist/src/lib/structure/Cylinder.svelte +0 -45
- package/dist/src/lib/structure/Lattice.svelte +0 -196
- package/dist/src/lib/structure/Structure.svelte +0 -2248
- package/dist/src/lib/structure/StructureControls.svelte +0 -1273
- package/dist/src/lib/structure/StructureExportPane.svelte +0 -252
- package/dist/src/lib/structure/StructureInfoPane.svelte +0 -737
- package/dist/src/lib/structure/StructureScene.svelte +0 -2255
- package/dist/src/lib/structure/atom-properties.ts +0 -316
- package/dist/src/lib/structure/bond-order-perception.ts +0 -447
- package/dist/src/lib/structure/bonding.ts +0 -944
- package/dist/src/lib/structure/export.ts +0 -861
- package/dist/src/lib/structure/index.ts +0 -291
- package/dist/src/lib/structure/label-placement.ts +0 -130
- package/dist/src/lib/structure/measure.ts +0 -45
- package/dist/src/lib/structure/parse.ts +0 -1705
- package/dist/src/lib/structure/partial-occupancy.ts +0 -183
- package/dist/src/lib/structure/pbc.ts +0 -164
- package/dist/src/lib/structure/supercell.ts +0 -226
- package/dist/src/lib/structure/validation.ts +0 -11
- package/dist/src/lib/symmetry/SymmetryStats.svelte +0 -226
- package/dist/src/lib/symmetry/WyckoffTable.svelte +0 -120
- package/dist/src/lib/symmetry/cell-transform.ts +0 -118
- package/dist/src/lib/symmetry/index.ts +0 -348
- package/dist/src/lib/symmetry/spacegroups.ts +0 -404
- package/dist/src/lib/table/HeatmapTable.svelte +0 -1833
- package/dist/src/lib/table/ToggleMenu.svelte +0 -385
- package/dist/src/lib/table/index.ts +0 -139
- package/dist/src/lib/theme/ThemeControl.svelte +0 -53
- package/dist/src/lib/theme/index.ts +0 -107
- package/dist/src/lib/time.ts +0 -71
- package/dist/src/lib/tooltip/TooltipContent.svelte +0 -58
- package/dist/src/lib/tooltip/index.ts +0 -2
- package/dist/src/lib/tooltip/types.ts +0 -13
- package/dist/src/lib/trajectory/Trajectory.svelte +0 -1545
- package/dist/src/lib/trajectory/TrajectoryError.svelte +0 -128
- package/dist/src/lib/trajectory/TrajectoryExportPane.svelte +0 -357
- package/dist/src/lib/trajectory/TrajectoryInfoPane.svelte +0 -313
- package/dist/src/lib/trajectory/constants.ts +0 -7
- package/dist/src/lib/trajectory/extract.ts +0 -196
- package/dist/src/lib/trajectory/format-detect.ts +0 -96
- package/dist/src/lib/trajectory/frame-reader.ts +0 -456
- package/dist/src/lib/trajectory/helpers.ts +0 -217
- package/dist/src/lib/trajectory/index.ts +0 -218
- package/dist/src/lib/trajectory/parse/ase.ts +0 -109
- package/dist/src/lib/trajectory/parse/hdf5.ts +0 -173
- package/dist/src/lib/trajectory/parse/index.ts +0 -411
- package/dist/src/lib/trajectory/parse/lammps.ts +0 -215
- package/dist/src/lib/trajectory/parse/vasp.ts +0 -102
- package/dist/src/lib/trajectory/parse/xyz.ts +0 -143
- package/dist/src/lib/trajectory/plotting.ts +0 -599
- package/dist/src/lib/trajectory/types.ts +0 -13
- package/dist/src/lib/utils.ts +0 -56
- package/dist/src/lib/xrd/XrdPlot.svelte +0 -615
- package/dist/src/lib/xrd/broadening.ts +0 -130
- package/dist/src/lib/xrd/calc-xrd.ts +0 -397
- package/dist/src/lib/xrd/index.ts +0 -38
- package/dist/src/lib/xrd/parse.ts +0 -858
- package/dist/webview.js +0 -29421
- package/icon.png +0 -0
- package/matterviz-0.3.2.vsix +0 -0
- package/matterviz-0.3.4.vsix +0 -0
- package/matterviz-0.3.5.vsix +0 -0
- package/scripts/sync-config.ts +0 -101
- package/src/declarations.d.ts +0 -2
- package/src/extension.ts +0 -972
- package/src/node-io.ts +0 -65
- package/src/types.ts +0 -17
- package/src/webview/JsonBrowser.svelte +0 -1079
- package/src/webview/PlotPanel.svelte +0 -346
- package/src/webview/detect.ts +0 -444
- package/src/webview/main.ts +0 -764
- package/src/webview/plot-utils.ts +0 -250
- package/test-fixtures/all-viz-types.json.gz +0 -0
- package/test-fixtures/plot-demo-data.json.gz +0 -0
- package/tests/detect.test.ts +0 -604
- package/tests/extension.test.ts +0 -2041
- package/tests/node-io.test.ts +0 -39
- package/tests/plot-utils.test.ts +0 -302
- package/tests/vite-plugin-json-gz.test.ts +0 -114
- package/tests/vscode-mock.ts +0 -18
- package/tests/webview.test.ts +0 -231
- package/tsconfig.json +0 -20
- package/vite-plugin-json-gz.ts +0 -29
- package/vite.config.ts +0 -34
- package/vite.extension.config.ts +0 -34
- /package/dist/{src/lib/EmptyState.svelte → EmptyState.svelte} +0 -0
- /package/dist/{src/lib/Icon.svelte → Icon.svelte} +0 -0
- /package/dist/{src/lib/app.css → app.css} +0 -0
- /package/dist/{src/lib/chempot-diagram → chempot-diagram}/ChemPotScene3D.svelte +0 -0
- /package/dist/{src/lib/colors → colors}/alloy-colors.json +0 -0
- /package/dist/{src/lib/colors → colors}/dark-mode-colors.json +0 -0
- /package/dist/{src/lib/colors → colors}/jmol-colors.json +0 -0
- /package/dist/{src/lib/colors → colors}/muted-colors.json +0 -0
- /package/dist/{src/lib/colors → colors}/pastel-colors.json +0 -0
- /package/dist/{src/lib/colors → colors}/vesta-colors.json +0 -0
- /package/dist/{src/lib/convex-hull → convex-hull}/TemperatureSlider.svelte +0 -0
- /package/dist/{src/lib/element → element}/BohrAtom.svelte +0 -0
- /package/dist/{src/lib/element → element}/Nucleus.svelte +0 -0
- /package/dist/{src/lib/element → element}/data.json +0 -0
- /package/dist/{src/lib/element → element}/data.json.gz +0 -0
- /package/dist/{src/lib/element → element}/data.json.gz.d.ts +0 -0
- /package/dist/{src/lib/element → element}/data.schema.json +0 -0
- /package/dist/{src/lib/element-image-urls.json → element-image-urls.json} +0 -0
- /package/dist/{src/lib/feedback → feedback}/Spinner.svelte +0 -0
- /package/dist/{src/lib/feedback → feedback}/StatusMessage.svelte +0 -0
- /package/dist/{src/lib/layout → layout}/json-tree/JsonValue.svelte +0 -0
- /package/dist/{src/lib/periodic-table → periodic-table}/TableInset.svelte +0 -0
- /package/dist/{src/lib/plot → plot}/FillArea.svelte +0 -0
- /package/dist/{src/lib/plot → plot}/ReferenceLine.svelte +0 -0
- /package/dist/{src/lib/theme → theme}/themes.mjs +0 -0
- /package/dist/{src/lib/xrd → xrd}/atomic_scattering_params.json +0 -0
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
// Core computational logic for chemical potential diagrams.
|
|
2
|
+
// Ports pymatgen's ChemicalPotentialDiagram algorithm to TypeScript.
|
|
3
|
+
// Reference: pymatgen/analysis/chempot_diagram.py
|
|
4
|
+
import { convex_hull_2d, EPS, polygon_centroid, solve_linear_system } from '../math';
|
|
5
|
+
import { CHEMPOT_DEFAULTS } from './types';
|
|
6
|
+
// Inlined from $lib/composition/parse to keep this module worker-safe
|
|
7
|
+
// ($lib/composition barrel transitively imports binary .json.gz data
|
|
8
|
+
// that the worker bundler can't handle).
|
|
9
|
+
const count_atoms_in_composition = (composition) => Object.values(composition).reduce((sum, count) => sum + (count ?? 0), 0);
|
|
10
|
+
const gcd = (num_a, num_b) => num_b === 0 ? num_a : gcd(num_b, num_a % num_b);
|
|
11
|
+
const get_reduced_formula = (composition) => {
|
|
12
|
+
const amounts = Object.values(composition).filter((amt) => amt > 0);
|
|
13
|
+
if (amounts.length === 0)
|
|
14
|
+
return {};
|
|
15
|
+
let scale = 1;
|
|
16
|
+
if (!amounts.every((amt) => Number.isInteger(amt))) {
|
|
17
|
+
scale = 0;
|
|
18
|
+
for (let mult = 1; mult <= 100; mult++) {
|
|
19
|
+
if (amounts.every((amt) => Math.abs(amt * mult - Math.round(amt * mult)) < 0.03)) {
|
|
20
|
+
scale = mult;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (scale === 0)
|
|
25
|
+
return composition;
|
|
26
|
+
}
|
|
27
|
+
const int_amounts = amounts.map((amt) => Math.round(amt * scale));
|
|
28
|
+
const divisor = int_amounts.reduce((acc, amt) => gcd(acc, amt));
|
|
29
|
+
if (scale === 1 && divisor <= 1)
|
|
30
|
+
return composition;
|
|
31
|
+
const factor = scale / divisor;
|
|
32
|
+
return Object.fromEntries(Object.entries(composition)
|
|
33
|
+
.filter(([, amt]) => amt > 0)
|
|
34
|
+
.map(([elem, amt]) => [elem, Math.round(amt * factor)]));
|
|
35
|
+
};
|
|
36
|
+
// === Entry Helpers ===
|
|
37
|
+
// Get energy per atom for a PhaseData entry
|
|
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)}`);
|
|
44
|
+
}
|
|
45
|
+
return entry.energy / atoms;
|
|
46
|
+
}
|
|
47
|
+
// Cache for reduced formula strings -- avoids recomputing get_reduced_formula
|
|
48
|
+
// in hot loops. Key is object identity (WeakMap), value is the formula string.
|
|
49
|
+
const formula_cache = new WeakMap();
|
|
50
|
+
// Get a stable reduced formula string from composition dict (cached)
|
|
51
|
+
export function formula_key_from_composition(composition) {
|
|
52
|
+
const cached = formula_cache.get(composition);
|
|
53
|
+
if (cached)
|
|
54
|
+
return cached;
|
|
55
|
+
const reduced = get_reduced_formula(composition);
|
|
56
|
+
const key = Object.entries(reduced)
|
|
57
|
+
.filter(([, amt]) => amt > 0)
|
|
58
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
59
|
+
.map(([el, amt]) => (amt === 1 ? el : `${el}${amt}`))
|
|
60
|
+
.join(``);
|
|
61
|
+
formula_cache.set(composition, key);
|
|
62
|
+
return key;
|
|
63
|
+
}
|
|
64
|
+
// === Core Algorithm ===
|
|
65
|
+
// Group entries by reduced formula, keep only the minimum-energy entry per composition.
|
|
66
|
+
// Also extract elemental reference entries.
|
|
67
|
+
export function get_min_entries_and_el_refs(entries) {
|
|
68
|
+
const by_formula = new Map();
|
|
69
|
+
for (const entry of entries) {
|
|
70
|
+
const key = formula_key_from_composition(entry.composition);
|
|
71
|
+
const epa = get_energy_per_atom(entry);
|
|
72
|
+
const existing = by_formula.get(key);
|
|
73
|
+
if (!existing || epa < existing.epa) {
|
|
74
|
+
by_formula.set(key, { entry, epa });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const min_entries = Array.from(by_formula.values(), ({ entry }) => entry);
|
|
78
|
+
const el_refs = {};
|
|
79
|
+
for (const entry of min_entries) {
|
|
80
|
+
const positive = Object.entries(entry.composition).filter(([, amt]) => amt > 0);
|
|
81
|
+
if (positive.length === 1)
|
|
82
|
+
el_refs[positive[0][0]] = entry;
|
|
83
|
+
}
|
|
84
|
+
return { min_entries, el_refs };
|
|
85
|
+
}
|
|
86
|
+
// Compute formation energy per atom against elemental references.
|
|
87
|
+
export function compute_form_energy_per_atom(entry, el_refs) {
|
|
88
|
+
const atom_count = count_atoms_in_composition(entry.composition);
|
|
89
|
+
const energy_per_atom = get_energy_per_atom(entry);
|
|
90
|
+
let ref_energy = 0;
|
|
91
|
+
for (const [element, amount] of Object.entries(entry.composition)) {
|
|
92
|
+
if (amount <= 0)
|
|
93
|
+
continue;
|
|
94
|
+
const fraction = amount / atom_count;
|
|
95
|
+
const ref_entry = el_refs[element];
|
|
96
|
+
if (ref_entry)
|
|
97
|
+
ref_energy += fraction * get_energy_per_atom(ref_entry);
|
|
98
|
+
}
|
|
99
|
+
return energy_per_atom - ref_energy;
|
|
100
|
+
}
|
|
101
|
+
// Find minimum formation energy per atom across entries of one formula.
|
|
102
|
+
export function best_form_energy_for_formula(entries, formula, el_refs) {
|
|
103
|
+
let best_value;
|
|
104
|
+
for (const entry of entries) {
|
|
105
|
+
if (formula_key_from_composition(entry.composition) !== formula)
|
|
106
|
+
continue;
|
|
107
|
+
const e_form = entry.e_form_per_atom ?? compute_form_energy_per_atom(entry, el_refs);
|
|
108
|
+
if (best_value === undefined || e_form < best_value)
|
|
109
|
+
best_value = e_form;
|
|
110
|
+
}
|
|
111
|
+
return best_value;
|
|
112
|
+
}
|
|
113
|
+
// Renormalize entry energies to be relative to elemental references (formal chemical potentials).
|
|
114
|
+
// For each entry, subtracts sum(x_i * E_ref_i) from its energy per atom.
|
|
115
|
+
export function renormalize_entries(entries, el_refs, elements) {
|
|
116
|
+
return entries.map((entry) => {
|
|
117
|
+
const atoms = count_atoms_in_composition(entry.composition);
|
|
118
|
+
let renorm_energy = 0;
|
|
119
|
+
for (const el of elements) {
|
|
120
|
+
const frac = atoms > 0 ? (entry.composition[el] ?? 0) / atoms : 0;
|
|
121
|
+
const ref = el_refs[el];
|
|
122
|
+
if (ref)
|
|
123
|
+
renorm_energy += frac * get_energy_per_atom(ref);
|
|
124
|
+
}
|
|
125
|
+
const new_energy_per_atom = get_energy_per_atom(entry) - renorm_energy;
|
|
126
|
+
return {
|
|
127
|
+
...entry,
|
|
128
|
+
energy: new_energy_per_atom * atoms,
|
|
129
|
+
energy_per_atom: new_energy_per_atom,
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
// Build hyperplane representation for minimum entries.
|
|
134
|
+
// Each row is [x_1, ..., x_n, -E_per_atom].
|
|
135
|
+
// Filters to entries with negative formation energy plus all elemental refs.
|
|
136
|
+
export function build_hyperplanes(min_entries, el_refs, elements) {
|
|
137
|
+
const n_elems = elements.length;
|
|
138
|
+
const element_ref_energies = elements.map((element) => {
|
|
139
|
+
const ref_entry = el_refs[element];
|
|
140
|
+
return ref_entry ? get_energy_per_atom(ref_entry) : 0;
|
|
141
|
+
});
|
|
142
|
+
const always_include = new Set(Object.values(el_refs));
|
|
143
|
+
const tol = 1e-6; // PhaseDiagram.formation_energy_tol
|
|
144
|
+
const use_precomputed_hull = min_entries.every((entry) => typeof entry.is_stable === `boolean` || typeof entry.e_above_hull === `number`);
|
|
145
|
+
const hyperplanes = [];
|
|
146
|
+
const hyperplane_entries = [];
|
|
147
|
+
for (const entry of min_entries) {
|
|
148
|
+
const atom_count = count_atoms_in_composition(entry.composition);
|
|
149
|
+
const composition = entry.composition;
|
|
150
|
+
const energy_per_atom = get_energy_per_atom(entry);
|
|
151
|
+
const row = Array(n_elems + 1).fill(0);
|
|
152
|
+
let ref_energy = 0;
|
|
153
|
+
for (let elem_idx = 0; elem_idx < n_elems; elem_idx++) {
|
|
154
|
+
const element = elements[elem_idx];
|
|
155
|
+
const fraction = atom_count > 0 ? (composition[element] ?? 0) / atom_count : 0;
|
|
156
|
+
row[elem_idx] = fraction;
|
|
157
|
+
ref_energy += fraction * element_ref_energies[elem_idx];
|
|
158
|
+
}
|
|
159
|
+
const form_energy = energy_per_atom - ref_energy;
|
|
160
|
+
const on_precomputed_hull = use_precomputed_hull &&
|
|
161
|
+
!entry.exclude_from_hull &&
|
|
162
|
+
(entry.is_stable === true ||
|
|
163
|
+
(typeof entry.e_above_hull === `number` && entry.e_above_hull <= tol));
|
|
164
|
+
const include_entry = use_precomputed_hull
|
|
165
|
+
? on_precomputed_hull || always_include.has(entry)
|
|
166
|
+
: form_energy < -tol || always_include.has(entry);
|
|
167
|
+
if (include_entry) {
|
|
168
|
+
row[n_elems] = -energy_per_atom;
|
|
169
|
+
hyperplanes.push(row);
|
|
170
|
+
hyperplane_entries.push(entry);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return { hyperplanes, hyperplane_entries };
|
|
174
|
+
}
|
|
175
|
+
// Build border hyperplanes from per-element limits.
|
|
176
|
+
// For each axis with limits [lo, hi], creates two halfspace rows.
|
|
177
|
+
export function build_border_hyperplanes(lims) {
|
|
178
|
+
const dim = lims.length;
|
|
179
|
+
const borders = [];
|
|
180
|
+
for (let idx = 0; idx < dim; idx++) {
|
|
181
|
+
// Lower bound: -mu_i + lo <= 0 → [-1, 0, ..., lo]
|
|
182
|
+
const lower = Array(dim + 1).fill(0);
|
|
183
|
+
lower[idx] = -1;
|
|
184
|
+
lower[dim] = lims[idx][0];
|
|
185
|
+
borders.push(lower);
|
|
186
|
+
// Upper bound: mu_i - hi <= 0 → [1, 0, ..., -hi]
|
|
187
|
+
const upper = Array(dim + 1).fill(0);
|
|
188
|
+
upper[idx] = 1;
|
|
189
|
+
upper[dim] = -lims[idx][1];
|
|
190
|
+
borders.push(upper);
|
|
191
|
+
}
|
|
192
|
+
return borders;
|
|
193
|
+
}
|
|
194
|
+
// Inline 2x2 linear solve (Cramer's rule). Returns false if singular.
|
|
195
|
+
// Writes solution into out[0], out[1].
|
|
196
|
+
function solve_2x2(a00, a01, b0, a10, a11, b1, out) {
|
|
197
|
+
const det = a00 * a11 - a01 * a10;
|
|
198
|
+
if (Math.abs(det) < EPS)
|
|
199
|
+
return false;
|
|
200
|
+
out[0] = (b0 * a11 - b1 * a01) / det;
|
|
201
|
+
out[1] = (a00 * b1 - a10 * b0) / det;
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
// Inline 3x3 linear solve via Cramer's rule. Returns false if singular.
|
|
205
|
+
// Takes three halfspace rows directly to avoid array allocation in the hot loop.
|
|
206
|
+
function solve_3x3(a, b, c, offsets, out) {
|
|
207
|
+
const det = a[0] * (b[1] * c[2] - b[2] * c[1]) -
|
|
208
|
+
a[1] * (b[0] * c[2] - b[2] * c[0]) +
|
|
209
|
+
a[2] * (b[0] * c[1] - b[1] * c[0]);
|
|
210
|
+
if (Math.abs(det) < EPS)
|
|
211
|
+
return false;
|
|
212
|
+
const inv = 1 / det;
|
|
213
|
+
out[0] =
|
|
214
|
+
(offsets[0] * (b[1] * c[2] - b[2] * c[1]) -
|
|
215
|
+
a[1] * (offsets[1] * c[2] - b[2] * offsets[2]) +
|
|
216
|
+
a[2] * (offsets[1] * c[1] - b[1] * offsets[2])) *
|
|
217
|
+
inv;
|
|
218
|
+
out[1] =
|
|
219
|
+
(a[0] * (offsets[1] * c[2] - b[2] * offsets[2]) -
|
|
220
|
+
offsets[0] * (b[0] * c[2] - b[2] * c[0]) +
|
|
221
|
+
a[2] * (b[0] * offsets[2] - offsets[1] * c[0])) *
|
|
222
|
+
inv;
|
|
223
|
+
out[2] =
|
|
224
|
+
(a[0] * (b[1] * offsets[2] - offsets[1] * c[1]) -
|
|
225
|
+
a[1] * (b[0] * offsets[2] - offsets[1] * c[0]) +
|
|
226
|
+
offsets[0] * (b[0] * c[1] - b[1] * c[0])) *
|
|
227
|
+
inv;
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
// Compute chemical potential domains via vertex enumeration.
|
|
231
|
+
// This replaces scipy's HalfspaceIntersection.
|
|
232
|
+
// For each combination of dim halfspaces, solves the linear system to find a
|
|
233
|
+
// candidate vertex, checks feasibility against all halfspaces, then assigns
|
|
234
|
+
// vertices to the phases whose hyperplanes are active at that vertex.
|
|
235
|
+
export function compute_domains(hyperplanes, border_hyperplanes, hyperplane_entries, dim) {
|
|
236
|
+
const n_entries = hyperplanes.length;
|
|
237
|
+
const all_hs = [...hyperplanes, ...border_hyperplanes];
|
|
238
|
+
const n_total = all_hs.length;
|
|
239
|
+
const tol = 1e-6;
|
|
240
|
+
// Pre-compute formula keys for entry hyperplanes (avoid repeated work in hot loop)
|
|
241
|
+
const entry_formulas = hyperplane_entries.map((entry) => formula_key_from_composition(entry.composition));
|
|
242
|
+
const domains = {};
|
|
243
|
+
for (const formula of entry_formulas) {
|
|
244
|
+
if (!domains[formula])
|
|
245
|
+
domains[formula] = [];
|
|
246
|
+
}
|
|
247
|
+
// Pre-allocate reusable buffers to avoid GC pressure in the combo loop
|
|
248
|
+
const mu = Array(dim).fill(0);
|
|
249
|
+
const offsets = Array(dim).fill(0);
|
|
250
|
+
// For dim <= 3, use inline solvers; for larger dims, build A on the fly
|
|
251
|
+
const A_rows = dim > 3 ? Array.from({ length: dim }, () => Array(dim).fill(0)) : [];
|
|
252
|
+
// Generate all combinations of dim indices from n_total halfspaces
|
|
253
|
+
const combo = Array(dim).fill(0);
|
|
254
|
+
for (let idx = 0; idx < dim; idx++)
|
|
255
|
+
combo[idx] = idx;
|
|
256
|
+
function advance_combo() {
|
|
257
|
+
let pos = dim - 1;
|
|
258
|
+
while (pos >= 0 && combo[pos] >= n_total - dim + pos)
|
|
259
|
+
pos--;
|
|
260
|
+
if (pos < 0)
|
|
261
|
+
return false;
|
|
262
|
+
combo[pos]++;
|
|
263
|
+
for (let idx = pos + 1; idx < dim; idx++)
|
|
264
|
+
combo[idx] = combo[idx - 1] + 1;
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
while (true) {
|
|
268
|
+
// Combinations containing only border halfspaces cannot be assigned to any
|
|
269
|
+
// entry domain, so skip solving them entirely.
|
|
270
|
+
let has_entry_hyperplane = false;
|
|
271
|
+
if (dim === 2) {
|
|
272
|
+
has_entry_hyperplane = combo[0] < n_entries || combo[1] < n_entries;
|
|
273
|
+
}
|
|
274
|
+
else if (dim === 3) {
|
|
275
|
+
has_entry_hyperplane =
|
|
276
|
+
combo[0] < n_entries || combo[1] < n_entries || combo[2] < n_entries;
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
for (let row = 0; row < dim; row++) {
|
|
280
|
+
if (combo[row] < n_entries) {
|
|
281
|
+
has_entry_hyperplane = true;
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (!has_entry_hyperplane) {
|
|
287
|
+
if (!advance_combo())
|
|
288
|
+
break;
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
// Compute offsets (negated last column of selected halfspaces)
|
|
292
|
+
for (let row = 0; row < dim; row++)
|
|
293
|
+
offsets[row] = -all_hs[combo[row]][dim];
|
|
294
|
+
// Solve for vertex using dimension-specialized solvers
|
|
295
|
+
let solved = false;
|
|
296
|
+
if (dim === 2) {
|
|
297
|
+
const h0 = all_hs[combo[0]];
|
|
298
|
+
const h1 = all_hs[combo[1]];
|
|
299
|
+
solved = solve_2x2(h0[0], h0[1], offsets[0], h1[0], h1[1], offsets[1], mu);
|
|
300
|
+
}
|
|
301
|
+
else if (dim === 3) {
|
|
302
|
+
solved = solve_3x3(all_hs[combo[0]], all_hs[combo[1]], all_hs[combo[2]], offsets, mu);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
// General case: build A matrix and use LU solver
|
|
306
|
+
for (let row = 0; row < dim; row++) {
|
|
307
|
+
const hs = all_hs[combo[row]];
|
|
308
|
+
for (let col = 0; col < dim; col++)
|
|
309
|
+
A_rows[row][col] = hs[col];
|
|
310
|
+
}
|
|
311
|
+
const result = solve_linear_system(A_rows, offsets);
|
|
312
|
+
if (result) {
|
|
313
|
+
for (let idx = 0; idx < dim; idx++)
|
|
314
|
+
mu[idx] = result[idx];
|
|
315
|
+
solved = true;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (solved) {
|
|
319
|
+
// Feasibility check: all halfspaces must be satisfied (a·mu + b <= tol)
|
|
320
|
+
const selected_hs_idx_0 = dim > 0 ? combo[0] : -1;
|
|
321
|
+
const selected_hs_idx_1 = dim > 1 ? combo[1] : -1;
|
|
322
|
+
const selected_hs_idx_2 = dim > 2 ? combo[2] : -1;
|
|
323
|
+
for (let idx = 0; idx < n_total; idx++) {
|
|
324
|
+
if (dim <= 3) {
|
|
325
|
+
if (idx === selected_hs_idx_0 ||
|
|
326
|
+
idx === selected_hs_idx_1 ||
|
|
327
|
+
idx === selected_hs_idx_2)
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
let is_active_halfspace = false;
|
|
332
|
+
for (let combo_idx = 0; combo_idx < dim; combo_idx++) {
|
|
333
|
+
if (combo[combo_idx] === idx) {
|
|
334
|
+
is_active_halfspace = true;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (is_active_halfspace)
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
const hs = all_hs[idx];
|
|
342
|
+
let val = hs[dim];
|
|
343
|
+
if (dim === 2) {
|
|
344
|
+
val += hs[0] * mu[0] + hs[1] * mu[1];
|
|
345
|
+
}
|
|
346
|
+
else if (dim === 3) {
|
|
347
|
+
val += hs[0] * mu[0] + hs[1] * mu[1] + hs[2] * mu[2];
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
for (let jdx = 0; jdx < dim; jdx++)
|
|
351
|
+
val += hs[jdx] * mu[jdx];
|
|
352
|
+
}
|
|
353
|
+
if (val > tol) {
|
|
354
|
+
solved = false;
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (solved) {
|
|
359
|
+
// Assign vertex to entries whose hyperplanes are active
|
|
360
|
+
const vertex = dim === 2 ? [mu[0], mu[1]] : dim === 3 ? [mu[0], mu[1], mu[2]] : [...mu];
|
|
361
|
+
for (let idx = 0; idx < dim; idx++) {
|
|
362
|
+
const hs_idx = combo[idx];
|
|
363
|
+
if (hs_idx < n_entries) {
|
|
364
|
+
domains[entry_formulas[hs_idx]].push([...vertex]);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
// Advance to next combination (lexicographic order)
|
|
370
|
+
if (!advance_combo())
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
return Object.fromEntries(Object.entries(domains).filter(([, domain]) => domain.length > 0));
|
|
374
|
+
}
|
|
375
|
+
// Apply element padding: replace coordinates close to default_min_limit with
|
|
376
|
+
// actual_min - padding for cleaner visual bounds. Single pass over all points.
|
|
377
|
+
export function apply_element_padding(domains, elem_indices, padding, default_min_limit) {
|
|
378
|
+
const replace_threshold = Math.max(Math.abs(padding), EPS);
|
|
379
|
+
// Single-pass: track min per axis, skipping default_min_limit values
|
|
380
|
+
const mins = elem_indices.map(() => Infinity);
|
|
381
|
+
for (const pts of Object.values(domains)) {
|
|
382
|
+
for (const pt of pts) {
|
|
383
|
+
for (let idx = 0; idx < elem_indices.length; idx++) {
|
|
384
|
+
const val = pt[elem_indices[idx]];
|
|
385
|
+
if (Math.abs(val - default_min_limit) > replace_threshold && val < mins[idx]) {
|
|
386
|
+
mins[idx] = val;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return mins.map((min_val) => (Number.isFinite(min_val) ? min_val : default_min_limit) - padding);
|
|
392
|
+
}
|
|
393
|
+
// Replace default_min_limit coordinates with padded limits for display
|
|
394
|
+
export function pad_domain_points(pts, elem_indices, new_lims, default_min_limit, padding) {
|
|
395
|
+
const replace_threshold = Math.max(Math.abs(padding), EPS);
|
|
396
|
+
return pts.map((pt) => {
|
|
397
|
+
const padded = [...pt];
|
|
398
|
+
for (let idx = 0; idx < elem_indices.length; idx++) {
|
|
399
|
+
const col = elem_indices[idx];
|
|
400
|
+
if (Math.abs(padded[col] - default_min_limit) < replace_threshold) {
|
|
401
|
+
padded[col] = new_lims[idx];
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return padded;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
// Build per-axis min/max ranges for a set of points
|
|
408
|
+
export function build_axis_ranges(points, elements) {
|
|
409
|
+
return elements.map((element, axis_idx) => {
|
|
410
|
+
let [min_val, max_val] = [Infinity, -Infinity];
|
|
411
|
+
for (const point of points) {
|
|
412
|
+
const val = point[axis_idx];
|
|
413
|
+
if (val < min_val)
|
|
414
|
+
min_val = val;
|
|
415
|
+
if (val > max_val)
|
|
416
|
+
max_val = val;
|
|
417
|
+
}
|
|
418
|
+
return { element: element ?? `\u03BC${axis_idx}`, min_val, max_val };
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
// === Label Placement Helpers ===
|
|
422
|
+
// Simple PCA: center data, compute covariance, eigendecompose, project to top-k.
|
|
423
|
+
// Used in 3D for finding domain polygon orientation for label placement.
|
|
424
|
+
export function simple_pca(data, k = 2) {
|
|
425
|
+
const n_rows = data.length;
|
|
426
|
+
const n_cols = data[0]?.length ?? 0;
|
|
427
|
+
if (n_rows === 0 || n_cols === 0) {
|
|
428
|
+
return { scores: [], eigenvectors: [] };
|
|
429
|
+
}
|
|
430
|
+
// Center the data
|
|
431
|
+
const means = Array(n_cols).fill(0);
|
|
432
|
+
for (const row of data) {
|
|
433
|
+
for (let col = 0; col < n_cols; col++)
|
|
434
|
+
means[col] += row[col];
|
|
435
|
+
}
|
|
436
|
+
for (let col = 0; col < n_cols; col++)
|
|
437
|
+
means[col] /= n_rows;
|
|
438
|
+
const centered = data.map((row) => row.map((val, col) => val - means[col]));
|
|
439
|
+
// Covariance matrix
|
|
440
|
+
const cov = Array.from({ length: n_cols }, () => Array(n_cols).fill(0));
|
|
441
|
+
for (const row of centered) {
|
|
442
|
+
for (let idx = 0; idx < n_cols; idx++) {
|
|
443
|
+
for (let jdx = idx; jdx < n_cols; jdx++) {
|
|
444
|
+
cov[idx][jdx] += row[idx] * row[jdx];
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
for (let idx = 0; idx < n_cols; idx++) {
|
|
449
|
+
cov[idx][idx] /= n_rows;
|
|
450
|
+
for (let jdx = idx + 1; jdx < n_cols; jdx++) {
|
|
451
|
+
cov[idx][jdx] /= n_rows;
|
|
452
|
+
cov[jdx][idx] = cov[idx][jdx];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// Power iteration for top-k eigenvectors (sufficient for k=2 on small matrices)
|
|
456
|
+
const eigenvectors = [];
|
|
457
|
+
const work_cov = cov.map((row) => [...row]);
|
|
458
|
+
for (let comp = 0; comp < k; comp++) {
|
|
459
|
+
let vec = Array(n_cols).fill(0);
|
|
460
|
+
vec[comp % n_cols] = 1; // initial guess
|
|
461
|
+
for (let iter = 0; iter < 100; iter++) {
|
|
462
|
+
// Matrix-vector multiply
|
|
463
|
+
const new_vec = Array(n_cols).fill(0);
|
|
464
|
+
for (let idx = 0; idx < n_cols; idx++) {
|
|
465
|
+
for (let jdx = 0; jdx < n_cols; jdx++) {
|
|
466
|
+
new_vec[idx] += work_cov[idx][jdx] * vec[jdx];
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// Normalize
|
|
470
|
+
const norm = Math.hypot(...new_vec);
|
|
471
|
+
if (norm < EPS)
|
|
472
|
+
break;
|
|
473
|
+
const prev = vec;
|
|
474
|
+
vec = new_vec.map((val) => val / norm);
|
|
475
|
+
// Early exit when eigenvector has converged
|
|
476
|
+
if (prev.every((val, idx) => Math.abs(val - vec[idx]) < EPS))
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
479
|
+
// Rayleigh quotient for deflation
|
|
480
|
+
const eigenvalue = vec.reduce((sum, val, idx) => {
|
|
481
|
+
let mv = 0;
|
|
482
|
+
for (let jdx = 0; jdx < n_cols; jdx++)
|
|
483
|
+
mv += work_cov[idx][jdx] * vec[jdx];
|
|
484
|
+
return sum + val * mv;
|
|
485
|
+
}, 0);
|
|
486
|
+
eigenvectors.push(vec);
|
|
487
|
+
// Deflate: remove this component from the covariance matrix
|
|
488
|
+
for (let idx = 0; idx < n_cols; idx++) {
|
|
489
|
+
for (let jdx = 0; jdx < n_cols; jdx++) {
|
|
490
|
+
work_cov[idx][jdx] -= eigenvalue * vec[idx] * vec[jdx];
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
// Project data onto eigenvectors
|
|
495
|
+
const scores = centered.map((row) => eigenvectors.map((ev) => row.reduce((sum, val, idx) => sum + val * ev[idx], 0)));
|
|
496
|
+
return { scores, eigenvectors };
|
|
497
|
+
}
|
|
498
|
+
// Compute orthonormal vector to a 2D line segment (for label offset in 2D diagrams)
|
|
499
|
+
export function orthonormal_2d(line_pts) {
|
|
500
|
+
const dx = line_pts[1][0] - line_pts[0][0];
|
|
501
|
+
const dy = line_pts[1][1] - line_pts[0][1];
|
|
502
|
+
const perp = [-dy, dx];
|
|
503
|
+
const len = Math.hypot(perp[0], perp[1]);
|
|
504
|
+
if (len < EPS)
|
|
505
|
+
return [0, 1];
|
|
506
|
+
return [perp[0] / len, perp[1] / len];
|
|
507
|
+
}
|
|
508
|
+
// Deduplicate points within tolerance, returning unique points and index mapping
|
|
509
|
+
export function dedup_points(pts, tol = 1e-4) {
|
|
510
|
+
const unique = [];
|
|
511
|
+
const orig_indices = [];
|
|
512
|
+
for (let idx = 0; idx < pts.length; idx++) {
|
|
513
|
+
const pt = pts[idx];
|
|
514
|
+
const is_dup = unique.some((existing) => existing.every((val, dim) => Math.abs(val - pt[dim]) < tol));
|
|
515
|
+
if (!is_dup) {
|
|
516
|
+
unique.push(pt);
|
|
517
|
+
orig_indices.push(idx);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return { unique, orig_indices };
|
|
521
|
+
}
|
|
522
|
+
// For a 3D domain, compute convex hull boundary edges and annotation location.
|
|
523
|
+
// Deduplicates vertices first, then uses PCA to project to 2D for the convex
|
|
524
|
+
// hull computation. Returns only the outer boundary edges, not interior lines.
|
|
525
|
+
export function get_3d_domain_simplexes_and_ann_loc(points_3d) {
|
|
526
|
+
// Deduplicate vertices to avoid cluttered interior edges
|
|
527
|
+
const { unique, orig_indices } = dedup_points(points_3d);
|
|
528
|
+
if (unique.length < 3) {
|
|
529
|
+
if (unique.length === 2) {
|
|
530
|
+
const midpoint = unique[0].map((val, dim) => (val + unique[1][dim]) / 2);
|
|
531
|
+
return { simplex_indices: [[orig_indices[0], orig_indices[1]]], ann_loc: midpoint };
|
|
532
|
+
}
|
|
533
|
+
return { simplex_indices: [], ann_loc: unique[0] ?? points_3d[0] ?? [0, 0, 0] };
|
|
534
|
+
}
|
|
535
|
+
const { scores, eigenvectors } = simple_pca(unique, 2);
|
|
536
|
+
// 2D convex hull of PCA-projected unique points → only boundary edges
|
|
537
|
+
const pts_2d = scores.map((row) => [row[0], row[1]]);
|
|
538
|
+
const hull = convex_hull_2d(pts_2d);
|
|
539
|
+
const centroid = polygon_centroid(hull);
|
|
540
|
+
// Map centroid back to 3D
|
|
541
|
+
const n_dims = unique[0].length;
|
|
542
|
+
const mean_3d = Array.from({ length: n_dims }, (_, dim) => unique.reduce((sum, pt) => sum + pt[dim], 0) / unique.length);
|
|
543
|
+
const centroid_x = centroid[0] ?? 0;
|
|
544
|
+
const centroid_y = centroid[1] ?? 0;
|
|
545
|
+
const first_eigenvector = eigenvectors[0] ?? Array(n_dims).fill(0);
|
|
546
|
+
const second_eigenvector = eigenvectors[1] ?? Array(n_dims).fill(0);
|
|
547
|
+
const ann_loc = mean_3d.map((m, dim) => m + centroid_x * first_eigenvector[dim] + centroid_y * second_eigenvector[dim]);
|
|
548
|
+
// Map hull vertices back to original point indices using nearest projected
|
|
549
|
+
// vertex instead of stringified coordinates to avoid precision aliasing.
|
|
550
|
+
function nearest_projected_idx(target) {
|
|
551
|
+
let [nearest_idx, min_sq_dist] = [0, Infinity];
|
|
552
|
+
for (let idx = 0; idx < pts_2d.length; idx++) {
|
|
553
|
+
const dx = pts_2d[idx][0] - target[0];
|
|
554
|
+
const dy = pts_2d[idx][1] - target[1];
|
|
555
|
+
const sq_dist = dx * dx + dy * dy;
|
|
556
|
+
if (sq_dist < min_sq_dist) {
|
|
557
|
+
min_sq_dist = sq_dist;
|
|
558
|
+
nearest_idx = idx;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return nearest_idx;
|
|
562
|
+
}
|
|
563
|
+
const simplex_indices = [];
|
|
564
|
+
for (let hull_idx = 0; hull_idx < hull.length; hull_idx++) {
|
|
565
|
+
const pt_a = hull[hull_idx];
|
|
566
|
+
const pt_b = hull[(hull_idx + 1) % hull.length];
|
|
567
|
+
const ui_a = nearest_projected_idx(pt_a);
|
|
568
|
+
const ui_b = nearest_projected_idx(pt_b);
|
|
569
|
+
// Map back to original array indices
|
|
570
|
+
simplex_indices.push([orig_indices[ui_a], orig_indices[ui_b]]);
|
|
571
|
+
}
|
|
572
|
+
return { simplex_indices, ann_loc };
|
|
573
|
+
}
|
|
574
|
+
// === Label Sizing ===
|
|
575
|
+
// Bounding box diagonal of a set of N-D points (Euclidean distance between
|
|
576
|
+
// the min and max corners). Returns 0 for fewer than 2 points.
|
|
577
|
+
export function bbox_diagonal(points) {
|
|
578
|
+
if (points.length < 2)
|
|
579
|
+
return 0;
|
|
580
|
+
let sq_sum = 0;
|
|
581
|
+
for (let col = 0; col < points[0].length; col++) {
|
|
582
|
+
let lo = Infinity, hi = -Infinity;
|
|
583
|
+
for (const pt of points) {
|
|
584
|
+
lo = Math.min(lo, pt[col]);
|
|
585
|
+
hi = Math.max(hi, pt[col]);
|
|
586
|
+
}
|
|
587
|
+
sq_sum += (hi - lo) ** 2;
|
|
588
|
+
}
|
|
589
|
+
return Math.sqrt(sq_sum);
|
|
590
|
+
}
|
|
591
|
+
// Map an array of raw size values to font sizes via linear interpolation.
|
|
592
|
+
// Returns a new array of font sizes in [min_font, max_font].
|
|
593
|
+
// If all sizes are equal, returns the midpoint for all.
|
|
594
|
+
export function scale_to_font_range(sizes, min_font, max_font) {
|
|
595
|
+
const min_size = Math.min(...sizes);
|
|
596
|
+
const max_size = Math.max(...sizes);
|
|
597
|
+
const range = max_size - min_size;
|
|
598
|
+
const mid = (min_font + max_font) / 2;
|
|
599
|
+
return sizes.map((size) => range > 0 ? min_font + ((max_font - min_font) * (size - min_size)) / range : mid);
|
|
600
|
+
}
|
|
601
|
+
export function get_visible_domain_labels(face_positions, face_domain_map, label_font_size_by_formula, pinned_labels = []) {
|
|
602
|
+
const n_faces = Math.min(Math.floor(face_positions.length / 9), face_domain_map.length);
|
|
603
|
+
const accum = new Map();
|
|
604
|
+
for (let face_idx = 0; face_idx < n_faces; face_idx++) {
|
|
605
|
+
const formula = face_domain_map[face_idx];
|
|
606
|
+
if (!formula || !label_font_size_by_formula.has(formula))
|
|
607
|
+
continue;
|
|
608
|
+
const base = face_idx * 9;
|
|
609
|
+
const ax = face_positions[base];
|
|
610
|
+
const ay = face_positions[base + 1];
|
|
611
|
+
const az = face_positions[base + 2];
|
|
612
|
+
const bx = face_positions[base + 3];
|
|
613
|
+
const by = face_positions[base + 4];
|
|
614
|
+
const bz = face_positions[base + 5];
|
|
615
|
+
const cx = face_positions[base + 6];
|
|
616
|
+
const cy = face_positions[base + 7];
|
|
617
|
+
const cz = face_positions[base + 8];
|
|
618
|
+
const abx = bx - ax;
|
|
619
|
+
const aby = by - ay;
|
|
620
|
+
const abz = bz - az;
|
|
621
|
+
const acx = cx - ax;
|
|
622
|
+
const acy = cy - ay;
|
|
623
|
+
const acz = cz - az;
|
|
624
|
+
const cross_x = aby * acz - abz * acy;
|
|
625
|
+
const cross_y = abz * acx - abx * acz;
|
|
626
|
+
const cross_z = abx * acy - aby * acx;
|
|
627
|
+
const area = Math.hypot(cross_x, cross_y, cross_z) / 2;
|
|
628
|
+
if (area <= EPS)
|
|
629
|
+
continue;
|
|
630
|
+
const centroid_x = (ax + bx + cx) / 3;
|
|
631
|
+
const centroid_y = (ay + by + cy) / 3;
|
|
632
|
+
const centroid_z = (az + bz + cz) / 3;
|
|
633
|
+
const entry = accum.get(formula) ?? { area: 0, x: 0, y: 0, z: 0 };
|
|
634
|
+
entry.area += area;
|
|
635
|
+
entry.x += centroid_x * area;
|
|
636
|
+
entry.y += centroid_y * area;
|
|
637
|
+
entry.z += centroid_z * area;
|
|
638
|
+
accum.set(formula, entry);
|
|
639
|
+
}
|
|
640
|
+
const visible_labels = [...accum.entries()]
|
|
641
|
+
.filter(([, entry]) => entry.area > EPS)
|
|
642
|
+
.map(([formula, entry]) => ({
|
|
643
|
+
formula,
|
|
644
|
+
position: [entry.x / entry.area, entry.y / entry.area, entry.z / entry.area],
|
|
645
|
+
label_font_size: label_font_size_by_formula.get(formula) ?? 12,
|
|
646
|
+
}));
|
|
647
|
+
for (const label of pinned_labels) {
|
|
648
|
+
if (!visible_labels.some((visible_label) => visible_label.formula === label.formula)) {
|
|
649
|
+
visible_labels.push(label);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
return visible_labels.sort((label_a, label_b) => label_a.formula.localeCompare(label_b.formula));
|
|
653
|
+
}
|
|
654
|
+
// === Ternary Combinations ===
|
|
655
|
+
// Generate all C(n,3) ternary element combinations from a sorted element list.
|
|
656
|
+
// Each triplet is sorted alphabetically. Returns empty array for fewer than 3 elements.
|
|
657
|
+
export function get_ternary_combinations(elements) {
|
|
658
|
+
const sorted = [...elements].sort();
|
|
659
|
+
const n_elems = sorted.length;
|
|
660
|
+
if (n_elems < 3)
|
|
661
|
+
return [];
|
|
662
|
+
const combos = [];
|
|
663
|
+
for (let first = 0; first < n_elems - 2; first++) {
|
|
664
|
+
for (let second = first + 1; second < n_elems - 1; second++) {
|
|
665
|
+
for (let third = second + 1; third < n_elems; third++) {
|
|
666
|
+
combos.push([sorted[first], sorted[second], sorted[third]]);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
return combos;
|
|
671
|
+
}
|
|
672
|
+
let nd_cache = null;
|
|
673
|
+
// Content-based fingerprint for N-D result caching. Uses sorted formula keys
|
|
674
|
+
// so deserialized Web Worker copies match and different compositions never collide.
|
|
675
|
+
export function make_nd_cache_key(entries, formal_chempots, default_min_limit, limits) {
|
|
676
|
+
const keyed = entries
|
|
677
|
+
.map((entry) => [
|
|
678
|
+
formula_key_from_composition(entry.composition),
|
|
679
|
+
entry.energy,
|
|
680
|
+
entry.is_stable ?? ``,
|
|
681
|
+
entry.e_above_hull ?? ``,
|
|
682
|
+
entry.exclude_from_hull ?? ``,
|
|
683
|
+
].join(`:`))
|
|
684
|
+
.sort();
|
|
685
|
+
return `${keyed.join(`,`)}|${formal_chempots}|${default_min_limit}|${JSON.stringify(limits ?? {})}`;
|
|
686
|
+
}
|
|
687
|
+
// === Main Pipeline ===
|
|
688
|
+
// Compute the full chemical potential diagram from entries and config.
|
|
689
|
+
// Returns domains, elements, refs, and all intermediate data.
|
|
690
|
+
//
|
|
691
|
+
// Supports two modes based on config.elements vs data dimensionality:
|
|
692
|
+
// - **Subsystem mode**: config.elements matches data element count → filter entries
|
|
693
|
+
// to subsystem, compute in reduced dimensionality (fast for ternary from ternary data)
|
|
694
|
+
// - **Projection mode**: config.elements has fewer elements than data → compute in
|
|
695
|
+
// full N-D, then project domain vertices to selected display axes (column extraction).
|
|
696
|
+
// This matches pymatgen's ChemicalPotentialDiagram behavior for multinary systems.
|
|
697
|
+
export function compute_chempot_diagram(entries, config = {}) {
|
|
698
|
+
const { formal_chempots = CHEMPOT_DEFAULTS.formal_chempots, default_min_limit = CHEMPOT_DEFAULTS.default_min_limit, limits, } = config;
|
|
699
|
+
// Detect all unique elements across all input entries (single pass, low allocation)
|
|
700
|
+
const all_data_elements_set = new Set();
|
|
701
|
+
for (const entry of entries) {
|
|
702
|
+
for (const [element, amount] of Object.entries(entry.composition)) {
|
|
703
|
+
if (amount > 0)
|
|
704
|
+
all_data_elements_set.add(element);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
const all_data_elements = Array.from(all_data_elements_set).sort();
|
|
708
|
+
// Display elements: user-specified order (controls axis mapping), or auto-detect
|
|
709
|
+
const display_elements = config.elements?.length ? [...config.elements] : all_data_elements;
|
|
710
|
+
// Projection mode: display fewer axes than the data has elements
|
|
711
|
+
// In this mode, compute in full N-D and project afterward
|
|
712
|
+
const is_projection = display_elements.length < all_data_elements.length &&
|
|
713
|
+
display_elements.every((el) => all_data_elements.includes(el));
|
|
714
|
+
// Computation elements: full element set for projection, display set for subsystem
|
|
715
|
+
const compute_elements = is_projection ? all_data_elements : display_elements;
|
|
716
|
+
// Try cache for projection mode (same entries + config = same N-D domains)
|
|
717
|
+
const cache_key = is_projection
|
|
718
|
+
? make_nd_cache_key(entries, formal_chempots, default_min_limit, limits)
|
|
719
|
+
: ``;
|
|
720
|
+
let nd_result = is_projection && nd_cache?.key === cache_key ? nd_cache.result : null;
|
|
721
|
+
if (!nd_result) {
|
|
722
|
+
// In subsystem mode, filter entries to only those within the element set
|
|
723
|
+
let working_entries = entries;
|
|
724
|
+
if (!is_projection && config.elements?.length) {
|
|
725
|
+
const target_set = new Set(config.elements);
|
|
726
|
+
working_entries = entries.filter((entry) => {
|
|
727
|
+
for (const [element, amount] of Object.entries(entry.composition)) {
|
|
728
|
+
if (amount > 0 && !target_set.has(element))
|
|
729
|
+
return false;
|
|
730
|
+
}
|
|
731
|
+
return true;
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
// Sort entries by composition (Schwartzian transform to avoid recomputing keys)
|
|
735
|
+
const sorted_entries = working_entries
|
|
736
|
+
.map((entry) => ({ entry, key: formula_key_from_composition(entry.composition) }))
|
|
737
|
+
.sort((a, b) => a.key.localeCompare(b.key))
|
|
738
|
+
.map(({ entry }) => entry);
|
|
739
|
+
// Get min entries and elemental references
|
|
740
|
+
let { min_entries, el_refs } = get_min_entries_and_el_refs(sorted_entries);
|
|
741
|
+
const dim = compute_elements.length;
|
|
742
|
+
if (dim < 2) {
|
|
743
|
+
throw new Error(`ChemicalPotentialDiagram requires 2+ elements, got ${dim}`);
|
|
744
|
+
}
|
|
745
|
+
// Check all elemental refs exist for the computation elements
|
|
746
|
+
const missing_refs = compute_elements.filter((el) => !el_refs[el]);
|
|
747
|
+
if (missing_refs.length > 0) {
|
|
748
|
+
throw new Error(`Missing elemental reference entries for: ${missing_refs.join(`, `)}`);
|
|
749
|
+
}
|
|
750
|
+
// Renormalize if using formal chemical potentials
|
|
751
|
+
if (formal_chempots) {
|
|
752
|
+
min_entries = renormalize_entries(min_entries, el_refs, compute_elements);
|
|
753
|
+
const renorm_result = get_min_entries_and_el_refs(min_entries);
|
|
754
|
+
el_refs = renorm_result.el_refs;
|
|
755
|
+
}
|
|
756
|
+
// Build limits array for computation elements
|
|
757
|
+
const compute_lims = compute_elements.map((el) => {
|
|
758
|
+
if (limits?.[el])
|
|
759
|
+
return limits[el];
|
|
760
|
+
return [default_min_limit, 0];
|
|
761
|
+
});
|
|
762
|
+
// Build hyperplanes and compute domains in full dimensionality
|
|
763
|
+
const { hyperplanes, hyperplane_entries } = build_hyperplanes(min_entries, el_refs, compute_elements);
|
|
764
|
+
const border_hyperplanes = build_border_hyperplanes(compute_lims);
|
|
765
|
+
const domains = compute_domains(hyperplanes, border_hyperplanes, hyperplane_entries, dim);
|
|
766
|
+
nd_result = {
|
|
767
|
+
domains,
|
|
768
|
+
el_refs,
|
|
769
|
+
min_entries,
|
|
770
|
+
hyperplanes,
|
|
771
|
+
hyperplane_entries,
|
|
772
|
+
compute_lims,
|
|
773
|
+
};
|
|
774
|
+
// Cache for projection mode reuse
|
|
775
|
+
if (is_projection) {
|
|
776
|
+
nd_cache = { key: cache_key, result: nd_result };
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
let domains = nd_result.domains;
|
|
780
|
+
let output_lims = nd_result.compute_lims;
|
|
781
|
+
// Project domain vertices from N-D to display axes (column extraction)
|
|
782
|
+
if (is_projection) {
|
|
783
|
+
const col_indices = display_elements.map((element) => {
|
|
784
|
+
const idx = compute_elements.indexOf(element);
|
|
785
|
+
if (idx < 0) {
|
|
786
|
+
throw new Error(`Display element ${element} not present in compute element set`);
|
|
787
|
+
}
|
|
788
|
+
return idx;
|
|
789
|
+
});
|
|
790
|
+
const projected = {};
|
|
791
|
+
for (const [formula, pts] of Object.entries(domains)) {
|
|
792
|
+
projected[formula] = pts.map((pt) => col_indices.map((idx) => pt[idx]));
|
|
793
|
+
}
|
|
794
|
+
domains = projected;
|
|
795
|
+
output_lims = col_indices.map((col_idx) => nd_result.compute_lims[col_idx]);
|
|
796
|
+
}
|
|
797
|
+
return {
|
|
798
|
+
domains,
|
|
799
|
+
elements: display_elements,
|
|
800
|
+
el_refs: nd_result.el_refs,
|
|
801
|
+
min_entries: nd_result.min_entries,
|
|
802
|
+
hyperplanes: nd_result.hyperplanes,
|
|
803
|
+
hyperplane_entries: nd_result.hyperplane_entries,
|
|
804
|
+
lims: output_lims,
|
|
805
|
+
};
|
|
806
|
+
}
|