matterviz 0.3.7 → 0.4.1
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/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +1 -1
- package/dist/api/optimade.js +32 -26
- package/dist/app.css +0 -3
- package/dist/brillouin/BrillouinZone.svelte +76 -148
- package/dist/brillouin/BrillouinZone.svelte.d.ts +6 -14
- package/dist/brillouin/BrillouinZoneExportPane.svelte +43 -96
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +9 -32
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +97 -205
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +4 -23
- package/dist/brillouin/BrillouinZoneTooltip.svelte +16 -25
- 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 +89 -90
- 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 +14 -13
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +109 -203
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +180 -470
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
- package/dist/chempot-diagram/async-compute.svelte.js +3 -1
- package/dist/chempot-diagram/chempot-worker.js +2 -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 +4 -4
- package/dist/chempot-diagram/compute.js +20 -20
- 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.js +8 -7
- package/dist/composition/FormulaFilter.svelte +18 -11
- package/dist/composition/PieChart.svelte +11 -10
- package/dist/composition/chem-sys.d.ts +8 -0
- package/dist/composition/chem-sys.js +86 -0
- package/dist/composition/format.js +7 -4
- package/dist/composition/index.d.ts +1 -0
- package/dist/composition/index.js +1 -0
- package/dist/composition/parse.d.ts +0 -1
- package/dist/composition/parse.js +41 -31
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +0 -1
- package/dist/convex-hull/ConvexHull.svelte +8 -10
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
- package/dist/convex-hull/ConvexHull2D.svelte +106 -185
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +179 -683
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +183 -687
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +268 -0
- package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
- package/dist/convex-hull/ConvexHullControls.svelte +88 -7
- 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 +36 -175
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +11 -2
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
- package/dist/convex-hull/GasPressureControls.svelte +4 -4
- package/dist/convex-hull/TemperatureSlider.svelte +2 -2
- 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 +278 -0
- package/dist/convex-hull/demo-temperature.d.ts +1 -1
- package/dist/convex-hull/demo-temperature.js +20 -22
- package/dist/convex-hull/gas-thermodynamics.d.ts +2 -2
- package/dist/convex-hull/gas-thermodynamics.js +22 -30
- package/dist/convex-hull/helpers.d.ts +42 -7
- package/dist/convex-hull/helpers.js +171 -78
- 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 +10 -8
- package/dist/convex-hull/index.js +7 -2
- package/dist/convex-hull/thermodynamics.js +136 -960
- package/dist/convex-hull/types.d.ts +13 -5
- package/dist/convex-hull/types.js +12 -0
- package/dist/coordination/CoordinationBarPlot.svelte +27 -34
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
- package/dist/element/BohrAtom.svelte +2 -1
- package/dist/element/index.d.ts +4 -0
- package/dist/element/index.js +18 -0
- package/dist/feedback/DragOverlay.svelte +3 -1
- package/dist/feedback/DragOverlay.svelte.d.ts +1 -0
- package/dist/feedback/StatusMessage.svelte +13 -3
- package/dist/fermi-surface/FermiSlice.svelte +13 -5
- package/dist/fermi-surface/FermiSurface.svelte +78 -151
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +5 -14
- package/dist/fermi-surface/FermiSurfaceControls.svelte +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +72 -221
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +8 -34
- package/dist/fermi-surface/compute.js +67 -66
- package/dist/fermi-surface/export.js +6 -16
- 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 +71 -79
- package/dist/fermi-surface/types.d.ts +3 -2
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +69 -52
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +4 -3
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +3 -2
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
- package/dist/heatmap-matrix/index.d.ts +3 -2
- package/dist/heatmap-matrix/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/ExportPane.svelte +166 -0
- package/dist/io/ExportPane.svelte.d.ts +17 -0
- package/dist/io/decompress.js +5 -4
- package/dist/io/export.d.ts +9 -5
- package/dist/io/export.js +77 -51
- package/dist/io/fetch.d.ts +2 -1
- package/dist/io/fetch.js +5 -1
- package/dist/io/file-drop.d.ts +8 -1
- package/dist/io/file-drop.js +48 -36
- package/dist/io/index.d.ts +2 -0
- package/dist/io/index.js +10 -0
- package/dist/io/types.d.ts +13 -0
- package/dist/io/url-drop.js +64 -33
- package/dist/isosurface/parse.js +52 -51
- package/dist/isosurface/slice.js +5 -4
- package/dist/isosurface/types.js +1 -1
- package/dist/keyboard.d.ts +3 -0
- package/dist/keyboard.js +23 -0
- package/dist/labels.d.ts +1 -1
- package/dist/labels.js +9 -8
- package/dist/layout/FullscreenButton.svelte +33 -0
- package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
- package/dist/layout/FullscreenToggle.svelte +8 -14
- package/dist/layout/PropertyFilter.svelte +3 -2
- package/dist/layout/SettingsSection.svelte +1 -1
- package/dist/layout/ViewerChrome.svelte +116 -0
- package/dist/layout/ViewerChrome.svelte.d.ts +17 -0
- package/dist/layout/fullscreen.d.ts +4 -0
- package/dist/layout/fullscreen.svelte.d.ts +8 -0
- package/dist/layout/fullscreen.svelte.js +37 -0
- package/dist/layout/index.d.ts +3 -0
- package/dist/layout/index.js +3 -0
- package/dist/layout/json-tree/JsonNode.svelte +1 -1
- package/dist/layout/json-tree/JsonTree.svelte +2 -2
- package/dist/layout/json-tree/utils.js +5 -4
- package/dist/marching-cubes.js +8 -13
- package/dist/math.d.ts +12 -4
- package/dist/math.js +42 -30
- package/dist/overlays/DraggablePane.svelte +4 -4
- package/dist/overlays/index.d.ts +4 -0
- package/dist/periodic-table/PeriodicTable.svelte +27 -15
- package/dist/periodic-table/PropertySelect.svelte +1 -0
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +9 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramControls.svelte +3 -2
- 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 +47 -132
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +1 -1
- package/dist/phase-diagram/build-diagram.js +2 -2
- package/dist/phase-diagram/colors.js +1 -1
- package/dist/phase-diagram/parse.d.ts +2 -1
- package/dist/phase-diagram/parse.js +6 -5
- package/dist/phase-diagram/types.d.ts +1 -1
- package/dist/phase-diagram/utils.d.ts +3 -3
- package/dist/phase-diagram/utils.js +8 -12
- package/dist/plot/{BarPlot.svelte → bar/BarPlot.svelte} +246 -841
- package/dist/plot/{BarPlot.svelte.d.ts → bar/BarPlot.svelte.d.ts} +8 -16
- package/dist/plot/{BarPlotControls.svelte → bar/BarPlotControls.svelte} +6 -5
- package/dist/plot/{BarPlotControls.svelte.d.ts → bar/BarPlotControls.svelte.d.ts} +3 -3
- package/dist/plot/{SpacegroupBarPlot.svelte → bar/SpacegroupBarPlot.svelte} +8 -7
- package/dist/plot/{SpacegroupBarPlot.svelte.d.ts → bar/SpacegroupBarPlot.svelte.d.ts} +1 -1
- package/dist/plot/bar/data.d.ts +40 -0
- package/dist/plot/bar/data.js +154 -0
- package/dist/plot/bar/geometry.d.ts +39 -0
- package/dist/plot/bar/geometry.js +60 -0
- package/dist/plot/bar/index.d.ts +3 -0
- package/dist/plot/bar/index.js +3 -0
- package/dist/plot/box/BoxPlot.svelte +1292 -0
- package/dist/plot/box/BoxPlot.svelte.d.ts +95 -0
- package/dist/plot/box/BoxPlotControls.svelte +109 -0
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +19 -0
- package/dist/plot/box/Violin.svelte +14 -0
- package/dist/plot/box/Violin.svelte.d.ts +70 -0
- package/dist/plot/box/box-plot.d.ts +56 -0
- package/dist/plot/box/box-plot.js +129 -0
- package/dist/plot/box/index.d.ts +5 -0
- package/dist/plot/box/index.js +5 -0
- package/dist/plot/box/kde.d.ts +17 -0
- package/dist/plot/box/kde.js +160 -0
- package/dist/plot/box/quantile.d.ts +3 -0
- package/dist/plot/box/quantile.js +53 -0
- package/dist/plot/{auto-place.d.ts → core/auto-place.d.ts} +1 -1
- package/dist/plot/{auto-place.js → core/auto-place.js} +6 -3
- package/dist/plot/core/axis-utils.d.ts +46 -0
- package/dist/plot/core/axis-utils.js +110 -0
- package/dist/plot/{AxisLabel.svelte → core/components/AxisLabel.svelte} +2 -2
- package/dist/plot/{AxisLabel.svelte.d.ts → core/components/AxisLabel.svelte.d.ts} +1 -1
- package/dist/plot/{ColorBar.svelte → core/components/ColorBar.svelte} +41 -38
- package/dist/plot/{ColorBar.svelte.d.ts → core/components/ColorBar.svelte.d.ts} +7 -6
- package/dist/plot/{ColorScaleSelect.svelte → core/components/ColorScaleSelect.svelte} +4 -3
- package/dist/plot/{ColorScaleSelect.svelte.d.ts → core/components/ColorScaleSelect.svelte.d.ts} +2 -2
- package/dist/plot/core/components/ControlPane.svelte +46 -0
- package/dist/plot/core/components/ControlPane.svelte.d.ts +13 -0
- package/dist/plot/{FillArea.svelte → core/components/FillArea.svelte} +17 -6
- package/dist/plot/{FillArea.svelte.d.ts → core/components/FillArea.svelte.d.ts} +1 -1
- package/dist/plot/{InteractiveAxisLabel.svelte → core/components/InteractiveAxisLabel.svelte} +3 -3
- package/dist/plot/{InteractiveAxisLabel.svelte.d.ts → core/components/InteractiveAxisLabel.svelte.d.ts} +2 -2
- package/dist/plot/{Line.svelte → core/components/Line.svelte} +33 -15
- package/dist/plot/{Line.svelte.d.ts → core/components/Line.svelte.d.ts} +3 -2
- package/dist/plot/{PlotAxis.svelte → core/components/PlotAxis.svelte} +9 -6
- package/dist/plot/{PlotAxis.svelte.d.ts → core/components/PlotAxis.svelte.d.ts} +5 -3
- package/dist/plot/{PlotControls.svelte → core/components/PlotControls.svelte} +17 -29
- package/dist/plot/core/components/PlotControls.svelte.d.ts +4 -0
- package/dist/plot/{PlotLegend.svelte → core/components/PlotLegend.svelte} +21 -10
- package/dist/plot/{PlotLegend.svelte.d.ts → core/components/PlotLegend.svelte.d.ts} +3 -2
- package/dist/plot/{PlotTooltip.svelte → core/components/PlotTooltip.svelte} +17 -1
- package/dist/plot/{PlotTooltip.svelte.d.ts → core/components/PlotTooltip.svelte.d.ts} +8 -0
- package/dist/plot/{PortalSelect.svelte → core/components/PortalSelect.svelte} +11 -7
- package/dist/plot/{ReferenceLine.svelte → core/components/ReferenceLine.svelte} +3 -3
- package/dist/plot/{ReferenceLine.svelte.d.ts → core/components/ReferenceLine.svelte.d.ts} +1 -1
- package/dist/plot/{ReferenceLine3D.svelte → core/components/ReferenceLine3D.svelte} +5 -5
- package/dist/plot/{ReferenceLine3D.svelte.d.ts → core/components/ReferenceLine3D.svelte.d.ts} +5 -5
- package/dist/plot/{ReferencePlane.svelte → core/components/ReferencePlane.svelte} +8 -8
- package/dist/plot/{ReferencePlane.svelte.d.ts → core/components/ReferencePlane.svelte.d.ts} +5 -5
- package/dist/plot/{ZeroLines.svelte → core/components/ZeroLines.svelte} +3 -3
- package/dist/plot/{ZeroLines.svelte.d.ts → core/components/ZeroLines.svelte.d.ts} +3 -3
- package/dist/plot/{ZoomRect.svelte → core/components/ZoomRect.svelte} +1 -1
- package/dist/plot/{ZoomRect.svelte.d.ts → core/components/ZoomRect.svelte.d.ts} +1 -1
- package/dist/plot/core/components/index.d.ts +17 -0
- package/dist/plot/core/components/index.js +17 -0
- package/dist/plot/{data-cleaning.d.ts → core/data-cleaning.d.ts} +71 -1
- package/dist/plot/{data-cleaning.js → core/data-cleaning.js} +21 -23
- package/dist/plot/{data-transform.d.ts → core/data-transform.d.ts} +2 -2
- package/dist/plot/{data-transform.js → core/data-transform.js} +3 -3
- package/dist/plot/core/fill-utils.d.ts +34 -0
- package/dist/plot/core/fill-utils.js +391 -0
- package/dist/plot/core/index.d.ts +10 -0
- package/dist/plot/core/index.js +11 -0
- package/dist/plot/core/interactions.d.ts +39 -0
- package/dist/plot/core/interactions.js +209 -0
- package/dist/plot/{layout.d.ts → core/layout.d.ts} +1 -0
- package/dist/plot/{layout.js → core/layout.js} +16 -8
- 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/{reference-line.d.ts → core/reference-line.d.ts} +11 -11
- package/dist/plot/{reference-line.js → core/reference-line.js} +29 -42
- package/dist/plot/core/scales.d.ts +40 -0
- package/dist/plot/{scales.js → core/scales.js} +94 -93
- package/dist/plot/core/svg.d.ts +3 -0
- package/dist/plot/core/svg.js +41 -0
- package/dist/plot/{types.d.ts → core/types.d.ts} +36 -85
- package/dist/plot/{types.js → core/types.js} +1 -1
- package/dist/plot/{utils → core/utils}/label-placement.d.ts +3 -3
- package/dist/plot/{utils → core/utils}/label-placement.js +3 -3
- package/dist/plot/core/utils/series-visibility.d.ts +26 -0
- package/dist/plot/{utils → core/utils}/series-visibility.js +29 -2
- package/dist/plot/core/utils.d.ts +12 -0
- package/dist/plot/core/utils.js +27 -0
- package/dist/plot/{Histogram.svelte → histogram/Histogram.svelte} +174 -551
- package/dist/plot/{Histogram.svelte.d.ts → histogram/Histogram.svelte.d.ts} +2 -2
- package/dist/plot/{HistogramControls.svelte → histogram/HistogramControls.svelte} +6 -6
- package/dist/plot/{HistogramControls.svelte.d.ts → histogram/HistogramControls.svelte.d.ts} +4 -4
- package/dist/plot/histogram/index.d.ts +2 -0
- package/dist/plot/histogram/index.js +2 -0
- package/dist/plot/index.d.ts +8 -41
- package/dist/plot/index.js +10 -39
- package/dist/plot/sankey/Sankey.svelte +697 -0
- package/dist/plot/sankey/Sankey.svelte.d.ts +74 -0
- package/dist/plot/sankey/SankeyControls.svelte +98 -0
- package/dist/plot/sankey/SankeyControls.svelte.d.ts +19 -0
- package/dist/plot/sankey/index.d.ts +4 -0
- package/dist/plot/sankey/index.js +3 -0
- package/dist/plot/sankey/sankey-types.d.ts +42 -0
- package/dist/plot/sankey/sankey-types.js +4 -0
- package/dist/plot/sankey/sankey.d.ts +52 -0
- package/dist/plot/sankey/sankey.js +189 -0
- package/dist/plot/{BinnedScatterPlot.svelte → scatter/BinnedScatterPlot.svelte} +64 -64
- package/dist/plot/{BinnedScatterPlot.svelte.d.ts → scatter/BinnedScatterPlot.svelte.d.ts} +6 -6
- package/dist/plot/{ElementScatter.svelte → scatter/ElementScatter.svelte} +6 -6
- package/dist/plot/{ElementScatter.svelte.d.ts → scatter/ElementScatter.svelte.d.ts} +2 -2
- package/dist/plot/{ScatterPlot.svelte → scatter/ScatterPlot.svelte} +297 -1008
- package/dist/plot/{ScatterPlot.svelte.d.ts → scatter/ScatterPlot.svelte.d.ts} +10 -18
- package/dist/plot/{ScatterPlotControls.svelte → scatter/ScatterPlotControls.svelte} +6 -5
- package/dist/plot/{ScatterPlotControls.svelte.d.ts → scatter/ScatterPlotControls.svelte.d.ts} +2 -2
- package/dist/plot/{ScatterPoint.svelte → scatter/ScatterPoint.svelte} +7 -7
- package/dist/plot/{ScatterPoint.svelte.d.ts → scatter/ScatterPoint.svelte.d.ts} +3 -3
- package/dist/plot/{adaptive-density.d.ts → scatter/adaptive-density.d.ts} +14 -4
- package/dist/plot/{adaptive-density.js → scatter/adaptive-density.js} +46 -20
- package/dist/plot/{binned-scatter-types.d.ts → scatter/binned-scatter-types.d.ts} +5 -12
- package/dist/plot/scatter/index.d.ts +7 -0
- package/dist/plot/scatter/index.js +5 -0
- package/dist/plot/scatter/scatter-data.d.ts +19 -0
- package/dist/plot/scatter/scatter-data.js +212 -0
- package/dist/plot/{ScatterPlot3D.svelte → scatter-3d/ScatterPlot3D.svelte} +25 -34
- package/dist/plot/{ScatterPlot3D.svelte.d.ts → scatter-3d/ScatterPlot3D.svelte.d.ts} +9 -17
- package/dist/plot/{ScatterPlot3DControls.svelte → scatter-3d/ScatterPlot3DControls.svelte} +14 -14
- package/dist/plot/{ScatterPlot3DControls.svelte.d.ts → scatter-3d/ScatterPlot3DControls.svelte.d.ts} +6 -6
- package/dist/plot/{ScatterPlot3DScene.svelte → scatter-3d/ScatterPlot3DScene.svelte} +129 -128
- package/dist/plot/{ScatterPlot3DScene.svelte.d.ts → scatter-3d/ScatterPlot3DScene.svelte.d.ts} +6 -15
- package/dist/plot/{Surface3D.svelte → scatter-3d/Surface3D.svelte} +7 -6
- package/dist/plot/{Surface3D.svelte.d.ts → scatter-3d/Surface3D.svelte.d.ts} +5 -4
- package/dist/plot/scatter-3d/index.d.ts +4 -0
- package/dist/plot/scatter-3d/index.js +4 -0
- package/dist/plot/sunburst/Sunburst.svelte +1041 -0
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +97 -0
- package/dist/plot/sunburst/SunburstControls.svelte +200 -0
- package/dist/plot/sunburst/SunburstControls.svelte.d.ts +26 -0
- package/dist/plot/sunburst/index.d.ts +4 -0
- package/dist/plot/sunburst/index.js +4 -0
- package/dist/plot/sunburst/render.d.ts +34 -0
- package/dist/plot/sunburst/render.js +122 -0
- package/dist/plot/sunburst/sunburst.d.ts +62 -0
- package/dist/plot/sunburst/sunburst.js +269 -0
- package/dist/rdf/RdfPlot.svelte +2 -1
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/calc-rdf.js +11 -24
- 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 +14 -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 +79 -3
- package/dist/settings.js +321 -1
- package/dist/spectral/Bands.svelte +47 -36
- package/dist/spectral/Bands.svelte.d.ts +6 -6
- package/dist/spectral/BandsAndDos.svelte +23 -25
- package/dist/spectral/BrillouinBandsDos.svelte +42 -30
- package/dist/spectral/Dos.svelte +15 -23
- package/dist/spectral/Dos.svelte.d.ts +4 -3
- package/dist/spectral/helpers.d.ts +8 -6
- package/dist/spectral/helpers.js +137 -65
- package/dist/state.svelte.d.ts +0 -7
- package/dist/state.svelte.js +0 -6
- package/dist/structure/Arrow.svelte +2 -4
- package/dist/structure/AtomLegend.svelte +8 -9
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/CanvasTooltip.svelte +1 -0
- package/dist/structure/CellSelect.svelte +12 -5
- package/dist/structure/CellSelect.svelte.d.ts +2 -1
- package/dist/structure/Cylinder.svelte +12 -8
- package/dist/structure/Cylinder.svelte.d.ts +4 -1
- package/dist/structure/Lattice.svelte +2 -2
- package/dist/structure/Structure.svelte +365 -423
- package/dist/structure/Structure.svelte.d.ts +5 -15
- package/dist/structure/StructureControls.svelte +217 -2
- package/dist/structure/StructureControls.svelte.d.ts +5 -3
- package/dist/structure/StructureExportPane.svelte +54 -156
- package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
- package/dist/structure/StructureInfoPane.svelte +10 -9
- package/dist/structure/StructureInfoPane.svelte.d.ts +5 -5
- package/dist/structure/StructureScene.svelte +376 -208
- package/dist/structure/StructureScene.svelte.d.ts +22 -20
- package/dist/structure/{label-placement.d.ts → atom-label-placement.d.ts} +3 -3
- package/dist/structure/{label-placement.js → atom-label-placement.js} +15 -5
- package/dist/structure/atom-properties.d.ts +1 -1
- package/dist/structure/atom-properties.js +17 -22
- package/dist/structure/bond-order-perception.js +3 -5
- package/dist/structure/bonding.d.ts +4 -0
- package/dist/structure/bonding.js +134 -63
- package/dist/structure/export.d.ts +24 -4
- package/dist/structure/export.js +89 -143
- package/dist/structure/index.d.ts +4 -4
- package/dist/structure/index.js +3 -3
- package/dist/structure/measure.d.ts +3 -2
- package/dist/structure/measure.js +6 -5
- package/dist/structure/parse.d.ts +3 -2
- package/dist/structure/parse.js +419 -438
- package/dist/structure/partial-occupancy.d.ts +0 -1
- package/dist/structure/partial-occupancy.js +1 -1
- package/dist/structure/pbc.d.ts +1 -1
- package/dist/structure/pbc.js +190 -13
- package/dist/structure/polyhedra.d.ts +41 -0
- package/dist/structure/polyhedra.js +602 -0
- package/dist/structure/site.d.ts +4 -0
- package/dist/structure/site.js +1 -0
- package/dist/structure/supercell.js +3 -2
- 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 +354 -0
- package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
- package/dist/symmetry/SymmetryStats.svelte +113 -8
- package/dist/symmetry/WyckoffTable.svelte +68 -7
- package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
- package/dist/symmetry/cell-transform.js +7 -14
- package/dist/symmetry/index.d.ts +14 -4
- package/dist/symmetry/index.js +291 -72
- package/dist/symmetry/spacegroups.d.ts +12 -1
- package/dist/symmetry/spacegroups.js +63 -14
- 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 +66 -25
- package/dist/table/HeatmapTable.svelte.d.ts +1 -1
- package/dist/table/index.d.ts +1 -3
- package/dist/table/index.js +1 -1
- package/dist/theme/index.js +8 -8
- package/dist/tooltip/KCoords.svelte +45 -0
- package/dist/tooltip/KCoords.svelte.d.ts +8 -0
- package/dist/tooltip/index.d.ts +1 -0
- package/dist/tooltip/index.js +1 -0
- package/dist/trajectory/Trajectory.svelte +123 -100
- package/dist/trajectory/Trajectory.svelte.d.ts +11 -22
- package/dist/trajectory/TrajectoryExportPane.svelte +17 -25
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
- package/dist/trajectory/TrajectoryInfoPane.svelte +5 -3
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
- package/dist/trajectory/constants.js +6 -2
- package/dist/trajectory/extract.js +17 -37
- package/dist/trajectory/format-detect.d.ts +1 -1
- package/dist/trajectory/format-detect.js +27 -19
- package/dist/trajectory/frame-reader.d.ts +0 -1
- package/dist/trajectory/frame-reader.js +63 -162
- package/dist/trajectory/helpers.d.ts +10 -2
- package/dist/trajectory/helpers.js +56 -36
- package/dist/trajectory/index.js +1 -1
- 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/hdf5.js +1 -1
- package/dist/trajectory/parse/index.d.ts +1 -1
- package/dist/trajectory/parse/index.js +65 -105
- package/dist/trajectory/parse/lammps.d.ts +0 -2
- package/dist/trajectory/parse/lammps.js +8 -6
- package/dist/trajectory/parse/pymatgen.d.ts +2 -0
- package/dist/trajectory/parse/pymatgen.js +74 -0
- package/dist/trajectory/parse/vasp.js +38 -18
- package/dist/trajectory/parse/xyz.d.ts +13 -1
- package/dist/trajectory/parse/xyz.js +102 -94
- package/dist/trajectory/plotting.d.ts +1 -2
- package/dist/trajectory/plotting.js +16 -113
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +7 -5
- package/dist/xrd/XrdPlot.svelte +16 -30
- package/dist/xrd/broadening.d.ts +2 -1
- package/dist/xrd/calc-xrd.js +18 -20
- package/dist/xrd/index.d.ts +2 -2
- package/dist/xrd/parse.js +2 -2
- package/package.json +43 -26
- 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/PlotControls.svelte.d.ts +0 -4
- package/dist/plot/axis-utils.d.ts +0 -19
- package/dist/plot/axis-utils.js +0 -78
- package/dist/plot/defaults.d.ts +0 -19
- package/dist/plot/defaults.js +0 -9
- package/dist/plot/fill-utils.d.ts +0 -46
- package/dist/plot/fill-utils.js +0 -322
- package/dist/plot/hover-lock.svelte.d.ts +0 -14
- package/dist/plot/hover-lock.svelte.js +0 -46
- package/dist/plot/interactions.d.ts +0 -12
- package/dist/plot/interactions.js +0 -101
- package/dist/plot/scales.d.ts +0 -48
- package/dist/plot/svg.d.ts +0 -1
- package/dist/plot/svg.js +0 -11
- package/dist/plot/utils/series-visibility.d.ts +0 -15
- package/dist/plot/utils.d.ts +0 -1
- package/dist/plot/utils.js +0 -14
- /package/dist/plot/{PortalSelect.svelte.d.ts → core/components/PortalSelect.svelte.d.ts} +0 -0
- /package/dist/plot/{binned-scatter-types.js → scatter/binned-scatter-types.js} +0 -0
|
@@ -2,31 +2,26 @@ import type { D3InterpolateName } from '../colors';
|
|
|
2
2
|
import type { ElementSymbol } from '../element';
|
|
3
3
|
import type { IsosurfaceSettings, VolumetricData } from '../isosurface/types';
|
|
4
4
|
import type { Vec3 } from '../math';
|
|
5
|
-
import type {
|
|
5
|
+
import type { SceneControlProps } from '../scene';
|
|
6
|
+
import type { ShowBonds, VectorColorMode, VectorLayerConfig } from '../settings';
|
|
6
7
|
import type { AnyStructure, BondEditMode, BondOrder, MeasureMode, Site, StructureBond } from './';
|
|
7
8
|
import { Lattice } from './';
|
|
8
9
|
import type { AtomColorConfig } from './atom-properties';
|
|
10
|
+
import type { SymmetryElement } from '../symmetry';
|
|
11
|
+
import SymmetryElements from '../symmetry/SymmetryElements.svelte';
|
|
9
12
|
import type { MoyoDataset } from '@spglib/moyo-wasm';
|
|
10
13
|
import * as extras from '@threlte/extras';
|
|
11
14
|
import { type ComponentProps, type Snippet } from 'svelte';
|
|
12
15
|
import { SvelteMap } from 'svelte/reactivity';
|
|
13
|
-
import { type Camera, type Scene } from 'three';
|
|
14
16
|
import type { BondingStrategy } from './bonding';
|
|
15
|
-
type
|
|
17
|
+
import type { PolyhedraColorMode } from './polyhedra';
|
|
18
|
+
type $$ComponentProps = SceneControlProps & {
|
|
16
19
|
structure?: AnyStructure;
|
|
17
20
|
base_structure?: AnyStructure;
|
|
18
21
|
atom_radius?: number;
|
|
19
22
|
same_size_atoms?: boolean;
|
|
20
23
|
camera_position?: [x: number, y: number, z: number];
|
|
21
24
|
camera_target?: Vec3;
|
|
22
|
-
camera_projection?: CameraProjection;
|
|
23
|
-
rotation_damping?: number;
|
|
24
|
-
max_zoom?: number;
|
|
25
|
-
min_zoom?: number;
|
|
26
|
-
rotate_speed?: number;
|
|
27
|
-
zoom_speed?: number;
|
|
28
|
-
pan_speed?: number;
|
|
29
|
-
zoom_to_cursor?: boolean;
|
|
30
25
|
show_atoms?: boolean;
|
|
31
26
|
show_bonds?: ShowBonds;
|
|
32
27
|
show_site_labels?: boolean;
|
|
@@ -42,23 +37,32 @@ type $$ComponentProps = {
|
|
|
42
37
|
vector_shaft_radius?: number;
|
|
43
38
|
vector_arrow_head_radius?: number;
|
|
44
39
|
vector_arrow_head_length?: number;
|
|
45
|
-
gizmo?: boolean | ComponentProps<typeof extras.Gizmo>;
|
|
46
40
|
hovered_idx?: number | null;
|
|
47
41
|
hovered_site?: Site | null;
|
|
48
42
|
float_fmt?: string;
|
|
49
|
-
auto_rotate?: number;
|
|
50
|
-
initial_zoom?: number;
|
|
51
43
|
bond_thickness?: number;
|
|
52
44
|
bond_color?: string;
|
|
53
45
|
bonding_strategy?: BondingStrategy;
|
|
54
46
|
auto_bond_order?: boolean;
|
|
55
47
|
aromatic_display?: `aromatic` | `kekule`;
|
|
56
48
|
bonding_options?: Record<string, unknown>;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
show_polyhedra?: ShowBonds;
|
|
50
|
+
polyhedra_opacity?: number;
|
|
51
|
+
polyhedra_show_edges?: boolean;
|
|
52
|
+
polyhedra_edge_color?: string;
|
|
53
|
+
polyhedra_color_mode?: PolyhedraColorMode;
|
|
54
|
+
polyhedra_color?: string;
|
|
55
|
+
polyhedra_hide_center_atoms?: boolean;
|
|
56
|
+
polyhedra_min_neighbors?: number;
|
|
57
|
+
polyhedra_max_neighbors?: number;
|
|
58
|
+
polyhedra_excluded_elements?: readonly string[];
|
|
59
|
+
polyhedra_included_elements?: readonly string[];
|
|
60
|
+
polyhedra_rendered_elements?: string[];
|
|
60
61
|
sphere_segments?: number;
|
|
61
62
|
lattice_props?: ComponentProps<typeof Lattice>;
|
|
63
|
+
symmetry_elements?: SymmetryElement[];
|
|
64
|
+
symmetry_elements_props?: Omit<ComponentProps<typeof SymmetryElements>, `elements` | `lattice`>;
|
|
65
|
+
symmetry_declutter?: boolean;
|
|
62
66
|
atom_label?: Snippet<[{
|
|
63
67
|
site: Site;
|
|
64
68
|
site_idx: number;
|
|
@@ -84,8 +88,6 @@ type $$ComponentProps = {
|
|
|
84
88
|
active_sites?: number[];
|
|
85
89
|
active_highlight_color?: string;
|
|
86
90
|
rotation?: Vec3;
|
|
87
|
-
scene?: Scene;
|
|
88
|
-
camera?: Camera;
|
|
89
91
|
orbit_controls?: ComponentProps<typeof extras.OrbitControls>[`ref`];
|
|
90
92
|
rotation_target_ref?: Vec3;
|
|
91
93
|
initial_computed_zoom?: number;
|
|
@@ -106,6 +108,6 @@ type $$ComponentProps = {
|
|
|
106
108
|
volumetric_data?: VolumetricData;
|
|
107
109
|
isosurface_settings?: IsosurfaceSettings;
|
|
108
110
|
};
|
|
109
|
-
declare const StructureScene: import("svelte").Component<$$ComponentProps, {}, "cursor" | "
|
|
111
|
+
declare const StructureScene: import("svelte").Component<$$ComponentProps, {}, "cursor" | "hidden_elements" | "hidden_prop_vals" | "element_radius_overrides" | "site_radius_overrides" | "selected_sites" | "site_label_offset" | "vector_configs" | "hovered_idx" | "hovered_site" | "polyhedra_rendered_elements" | "camera_is_moving" | "measured_sites" | "added_bonds" | "removed_bonds" | "bond_order_overrides" | "bond_edit_mode" | "active_sites" | "scene" | "camera" | "orbit_controls" | "rotation_target_ref" | "initial_computed_zoom" | "add_atom_mode" | "add_element" | "dragging_atoms">;
|
|
110
112
|
type StructureScene = ReturnType<typeof StructureScene>;
|
|
111
113
|
export default StructureScene;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Vec3 } from '../math';
|
|
1
|
+
import type { Vec2, Vec3 } from '../math';
|
|
2
2
|
import type { Camera, Object3D } from 'three';
|
|
3
3
|
export declare const LABEL_OFFSET_EPS = 1e-9;
|
|
4
4
|
type LabelOffsetSource = Vec3 | (() => Vec3);
|
|
@@ -6,9 +6,9 @@ export declare const choose_site_label_offset: (bond_directions: Vec3[], base_of
|
|
|
6
6
|
export declare const label_screen_position: (atom_position: Vec3, label_offset: Vec3, visual_radius: number, label_screen_margin: number, label_camera: Camera, size: {
|
|
7
7
|
width: number;
|
|
8
8
|
height: number;
|
|
9
|
-
}) =>
|
|
9
|
+
}) => Vec2;
|
|
10
10
|
export declare const make_label_position_calculator: (_atom_position: Vec3, label_offset: LabelOffsetSource, visual_radius: number, label_screen_margin: number) => (object: Object3D, label_camera: Camera, size: {
|
|
11
11
|
width: number;
|
|
12
12
|
height: number;
|
|
13
|
-
}) =>
|
|
13
|
+
}) => Vec2;
|
|
14
14
|
export {};
|
|
@@ -26,8 +26,8 @@ export const choose_site_label_offset = (bond_directions, base_offset) => {
|
|
|
26
26
|
if (offset_length < LABEL_OFFSET_EPS || bond_directions.length === 0) {
|
|
27
27
|
return base_offset;
|
|
28
28
|
}
|
|
29
|
-
const preferred_direction = math.
|
|
30
|
-
const repulsion_direction = math.
|
|
29
|
+
const preferred_direction = math.normalize_vec(base_offset, [0, 1, 0]);
|
|
30
|
+
const repulsion_direction = math.normalize_vec(bond_directions.reduce((offset_sum, bond_direction) => math.subtract(offset_sum, bond_direction), [0, 0, 0]), preferred_direction);
|
|
31
31
|
let best_direction = preferred_direction;
|
|
32
32
|
let best_score = -Infinity;
|
|
33
33
|
for (const candidate_direction of [
|
|
@@ -35,7 +35,7 @@ export const choose_site_label_offset = (bond_directions, base_offset) => {
|
|
|
35
35
|
repulsion_direction,
|
|
36
36
|
...LABEL_OFFSET_DIRECTIONS,
|
|
37
37
|
]) {
|
|
38
|
-
const direction = math.
|
|
38
|
+
const direction = math.normalize_vec(candidate_direction, preferred_direction);
|
|
39
39
|
const score = label_direction_score(direction, bond_directions, preferred_direction);
|
|
40
40
|
if (score <= best_score + LABEL_OFFSET_EPS)
|
|
41
41
|
continue;
|
|
@@ -59,8 +59,18 @@ export const label_screen_position = (atom_position, label_offset, visual_radius
|
|
|
59
59
|
const offset_length = Math.hypot(offset_x, offset_y);
|
|
60
60
|
const direction_x = offset_length > LABEL_OFFSET_EPS ? offset_x / offset_length : 0;
|
|
61
61
|
const direction_y = offset_length > LABEL_OFFSET_EPS ? offset_y / offset_length : label_offset[1] >= 0 ? -1 : 1;
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
// Measure the atom's projected radius along the camera's right axis (always
|
|
63
|
+
// view-perpendicular). Measuring along label_offset would collapse the clearance
|
|
64
|
+
// to ~zero for offsets near the view axis, letting the label overlap the atom.
|
|
65
|
+
const radius_dir = new Vector3()
|
|
66
|
+
.setFromMatrixColumn(label_camera.matrixWorld, 0)
|
|
67
|
+
.normalize()
|
|
68
|
+
.multiplyScalar(visual_radius);
|
|
69
|
+
const radius_edge = math.add(atom_position, [
|
|
70
|
+
radius_dir.x,
|
|
71
|
+
radius_dir.y,
|
|
72
|
+
radius_dir.z,
|
|
73
|
+
]);
|
|
64
74
|
const radius_screen = project_to_screen(radius_edge, label_camera, size);
|
|
65
75
|
const atom_screen_radius = Math.hypot(radius_screen[0] - atom_screen[0], radius_screen[1] - atom_screen[1]);
|
|
66
76
|
const screen_gap = atom_screen_radius + label_screen_margin;
|
|
@@ -17,7 +17,7 @@ export interface AtomPropertyColors {
|
|
|
17
17
|
unique_values?: (number | string)[];
|
|
18
18
|
}
|
|
19
19
|
type SymmetryDataWithOrigMap = MoyoDataset & {
|
|
20
|
-
|
|
20
|
+
orig_site_indices_by_input_idx?: number[][];
|
|
21
21
|
};
|
|
22
22
|
export declare const get_d3_color_scales: () => string[];
|
|
23
23
|
export declare function apply_color_scale(vals: number[], scale?: string, type?: ColorScaleType): {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Utility functions for computing atom properties and applying color scales
|
|
2
|
+
import { get_d3_interpolator } from '../colors';
|
|
2
3
|
import { calc_coordination_nums } from '../coordination';
|
|
3
4
|
import * as math from '../math';
|
|
4
5
|
import { wrap_to_unit_cell } from './pbc';
|
|
@@ -7,15 +8,7 @@ import * as d3_sc from 'd3-scale-chromatic';
|
|
|
7
8
|
const GRAY = `#808080`;
|
|
8
9
|
const DEFAULT_COLOR_SCALE = `interpolateViridis`;
|
|
9
10
|
export const get_d3_color_scales = () => Object.keys(d3_sc).filter((key) => key.startsWith(`interpolate`));
|
|
10
|
-
const
|
|
11
|
-
const interp_fn = d3_sc[scale];
|
|
12
|
-
if (typeof interp_fn !== `function`) {
|
|
13
|
-
console.warn(`Unknown D3 scale: ${scale}, using ${DEFAULT_COLOR_SCALE}`);
|
|
14
|
-
return d3_sc.interpolateViridis;
|
|
15
|
-
}
|
|
16
|
-
return interp_fn;
|
|
17
|
-
};
|
|
18
|
-
const to_hex = (interp_fn, t) => rgb(interp_fn(t)).formatHex();
|
|
11
|
+
const to_hex = (interp_fn, frac) => rgb(interp_fn(frac)).formatHex();
|
|
19
12
|
const build_image_site = (site, frac_to_cart, offset, orig_idx) => {
|
|
20
13
|
const img_abc = [
|
|
21
14
|
site.abc[0] + offset[0],
|
|
@@ -36,7 +29,7 @@ const get_all_offsets = (pbc) => [-1, 0, 1]
|
|
|
36
29
|
(pbc[1] || dy === 0) &&
|
|
37
30
|
(pbc[2] || dz === 0));
|
|
38
31
|
const make_categorical = (vals, scale, sort_fn) => {
|
|
39
|
-
const interp_fn =
|
|
32
|
+
const interp_fn = get_d3_interpolator(scale);
|
|
40
33
|
const uniq = sort_fn
|
|
41
34
|
? [...new Set(vals)].sort(sort_fn)
|
|
42
35
|
: [...new Set(vals)].sort((val_a, val_b) => String(val_a).localeCompare(String(val_b)));
|
|
@@ -55,13 +48,13 @@ const build_prop_colors = (vals, colors, unique_values) => {
|
|
|
55
48
|
return { colors, values: vals, min_value, max_value, unique_values: uniq };
|
|
56
49
|
};
|
|
57
50
|
export function apply_color_scale(vals, scale = DEFAULT_COLOR_SCALE, type = `continuous`) {
|
|
58
|
-
if (
|
|
51
|
+
if (vals.length === 0)
|
|
59
52
|
return { colors: [] };
|
|
60
53
|
if (type === `categorical`) {
|
|
61
54
|
const result = make_categorical(vals, scale, (val_a, val_b) => val_a - val_b);
|
|
62
55
|
return { colors: result.colors, unique_values: result.unique_values };
|
|
63
56
|
}
|
|
64
|
-
const interp_fn =
|
|
57
|
+
const interp_fn = get_d3_interpolator(scale);
|
|
65
58
|
// Compute min/max in single pass to avoid spreading large arrays
|
|
66
59
|
let [min, max] = [vals[0], vals[0]];
|
|
67
60
|
for (const val of vals) {
|
|
@@ -74,7 +67,7 @@ export function apply_color_scale(vals, scale = DEFAULT_COLOR_SCALE, type = `con
|
|
|
74
67
|
colors: vals.map((val) => to_hex(interp_fn, max === min ? 0.5 : (val - min) / (max - min))),
|
|
75
68
|
};
|
|
76
69
|
}
|
|
77
|
-
export const apply_categorical_color_scale = (vals, scale = DEFAULT_COLOR_SCALE) => vals.length ? make_categorical(vals, scale) : { colors: [], unique_values: [] };
|
|
70
|
+
export const apply_categorical_color_scale = (vals, scale = DEFAULT_COLOR_SCALE) => vals.length > 0 ? make_categorical(vals, scale) : { colors: [], unique_values: [] };
|
|
78
71
|
// Get original site index for property color lookup.
|
|
79
72
|
// Supercell atoms use orig_unit_cell_idx, image atoms use orig_site_idx, otherwise use site_idx.
|
|
80
73
|
export const get_orig_site_idx = (site, site_idx) => typeof site?.properties?.orig_unit_cell_idx === `number`
|
|
@@ -84,7 +77,7 @@ export const get_orig_site_idx = (site, site_idx) => typeof site?.properties?.or
|
|
|
84
77
|
: site_idx;
|
|
85
78
|
// Expand structure with PBC images - use minimal expansion based on atom positions
|
|
86
79
|
function expand_structure_for_pbc(structure) {
|
|
87
|
-
if (!(`lattice` in structure) || !structure.lattice ||
|
|
80
|
+
if (!(`lattice` in structure) || !structure.lattice || structure.sites.length === 0) {
|
|
88
81
|
return structure;
|
|
89
82
|
}
|
|
90
83
|
const { sites, lattice } = structure;
|
|
@@ -92,7 +85,7 @@ function expand_structure_for_pbc(structure) {
|
|
|
92
85
|
const pbc = lattice.pbc ?? [true, true, true];
|
|
93
86
|
const all_offsets = get_all_offsets(pbc);
|
|
94
87
|
// Small structures: expand all atoms
|
|
95
|
-
if (sites.length < 20 || !pbc.some(
|
|
88
|
+
if (sites.length < 20 || !pbc.some(Boolean)) {
|
|
96
89
|
const image_sites = sites.flatMap((site, orig_idx) => all_offsets.map((offset) => build_image_site(site, frac_to_cart, offset, orig_idx)));
|
|
97
90
|
return { ...structure, sites: [...sites, ...image_sites] };
|
|
98
91
|
}
|
|
@@ -113,7 +106,7 @@ export function get_coordination_colors(structure, strategy = `electroneg_ratio`
|
|
|
113
106
|
// Check if structure has periodic boundary conditions
|
|
114
107
|
const has_lattice = `lattice` in structure && structure.lattice !== undefined;
|
|
115
108
|
const pbc = has_lattice ? structure.lattice.pbc : undefined;
|
|
116
|
-
const has_pbc = has_lattice && (pbc === undefined || pbc.some(
|
|
109
|
+
const has_pbc = has_lattice && (pbc === undefined || pbc.some(Boolean));
|
|
117
110
|
// For PBC structures, expand with images from neighboring cells for accurate coordination
|
|
118
111
|
const coord_structure = has_pbc ? expand_structure_for_pbc(structure) : structure;
|
|
119
112
|
// Calculate coordination numbers on the (potentially expanded) structure
|
|
@@ -134,12 +127,14 @@ export function get_wyckoff_colors(structure, sym_data, scale = DEFAULT_COLOR_SC
|
|
|
134
127
|
unique_values: [`unknown`],
|
|
135
128
|
};
|
|
136
129
|
}
|
|
130
|
+
// moyo's wyckoffs array is indexed by INPUT cell sites (the merged moyo input cell),
|
|
131
|
+
// so map letters to original sites through orig_site_indices_by_input_idx
|
|
137
132
|
const wyckoff_by_orig_idx = new Map();
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
140
|
-
for (let
|
|
141
|
-
const wyckoff = sym_data.wyckoffs[
|
|
142
|
-
for (const orig_idx of
|
|
133
|
+
const mapping_by_input_idx = sym_data.orig_site_indices_by_input_idx;
|
|
134
|
+
if (mapping_by_input_idx) {
|
|
135
|
+
for (let input_idx = 0; input_idx < sym_data.wyckoffs.length; input_idx += 1) {
|
|
136
|
+
const wyckoff = sym_data.wyckoffs[input_idx];
|
|
137
|
+
for (const orig_idx of mapping_by_input_idx[input_idx] ?? []) {
|
|
143
138
|
if (!wyckoff_by_orig_idx.has(orig_idx))
|
|
144
139
|
wyckoff_by_orig_idx.set(orig_idx, wyckoff);
|
|
145
140
|
}
|
|
@@ -196,5 +191,5 @@ export function get_property_colors(structure, config, bonding_strategy, sym_dat
|
|
|
196
191
|
if (!structure || config.mode === `element`)
|
|
197
192
|
return null;
|
|
198
193
|
const result = get_atom_colors(structure, config, bonding_strategy, sym_data);
|
|
199
|
-
return result.colors.length ? result : null;
|
|
194
|
+
return result.colors.length > 0 ? result : null;
|
|
200
195
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { get_bond_key } from './bonding';
|
|
2
|
-
const primary_element = (site) =>
|
|
3
|
-
return (site.species?.reduce((best_species, species) => (species.occu > best_species.occu ? species : best_species), site.species[0])?.element ?? ``);
|
|
4
|
-
};
|
|
1
|
+
import { get_bond_key, get_majority_element } from './bonding';
|
|
2
|
+
const primary_element = (site) => get_majority_element(site) ?? ``;
|
|
5
3
|
// xyz2mol atomic_valence. Valence combinations are re-sorted by total
|
|
6
4
|
// valence sum so the least-saturated solution is tried first.
|
|
7
5
|
const ATOMIC_VALENCE = {
|
|
@@ -71,7 +69,7 @@ function split_fragments(n_atoms, edges) {
|
|
|
71
69
|
const stack = [start];
|
|
72
70
|
const frag = [];
|
|
73
71
|
seen.add(start);
|
|
74
|
-
while (stack.length) {
|
|
72
|
+
while (stack.length > 0) {
|
|
75
73
|
const node = stack.pop();
|
|
76
74
|
if (node === undefined)
|
|
77
75
|
break;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { ElementSymbol } from '../element';
|
|
1
2
|
import type { Vec3 } from '../math';
|
|
2
3
|
import type { AnyStructure, BondOrder, BondPair, Site, StructureBond } from './';
|
|
4
|
+
export declare const element_lookup: Map<"S" | "K" | "B" | "H" | "He" | "Li" | "Be" | "C" | "N" | "O" | "F" | "Ne" | "Na" | "Mg" | "Al" | "Si" | "P" | "Cl" | "Ar" | "Ca" | "Sc" | "Ti" | "V" | "Cr" | "Mn" | "Fe" | "Co" | "Ni" | "Cu" | "Zn" | "Ga" | "Ge" | "As" | "Se" | "Br" | "Kr" | "Rb" | "Sr" | "Y" | "Zr" | "Nb" | "Mo" | "Tc" | "Ru" | "Rh" | "Pd" | "Ag" | "Cd" | "In" | "Sn" | "Sb" | "Te" | "I" | "Xe" | "Cs" | "Ba" | "La" | "Ce" | "Pr" | "Nd" | "Pm" | "Sm" | "Eu" | "Gd" | "Tb" | "Dy" | "Ho" | "Er" | "Tm" | "Yb" | "Lu" | "Hf" | "Ta" | "W" | "Re" | "Os" | "Ir" | "Pt" | "Au" | "Hg" | "Tl" | "Pb" | "Bi" | "Po" | "At" | "Rn" | "Fr" | "Ra" | "Ac" | "Th" | "Pa" | "U" | "Np" | "Pu" | "Am" | "Cm" | "Bk" | "Cf" | "Es" | "Fm" | "Md" | "No" | "Lr" | "Rf" | "Db" | "Sg" | "Bh" | "Hs" | "Mt" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og", import("../element").ChemicalElement>;
|
|
5
|
+
export declare const get_majority_element: (site: Site | undefined) => ElementSymbol | null;
|
|
3
6
|
export declare const normalize_structure_bond: (site_idx_1: number, site_idx_2: number, order: BondOrder, cell_shift?: Vec3) => StructureBond;
|
|
4
7
|
export declare const get_bond_key: (idx_1: number, idx_2: number, cell_shift?: Vec3) => string;
|
|
8
|
+
export declare function remap_bonds_after_deletion(bonds: readonly StructureBond[], deleted_indices: ReadonlySet<number>): StructureBond[];
|
|
5
9
|
export type BondEditState = {
|
|
6
10
|
added_bonds: StructureBond[];
|
|
7
11
|
removed_bonds: StructureBond[];
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
// Bonding algorithms for structure visualization
|
|
2
2
|
import { element_data } from '../element';
|
|
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
|
+
};
|
|
6
13
|
const is_zero_cell_shift = (cell_shift) => cell_shift === undefined || cell_shift.every((val) => val === 0);
|
|
7
14
|
const format_cell_shift = (cell_shift) => {
|
|
8
15
|
if (cell_shift === undefined || is_zero_cell_shift(cell_shift))
|
|
@@ -45,6 +52,31 @@ export const get_bond_key = (idx_1, idx_2, cell_shift) => {
|
|
|
45
52
|
const normalized = normalize_bond_endpoints(idx_1, idx_2, cell_shift);
|
|
46
53
|
return `${normalized.site_idx_1}-${normalized.site_idx_2}${format_cell_shift(normalized.cell_shift)}`;
|
|
47
54
|
};
|
|
55
|
+
// Remap explicit bond metadata after site deletion: drop bonds touching deleted
|
|
56
|
+
// sites and shift each surviving index down by the number of deleted indices below it.
|
|
57
|
+
export function remap_bonds_after_deletion(bonds, deleted_indices) {
|
|
58
|
+
// Sort the deleted indices once; shift each surviving index down by the count of deleted
|
|
59
|
+
// indices below it via binary search (O(log m) per lookup vs re-filtering the set each call).
|
|
60
|
+
const sorted = [...deleted_indices].sort((idx_a, idx_b) => idx_a - idx_b);
|
|
61
|
+
const shift = (idx) => {
|
|
62
|
+
let [lo, hi] = [0, sorted.length];
|
|
63
|
+
while (lo < hi) {
|
|
64
|
+
const mid = (lo + hi) >> 1;
|
|
65
|
+
if (sorted[mid] < idx)
|
|
66
|
+
lo = mid + 1;
|
|
67
|
+
else
|
|
68
|
+
hi = mid;
|
|
69
|
+
}
|
|
70
|
+
return idx - lo; // lo == count of deleted indices < idx
|
|
71
|
+
};
|
|
72
|
+
return bonds
|
|
73
|
+
.filter((bond) => !deleted_indices.has(bond.site_idx_1) && !deleted_indices.has(bond.site_idx_2))
|
|
74
|
+
.map((bond) => ({
|
|
75
|
+
...bond,
|
|
76
|
+
site_idx_1: shift(bond.site_idx_1),
|
|
77
|
+
site_idx_2: shift(bond.site_idx_2),
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
48
80
|
export const BOND_ORDER_OPTIONS = [
|
|
49
81
|
{ order: 1, label: `Single` },
|
|
50
82
|
{ order: 1.5, label: `1.5` },
|
|
@@ -364,29 +396,30 @@ export function scale_and_offset_bond_matrix(transform_matrix, offset, radius_sc
|
|
|
364
396
|
export function get_bond_render_matrices(bond, bond_thickness) {
|
|
365
397
|
const order = bond.bond_order ?? 1;
|
|
366
398
|
const gap = bond_thickness * 1.8;
|
|
367
|
-
|
|
368
|
-
|
|
399
|
+
// Parallel cylinder [offset, radius_scale] pairs per bond order; empty → a single
|
|
400
|
+
// full-width bond (handled by the fallback below)
|
|
401
|
+
let offsets_and_scales = [];
|
|
402
|
+
if (order === 2)
|
|
403
|
+
offsets_and_scales = [
|
|
369
404
|
[-gap / 2, 0.65],
|
|
370
405
|
[gap / 2, 0.65],
|
|
371
|
-
]
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
406
|
+
];
|
|
407
|
+
else if (order === 3)
|
|
408
|
+
offsets_and_scales = [
|
|
409
|
+
[-gap, 0.55],
|
|
410
|
+
[0, 0.55],
|
|
411
|
+
[gap, 0.55],
|
|
412
|
+
];
|
|
413
|
+
else if (order === 1.5 || order === `aromatic`) {
|
|
414
|
+
offsets_and_scales = [
|
|
415
|
+
[-gap / 2, 0.75],
|
|
416
|
+
[gap / 2, 0.4],
|
|
417
|
+
];
|
|
418
|
+
}
|
|
384
419
|
return offsets_and_scales.length === 0
|
|
385
420
|
? [bond.transform_matrix]
|
|
386
421
|
: offsets_and_scales.map(([offset, radius_scale]) => scale_and_offset_bond_matrix(bond.transform_matrix, offset, radius_scale));
|
|
387
422
|
}
|
|
388
|
-
// Get the species with highest occupancy from a site.
|
|
389
|
-
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 });
|
|
390
423
|
// Helper to extract numeric index from site properties
|
|
391
424
|
function get_orig_idx(site, fallback) {
|
|
392
425
|
const props = site.properties;
|
|
@@ -468,12 +501,16 @@ export function compute_bond_transform(pos_1, pos_2) {
|
|
|
468
501
|
1,
|
|
469
502
|
]);
|
|
470
503
|
}
|
|
504
|
+
// Pack quantized cell coordinates into one integer key (exact for cell coords in
|
|
505
|
+
// [-512, 511], i.e. structures up to ~1000 cells per axis - far beyond any real
|
|
506
|
+
// case). Integer Map keys avoid per-lookup string building in the hot pair loop.
|
|
507
|
+
const CELL_OFFSET = 512;
|
|
508
|
+
const pack_cell_key = (x, y, z) => (x + CELL_OFFSET) * 1048576 + (y + CELL_OFFSET) * 1024 + (z + CELL_OFFSET);
|
|
471
509
|
// Build spatial grid by dividing 3D space into cubic cells.
|
|
472
510
|
function build_spatial_grid(sites, cell_size) {
|
|
473
511
|
const grid = new Map();
|
|
474
512
|
for (let idx = 0; idx < sites.length; idx++) {
|
|
475
|
-
const
|
|
476
|
-
const key = `${x},${y},${z}`;
|
|
513
|
+
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));
|
|
477
514
|
const cell = grid.get(key);
|
|
478
515
|
if (cell)
|
|
479
516
|
cell.push(idx);
|
|
@@ -493,9 +530,10 @@ function get_neighbors_from_grid(pos, grid, cell_size) {
|
|
|
493
530
|
for (let dx = -1; dx <= 1; dx++) {
|
|
494
531
|
for (let dy = -1; dy <= 1; dy++) {
|
|
495
532
|
for (let dz = -1; dz <= 1; dz++) {
|
|
496
|
-
const cell = grid.get(
|
|
533
|
+
const cell = grid.get(pack_cell_key(cx + dx, cy + dy, cz + dz));
|
|
497
534
|
if (cell)
|
|
498
|
-
|
|
535
|
+
for (const idx of cell)
|
|
536
|
+
neighbors.push(idx);
|
|
499
537
|
}
|
|
500
538
|
}
|
|
501
539
|
}
|
|
@@ -529,19 +567,39 @@ strength_threshold = 0.3, // Minimum bond strength to include in results
|
|
|
529
567
|
return [];
|
|
530
568
|
const bonds = [];
|
|
531
569
|
const min_dist_sq = min_bond_dist ** 2;
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
570
|
+
// Per-site properties in flat typed arrays - the pair loop below visits
|
|
571
|
+
// millions of candidate pairs in large supercells, so object property chains
|
|
572
|
+
// and Map lookups are replaced with indexed array reads.
|
|
573
|
+
const n_sites = sites.length;
|
|
574
|
+
const electronegs = new Float64Array(n_sites);
|
|
575
|
+
const radii = new Float64Array(n_sites); // 0 = no covalent radius known
|
|
576
|
+
const metal_flags = new Uint8Array(n_sites);
|
|
577
|
+
const nonmetal_flags = new Uint8Array(n_sites);
|
|
578
|
+
const elem_ids = new Int32Array(n_sites); // same-species check via integer ids
|
|
579
|
+
const orig_idxs = new Int32Array(n_sites);
|
|
580
|
+
const elem_id_lookup = new Map();
|
|
581
|
+
for (let idx = 0; idx < n_sites; idx++) {
|
|
582
|
+
const elem = get_majority_element(sites[idx]);
|
|
583
|
+
const data = elem ? element_lookup.get(elem) : undefined;
|
|
584
|
+
electronegs[idx] = data?.electronegativity ?? 2.0;
|
|
585
|
+
metal_flags[idx] = data?.metal ? 1 : 0;
|
|
586
|
+
nonmetal_flags[idx] = data?.nonmetal ? 1 : 0;
|
|
587
|
+
radii[idx] = (elem ? covalent_radii.get(elem) : undefined) ?? 0;
|
|
588
|
+
let elem_id = elem_id_lookup.get(elem ?? ``);
|
|
589
|
+
if (elem_id === undefined) {
|
|
590
|
+
elem_id = elem_id_lookup.size;
|
|
591
|
+
elem_id_lookup.set(elem ?? ``, elem_id);
|
|
592
|
+
}
|
|
593
|
+
elem_ids[idx] = elem_id;
|
|
594
|
+
// Valid orig indices always reference a site in this structure; fall back to
|
|
595
|
+
// the site's own index on malformed orig_*_idx properties so the typed
|
|
596
|
+
// `closest` array below stays bounded by n_sites
|
|
597
|
+
const orig_idx = get_orig_idx(sites[idx], idx);
|
|
598
|
+
orig_idxs[idx] =
|
|
599
|
+
Number.isInteger(orig_idx) && orig_idx >= 0 && orig_idx < n_sites ? orig_idx : idx;
|
|
600
|
+
}
|
|
601
|
+
// Closest normalized bond distance per original atom (typed array instead of Map)
|
|
602
|
+
const closest = new Float64Array(n_sites).fill(Infinity);
|
|
545
603
|
let max_radius = 0;
|
|
546
604
|
for (const radius of covalent_radii.values()) {
|
|
547
605
|
if (radius > max_radius)
|
|
@@ -551,29 +609,44 @@ strength_threshold = 0.3, // Minimum bond strength to include in results
|
|
|
551
609
|
const spatial = setup_spatial_grid(sites, max_cutoff);
|
|
552
610
|
const potential_bonds = [];
|
|
553
611
|
for (let idx_a = 0; idx_a < sites.length - 1; idx_a++) {
|
|
612
|
+
const radius_a = radii[idx_a];
|
|
613
|
+
if (radius_a === 0)
|
|
614
|
+
continue; // no covalent radius -> no pairs (symmetric: idx_b skips too)
|
|
554
615
|
const [x1, y1, z1] = sites[idx_a].xyz;
|
|
555
|
-
const
|
|
616
|
+
const electroneg_a = electronegs[idx_a];
|
|
617
|
+
const is_metal_a = metal_flags[idx_a] === 1;
|
|
618
|
+
const is_nonmetal_a = nonmetal_flags[idx_a] === 1;
|
|
619
|
+
const elem_id_a = elem_ids[idx_a];
|
|
556
620
|
for (const idx_b of get_candidates(sites[idx_a].xyz, sites, spatial)) {
|
|
557
621
|
if (idx_b <= idx_a)
|
|
558
622
|
continue;
|
|
623
|
+
const radius_b = radii[idx_b];
|
|
624
|
+
if (radius_b === 0)
|
|
625
|
+
continue;
|
|
559
626
|
const [x2, y2, z2] = sites[idx_b].xyz;
|
|
560
|
-
const
|
|
561
|
-
const
|
|
627
|
+
const dx = x2 - x1;
|
|
628
|
+
const dy = y2 - y1;
|
|
629
|
+
const dz = z2 - z1;
|
|
562
630
|
const dist_sq = dx * dx + dy * dy + dz * dz;
|
|
563
|
-
|
|
564
|
-
if (dist_sq < min_dist_sq || !props_a.radius || !props_b.radius)
|
|
631
|
+
if (dist_sq < min_dist_sq)
|
|
565
632
|
continue;
|
|
566
|
-
|
|
567
|
-
|
|
633
|
+
// Compare squared distances to defer the sqrt until a pair survives the
|
|
634
|
+
// cutoff (the vast majority of candidate pairs are rejected here)
|
|
635
|
+
const expected = radius_a + radius_b;
|
|
636
|
+
const max_dist = expected * max_distance_ratio;
|
|
637
|
+
if (dist_sq > max_dist * max_dist)
|
|
568
638
|
continue;
|
|
569
|
-
const
|
|
570
|
-
const
|
|
639
|
+
const dist = Math.sqrt(dist_sq);
|
|
640
|
+
const electroneg_b = electronegs[idx_b];
|
|
641
|
+
const electroneg_diff = Math.abs(electroneg_a - electroneg_b);
|
|
642
|
+
const electroneg_balance = electroneg_diff / (electroneg_a + electroneg_b);
|
|
643
|
+
const is_metal_b = metal_flags[idx_b] === 1;
|
|
644
|
+
const is_nonmetal_b = nonmetal_flags[idx_b] === 1;
|
|
571
645
|
let bond_strength = 1.0;
|
|
572
|
-
if (
|
|
646
|
+
if (is_metal_a && is_metal_b) {
|
|
573
647
|
bond_strength *= metal_metal_penalty;
|
|
574
648
|
}
|
|
575
|
-
else if ((
|
|
576
|
-
(props_a.is_nonmetal && props_b.is_metal)) {
|
|
649
|
+
else if ((is_metal_a && is_nonmetal_b) || (is_nonmetal_a && is_metal_b)) {
|
|
577
650
|
bond_strength *= metal_nonmetal_bonus;
|
|
578
651
|
if (electroneg_diff > electronegativity_threshold)
|
|
579
652
|
bond_strength *= 1.3;
|
|
@@ -584,25 +657,23 @@ strength_threshold = 0.3, // Minimum bond strength to include in results
|
|
|
584
657
|
const dist_weight = Math.exp(-((dist / expected - 1) ** 2) / 0.18);
|
|
585
658
|
const electroneg_weight = 1.0 - 0.3 * electroneg_balance;
|
|
586
659
|
let strength = bond_strength * dist_weight * electroneg_weight;
|
|
587
|
-
if (
|
|
660
|
+
if (elem_id_a === elem_ids[idx_b])
|
|
588
661
|
strength *= same_species_penalty;
|
|
589
662
|
// If raw strength is already too low, we can skip early
|
|
590
663
|
// (penalty will only reduce it further)
|
|
591
664
|
if (strength <= strength_threshold)
|
|
592
665
|
continue;
|
|
593
|
-
// Use
|
|
594
|
-
const orig_idx_a =
|
|
595
|
-
const orig_idx_b =
|
|
666
|
+
// Use precomputed original-site indices to handle supercell and image atoms
|
|
667
|
+
const orig_idx_a = orig_idxs[idx_a];
|
|
668
|
+
const orig_idx_b = orig_idxs[idx_b];
|
|
596
669
|
// Update closest known normalized distance (dist / expected) for original atoms
|
|
597
670
|
// Normalized distance handles atoms of different sizes better than raw distance
|
|
598
671
|
// (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)
|
|
599
672
|
const norm_dist = dist / expected;
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
if (norm_dist < closest_dist_b)
|
|
605
|
-
closest.set(orig_idx_b, norm_dist);
|
|
673
|
+
if (norm_dist < closest[orig_idx_a])
|
|
674
|
+
closest[orig_idx_a] = norm_dist;
|
|
675
|
+
if (norm_dist < closest[orig_idx_b])
|
|
676
|
+
closest[orig_idx_b] = norm_dist;
|
|
606
677
|
potential_bonds.push({
|
|
607
678
|
site_idx_1: idx_a,
|
|
608
679
|
site_idx_2: idx_b,
|
|
@@ -617,8 +688,8 @@ strength_threshold = 0.3, // Minimum bond strength to include in results
|
|
|
617
688
|
// Second pass: Apply penalties and filter
|
|
618
689
|
for (const bond of potential_bonds) {
|
|
619
690
|
const { site_idx_1, site_idx_2, dist, expected_dist, base_strength, orig_idx_a, orig_idx_b, } = bond;
|
|
620
|
-
const closest_dist_a = closest
|
|
621
|
-
const closest_dist_b = closest
|
|
691
|
+
const closest_dist_a = closest[orig_idx_a];
|
|
692
|
+
const closest_dist_b = closest[orig_idx_b];
|
|
622
693
|
const norm_dist = dist / expected_dist;
|
|
623
694
|
let strength = base_strength;
|
|
624
695
|
// Apply penalty if this bond is much longer (relative to radii) than the closest known bond
|
|
@@ -657,14 +728,14 @@ export function solid_angle(structure, { min_solid_angle = 0.01, min_face_area =
|
|
|
657
728
|
const spatial = setup_spatial_grid(sites, max_distance);
|
|
658
729
|
for (let idx_a = 0; idx_a < sites.length - 1; idx_a++) {
|
|
659
730
|
const [x1, y1, z1] = sites[idx_a].xyz;
|
|
660
|
-
const
|
|
661
|
-
const radius_a =
|
|
731
|
+
const elem_a = get_majority_element(sites[idx_a]);
|
|
732
|
+
const radius_a = elem_a ? covalent_radii.get(elem_a) : undefined;
|
|
662
733
|
for (const idx_b of get_candidates(sites[idx_a].xyz, sites, spatial)) {
|
|
663
734
|
if (idx_b <= idx_a)
|
|
664
735
|
continue;
|
|
665
736
|
const [x2, y2, z2] = sites[idx_b].xyz;
|
|
666
|
-
const
|
|
667
|
-
const radius_b =
|
|
737
|
+
const elem_b = get_majority_element(sites[idx_b]);
|
|
738
|
+
const radius_b = elem_b ? covalent_radii.get(elem_b) : undefined;
|
|
668
739
|
const [dx, dy, dz] = [x2 - x1, y2 - y1, z2 - z1];
|
|
669
740
|
const dist_sq = dx * dx + dy * dy + dz * dz;
|
|
670
741
|
const dist = Math.sqrt(dist_sq);
|