matterviz 0.4.0 → 0.4.2
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 +12 -14
- package/dist/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +2 -2
- package/dist/app.css +53 -0
- package/dist/brillouin/BrillouinZone.svelte +132 -219
- package/dist/brillouin/BrillouinZone.svelte.d.ts +9 -20
- package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
- package/dist/brillouin/BrillouinZoneExportPane.svelte +47 -96
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +15 -42
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +63 -230
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +3 -23
- package/dist/brillouin/ReciprocalVectors.svelte +39 -0
- package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
- package/dist/brillouin/compute.d.ts +2 -0
- package/dist/brillouin/compute.js +80 -77
- package/dist/brillouin/geometry.d.ts +8 -0
- package/dist/brillouin/geometry.js +57 -0
- package/dist/brillouin/index.d.ts +2 -0
- package/dist/brillouin/index.js +2 -0
- package/dist/brillouin/types.d.ts +2 -2
- package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +143 -246
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +652 -976
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
- package/dist/chempot-diagram/async-compute.svelte.js +1 -1
- package/dist/chempot-diagram/color.d.ts +3 -6
- package/dist/chempot-diagram/color.js +5 -5
- package/dist/chempot-diagram/compute.d.ts +3 -3
- package/dist/chempot-diagram/compute.js +3 -1
- package/dist/chempot-diagram/controls-state.svelte.d.ts +10 -0
- package/dist/chempot-diagram/controls-state.svelte.js +42 -0
- package/dist/chempot-diagram/export.d.ts +47 -0
- package/dist/chempot-diagram/export.js +133 -0
- package/dist/chempot-diagram/index.d.ts +1 -0
- package/dist/chempot-diagram/index.js +1 -0
- package/dist/chempot-diagram/pointer.d.ts +0 -10
- package/dist/chempot-diagram/pointer.js +4 -4
- package/dist/chempot-diagram/types.d.ts +3 -3
- package/dist/colors/index.d.ts +0 -4
- package/dist/colors/index.js +21 -22
- package/dist/composition/BarChart.svelte +37 -31
- package/dist/composition/BubbleChart.svelte +17 -17
- package/dist/composition/Composition.svelte +7 -11
- package/dist/composition/Formula.svelte +18 -25
- package/dist/composition/FormulaFilter.svelte +96 -98
- package/dist/composition/PieChart.svelte +60 -46
- package/dist/composition/chem-sys.js +3 -2
- package/dist/composition/format.js +4 -3
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +2 -3
- package/dist/composition/parse.js +27 -28
- package/dist/constants.js +11 -9
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +0 -1
- package/dist/convex-hull/ConvexHull.svelte +20 -25
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
- package/dist/convex-hull/ConvexHull2D.svelte +176 -256
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +269 -804
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +236 -755
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +264 -0
- package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
- package/dist/convex-hull/ConvexHullControls.svelte +128 -49
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
- package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
- package/dist/convex-hull/ConvexHullStats.svelte +210 -351
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +16 -14
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
- package/dist/convex-hull/GasPressureControls.svelte +5 -12
- package/dist/convex-hull/StructurePopup.svelte +17 -21
- package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
- package/dist/convex-hull/TemperatureSlider.svelte +4 -10
- package/dist/convex-hull/barycentric-coords.d.ts +2 -4
- package/dist/convex-hull/barycentric-coords.js +6 -33
- package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
- package/dist/convex-hull/canvas-interactions.svelte.js +279 -0
- package/dist/convex-hull/helpers.d.ts +47 -17
- package/dist/convex-hull/helpers.js +186 -101
- package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
- package/dist/convex-hull/hull-state.svelte.js +124 -0
- package/dist/convex-hull/index.d.ts +9 -7
- package/dist/convex-hull/index.js +7 -2
- package/dist/convex-hull/thermodynamics.js +109 -937
- package/dist/convex-hull/types.d.ts +12 -4
- package/dist/convex-hull/types.js +12 -0
- package/dist/coordination/CoordinationBarPlot.svelte +41 -43
- 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 +6 -8
- 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 +24 -29
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/element/Nucleus.svelte +4 -2
- package/dist/element/data.d.ts +1 -2
- package/dist/element/helpers.d.ts +4 -0
- package/dist/element/helpers.js +18 -0
- package/dist/element/index.d.ts +1 -0
- package/dist/element/index.js +3 -0
- package/dist/feedback/DragOverlay.svelte +5 -3
- package/dist/feedback/DragOverlay.svelte.d.ts +2 -1
- package/dist/feedback/StatusMessage.svelte +20 -7
- package/dist/fermi-surface/FermiSlice.svelte +21 -18
- package/dist/fermi-surface/FermiSurface.svelte +78 -165
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +9 -20
- package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
- package/dist/fermi-surface/FermiSurfaceScene.svelte +93 -272
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
- package/dist/fermi-surface/compute.js +14 -13
- package/dist/fermi-surface/export.js +4 -15
- package/dist/fermi-surface/index.d.ts +0 -1
- package/dist/fermi-surface/index.js +0 -1
- package/dist/fermi-surface/parse.d.ts +1 -1
- package/dist/fermi-surface/parse.js +84 -97
- package/dist/fermi-surface/types.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +161 -185
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +6 -5
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +12 -9
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
- package/dist/heatmap-matrix/index.d.ts +8 -2
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/ExportPane.svelte +170 -0
- package/dist/io/ExportPane.svelte.d.ts +17 -0
- package/dist/io/decompress.d.ts +2 -1
- package/dist/io/decompress.js +22 -36
- package/dist/io/export.d.ts +9 -1
- package/dist/io/export.js +37 -29
- package/dist/io/fetch.d.ts +2 -4
- package/dist/io/fetch.js +0 -11
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +13 -0
- package/dist/io/index.d.ts +1 -0
- package/dist/io/index.js +3 -0
- package/dist/io/is-binary.d.ts +9 -0
- package/dist/io/is-binary.js +45 -1
- package/dist/io/types.d.ts +13 -0
- package/dist/io/url-drop.js +13 -25
- package/dist/isosurface/Isosurface.svelte +17 -23
- package/dist/isosurface/IsosurfaceControls.svelte +37 -42
- package/dist/isosurface/parse-vaspwave.d.ts +3 -0
- package/dist/isosurface/parse-vaspwave.js +138 -0
- package/dist/isosurface/parse.js +50 -48
- package/dist/labels.d.ts +6 -2
- package/dist/labels.js +44 -14
- package/dist/layout/FullscreenButton.svelte +34 -0
- package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
- package/dist/layout/FullscreenToggle.svelte +12 -12
- package/dist/layout/InfoCard.svelte +7 -18
- 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 +21 -17
- package/dist/layout/SubpageGrid.svelte +3 -1
- package/dist/layout/ViewerChrome.svelte +115 -0
- package/dist/layout/ViewerChrome.svelte.d.ts +18 -0
- package/dist/layout/fullscreen.d.ts +4 -0
- package/dist/layout/fullscreen.js +3 -5
- package/dist/layout/fullscreen.svelte.d.ts +8 -0
- package/dist/layout/fullscreen.svelte.js +36 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.js +4 -0
- package/dist/layout/json-tree/JsonNode.svelte +8 -11
- package/dist/layout/json-tree/JsonTree.svelte +53 -77
- package/dist/layout/json-tree/JsonValue.svelte +7 -15
- package/dist/layout/json-tree/utils.js +14 -23
- package/dist/math.d.ts +9 -3
- package/dist/math.js +37 -21
- package/dist/overlays/ContextMenu.svelte +4 -2
- package/dist/overlays/CopyButton.svelte +11 -5
- package/dist/overlays/DragControlTab.svelte +6 -1
- package/dist/overlays/DraggablePane.svelte +81 -26
- package/dist/overlays/DraggablePane.svelte.d.ts +1 -0
- package/dist/overlays/GlassChip.svelte +30 -0
- package/dist/overlays/GlassChip.svelte.d.ts +8 -0
- package/dist/overlays/InfoPaneCards.svelte +11 -23
- package/dist/overlays/index.d.ts +11 -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 +115 -146
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
- package/dist/periodic-table/PeriodicTableControls.svelte +11 -63
- package/dist/periodic-table/TableInset.svelte +9 -4
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +50 -71
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
- package/dist/phase-diagram/PhaseDiagramControls.svelte +73 -96
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +4 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +49 -134
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
- package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
- package/dist/phase-diagram/build-diagram.js +3 -3
- package/dist/phase-diagram/colors.js +1 -1
- package/dist/phase-diagram/diagram-input.d.ts +1 -2
- package/dist/phase-diagram/parse.d.ts +2 -1
- package/dist/phase-diagram/parse.js +15 -15
- package/dist/phase-diagram/svg-to-diagram.js +21 -15
- package/dist/phase-diagram/utils.js +2 -3
- package/dist/plot/bar/BarPlot.svelte +494 -692
- package/dist/plot/bar/BarPlot.svelte.d.ts +9 -15
- package/dist/plot/bar/BarPlotControls.svelte +1 -3
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +5 -7
- package/dist/plot/bar/SpacegroupBarPlot.svelte +31 -37
- package/dist/plot/bar/data.d.ts +5 -4
- package/dist/plot/bar/data.js +2 -1
- package/dist/plot/box/BoxPlot.svelte +361 -439
- package/dist/plot/box/BoxPlot.svelte.d.ts +6 -3
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
- package/dist/plot/box/Violin.svelte.d.ts +2 -1
- package/dist/plot/box/box-plot.d.ts +3 -2
- package/dist/plot/box/box-plot.js +6 -3
- package/dist/plot/box/kde.d.ts +2 -1
- package/dist/plot/box/kde.js +4 -4
- package/dist/plot/core/auto-place.d.ts +1 -1
- package/dist/plot/core/auto-place.js +5 -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 +106 -111
- package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
- 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 +21 -11
- package/dist/plot/core/components/Line.svelte.d.ts +5 -2
- package/dist/plot/core/components/PlotAxis.svelte +42 -18
- package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
- package/dist/plot/core/components/PlotControls.svelte +65 -41
- package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
- 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 +56 -59
- package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
- package/dist/plot/core/components/ReferencePlane.svelte +9 -10
- package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
- 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 +29 -476
- package/dist/plot/core/data-transform.js +9 -5
- package/dist/plot/core/fill-utils.d.ts +7 -4
- package/dist/plot/core/fill-utils.js +34 -9
- package/dist/plot/core/index.d.ts +1 -0
- package/dist/plot/core/index.js +1 -0
- package/dist/plot/core/interactions.d.ts +5 -1
- package/dist/plot/core/interactions.js +14 -2
- package/dist/plot/core/layout.d.ts +3 -1
- package/dist/plot/core/layout.js +22 -13
- 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 +35 -0
- package/dist/plot/core/pan-zoom.svelte.js +221 -0
- package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
- package/dist/plot/core/placed-tween.svelte.js +68 -0
- package/dist/plot/core/reference-line.d.ts +10 -10
- package/dist/plot/core/reference-line.js +7 -7
- package/dist/plot/core/scales.d.ts +40 -25
- package/dist/plot/core/scales.js +49 -21
- package/dist/plot/core/svg.d.ts +2 -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 +47 -331
- package/dist/plot/core/types.js +23 -20
- package/dist/plot/core/utils/hierarchy-chart.d.ts +51 -0
- package/dist/plot/core/utils/hierarchy-chart.js +179 -0
- package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
- package/dist/plot/core/utils/hierarchy-labels.js +99 -0
- package/dist/plot/core/utils/label-placement.d.ts +1 -1
- package/dist/plot/core/utils/label-placement.js +5 -5
- package/dist/plot/core/utils.d.ts +2 -1
- package/dist/plot/histogram/Histogram.svelte +373 -631
- package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
- package/dist/plot/histogram/HistogramControls.svelte +30 -28
- package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
- 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 +79 -73
- package/dist/plot/sankey/Sankey.svelte.d.ts +3 -3
- package/dist/plot/sankey/SankeyControls.svelte +22 -16
- package/dist/plot/sankey/sankey.js +3 -1
- package/dist/plot/scatter/BinnedScatterPlot.svelte +264 -112
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +11 -4
- package/dist/plot/scatter/ElementScatter.svelte +4 -1
- package/dist/plot/scatter/ScatterPlot.svelte +623 -821
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +9 -15
- 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/binned-scatter-types.d.ts +6 -12
- package/dist/plot/scatter/binned-scatter-types.js +6 -1
- package/dist/plot/scatter/index.d.ts +1 -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 +40 -60
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +17 -15
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +232 -234
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
- package/dist/plot/scatter-3d/Surface3D.svelte +9 -17
- package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
- package/dist/plot/sunburst/Sunburst.svelte +256 -338
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
- 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 +14 -4
- package/dist/plot/treemap/Treemap.svelte +907 -0
- package/dist/plot/treemap/Treemap.svelte.d.ts +84 -0
- package/dist/plot/treemap/index.d.ts +3 -0
- package/dist/plot/treemap/index.js +4 -0
- package/dist/plot/treemap/treemap.d.ts +26 -0
- package/dist/plot/treemap/treemap.js +99 -0
- package/dist/rdf/RdfPlot.svelte +22 -26
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/calc-rdf.js +4 -8
- package/dist/sanitize.js +14 -3
- package/dist/scene/SceneCamera.svelte +62 -0
- package/dist/scene/SceneCamera.svelte.d.ts +19 -0
- package/dist/scene/bind-renderer.svelte.d.ts +2 -0
- package/dist/scene/bind-renderer.svelte.js +22 -0
- package/dist/scene/index.d.ts +4 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/props.js +52 -0
- package/dist/scene/types.d.ts +26 -0
- package/dist/scene/types.js +1 -0
- package/dist/settings.d.ts +33 -11
- package/dist/settings.js +136 -51
- package/dist/spectral/Bands.svelte +231 -237
- package/dist/spectral/Bands.svelte.d.ts +3 -2
- package/dist/spectral/BandsAndDos.svelte +29 -29
- package/dist/spectral/BrillouinBandsDos.svelte +21 -29
- package/dist/spectral/Dos.svelte +75 -77
- package/dist/spectral/Dos.svelte.d.ts +2 -1
- package/dist/spectral/helpers.d.ts +9 -9
- package/dist/spectral/helpers.js +66 -70
- package/dist/state.svelte.d.ts +0 -7
- package/dist/state.svelte.js +5 -24
- package/dist/structure/Arrow.svelte +6 -21
- package/dist/structure/ArrowInstances.svelte +160 -0
- package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
- package/dist/structure/AtomLegend.svelte +115 -75
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +31 -23
- package/dist/structure/CanvasTooltip.svelte +16 -3
- package/dist/structure/CellSelect.svelte +22 -29
- package/dist/structure/CellSelect.svelte.d.ts +2 -1
- 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 +725 -735
- package/dist/structure/Structure.svelte.d.ts +8 -16
- package/dist/structure/StructureCarousel.svelte +630 -0
- package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
- package/dist/structure/StructureControls.svelte +298 -325
- package/dist/structure/StructureControls.svelte.d.ts +5 -3
- package/dist/structure/StructureExportPane.svelte +62 -168
- package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
- package/dist/structure/StructureInfoPane.svelte +77 -69
- package/dist/structure/StructureInfoPane.svelte.d.ts +6 -6
- package/dist/structure/StructureScene.svelte +758 -600
- package/dist/structure/StructureScene.svelte.d.ts +24 -20
- package/dist/structure/StructureViewport.svelte +386 -0
- package/dist/structure/StructureViewport.svelte.d.ts +63 -0
- package/dist/structure/atom-label-placement.d.ts +18 -0
- package/dist/structure/atom-label-placement.js +115 -0
- package/dist/structure/atom-properties.d.ts +3 -1
- package/dist/structure/atom-properties.js +115 -54
- package/dist/structure/bond-order-perception.js +2 -4
- package/dist/structure/bonding.d.ts +12 -2
- package/dist/structure/bonding.js +172 -73
- package/dist/structure/edit-history.d.ts +6 -0
- package/dist/structure/edit-history.js +27 -0
- package/dist/structure/export.d.ts +25 -4
- package/dist/structure/export.js +103 -153
- package/dist/structure/format-detect.d.ts +1 -0
- package/dist/structure/format-detect.js +22 -0
- package/dist/structure/geometry.d.ts +9 -0
- package/dist/structure/geometry.js +27 -0
- package/dist/structure/index.d.ts +18 -1
- package/dist/structure/index.js +15 -2
- package/dist/structure/measure.d.ts +1 -1
- package/dist/structure/measure.js +6 -12
- package/dist/structure/parse.d.ts +5 -3
- package/dist/structure/parse.js +551 -567
- package/dist/structure/partial-occupancy.d.ts +0 -1
- package/dist/structure/partial-occupancy.js +5 -3
- package/dist/structure/pbc.d.ts +1 -1
- package/dist/structure/pbc.js +204 -51
- package/dist/structure/polyhedra.d.ts +40 -0
- package/dist/structure/polyhedra.js +587 -0
- package/dist/structure/site.d.ts +4 -0
- package/dist/structure/site.js +1 -0
- package/dist/structure/supercell.d.ts +1 -2
- package/dist/structure/supercell.js +10 -15
- package/dist/structure/validation.js +5 -6
- package/dist/symmetry/SymmetryElementControls.svelte +69 -0
- package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
- package/dist/symmetry/SymmetryElements.svelte +350 -0
- package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
- package/dist/symmetry/SymmetryStats.svelte +142 -49
- package/dist/symmetry/WyckoffTable.svelte +58 -16
- package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
- package/dist/symmetry/cell-transform.js +8 -14
- package/dist/symmetry/index.d.ts +15 -4
- package/dist/symmetry/index.js +308 -81
- package/dist/symmetry/spacegroups.d.ts +5 -1
- package/dist/symmetry/spacegroups.js +18 -3
- package/dist/symmetry/symmetry-elements.d.ts +33 -0
- package/dist/symmetry/symmetry-elements.js +521 -0
- package/dist/symmetry/wyckoff-db.d.ts +9 -0
- package/dist/symmetry/wyckoff-db.js +87 -0
- package/dist/table/HeatmapTable.svelte +1104 -378
- package/dist/table/HeatmapTable.svelte.d.ts +12 -2
- package/dist/table/ToggleMenu.svelte +5 -12
- 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/index.d.ts +1 -5
- package/dist/theme/index.js +4 -10
- package/dist/theme/themes.mjs +14 -7
- package/dist/tooltip/KCoords.svelte +4 -1
- package/dist/tooltip/TooltipContent.svelte +2 -5
- package/dist/trajectory/Trajectory.svelte +556 -352
- package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
- package/dist/trajectory/TrajectoryError.svelte +11 -8
- package/dist/trajectory/TrajectoryExportPane.svelte +28 -54
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
- package/dist/trajectory/TrajectoryInfoPane.svelte +88 -99
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
- package/dist/trajectory/constants.js +6 -2
- package/dist/trajectory/extract.js +73 -71
- package/dist/trajectory/format-detect.d.ts +0 -1
- package/dist/trajectory/format-detect.js +13 -17
- package/dist/trajectory/frame-reader.d.ts +2 -1
- package/dist/trajectory/frame-reader.js +74 -136
- package/dist/trajectory/helpers.d.ts +12 -2
- package/dist/trajectory/helpers.js +68 -37
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +3 -0
- package/dist/trajectory/parse/ase.d.ts +9 -1
- package/dist/trajectory/parse/ase.js +47 -32
- package/dist/trajectory/parse/diagnostics.d.ts +3 -0
- package/dist/trajectory/parse/diagnostics.js +14 -0
- 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 +3 -4
- package/dist/trajectory/parse/index.js +68 -119
- package/dist/trajectory/parse/lammps.d.ts +0 -2
- package/dist/trajectory/parse/lammps.js +14 -16
- package/dist/trajectory/parse/pymatgen.d.ts +2 -0
- package/dist/trajectory/parse/pymatgen.js +74 -0
- package/dist/trajectory/parse/vasp.js +13 -9
- 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 +5 -0
- package/dist/trajectory/parse/vaspout-h5.js +284 -0
- package/dist/trajectory/parse/xyz.d.ts +9 -21
- package/dist/trajectory/parse/xyz.js +38 -39
- package/dist/trajectory/plotting.d.ts +8 -10
- package/dist/trajectory/plotting.js +102 -127
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +8 -1
- package/dist/xrd/XrdPlot.svelte +56 -85
- package/dist/xrd/broadening.d.ts +2 -1
- package/dist/xrd/broadening.js +2 -1
- package/dist/xrd/calc-xrd.js +8 -15
- package/dist/xrd/index.d.ts +2 -2
- package/dist/xrd/parse.d.ts +0 -1
- package/dist/xrd/parse.js +56 -73
- package/package.json +77 -36
- package/dist/api/mp.d.ts +0 -6
- package/dist/api/mp.js +0 -22
- package/dist/element/data.json +0 -11864
- package/dist/fermi-surface/marching-cubes.d.ts +0 -2
- package/dist/fermi-surface/marching-cubes.js +0 -2
- package/dist/plot/core/hover-lock.svelte.d.ts +0 -14
- package/dist/plot/core/hover-lock.svelte.js +0 -45
- package/dist/plot/sunburst/SunburstControls.svelte +0 -200
- package/dist/structure/label-placement.d.ts +0 -14
- package/dist/structure/label-placement.js +0 -72
|
@@ -1,8 +1,48 @@
|
|
|
1
1
|
// Bonding algorithms for structure visualization
|
|
2
|
-
import { element_data } from '../element';
|
|
2
|
+
import { default as element_data } from '../element/data';
|
|
3
3
|
import * as math from '../math';
|
|
4
|
-
|
|
4
|
+
// Shared per-symbol element data lookup (also used by pbc.ts and polyhedra.ts)
|
|
5
|
+
export const element_lookup = new Map(element_data.map((el) => [el.symbol, el]));
|
|
5
6
|
const covalent_radii = new Map(element_data.flatMap((el) => el.covalent_radius === null ? [] : [[el.symbol, el.covalent_radius]]));
|
|
7
|
+
// Majority-occupancy element of a (possibly disordered) site
|
|
8
|
+
export const get_majority_element = (site) => {
|
|
9
|
+
if (!site?.species?.length)
|
|
10
|
+
return null;
|
|
11
|
+
return site.species.reduce((max, spec) => (spec.occu > max.occu ? spec : max)).element;
|
|
12
|
+
};
|
|
13
|
+
// Large low-valent A-site cations whose coordination polyhedra (CN 8-12) tend to
|
|
14
|
+
// obscure the structural framework. VESTA-style figures draw the framework
|
|
15
|
+
// (e.g. TiO6 in BaTiO3, FeO6/PO4 in LiFePO4) and leave these as plain spheres.
|
|
16
|
+
// They still get polyhedra when they are the only qualifying cations (e.g. NaCl)
|
|
17
|
+
// or when force-included via `included_center_elements`. Shared by polyhedra.ts
|
|
18
|
+
// (vertex/center selection) and pbc.ts (phase-2 boundary completion) so the bond
|
|
19
|
+
// graph and the polyhedra it feeds stay consistent.
|
|
20
|
+
const SPECTATOR_CATEGORIES = new Set([`alkali metal`]);
|
|
21
|
+
const HEAVY_ALKALINE_EARTHS = new Set([`Ca`, `Sr`, `Ba`, `Ra`]);
|
|
22
|
+
export const is_spectator_center = (element) => SPECTATOR_CATEGORIES.has(element_lookup.get(element)?.category ?? ``) ||
|
|
23
|
+
HEAVY_ALKALINE_EARTHS.has(element);
|
|
24
|
+
// True if the composition contains a framework cation: a non-spectator element
|
|
25
|
+
// strictly less electronegative than the most electronegative element present
|
|
26
|
+
// (i.e. one that can coordinate the anions). When true, spectator A-site cations
|
|
27
|
+
// are hidden from coordination polyhedra (compute_polyhedra) and skipped by phase-2
|
|
28
|
+
// boundary completion (find_image_atoms) - sharing this keeps the bond graph and
|
|
29
|
+
// the polyhedra it feeds consistent. Purely ionic binaries (NaCl, Li2O) return
|
|
30
|
+
// false, so the spectator IS the framework and keeps its polyhedra/completions.
|
|
31
|
+
export function has_framework_potential(elements) {
|
|
32
|
+
const els = [...new Set(elements)]; // dedupe so callers can pass per-site element lists
|
|
33
|
+
let max_en = -Infinity;
|
|
34
|
+
for (const el of els) {
|
|
35
|
+
const en = element_lookup.get(el)?.electronegativity;
|
|
36
|
+
if (en != null && en > max_en)
|
|
37
|
+
max_en = en;
|
|
38
|
+
}
|
|
39
|
+
return els.some((el) => {
|
|
40
|
+
if (is_spectator_center(el))
|
|
41
|
+
return false;
|
|
42
|
+
const en = element_lookup.get(el)?.electronegativity;
|
|
43
|
+
return en != null && en < max_en;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
6
46
|
const is_zero_cell_shift = (cell_shift) => cell_shift === undefined || cell_shift.every((val) => val === 0);
|
|
7
47
|
const format_cell_shift = (cell_shift) => {
|
|
8
48
|
if (cell_shift === undefined || is_zero_cell_shift(cell_shift))
|
|
@@ -413,8 +453,6 @@ export function get_bond_render_matrices(bond, bond_thickness) {
|
|
|
413
453
|
? [bond.transform_matrix]
|
|
414
454
|
: offsets_and_scales.map(([offset, radius_scale]) => scale_and_offset_bond_matrix(bond.transform_matrix, offset, radius_scale));
|
|
415
455
|
}
|
|
416
|
-
// Get the species with highest occupancy from a site.
|
|
417
|
-
const get_majority_species = (site) => (site.species ?? []).reduce((max_species, species) => (species.occu > max_species.occu ? species : max_species), site.species?.[0] ?? { element: ``, occu: -1 });
|
|
418
456
|
// Helper to extract numeric index from site properties
|
|
419
457
|
function get_orig_idx(site, fallback) {
|
|
420
458
|
const props = site.properties;
|
|
@@ -496,12 +534,27 @@ export function compute_bond_transform(pos_1, pos_2) {
|
|
|
496
534
|
1,
|
|
497
535
|
]);
|
|
498
536
|
}
|
|
537
|
+
// Build a BondPair between two sites (shared by electroneg_ratio and solid_angle)
|
|
538
|
+
const make_bond = (sites, idx_1, idx_2, bond_length, strength) => ({
|
|
539
|
+
pos_1: sites[idx_1].xyz,
|
|
540
|
+
pos_2: sites[idx_2].xyz,
|
|
541
|
+
site_idx_1: idx_1,
|
|
542
|
+
site_idx_2: idx_2,
|
|
543
|
+
bond_length,
|
|
544
|
+
strength,
|
|
545
|
+
transform_matrix: compute_bond_transform(sites[idx_1].xyz, sites[idx_2].xyz),
|
|
546
|
+
});
|
|
547
|
+
// Pack quantized cell coordinates into one integer key (exact for cell coords in
|
|
548
|
+
// [-512, 511], i.e. structures up to ~1000 cells per axis - far beyond any real
|
|
549
|
+
// case). Integer Map keys avoid per-lookup string building in the hot pair loop.
|
|
550
|
+
// Also used by pbc.ts for its phase-2 boundary-completion grid.
|
|
551
|
+
const CELL_OFFSET = 512;
|
|
552
|
+
export const pack_cell_key = (x, y, z) => (x + CELL_OFFSET) * 1048576 + (y + CELL_OFFSET) * 1024 + (z + CELL_OFFSET);
|
|
499
553
|
// Build spatial grid by dividing 3D space into cubic cells.
|
|
500
554
|
function build_spatial_grid(sites, cell_size) {
|
|
501
555
|
const grid = new Map();
|
|
502
556
|
for (let idx = 0; idx < sites.length; idx++) {
|
|
503
|
-
const
|
|
504
|
-
const key = `${x},${y},${z}`;
|
|
557
|
+
const key = pack_cell_key(Math.floor(sites[idx].xyz[0] / cell_size), Math.floor(sites[idx].xyz[1] / cell_size), Math.floor(sites[idx].xyz[2] / cell_size));
|
|
505
558
|
const cell = grid.get(key);
|
|
506
559
|
if (cell)
|
|
507
560
|
cell.push(idx);
|
|
@@ -511,23 +564,28 @@ function build_spatial_grid(sites, cell_size) {
|
|
|
511
564
|
return grid;
|
|
512
565
|
}
|
|
513
566
|
// Get all site indices in 3x3x3 cube of cells around position.
|
|
567
|
+
// Fills and returns a REUSED module-level array (valid until the next call):
|
|
568
|
+
// this runs once per bond center, so per-call allocations would dominate GC
|
|
569
|
+
// pressure when computing bonds for large supercells.
|
|
570
|
+
const scratch_neighbors = [];
|
|
514
571
|
function get_neighbors_from_grid(pos, grid, cell_size) {
|
|
515
572
|
const [cx, cy, cz] = [
|
|
516
573
|
Math.floor(pos[0] / cell_size),
|
|
517
574
|
Math.floor(pos[1] / cell_size),
|
|
518
575
|
Math.floor(pos[2] / cell_size),
|
|
519
576
|
];
|
|
520
|
-
|
|
577
|
+
scratch_neighbors.length = 0;
|
|
521
578
|
for (let dx = -1; dx <= 1; dx++) {
|
|
522
579
|
for (let dy = -1; dy <= 1; dy++) {
|
|
523
580
|
for (let dz = -1; dz <= 1; dz++) {
|
|
524
|
-
const cell = grid.get(
|
|
581
|
+
const cell = grid.get(pack_cell_key(cx + dx, cy + dy, cz + dz));
|
|
525
582
|
if (cell)
|
|
526
|
-
|
|
583
|
+
for (const site_idx of cell)
|
|
584
|
+
scratch_neighbors.push(site_idx);
|
|
527
585
|
}
|
|
528
586
|
}
|
|
529
587
|
}
|
|
530
|
-
return
|
|
588
|
+
return scratch_neighbors;
|
|
531
589
|
}
|
|
532
590
|
// Setup spatial decomposition for structures with >50 atoms.
|
|
533
591
|
function setup_spatial_grid(sites, cutoff) {
|
|
@@ -539,6 +597,23 @@ const get_candidates = (pos, sites, spatial) => spatial
|
|
|
539
597
|
? get_neighbors_from_grid(pos, spatial.grid, spatial.cell_size)
|
|
540
598
|
: Array.from({ length: sites.length }, (_, idx) => idx);
|
|
541
599
|
export const BONDING_STRATEGIES = { electroneg_ratio, solid_angle };
|
|
600
|
+
// Memo for the costly neighbor search: WeakMap keyed by structure (GC'd with it), each holding a
|
|
601
|
+
// per-signature (strategy + JSON options) map of results. The multi-side view's 4 panes share one
|
|
602
|
+
// search (identical inputs, one flush); the per-signature map also lets alternating
|
|
603
|
+
// strategies/options on the same structure reuse earlier results instead of thrashing one slot.
|
|
604
|
+
const bond_memo = new WeakMap();
|
|
605
|
+
export function compute_bonds(structure, strategy, options = {}) {
|
|
606
|
+
const sig = `${strategy}:${JSON.stringify(options)}`;
|
|
607
|
+
let by_sig = bond_memo.get(structure);
|
|
608
|
+
const cached = by_sig?.get(sig);
|
|
609
|
+
if (cached)
|
|
610
|
+
return cached;
|
|
611
|
+
const bonds = BONDING_STRATEGIES[strategy](structure, options);
|
|
612
|
+
if (!by_sig)
|
|
613
|
+
bond_memo.set(structure, (by_sig = new Map()));
|
|
614
|
+
by_sig.set(sig, bonds);
|
|
615
|
+
return bonds;
|
|
616
|
+
}
|
|
542
617
|
// Electronegativity-based bonding with chemical preferences.
|
|
543
618
|
// This algorithm considers electronegativity differences between atoms, metal/nonmetal
|
|
544
619
|
// properties, and distance to determine bond strength. Bonds are only created if the
|
|
@@ -551,25 +626,50 @@ metal_nonmetal_bonus = 1.5, // Strength bonus for metal-nonmetal bonds
|
|
|
551
626
|
similar_electronegativity_bonus = 1.2, // Bonus for similar electronegativity
|
|
552
627
|
same_species_penalty = 0.5, // Penalty for bonds between same element
|
|
553
628
|
strength_threshold = 0.3, // Minimum bond strength to include in results
|
|
554
|
-
|
|
629
|
+
// Only iterate the first `center_count` sites as bond centers (default: all).
|
|
630
|
+
// Coordination coloring sets this to the original-atom count so appended PBC image
|
|
631
|
+
// atoms are used as neighbors but not iterated as centers — identical coordination
|
|
632
|
+
// for the originals (by translational symmetry), far cheaper when images dominate.
|
|
633
|
+
center_count = Infinity, } = {}) {
|
|
555
634
|
const { sites } = structure;
|
|
556
635
|
if (sites.length < 2)
|
|
557
636
|
return [];
|
|
558
637
|
const bonds = [];
|
|
559
638
|
const min_dist_sq = min_bond_dist ** 2;
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
639
|
+
// Per-site properties in flat typed arrays - the pair loop below visits
|
|
640
|
+
// millions of candidate pairs in large supercells, so object property chains
|
|
641
|
+
// and Map lookups are replaced with indexed array reads.
|
|
642
|
+
const n_sites = sites.length;
|
|
643
|
+
const n_center = Math.min(center_count, n_sites - 1);
|
|
644
|
+
const electronegs = new Float64Array(n_sites);
|
|
645
|
+
const radii = new Float64Array(n_sites); // 0 = no covalent radius known
|
|
646
|
+
const metal_flags = new Uint8Array(n_sites);
|
|
647
|
+
const nonmetal_flags = new Uint8Array(n_sites);
|
|
648
|
+
const elem_ids = new Int32Array(n_sites); // same-species check via integer ids
|
|
649
|
+
const orig_idxs = new Int32Array(n_sites);
|
|
650
|
+
const elem_id_lookup = new Map();
|
|
651
|
+
for (let idx = 0; idx < n_sites; idx++) {
|
|
652
|
+
const elem = get_majority_element(sites[idx]);
|
|
653
|
+
const data = elem ? element_lookup.get(elem) : undefined;
|
|
654
|
+
electronegs[idx] = data?.electronegativity ?? 2.0;
|
|
655
|
+
metal_flags[idx] = data?.metal ? 1 : 0;
|
|
656
|
+
nonmetal_flags[idx] = data?.nonmetal ? 1 : 0;
|
|
657
|
+
radii[idx] = (elem ? covalent_radii.get(elem) : undefined) ?? 0;
|
|
658
|
+
let elem_id = elem_id_lookup.get(elem ?? ``);
|
|
659
|
+
if (elem_id === undefined) {
|
|
660
|
+
elem_id = elem_id_lookup.size;
|
|
661
|
+
elem_id_lookup.set(elem ?? ``, elem_id);
|
|
662
|
+
}
|
|
663
|
+
elem_ids[idx] = elem_id;
|
|
664
|
+
// Valid orig indices always reference a site in this structure; fall back to
|
|
665
|
+
// the site's own index on malformed orig_*_idx properties so the typed
|
|
666
|
+
// `closest` array below stays bounded by n_sites
|
|
667
|
+
const orig_idx = get_orig_idx(sites[idx], idx);
|
|
668
|
+
orig_idxs[idx] =
|
|
669
|
+
Number.isInteger(orig_idx) && orig_idx >= 0 && orig_idx < n_sites ? orig_idx : idx;
|
|
670
|
+
}
|
|
671
|
+
// Closest normalized bond distance per original atom (typed array instead of Map)
|
|
672
|
+
const closest = new Float64Array(n_sites).fill(Infinity);
|
|
573
673
|
let max_radius = 0;
|
|
574
674
|
for (const radius of covalent_radii.values()) {
|
|
575
675
|
if (radius > max_radius)
|
|
@@ -578,30 +678,45 @@ strength_threshold = 0.3, // Minimum bond strength to include in results
|
|
|
578
678
|
const max_cutoff = max_radius * 2 * max_distance_ratio;
|
|
579
679
|
const spatial = setup_spatial_grid(sites, max_cutoff);
|
|
580
680
|
const potential_bonds = [];
|
|
581
|
-
for (let idx_a = 0; idx_a <
|
|
681
|
+
for (let idx_a = 0; idx_a < n_center; idx_a++) {
|
|
682
|
+
const radius_a = radii[idx_a];
|
|
683
|
+
if (radius_a === 0)
|
|
684
|
+
continue; // no covalent radius -> no pairs (symmetric: idx_b skips too)
|
|
582
685
|
const [x1, y1, z1] = sites[idx_a].xyz;
|
|
583
|
-
const
|
|
686
|
+
const electroneg_a = electronegs[idx_a];
|
|
687
|
+
const is_metal_a = metal_flags[idx_a] === 1;
|
|
688
|
+
const is_nonmetal_a = nonmetal_flags[idx_a] === 1;
|
|
689
|
+
const elem_id_a = elem_ids[idx_a];
|
|
584
690
|
for (const idx_b of get_candidates(sites[idx_a].xyz, sites, spatial)) {
|
|
585
691
|
if (idx_b <= idx_a)
|
|
586
692
|
continue;
|
|
693
|
+
const radius_b = radii[idx_b];
|
|
694
|
+
if (radius_b === 0)
|
|
695
|
+
continue;
|
|
587
696
|
const [x2, y2, z2] = sites[idx_b].xyz;
|
|
588
|
-
const
|
|
589
|
-
const
|
|
697
|
+
const dx = x2 - x1;
|
|
698
|
+
const dy = y2 - y1;
|
|
699
|
+
const dz = z2 - z1;
|
|
590
700
|
const dist_sq = dx * dx + dy * dy + dz * dz;
|
|
591
|
-
|
|
592
|
-
if (dist_sq < min_dist_sq || !props_a.radius || !props_b.radius)
|
|
701
|
+
if (dist_sq < min_dist_sq)
|
|
593
702
|
continue;
|
|
594
|
-
|
|
595
|
-
|
|
703
|
+
// Compare squared distances to defer the sqrt until a pair survives the
|
|
704
|
+
// cutoff (the vast majority of candidate pairs are rejected here)
|
|
705
|
+
const expected = radius_a + radius_b;
|
|
706
|
+
const max_dist = expected * max_distance_ratio;
|
|
707
|
+
if (dist_sq > max_dist * max_dist)
|
|
596
708
|
continue;
|
|
597
|
-
const
|
|
598
|
-
const
|
|
709
|
+
const dist = Math.sqrt(dist_sq);
|
|
710
|
+
const electroneg_b = electronegs[idx_b];
|
|
711
|
+
const electroneg_diff = Math.abs(electroneg_a - electroneg_b);
|
|
712
|
+
const electroneg_balance = electroneg_diff / (electroneg_a + electroneg_b);
|
|
713
|
+
const is_metal_b = metal_flags[idx_b] === 1;
|
|
714
|
+
const is_nonmetal_b = nonmetal_flags[idx_b] === 1;
|
|
599
715
|
let bond_strength = 1.0;
|
|
600
|
-
if (
|
|
716
|
+
if (is_metal_a && is_metal_b) {
|
|
601
717
|
bond_strength *= metal_metal_penalty;
|
|
602
718
|
}
|
|
603
|
-
else if ((
|
|
604
|
-
(props_a.is_nonmetal && props_b.is_metal)) {
|
|
719
|
+
else if ((is_metal_a && is_nonmetal_b) || (is_nonmetal_a && is_metal_b)) {
|
|
605
720
|
bond_strength *= metal_nonmetal_bonus;
|
|
606
721
|
if (electroneg_diff > electronegativity_threshold)
|
|
607
722
|
bond_strength *= 1.3;
|
|
@@ -612,25 +727,23 @@ strength_threshold = 0.3, // Minimum bond strength to include in results
|
|
|
612
727
|
const dist_weight = Math.exp(-((dist / expected - 1) ** 2) / 0.18);
|
|
613
728
|
const electroneg_weight = 1.0 - 0.3 * electroneg_balance;
|
|
614
729
|
let strength = bond_strength * dist_weight * electroneg_weight;
|
|
615
|
-
if (
|
|
730
|
+
if (elem_id_a === elem_ids[idx_b])
|
|
616
731
|
strength *= same_species_penalty;
|
|
617
732
|
// If raw strength is already too low, we can skip early
|
|
618
733
|
// (penalty will only reduce it further)
|
|
619
734
|
if (strength <= strength_threshold)
|
|
620
735
|
continue;
|
|
621
|
-
// Use
|
|
622
|
-
const orig_idx_a =
|
|
623
|
-
const orig_idx_b =
|
|
736
|
+
// Use precomputed original-site indices to handle supercell and image atoms
|
|
737
|
+
const orig_idx_a = orig_idxs[idx_a];
|
|
738
|
+
const orig_idx_b = orig_idxs[idx_b];
|
|
624
739
|
// Update closest known normalized distance (dist / expected) for original atoms
|
|
625
740
|
// Normalized distance handles atoms of different sizes better than raw distance
|
|
626
741
|
// (e.g. C-H is short but C-C is longer; we don't want C-H to penalize C-C just because H is small)
|
|
627
742
|
const norm_dist = dist / expected;
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
if (norm_dist < closest_dist_b)
|
|
633
|
-
closest.set(orig_idx_b, norm_dist);
|
|
743
|
+
if (norm_dist < closest[orig_idx_a])
|
|
744
|
+
closest[orig_idx_a] = norm_dist;
|
|
745
|
+
if (norm_dist < closest[orig_idx_b])
|
|
746
|
+
closest[orig_idx_b] = norm_dist;
|
|
634
747
|
potential_bonds.push({
|
|
635
748
|
site_idx_1: idx_a,
|
|
636
749
|
site_idx_2: idx_b,
|
|
@@ -645,8 +758,8 @@ strength_threshold = 0.3, // Minimum bond strength to include in results
|
|
|
645
758
|
// Second pass: Apply penalties and filter
|
|
646
759
|
for (const bond of potential_bonds) {
|
|
647
760
|
const { site_idx_1, site_idx_2, dist, expected_dist, base_strength, orig_idx_a, orig_idx_b, } = bond;
|
|
648
|
-
const closest_dist_a = closest
|
|
649
|
-
const closest_dist_b = closest
|
|
761
|
+
const closest_dist_a = closest[orig_idx_a];
|
|
762
|
+
const closest_dist_b = closest[orig_idx_b];
|
|
650
763
|
const norm_dist = dist / expected_dist;
|
|
651
764
|
let strength = base_strength;
|
|
652
765
|
// Apply penalty if this bond is much longer (relative to radii) than the closest known bond
|
|
@@ -657,15 +770,7 @@ strength_threshold = 0.3, // Minimum bond strength to include in results
|
|
|
657
770
|
strength *= Math.exp(-(norm_dist / closest_dist_b - 1) / 0.5);
|
|
658
771
|
}
|
|
659
772
|
if (strength > strength_threshold) {
|
|
660
|
-
bonds.push(
|
|
661
|
-
pos_1: sites[site_idx_1].xyz,
|
|
662
|
-
pos_2: sites[site_idx_2].xyz,
|
|
663
|
-
site_idx_1,
|
|
664
|
-
site_idx_2,
|
|
665
|
-
bond_length: dist,
|
|
666
|
-
strength,
|
|
667
|
-
transform_matrix: compute_bond_transform(sites[site_idx_1].xyz, sites[site_idx_2].xyz),
|
|
668
|
-
});
|
|
773
|
+
bonds.push(make_bond(sites, site_idx_1, site_idx_2, dist, strength));
|
|
669
774
|
}
|
|
670
775
|
}
|
|
671
776
|
return apply_explicit_bond_metadata(structure, bonds);
|
|
@@ -675,7 +780,8 @@ strength_threshold = 0.3, // Minimum bond strength to include in results
|
|
|
675
780
|
// This algorithm computes bond strength based on the solid angle subtended by atoms
|
|
676
781
|
// and their distance penalty. Bonds are only created if the computed strength exceeds
|
|
677
782
|
// the strength_threshold parameter.
|
|
678
|
-
export function solid_angle(structure, { min_solid_angle = 0.01, min_face_area = 0.05, max_distance = 5.0, min_bond_dist = 0.4, strength_threshold = 0.05,
|
|
783
|
+
export function solid_angle(structure, { min_solid_angle = 0.01, min_face_area = 0.05, max_distance = 5.0, min_bond_dist = 0.4, strength_threshold = 0.05, center_count = Infinity, // see electroneg_ratio: limit bond centers to first N sites
|
|
784
|
+
} = {}) {
|
|
679
785
|
const { sites } = structure;
|
|
680
786
|
if (sites.length < 2)
|
|
681
787
|
return [];
|
|
@@ -683,16 +789,17 @@ export function solid_angle(structure, { min_solid_angle = 0.01, min_face_area =
|
|
|
683
789
|
const min_dist_sq = min_bond_dist ** 2;
|
|
684
790
|
const max_dist_sq = max_distance ** 2;
|
|
685
791
|
const spatial = setup_spatial_grid(sites, max_distance);
|
|
686
|
-
|
|
792
|
+
const n_center = Math.min(center_count, sites.length - 1);
|
|
793
|
+
for (let idx_a = 0; idx_a < n_center; idx_a++) {
|
|
687
794
|
const [x1, y1, z1] = sites[idx_a].xyz;
|
|
688
|
-
const
|
|
689
|
-
const radius_a =
|
|
795
|
+
const elem_a = get_majority_element(sites[idx_a]);
|
|
796
|
+
const radius_a = elem_a ? covalent_radii.get(elem_a) : undefined;
|
|
690
797
|
for (const idx_b of get_candidates(sites[idx_a].xyz, sites, spatial)) {
|
|
691
798
|
if (idx_b <= idx_a)
|
|
692
799
|
continue;
|
|
693
800
|
const [x2, y2, z2] = sites[idx_b].xyz;
|
|
694
|
-
const
|
|
695
|
-
const radius_b =
|
|
801
|
+
const elem_b = get_majority_element(sites[idx_b]);
|
|
802
|
+
const radius_b = elem_b ? covalent_radii.get(elem_b) : undefined;
|
|
696
803
|
const [dx, dy, dz] = [x2 - x1, y2 - y1, z2 - z1];
|
|
697
804
|
const dist_sq = dx * dx + dy * dy + dz * dz;
|
|
698
805
|
const dist = Math.sqrt(dist_sq);
|
|
@@ -708,15 +815,7 @@ export function solid_angle(structure, { min_solid_angle = 0.01, min_face_area =
|
|
|
708
815
|
const angle_strength = Math.min(bond_solid_angle / (4.0 * Math.PI), 1.0);
|
|
709
816
|
const strength = angle_strength * dist_penalty;
|
|
710
817
|
if (strength > strength_threshold) {
|
|
711
|
-
bonds.push(
|
|
712
|
-
pos_1: sites[idx_a].xyz,
|
|
713
|
-
pos_2: sites[idx_b].xyz,
|
|
714
|
-
site_idx_1: idx_a,
|
|
715
|
-
site_idx_2: idx_b,
|
|
716
|
-
bond_length: dist,
|
|
717
|
-
strength,
|
|
718
|
-
transform_matrix: compute_bond_transform(sites[idx_a].xyz, sites[idx_b].xyz),
|
|
719
|
-
});
|
|
818
|
+
bonds.push(make_bond(sites, idx_a, idx_b, dist, strength));
|
|
720
819
|
}
|
|
721
820
|
}
|
|
722
821
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type HistoryStacks<T> = [undo_stack: T[], redo_stack: T[]];
|
|
2
|
+
export declare function push_edit<T>([undo_stack]: HistoryStacks<T>, snapshot: T, max_history: number): HistoryStacks<T>;
|
|
3
|
+
export declare function step_history<T>([undo_stack, redo_stack]: HistoryStacks<T>, direction: `undo` | `redo`, current: T): {
|
|
4
|
+
stacks: HistoryStacks<T>;
|
|
5
|
+
restored: T;
|
|
6
|
+
} | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Pure undo/redo stack mechanics for Structure.svelte's edit-atoms history.
|
|
2
|
+
// Stacks are treated as immutable (updates return new arrays) so they work with
|
|
3
|
+
// $state.raw holders where only reassignment is reactive. Kept free of
|
|
4
|
+
// component state so the real logic (not a test-local mirror) is unit-testable.
|
|
5
|
+
// Record a new edit: push `snapshot` onto the undo stack (trimming to
|
|
6
|
+
// `max_history` entries) and invalidate the redo stack.
|
|
7
|
+
export function push_edit([undo_stack], snapshot, max_history) {
|
|
8
|
+
const trimmed = undo_stack.length >= max_history
|
|
9
|
+
? undo_stack.slice(undo_stack.length - max_history + 1)
|
|
10
|
+
: undo_stack;
|
|
11
|
+
return [[...trimmed, snapshot], []];
|
|
12
|
+
}
|
|
13
|
+
// Step the history in `direction`: pop that stack's top as the state to
|
|
14
|
+
// restore, pushing `current` onto the opposite stack. Returns null when there
|
|
15
|
+
// is nothing to step to (callers should snapshot `current` lazily by checking
|
|
16
|
+
// stack length first if snapshots are expensive).
|
|
17
|
+
export function step_history([undo_stack, redo_stack], direction, current) {
|
|
18
|
+
const source = direction === `undo` ? undo_stack : redo_stack;
|
|
19
|
+
const restored = source.at(-1);
|
|
20
|
+
if (restored === undefined)
|
|
21
|
+
return null;
|
|
22
|
+
const remaining = source.slice(0, -1);
|
|
23
|
+
const stacks = direction === `undo`
|
|
24
|
+
? [remaining, [...redo_stack, current]]
|
|
25
|
+
: [[...undo_stack, current], remaining];
|
|
26
|
+
return { stacks, restored };
|
|
27
|
+
}
|
|
@@ -7,14 +7,35 @@ export declare function has_color_property(mat: Material): mat is Material & {
|
|
|
7
7
|
export declare function extract_bond_color_for_instance(geometry: BufferGeometry, instance_idx: number): Color | null;
|
|
8
8
|
export declare function clean_geometry_for_export(geometry: BufferGeometry): void;
|
|
9
9
|
export declare function generate_mtl_content(scene: Scene): string;
|
|
10
|
+
export declare function convert_instanced_meshes_to_regular(scene: Scene): Scene;
|
|
10
11
|
export declare function create_structure_filename(structure: AnyStructure | undefined, extension: string): string;
|
|
11
12
|
export declare function structure_to_xyz_str(structure?: AnyStructure): string;
|
|
12
13
|
export declare function structure_to_cif_str(structure?: AnyStructure): string;
|
|
13
14
|
export declare function structure_to_poscar_str(structure?: AnyStructure): string;
|
|
14
15
|
export declare function structure_to_json_str(structure?: AnyStructure): string;
|
|
15
|
-
export declare
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export declare const STRUCT_TEXT_FORMATS: {
|
|
17
|
+
readonly json: {
|
|
18
|
+
readonly to_str: typeof structure_to_json_str;
|
|
19
|
+
readonly ext: "json";
|
|
20
|
+
readonly mime: "application/json";
|
|
21
|
+
};
|
|
22
|
+
readonly xyz: {
|
|
23
|
+
readonly to_str: typeof structure_to_xyz_str;
|
|
24
|
+
readonly ext: "xyz";
|
|
25
|
+
readonly mime: "text/plain";
|
|
26
|
+
};
|
|
27
|
+
readonly cif: {
|
|
28
|
+
readonly to_str: typeof structure_to_cif_str;
|
|
29
|
+
readonly ext: "cif";
|
|
30
|
+
readonly mime: "chemical/x-cif";
|
|
31
|
+
};
|
|
32
|
+
readonly poscar: {
|
|
33
|
+
readonly to_str: typeof structure_to_poscar_str;
|
|
34
|
+
readonly ext: "poscar";
|
|
35
|
+
readonly mime: "text/plain";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type StructTextFormat = keyof typeof STRUCT_TEXT_FORMATS;
|
|
39
|
+
export declare function export_structure_as(fmt: StructTextFormat, structure?: AnyStructure): void;
|
|
19
40
|
export declare function export_structure_as_glb(scene: Scene | null, structure: AnyStructure | undefined): void;
|
|
20
41
|
export declare function export_structure_as_obj(scene: Scene | null, structure: AnyStructure | undefined): void;
|