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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PaneProps, PaneToggleProps } from '../overlays';
|
|
1
2
|
import DraggablePane from '../overlays/DraggablePane.svelte';
|
|
2
3
|
import type { ComponentProps } from 'svelte';
|
|
3
4
|
import type { TrajectoryType } from './index';
|
|
@@ -9,8 +10,8 @@ type $$ComponentProps = Omit<ComponentProps<typeof DraggablePane>, `children`> &
|
|
|
9
10
|
file_size?: number | null;
|
|
10
11
|
file_object?: File | null;
|
|
11
12
|
pane_open?: boolean;
|
|
12
|
-
toggle_props?:
|
|
13
|
-
pane_props?:
|
|
13
|
+
toggle_props?: PaneToggleProps;
|
|
14
|
+
pane_props?: PaneProps;
|
|
14
15
|
};
|
|
15
16
|
declare const TrajectoryInfoPane: import("svelte").Component<$$ComponentProps, {}, "pane_open">;
|
|
16
17
|
type TrajectoryInfoPane = ReturnType<typeof TrajectoryInfoPane>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// Constants for trajectory parsing and large file handling
|
|
2
|
+
import { DEFAULTS } from '../settings';
|
|
2
3
|
export const MAX_SAFE_STRING_LENGTH = 0x1fffffe8 * 0.5; // 50% of JS max string length as safety
|
|
3
4
|
export const MAX_METADATA_SIZE = 50 * 1024 * 1024; // 50MB limit for metadata
|
|
4
5
|
export const LARGE_FILE_THRESHOLD = 400 * 1024 * 1024; // 400MB
|
|
5
6
|
export const INDEX_SAMPLE_RATE = 100; // Default sample rate for frame indexing
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
// Fallback thresholds for component usage without loading_options, derived from the
|
|
8
|
+
// settings schema so settings-driven contexts (e.g. the VSCode extension) and direct
|
|
9
|
+
// component use agree on when large-file/indexed loading kicks in.
|
|
10
|
+
export const MAX_BIN_FILE_SIZE = DEFAULTS.trajectory.bin_file_threshold; // 50MB
|
|
11
|
+
export const MAX_TEXT_FILE_SIZE = DEFAULTS.trajectory.text_file_threshold; // 25MB
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Data extraction functions for trajectory analysis and plotting
|
|
2
2
|
import { get_density } from '../structure/index';
|
|
3
|
+
import { calc_force_stats, copy_numeric_fields } from './helpers';
|
|
3
4
|
// Common data extractor that extracts energy and structural properties
|
|
4
5
|
export const energy_data_extractor = (frame) => {
|
|
5
6
|
const data = {
|
|
@@ -7,18 +8,13 @@ export const energy_data_extractor = (frame) => {
|
|
|
7
8
|
};
|
|
8
9
|
if (frame.metadata) {
|
|
9
10
|
// Extract energy-related properties
|
|
10
|
-
|
|
11
|
+
copy_numeric_fields(data, frame.metadata, [
|
|
11
12
|
`energy`,
|
|
12
13
|
`energy_per_atom`,
|
|
13
14
|
`potential_energy`,
|
|
14
15
|
`kinetic_energy`,
|
|
15
16
|
`total_energy`,
|
|
16
|
-
];
|
|
17
|
-
for (const field of energy_fields) {
|
|
18
|
-
if (field in frame.metadata && typeof frame.metadata[field] === `number`) {
|
|
19
|
-
data[field] = frame.metadata[field];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
17
|
+
]);
|
|
22
18
|
}
|
|
23
19
|
return data;
|
|
24
20
|
};
|
|
@@ -30,13 +26,8 @@ export const force_stress_data_extractor = (frame) => {
|
|
|
30
26
|
if (frame.metadata) {
|
|
31
27
|
// Calculate force properties from forces array if available (preferred)
|
|
32
28
|
if (frame.metadata.forces && Array.isArray(frame.metadata.forces)) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const force_magnitudes = forces.map((force) => Math.hypot(...force));
|
|
36
|
-
data.force_max = Math.max(...force_magnitudes);
|
|
37
|
-
// Calculate RMS (root mean square) of force magnitudes
|
|
38
|
-
data.force_norm = Math.sqrt(force_magnitudes.reduce((sum, f) => sum + f ** 2, 0) / force_magnitudes.length);
|
|
39
|
-
}
|
|
29
|
+
// Object.assign ignores the null calc_force_stats returns for empty forces
|
|
30
|
+
Object.assign(data, calc_force_stats(frame.metadata.forces));
|
|
40
31
|
}
|
|
41
32
|
else {
|
|
42
33
|
// Fallback to metadata values if forces array not available
|
|
@@ -52,12 +43,12 @@ export const force_stress_data_extractor = (frame) => {
|
|
|
52
43
|
}
|
|
53
44
|
}
|
|
54
45
|
// Extract other stress and pressure properties (no duplicates expected)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
copy_numeric_fields(data, frame.metadata, [
|
|
47
|
+
`stress_max`,
|
|
48
|
+
`stress_frobenius`,
|
|
49
|
+
`stress_trace`,
|
|
50
|
+
`pressure`,
|
|
51
|
+
]);
|
|
61
52
|
}
|
|
62
53
|
return data;
|
|
63
54
|
};
|
|
@@ -79,31 +70,20 @@ export const structural_data_extractor = (frame) => {
|
|
|
79
70
|
}
|
|
80
71
|
if (frame.metadata) {
|
|
81
72
|
// Extract other structural properties, avoiding volume duplicate
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// Handle density separately - prefer metadata, but calculate if not available
|
|
88
|
-
if (frame.metadata.density && typeof frame.metadata.density === `number`) {
|
|
73
|
+
copy_numeric_fields(data, frame.metadata, [`temperature`]);
|
|
74
|
+
// Prefer metadata density (fall back to calculating from structure below).
|
|
75
|
+
// Finite-number check (not truthiness) so a legitimate density of 0 is kept.
|
|
76
|
+
if (typeof frame.metadata.density === `number` &&
|
|
77
|
+
Number.isFinite(frame.metadata.density)) {
|
|
89
78
|
data.density = frame.metadata.density;
|
|
90
79
|
}
|
|
91
|
-
else if (`lattice` in frame.structure) {
|
|
92
|
-
try {
|
|
93
|
-
data.density = get_density(frame.structure);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
console.warn(`Failed to calculate density for frame ${frame.step}:`, error);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
80
|
// Only use metadata volume if lattice volume is not available
|
|
100
81
|
if (!data.volume && frame.metadata.volume && typeof frame.metadata.volume === `number`) {
|
|
101
82
|
data.volume = frame.metadata.volume;
|
|
102
83
|
}
|
|
103
84
|
// Note: pressure is handled by force_stress_data_extractor to avoid duplication
|
|
104
85
|
}
|
|
105
|
-
|
|
106
|
-
// Calculate density even when no metadata is available
|
|
86
|
+
if (data.density === undefined && `lattice` in frame.structure) {
|
|
107
87
|
try {
|
|
108
88
|
data.density = get_density(frame.structure);
|
|
109
89
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function ext_hint(filename: string | undefined, ext_regex: RegExp): boolean | null;
|
|
2
2
|
export declare const FORMAT_PATTERNS: {
|
|
3
3
|
readonly ase: (data: unknown, filename?: string) => boolean;
|
|
4
4
|
readonly hdf5: (data: unknown, filename?: string) => boolean;
|
|
@@ -1,33 +1,43 @@
|
|
|
1
1
|
// Format detection for trajectory files
|
|
2
|
-
import {
|
|
2
|
+
import { CONFIG_DIRS_REGEX, MD_SIM_EXCLUDE_REGEX, TRAJ_EXTENSIONS_REGEX, TRAJ_FALLBACK_EXTENSIONS_REGEX, TRAJ_KEYWORDS_SIMPLE_REGEX, XDATCAR_REGEX, } from '../constants';
|
|
3
|
+
import { strip_compression_extensions } from '../io';
|
|
3
4
|
import { count_xyz_frames } from './helpers';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
// Extensions that explicitly identify a format — when present, format detection trusts
|
|
6
|
+
// the extension instead of sniffing content
|
|
7
|
+
const KNOWN_FORMAT_EXT_REGEX = /\.(xyz|extxyz|traj|h5|hdf5|lammpstrj|json|cif|poscar|vasp|yaml|yml|xml|csv)$/;
|
|
8
|
+
// Classify the filename hint for a format whose extensions match ext_regex:
|
|
9
|
+
// true = filename matches, false = filename names a different known format,
|
|
10
|
+
// null = no usable hint (missing filename or unrecognized extension, e.g. the UUID
|
|
11
|
+
// basenames of blob: object URLs) — callers should fall back to content detection
|
|
12
|
+
export function ext_hint(filename, ext_regex) {
|
|
13
|
+
if (!filename)
|
|
14
|
+
return null;
|
|
15
|
+
const base = strip_compression_extensions(filename);
|
|
16
|
+
if (ext_regex.test(base))
|
|
17
|
+
return true;
|
|
18
|
+
return KNOWN_FORMAT_EXT_REGEX.test(base) ? false : null;
|
|
10
19
|
}
|
|
11
|
-
// Unified format detection
|
|
20
|
+
// Unified format detection. Each pattern trusts a matching file extension when present
|
|
21
|
+
// but falls back to content/magic-byte detection when the filename gives no hint
|
|
22
|
+
// (e.g. blob: object URLs, extensionless API endpoints).
|
|
12
23
|
export const FORMAT_PATTERNS = {
|
|
13
24
|
ase: (data, filename) => {
|
|
14
|
-
|
|
15
|
-
if (!base_name?.endsWith(`.traj`) || !(data instanceof ArrayBuffer)) {
|
|
25
|
+
if (ext_hint(filename, /\.traj$/) === false || !(data instanceof ArrayBuffer)) {
|
|
16
26
|
return false;
|
|
17
27
|
}
|
|
18
28
|
const view = new Uint8Array(data.slice(0, 24));
|
|
19
29
|
return [0x2d, 0x20, 0x6f, 0x66, 0x20, 0x55, 0x6c, 0x6d].every((byte, idx) => view[idx] === byte);
|
|
20
30
|
},
|
|
21
31
|
hdf5: (data, filename) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (!
|
|
32
|
+
if (ext_hint(filename, /\.(h5|hdf5)$/) === false)
|
|
33
|
+
return false;
|
|
34
|
+
if (!(data instanceof ArrayBuffer) || data.byteLength < 8)
|
|
25
35
|
return false;
|
|
26
36
|
const signature = new Uint8Array(data.slice(0, 8));
|
|
27
|
-
return [0x89, 0x48, 0x44, 0x46, 0x0d, 0x0a, 0x1a, 0x0a].every((
|
|
37
|
+
return [0x89, 0x48, 0x44, 0x46, 0x0d, 0x0a, 0x1a, 0x0a].every((byte, idx) => signature[idx] === byte);
|
|
28
38
|
},
|
|
29
39
|
vasp: (data, filename) => {
|
|
30
|
-
const basename = filename?.toLowerCase().split(`/`).pop()
|
|
40
|
+
const basename = filename?.toLowerCase().split(`/`).pop() ?? ``;
|
|
31
41
|
if (basename === `xdatcar` || basename.startsWith(`xdatcar`))
|
|
32
42
|
return true;
|
|
33
43
|
const lines = data.trim().split(/\r?\n/);
|
|
@@ -37,14 +47,12 @@ export const FORMAT_PATTERNS = {
|
|
|
37
47
|
lines.slice(2, 5).every((line) => line.trim().split(/\s+/).length === 3));
|
|
38
48
|
},
|
|
39
49
|
xyz_multi: (data, filename) => {
|
|
40
|
-
|
|
41
|
-
if (!/\.(xyz|extxyz)$/.test(base))
|
|
50
|
+
if (ext_hint(filename, /\.(xyz|extxyz)$/) === false)
|
|
42
51
|
return false;
|
|
43
52
|
return count_xyz_frames(data) >= 2;
|
|
44
53
|
},
|
|
45
54
|
lammpstrj: (data, filename) => {
|
|
46
|
-
|
|
47
|
-
if (!base.endsWith(`.lammpstrj`))
|
|
55
|
+
if (ext_hint(filename, /\.lammpstrj$/) === false)
|
|
48
56
|
return false;
|
|
49
57
|
return data.includes(`ITEM: TIMESTEP`) && data.includes(`ITEM: ATOMS`);
|
|
50
58
|
},
|
|
@@ -12,6 +12,5 @@ export declare class TrajFrameReader implements FrameLoader {
|
|
|
12
12
|
}, on_progress?: (progress: ParseProgress) => void): Promise<TrajectoryMetadata[]>;
|
|
13
13
|
private load_xyz_frame;
|
|
14
14
|
private load_ase_frame;
|
|
15
|
-
private parse_xyz_metadata;
|
|
16
15
|
private parse_ase_metadata;
|
|
17
16
|
}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
// Unified frame loader for XYZ and ASE trajectories (large file indexing)
|
|
1
2
|
import * as math from '../math';
|
|
2
3
|
import { MAX_METADATA_SIZE } from './constants';
|
|
3
|
-
import {
|
|
4
|
-
import { strip_compression_extensions } from '
|
|
4
|
+
import { copy_numeric_fields, count_xyz_frames, iter_xyz_frames, validate_3x3_matrix, } from './helpers';
|
|
5
|
+
import { strip_compression_extensions } from '../io';
|
|
6
|
+
import { decode_ase_frame, read_ase_header } from './parse/ase';
|
|
7
|
+
import { build_xyz_frame, parse_xyz_comment_metadata } from './parse/xyz';
|
|
8
|
+
// Restrict frame metadata to the requested property keys (no-op when unset)
|
|
9
|
+
const filter_properties = (metadata, properties) => {
|
|
10
|
+
if (!properties)
|
|
11
|
+
return;
|
|
12
|
+
metadata.properties = Object.fromEntries(Object.entries(metadata.properties).filter(([key]) => properties.includes(key)));
|
|
13
|
+
};
|
|
5
14
|
export class TrajFrameReader {
|
|
6
15
|
format;
|
|
7
16
|
global_numbers;
|
|
@@ -17,8 +26,7 @@ export class TrajFrameReader {
|
|
|
17
26
|
}
|
|
18
27
|
if (!(data instanceof ArrayBuffer))
|
|
19
28
|
throw new Error(`ASE loader requires binary data`);
|
|
20
|
-
|
|
21
|
-
return Number(view.getBigInt64(32, true));
|
|
29
|
+
return read_ase_header(new DataView(data)).n_items;
|
|
22
30
|
}
|
|
23
31
|
async build_frame_index(data, sample_rate, on_progress) {
|
|
24
32
|
const total_frames = await this.get_total_frames(data);
|
|
@@ -29,35 +37,25 @@ export class TrajFrameReader {
|
|
|
29
37
|
const encoder = new TextEncoder();
|
|
30
38
|
const newline_sequence = data_str.includes(`\r\n`) ? `\r\n` : `\n`;
|
|
31
39
|
const newline_byte_len = encoder.encode(newline_sequence).length;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
40
|
+
const line_bytes = (idx) => encoder.encode(lines[idx]).length + newline_byte_len;
|
|
41
|
+
// cursor = next line whose bytes haven't been added to byte_offset yet
|
|
42
|
+
let [current_frame, cursor, byte_offset] = [0, 0, 0];
|
|
43
|
+
for (const { start, num_atoms } of iter_xyz_frames(lines)) {
|
|
44
|
+
if (current_frame >= total_frames)
|
|
45
|
+
break;
|
|
46
|
+
// Accumulate bytes of blank/invalid lines skipped before this frame
|
|
47
|
+
for (; cursor < start; cursor++)
|
|
48
|
+
byte_offset += line_bytes(cursor);
|
|
49
|
+
let frame_size = 0;
|
|
50
|
+
for (; cursor < start + num_atoms + 2; cursor++)
|
|
51
|
+
frame_size += line_bytes(cursor);
|
|
45
52
|
if (current_frame % sample_rate === 0) {
|
|
46
53
|
frame_index.push({
|
|
47
54
|
frame_number: current_frame,
|
|
48
55
|
byte_offset,
|
|
49
|
-
estimated_size:
|
|
56
|
+
estimated_size: frame_size,
|
|
50
57
|
});
|
|
51
58
|
}
|
|
52
|
-
const frame_start = line_idx;
|
|
53
|
-
line_idx += 2 + num_atoms;
|
|
54
|
-
let frame_size = 0;
|
|
55
|
-
for (let idx = frame_start; idx < line_idx; idx++) {
|
|
56
|
-
frame_size += encoder.encode(lines[idx]).length + newline_byte_len;
|
|
57
|
-
}
|
|
58
|
-
if (current_frame % sample_rate === 0) {
|
|
59
|
-
frame_index[frame_index.length - 1].estimated_size = frame_size;
|
|
60
|
-
}
|
|
61
59
|
byte_offset += frame_size;
|
|
62
60
|
current_frame++;
|
|
63
61
|
if (on_progress && current_frame % 1000 === 0) {
|
|
@@ -71,7 +69,7 @@ export class TrajFrameReader {
|
|
|
71
69
|
}
|
|
72
70
|
else {
|
|
73
71
|
const view = new DataView(data);
|
|
74
|
-
const offsets_pos =
|
|
72
|
+
const { offsets_pos } = read_ase_header(view);
|
|
75
73
|
for (let idx = 0; idx < total_frames; idx += sample_rate) {
|
|
76
74
|
const frame_offset = Number(view.getBigInt64(offsets_pos + idx * 8, true));
|
|
77
75
|
frame_index.push({
|
|
@@ -109,34 +107,28 @@ export class TrajFrameReader {
|
|
|
109
107
|
const total_frames = await this.get_total_frames(data);
|
|
110
108
|
if (this.format === `xyz`) {
|
|
111
109
|
const lines = data.trim().split(/\r?\n/);
|
|
112
|
-
let
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
const num_atoms = parseInt(lines[line_idx].trim(), 10);
|
|
119
|
-
if (isNaN(num_atoms) || num_atoms <= 0 || line_idx + num_atoms + 1 >= lines.length) {
|
|
120
|
-
line_idx++;
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
110
|
+
let current_frame = 0;
|
|
111
|
+
for (const { start, comment } of iter_xyz_frames(lines)) {
|
|
112
|
+
if (current_frame >= total_frames)
|
|
113
|
+
break;
|
|
123
114
|
if (current_frame % sample_rate === 0) {
|
|
124
|
-
const comment = lines[line_idx + 1] || ``;
|
|
125
115
|
let frame_metadata = null;
|
|
126
116
|
try {
|
|
127
|
-
|
|
117
|
+
const { step, properties: props } = parse_xyz_comment_metadata(comment);
|
|
118
|
+
frame_metadata = {
|
|
119
|
+
frame_number: current_frame,
|
|
120
|
+
step: step ?? current_frame,
|
|
121
|
+
properties: props,
|
|
122
|
+
};
|
|
128
123
|
}
|
|
129
124
|
catch (error) {
|
|
130
|
-
console.warn(`Failed to parse XYZ metadata for frame ${current_frame} at line ${
|
|
131
|
-
}
|
|
132
|
-
if (frame_metadata && properties) {
|
|
133
|
-
const filtered = Object.fromEntries(Object.entries(frame_metadata.properties).filter(([key]) => properties.includes(key)));
|
|
134
|
-
frame_metadata.properties = filtered;
|
|
125
|
+
console.warn(`Failed to parse XYZ metadata for frame ${current_frame} at line ${start + 1}:`, error);
|
|
135
126
|
}
|
|
136
|
-
if (frame_metadata)
|
|
127
|
+
if (frame_metadata) {
|
|
128
|
+
filter_properties(frame_metadata, properties);
|
|
137
129
|
metadata_list.push(frame_metadata);
|
|
130
|
+
}
|
|
138
131
|
}
|
|
139
|
-
line_idx += 2 + num_atoms;
|
|
140
132
|
current_frame++;
|
|
141
133
|
if (on_progress && current_frame % 5000 === 0) {
|
|
142
134
|
on_progress({
|
|
@@ -149,8 +141,7 @@ export class TrajFrameReader {
|
|
|
149
141
|
}
|
|
150
142
|
else if (this.format === `ase`) {
|
|
151
143
|
const view = new DataView(data);
|
|
152
|
-
const n_items =
|
|
153
|
-
const offsets_pos = Number(view.getBigInt64(40, true));
|
|
144
|
+
const { n_items, offsets_pos } = read_ase_header(view);
|
|
154
145
|
for (let idx = 0; idx < n_items; idx += sample_rate) {
|
|
155
146
|
try {
|
|
156
147
|
const frame_offset = Number(view.getBigInt64(offsets_pos + idx * 8, true));
|
|
@@ -161,10 +152,7 @@ export class TrajFrameReader {
|
|
|
161
152
|
}
|
|
162
153
|
const frame_data = JSON.parse(new TextDecoder().decode(new Uint8Array(data, frame_offset + 8, json_length)));
|
|
163
154
|
const frame_metadata = this.parse_ase_metadata(frame_data, idx);
|
|
164
|
-
|
|
165
|
-
const filtered = Object.fromEntries(Object.entries(frame_metadata.properties).filter(([key]) => properties.includes(key)));
|
|
166
|
-
frame_metadata.properties = filtered;
|
|
167
|
-
}
|
|
155
|
+
filter_properties(frame_metadata, properties);
|
|
168
156
|
metadata_list.push(frame_metadata);
|
|
169
157
|
if (on_progress && idx % 5000 === 0) {
|
|
170
158
|
on_progress({
|
|
@@ -183,140 +171,53 @@ export class TrajFrameReader {
|
|
|
183
171
|
}
|
|
184
172
|
load_xyz_frame(data, frame_number) {
|
|
185
173
|
const lines = data.trim().split(/\r?\n/);
|
|
186
|
-
let
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
line_idx++;
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
line_idx += 2 + num_atoms;
|
|
198
|
-
current_frame++;
|
|
199
|
-
}
|
|
200
|
-
if (line_idx >= lines.length)
|
|
201
|
-
return null;
|
|
202
|
-
const num_atoms = parseInt(lines[line_idx].trim(), 10);
|
|
203
|
-
if (isNaN(num_atoms) || line_idx + num_atoms + 1 >= lines.length)
|
|
204
|
-
return null;
|
|
205
|
-
const comment = lines[line_idx + 1] || ``;
|
|
206
|
-
const positions = [];
|
|
207
|
-
const elements = [];
|
|
208
|
-
for (let idx = 0; idx < num_atoms; idx++) {
|
|
209
|
-
const parts = lines[line_idx + 2 + idx]?.trim().split(/\s+/);
|
|
210
|
-
if (parts?.length >= 4) {
|
|
211
|
-
const x_coord = parseFloat(parts[1]);
|
|
212
|
-
const y_coord = parseFloat(parts[2]);
|
|
213
|
-
const z_coord = parseFloat(parts[3]);
|
|
214
|
-
if (!Number.isFinite(x_coord) ||
|
|
215
|
-
!Number.isFinite(y_coord) ||
|
|
216
|
-
!Number.isFinite(z_coord)) {
|
|
217
|
-
console.warn(`Skipping XYZ atom with invalid coordinates in indexed frame ${frame_number} at line ${line_idx + 2 + idx}`);
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
const raw_symbol = parts[0];
|
|
221
|
-
const element_symbol = coerce_element_symbol(raw_symbol);
|
|
222
|
-
if (!element_symbol) {
|
|
223
|
-
console.warn(`Skipping XYZ atom with unknown element symbol "${raw_symbol}" in indexed frame ${frame_number}`);
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
elements.push(element_symbol);
|
|
227
|
-
positions.push([x_coord, y_coord, z_coord]);
|
|
228
|
-
}
|
|
174
|
+
let current_frame = 0;
|
|
175
|
+
for (const frame of iter_xyz_frames(lines)) {
|
|
176
|
+
if (current_frame++ < frame_number)
|
|
177
|
+
continue; // skip frames before the target
|
|
178
|
+
return build_xyz_frame(lines, frame, {
|
|
179
|
+
frame_label: `indexed frame ${frame_number}`,
|
|
180
|
+
default_step: frame_number,
|
|
181
|
+
});
|
|
229
182
|
}
|
|
230
|
-
|
|
231
|
-
return create_trajectory_frame(positions, elements, undefined, undefined, metadata.step, metadata.properties);
|
|
183
|
+
return null;
|
|
232
184
|
}
|
|
233
185
|
load_ase_frame(data, frame_number) {
|
|
234
186
|
try {
|
|
235
187
|
const view = new DataView(data);
|
|
236
|
-
const n_items =
|
|
237
|
-
const offsets_pos = Number(view.getBigInt64(40, true));
|
|
188
|
+
const { n_items, offsets_pos } = read_ase_header(view);
|
|
238
189
|
if (frame_number >= n_items)
|
|
239
190
|
return null;
|
|
240
191
|
const frame_offset = Number(view.getBigInt64(offsets_pos + frame_number * 8, true));
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const positions = positions_ref?.ndarray
|
|
245
|
-
? read_ndarray_from_view(view, positions_ref)
|
|
246
|
-
: positions_ref;
|
|
247
|
-
const numbers_ref = frame_data[`numbers.`] ?? frame_data.numbers ?? this.global_numbers;
|
|
248
|
-
const numbers = numbers_ref?.ndarray
|
|
249
|
-
? read_ndarray_from_view(view, numbers_ref).flat()
|
|
250
|
-
: numbers_ref;
|
|
251
|
-
if (numbers)
|
|
252
|
-
this.global_numbers = numbers;
|
|
253
|
-
if (!numbers || !positions)
|
|
254
|
-
throw new Error(`Missing atomic numbers or positions`);
|
|
255
|
-
const cell = frame_data.cell ? validate_3x3_matrix(frame_data.cell) : undefined;
|
|
256
|
-
const metadata = {
|
|
257
|
-
step: frame_number,
|
|
258
|
-
...frame_data.calculator,
|
|
259
|
-
...frame_data.info,
|
|
260
|
-
};
|
|
261
|
-
if (cell) {
|
|
262
|
-
try {
|
|
263
|
-
metadata.volume = Math.abs(math.det_3x3(cell));
|
|
264
|
-
}
|
|
265
|
-
catch (error) {
|
|
266
|
-
console.warn(`Failed to calculate volume for frame ${frame_number}:`, error);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
return create_trajectory_frame(positions, convert_atomic_numbers(numbers), cell, frame_data.pbc ?? [true, true, true], frame_number, metadata);
|
|
192
|
+
const { frame, numbers } = decode_ase_frame(view, data, frame_offset, frame_number, this.global_numbers);
|
|
193
|
+
this.global_numbers = numbers;
|
|
194
|
+
return frame;
|
|
270
195
|
}
|
|
271
196
|
catch (error) {
|
|
272
197
|
console.warn(`Failed to load ASE frame ${frame_number}:`, error);
|
|
273
198
|
return null;
|
|
274
199
|
}
|
|
275
200
|
}
|
|
276
|
-
parse_xyz_metadata(comment, frame_number) {
|
|
277
|
-
const properties = {};
|
|
278
|
-
const patterns = {
|
|
279
|
-
energy: /(?:energy|E|etot)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
280
|
-
volume: /(?:volume|vol|V)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
281
|
-
pressure: /(?:pressure|press|P)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
282
|
-
force_max: /(?:max_force|fmax)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
283
|
-
};
|
|
284
|
-
Object.entries(patterns).forEach(([key, pattern]) => {
|
|
285
|
-
const match = pattern.exec(comment);
|
|
286
|
-
if (match)
|
|
287
|
-
properties[key] = parseFloat(match[1]);
|
|
288
|
-
});
|
|
289
|
-
const step_match = /(?:step|frame)\s*[=:]?\s*(\d+)/i.exec(comment);
|
|
290
|
-
const step = step_match ? parseInt(step_match[1]) : frame_number;
|
|
291
|
-
return { frame_number, step, properties };
|
|
292
|
-
}
|
|
293
201
|
parse_ase_metadata(frame_data, frame_number) {
|
|
294
202
|
const properties = {};
|
|
295
203
|
const step = frame_number;
|
|
296
204
|
if (frame_data.calculator && typeof frame_data.calculator === `object`) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
205
|
+
copy_numeric_fields(properties, frame_data.calculator, [
|
|
206
|
+
`energy`,
|
|
207
|
+
`potential_energy`,
|
|
208
|
+
`kinetic_energy`,
|
|
209
|
+
`total_energy`,
|
|
210
|
+
]);
|
|
304
211
|
}
|
|
305
212
|
if (frame_data.info && typeof frame_data.info === `object`) {
|
|
306
|
-
|
|
307
|
-
const info_properties = [
|
|
213
|
+
copy_numeric_fields(properties, frame_data.info, [
|
|
308
214
|
`force_max`,
|
|
309
215
|
`force_norm`,
|
|
310
216
|
`stress_max`,
|
|
311
217
|
`stress_frobenius`,
|
|
312
218
|
`pressure`,
|
|
313
219
|
`temperature`,
|
|
314
|
-
];
|
|
315
|
-
for (const prop of info_properties) {
|
|
316
|
-
if (prop in info && typeof info[prop] === `number`) {
|
|
317
|
-
properties[prop] = info[prop];
|
|
318
|
-
}
|
|
319
|
-
}
|
|
220
|
+
]);
|
|
320
221
|
}
|
|
321
222
|
if (frame_data.cell && Array.isArray(frame_data.cell)) {
|
|
322
223
|
try {
|
|
@@ -3,8 +3,6 @@ import * as math from '../math';
|
|
|
3
3
|
import type { AnyStructure } from '../structure/index';
|
|
4
4
|
import type { Pbc } from '../structure/pbc';
|
|
5
5
|
import type { TrajectoryFrame } from './index';
|
|
6
|
-
export declare const is_valid_element_symbol: (symbol: string) => symbol is ElementSymbol;
|
|
7
|
-
export declare const coerce_element_symbol: (symbol: string) => ElementSymbol | undefined;
|
|
8
6
|
export declare function validate_3x3_matrix(data: unknown): math.Matrix3x3;
|
|
9
7
|
export declare const convert_atomic_numbers: (numbers: number[]) => ElementSymbol[];
|
|
10
8
|
export declare const create_structure: (positions: number[][], elements: ElementSymbol[], lattice_matrix?: math.Matrix3x3, pbc?: Pbc, force_data?: number[][]) => AnyStructure;
|
|
@@ -12,4 +10,14 @@ export declare const create_trajectory_frame: (positions: number[][], elements:
|
|
|
12
10
|
export declare const read_ndarray_from_view: (view: DataView, ref: {
|
|
13
11
|
ndarray: unknown[];
|
|
14
12
|
}) => number[][];
|
|
13
|
+
export declare const copy_numeric_fields: (target: Record<string, number>, source: Record<string, unknown>, fields: readonly string[]) => void;
|
|
14
|
+
export declare function calc_force_stats(forces: number[][]): {
|
|
15
|
+
force_max: number;
|
|
16
|
+
force_norm: number;
|
|
17
|
+
} | null;
|
|
18
|
+
export declare function iter_xyz_frames(lines: string[]): Generator<{
|
|
19
|
+
start: number;
|
|
20
|
+
num_atoms: number;
|
|
21
|
+
comment: string;
|
|
22
|
+
}>;
|
|
15
23
|
export declare function count_xyz_frames(data: string): number;
|