matterviz 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EmptyState.svelte +10 -4
- package/dist/FilePicker.svelte +12 -14
- package/dist/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +2 -2
- package/dist/app.css +53 -0
- package/dist/brillouin/BrillouinZone.svelte +132 -219
- package/dist/brillouin/BrillouinZone.svelte.d.ts +9 -20
- package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
- package/dist/brillouin/BrillouinZoneExportPane.svelte +47 -96
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +15 -42
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +63 -230
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +3 -23
- package/dist/brillouin/ReciprocalVectors.svelte +39 -0
- package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
- package/dist/brillouin/compute.d.ts +2 -0
- package/dist/brillouin/compute.js +80 -77
- package/dist/brillouin/geometry.d.ts +8 -0
- package/dist/brillouin/geometry.js +57 -0
- package/dist/brillouin/index.d.ts +2 -0
- package/dist/brillouin/index.js +2 -0
- package/dist/brillouin/types.d.ts +2 -2
- package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +143 -246
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +652 -976
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
- package/dist/chempot-diagram/async-compute.svelte.js +1 -1
- package/dist/chempot-diagram/color.d.ts +3 -6
- package/dist/chempot-diagram/color.js +5 -5
- package/dist/chempot-diagram/compute.d.ts +3 -3
- package/dist/chempot-diagram/compute.js +3 -1
- package/dist/chempot-diagram/controls-state.svelte.d.ts +10 -0
- package/dist/chempot-diagram/controls-state.svelte.js +42 -0
- package/dist/chempot-diagram/export.d.ts +47 -0
- package/dist/chempot-diagram/export.js +133 -0
- package/dist/chempot-diagram/index.d.ts +1 -0
- package/dist/chempot-diagram/index.js +1 -0
- package/dist/chempot-diagram/pointer.d.ts +0 -10
- package/dist/chempot-diagram/pointer.js +4 -4
- package/dist/chempot-diagram/types.d.ts +3 -3
- package/dist/colors/index.d.ts +0 -4
- package/dist/colors/index.js +21 -22
- package/dist/composition/BarChart.svelte +37 -31
- package/dist/composition/BubbleChart.svelte +17 -17
- package/dist/composition/Composition.svelte +7 -11
- package/dist/composition/Formula.svelte +18 -25
- package/dist/composition/FormulaFilter.svelte +96 -98
- package/dist/composition/PieChart.svelte +60 -46
- package/dist/composition/chem-sys.js +3 -2
- package/dist/composition/format.js +4 -3
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +2 -3
- package/dist/composition/parse.js +27 -28
- package/dist/constants.js +11 -9
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +0 -1
- package/dist/convex-hull/ConvexHull.svelte +20 -25
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
- package/dist/convex-hull/ConvexHull2D.svelte +176 -256
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +269 -804
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +236 -755
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +264 -0
- package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
- package/dist/convex-hull/ConvexHullControls.svelte +128 -49
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
- package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
- package/dist/convex-hull/ConvexHullStats.svelte +210 -351
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +16 -14
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
- package/dist/convex-hull/GasPressureControls.svelte +5 -12
- package/dist/convex-hull/StructurePopup.svelte +17 -21
- package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
- package/dist/convex-hull/TemperatureSlider.svelte +4 -10
- package/dist/convex-hull/barycentric-coords.d.ts +2 -4
- package/dist/convex-hull/barycentric-coords.js +6 -33
- package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
- package/dist/convex-hull/canvas-interactions.svelte.js +279 -0
- package/dist/convex-hull/helpers.d.ts +47 -17
- package/dist/convex-hull/helpers.js +186 -101
- package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
- package/dist/convex-hull/hull-state.svelte.js +124 -0
- package/dist/convex-hull/index.d.ts +9 -7
- package/dist/convex-hull/index.js +7 -2
- package/dist/convex-hull/thermodynamics.js +109 -937
- package/dist/convex-hull/types.d.ts +12 -4
- package/dist/convex-hull/types.js +12 -0
- package/dist/coordination/CoordinationBarPlot.svelte +41 -43
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
- package/dist/coordination/calc-coordination.d.ts +1 -1
- package/dist/coordination/calc-coordination.js +28 -25
- package/dist/element/BohrAtom.svelte +6 -8
- package/dist/element/ElementHeading.svelte +4 -1
- package/dist/element/ElementPhoto.svelte +11 -9
- package/dist/element/ElementStats.svelte +12 -10
- package/dist/element/ElementTile.svelte +24 -29
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/element/Nucleus.svelte +4 -2
- package/dist/element/data.d.ts +1 -2
- package/dist/element/helpers.d.ts +4 -0
- package/dist/element/helpers.js +18 -0
- package/dist/element/index.d.ts +1 -0
- package/dist/element/index.js +3 -0
- package/dist/feedback/DragOverlay.svelte +5 -3
- package/dist/feedback/DragOverlay.svelte.d.ts +2 -1
- package/dist/feedback/StatusMessage.svelte +20 -7
- package/dist/fermi-surface/FermiSlice.svelte +21 -18
- package/dist/fermi-surface/FermiSurface.svelte +78 -165
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +9 -20
- package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
- package/dist/fermi-surface/FermiSurfaceScene.svelte +93 -272
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
- package/dist/fermi-surface/compute.js +14 -13
- package/dist/fermi-surface/export.js +4 -15
- package/dist/fermi-surface/index.d.ts +0 -1
- package/dist/fermi-surface/index.js +0 -1
- package/dist/fermi-surface/parse.d.ts +1 -1
- package/dist/fermi-surface/parse.js +84 -97
- package/dist/fermi-surface/types.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +161 -185
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +6 -5
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +12 -9
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
- package/dist/heatmap-matrix/index.d.ts +8 -2
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/ExportPane.svelte +170 -0
- package/dist/io/ExportPane.svelte.d.ts +17 -0
- package/dist/io/decompress.d.ts +2 -1
- package/dist/io/decompress.js +22 -36
- package/dist/io/export.d.ts +9 -1
- package/dist/io/export.js +37 -29
- package/dist/io/fetch.d.ts +2 -4
- package/dist/io/fetch.js +0 -11
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +13 -0
- package/dist/io/index.d.ts +1 -0
- package/dist/io/index.js +3 -0
- package/dist/io/is-binary.d.ts +9 -0
- package/dist/io/is-binary.js +45 -1
- package/dist/io/types.d.ts +13 -0
- package/dist/io/url-drop.js +13 -25
- package/dist/isosurface/Isosurface.svelte +17 -23
- package/dist/isosurface/IsosurfaceControls.svelte +37 -42
- package/dist/isosurface/parse-vaspwave.d.ts +3 -0
- package/dist/isosurface/parse-vaspwave.js +138 -0
- package/dist/isosurface/parse.js +50 -48
- package/dist/labels.d.ts +6 -2
- package/dist/labels.js +44 -14
- package/dist/layout/FullscreenButton.svelte +34 -0
- package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
- package/dist/layout/FullscreenToggle.svelte +12 -12
- package/dist/layout/InfoCard.svelte +7 -18
- package/dist/layout/InfoTag.svelte +1 -3
- package/dist/layout/NumberRangeInput.svelte +46 -0
- package/dist/layout/NumberRangeInput.svelte.d.ts +12 -0
- package/dist/layout/PropertyFilter.svelte +2 -6
- package/dist/layout/SettingsSection.svelte +21 -17
- package/dist/layout/SubpageGrid.svelte +3 -1
- package/dist/layout/ViewerChrome.svelte +115 -0
- package/dist/layout/ViewerChrome.svelte.d.ts +18 -0
- package/dist/layout/fullscreen.d.ts +4 -0
- package/dist/layout/fullscreen.js +3 -5
- package/dist/layout/fullscreen.svelte.d.ts +8 -0
- package/dist/layout/fullscreen.svelte.js +36 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.js +4 -0
- package/dist/layout/json-tree/JsonNode.svelte +8 -11
- package/dist/layout/json-tree/JsonTree.svelte +53 -77
- package/dist/layout/json-tree/JsonValue.svelte +7 -15
- package/dist/layout/json-tree/utils.js +14 -23
- package/dist/math.d.ts +9 -3
- package/dist/math.js +37 -21
- package/dist/overlays/ContextMenu.svelte +4 -2
- package/dist/overlays/CopyButton.svelte +11 -5
- package/dist/overlays/DragControlTab.svelte +6 -1
- package/dist/overlays/DraggablePane.svelte +81 -26
- package/dist/overlays/DraggablePane.svelte.d.ts +1 -0
- package/dist/overlays/GlassChip.svelte +30 -0
- package/dist/overlays/GlassChip.svelte.d.ts +8 -0
- package/dist/overlays/InfoPaneCards.svelte +11 -23
- package/dist/overlays/index.d.ts +11 -0
- package/dist/overlays/index.js +26 -0
- package/dist/overlays/portal.d.ts +2 -0
- package/dist/overlays/portal.js +14 -0
- package/dist/periodic-table/PeriodicTable.svelte +115 -146
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
- package/dist/periodic-table/PeriodicTableControls.svelte +11 -63
- package/dist/periodic-table/TableInset.svelte +9 -4
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +50 -71
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
- package/dist/phase-diagram/PhaseDiagramControls.svelte +73 -96
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +4 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +49 -134
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
- package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
- package/dist/phase-diagram/build-diagram.js +3 -3
- package/dist/phase-diagram/colors.js +1 -1
- package/dist/phase-diagram/diagram-input.d.ts +1 -2
- package/dist/phase-diagram/parse.d.ts +2 -1
- package/dist/phase-diagram/parse.js +15 -15
- package/dist/phase-diagram/svg-to-diagram.js +21 -15
- package/dist/phase-diagram/utils.js +2 -3
- package/dist/plot/bar/BarPlot.svelte +494 -692
- package/dist/plot/bar/BarPlot.svelte.d.ts +9 -15
- package/dist/plot/bar/BarPlotControls.svelte +1 -3
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +5 -7
- package/dist/plot/bar/SpacegroupBarPlot.svelte +31 -37
- package/dist/plot/bar/data.d.ts +5 -4
- package/dist/plot/bar/data.js +2 -1
- package/dist/plot/box/BoxPlot.svelte +361 -439
- package/dist/plot/box/BoxPlot.svelte.d.ts +6 -3
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
- package/dist/plot/box/Violin.svelte.d.ts +2 -1
- package/dist/plot/box/box-plot.d.ts +3 -2
- package/dist/plot/box/box-plot.js +6 -3
- package/dist/plot/box/kde.d.ts +2 -1
- package/dist/plot/box/kde.js +4 -4
- package/dist/plot/core/auto-place.d.ts +1 -1
- package/dist/plot/core/auto-place.js +5 -2
- package/dist/plot/core/axis-utils.d.ts +12 -7
- package/dist/plot/core/axis-utils.js +48 -48
- package/dist/plot/core/components/AxisLabel.svelte +82 -20
- package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
- package/dist/plot/core/components/ColorBar.svelte +106 -111
- package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
- package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
- package/dist/plot/core/components/FillArea.svelte +10 -17
- package/dist/plot/core/components/HierarchyControls.svelte +249 -0
- package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
- package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
- package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/core/components/Line.svelte +21 -11
- package/dist/plot/core/components/Line.svelte.d.ts +5 -2
- package/dist/plot/core/components/PlotAxis.svelte +42 -18
- package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
- package/dist/plot/core/components/PlotControls.svelte +65 -41
- package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/core/components/PlotLegend.svelte +31 -35
- package/dist/plot/core/components/PlotMarginals.svelte +616 -0
- package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
- package/dist/plot/core/components/PlotTooltip.svelte +1 -1
- package/dist/plot/core/components/PortalSelect.svelte +4 -8
- package/dist/plot/core/components/ReferenceLine.svelte +27 -24
- package/dist/plot/core/components/ReferenceLine3D.svelte +56 -59
- package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
- package/dist/plot/core/components/ReferencePlane.svelte +9 -10
- package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
- package/dist/plot/core/components/ZeroLines.svelte +4 -8
- package/dist/plot/core/components/ZoomRect.svelte +1 -2
- package/dist/plot/core/components/index.d.ts +1 -0
- package/dist/plot/core/components/index.js +1 -0
- package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
- package/dist/plot/core/data-cleaning-signal.js +467 -0
- package/dist/plot/core/data-cleaning.d.ts +2 -42
- package/dist/plot/core/data-cleaning.js +29 -476
- package/dist/plot/core/data-transform.js +9 -5
- package/dist/plot/core/fill-utils.d.ts +7 -4
- package/dist/plot/core/fill-utils.js +34 -9
- package/dist/plot/core/index.d.ts +1 -0
- package/dist/plot/core/index.js +1 -0
- package/dist/plot/core/interactions.d.ts +5 -1
- package/dist/plot/core/interactions.js +14 -2
- package/dist/plot/core/layout.d.ts +3 -1
- package/dist/plot/core/layout.js +22 -13
- package/dist/plot/core/marginals.d.ts +170 -0
- package/dist/plot/core/marginals.js +436 -0
- package/dist/plot/core/pan-zoom.svelte.d.ts +35 -0
- package/dist/plot/core/pan-zoom.svelte.js +221 -0
- package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
- package/dist/plot/core/placed-tween.svelte.js +68 -0
- package/dist/plot/core/reference-line.d.ts +10 -10
- package/dist/plot/core/reference-line.js +7 -7
- package/dist/plot/core/scales.d.ts +40 -25
- package/dist/plot/core/scales.js +49 -21
- package/dist/plot/core/svg.d.ts +2 -1
- package/dist/plot/core/types/fills.d.ts +101 -0
- package/dist/plot/core/types/fills.js +15 -0
- package/dist/plot/core/types/plot-3d.d.ts +87 -0
- package/dist/plot/core/types/plot-3d.js +4 -0
- package/dist/plot/core/types/reference-lines.d.ts +140 -0
- package/dist/plot/core/types/reference-lines.js +9 -0
- package/dist/plot/core/types.d.ts +47 -331
- package/dist/plot/core/types.js +23 -20
- package/dist/plot/core/utils/hierarchy-chart.d.ts +51 -0
- package/dist/plot/core/utils/hierarchy-chart.js +179 -0
- package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
- package/dist/plot/core/utils/hierarchy-labels.js +99 -0
- package/dist/plot/core/utils/label-placement.d.ts +1 -1
- package/dist/plot/core/utils/label-placement.js +5 -5
- package/dist/plot/core/utils.d.ts +2 -1
- package/dist/plot/histogram/Histogram.svelte +373 -631
- package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
- package/dist/plot/histogram/HistogramControls.svelte +30 -28
- package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/histogram/histogram.d.ts +31 -0
- package/dist/plot/histogram/histogram.js +70 -0
- package/dist/plot/histogram/index.d.ts +1 -0
- package/dist/plot/histogram/index.js +1 -0
- package/dist/plot/index.d.ts +1 -0
- package/dist/plot/index.js +1 -0
- package/dist/plot/sankey/Sankey.svelte +79 -73
- package/dist/plot/sankey/Sankey.svelte.d.ts +3 -3
- package/dist/plot/sankey/SankeyControls.svelte +22 -16
- package/dist/plot/sankey/sankey.js +3 -1
- package/dist/plot/scatter/BinnedScatterPlot.svelte +264 -112
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +11 -4
- package/dist/plot/scatter/ElementScatter.svelte +4 -1
- package/dist/plot/scatter/ScatterPlot.svelte +623 -821
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +9 -15
- package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
- package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/scatter/ScatterPoint.svelte +16 -9
- package/dist/plot/scatter/binned-scatter-types.d.ts +6 -12
- package/dist/plot/scatter/binned-scatter-types.js +6 -1
- package/dist/plot/scatter/index.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.js +8 -7
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte +40 -60
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +17 -15
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +232 -234
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
- package/dist/plot/scatter-3d/Surface3D.svelte +9 -17
- package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
- package/dist/plot/sunburst/Sunburst.svelte +256 -338
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
- package/dist/plot/sunburst/index.d.ts +1 -1
- package/dist/plot/sunburst/index.js +2 -1
- package/dist/plot/sunburst/render.d.ts +2 -2
- package/dist/plot/sunburst/render.js +47 -22
- package/dist/plot/sunburst/sunburst.d.ts +5 -1
- package/dist/plot/sunburst/sunburst.js +14 -4
- package/dist/plot/treemap/Treemap.svelte +907 -0
- package/dist/plot/treemap/Treemap.svelte.d.ts +84 -0
- package/dist/plot/treemap/index.d.ts +3 -0
- package/dist/plot/treemap/index.js +4 -0
- package/dist/plot/treemap/treemap.d.ts +26 -0
- package/dist/plot/treemap/treemap.js +99 -0
- package/dist/rdf/RdfPlot.svelte +22 -26
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/calc-rdf.js +4 -8
- package/dist/sanitize.js +14 -3
- package/dist/scene/SceneCamera.svelte +62 -0
- package/dist/scene/SceneCamera.svelte.d.ts +19 -0
- package/dist/scene/bind-renderer.svelte.d.ts +2 -0
- package/dist/scene/bind-renderer.svelte.js +22 -0
- package/dist/scene/index.d.ts +4 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/props.js +52 -0
- package/dist/scene/types.d.ts +26 -0
- package/dist/scene/types.js +1 -0
- package/dist/settings.d.ts +33 -11
- package/dist/settings.js +136 -51
- package/dist/spectral/Bands.svelte +231 -237
- package/dist/spectral/Bands.svelte.d.ts +3 -2
- package/dist/spectral/BandsAndDos.svelte +29 -29
- package/dist/spectral/BrillouinBandsDos.svelte +21 -29
- package/dist/spectral/Dos.svelte +75 -77
- package/dist/spectral/Dos.svelte.d.ts +2 -1
- package/dist/spectral/helpers.d.ts +9 -9
- package/dist/spectral/helpers.js +66 -70
- package/dist/state.svelte.d.ts +0 -7
- package/dist/state.svelte.js +5 -24
- package/dist/structure/Arrow.svelte +6 -21
- package/dist/structure/ArrowInstances.svelte +160 -0
- package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
- package/dist/structure/AtomLegend.svelte +115 -75
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +31 -23
- package/dist/structure/CanvasTooltip.svelte +16 -3
- package/dist/structure/CellSelect.svelte +22 -29
- package/dist/structure/CellSelect.svelte.d.ts +2 -1
- package/dist/structure/Cylinder.svelte +24 -40
- package/dist/structure/InstancedAtoms.svelte +114 -0
- package/dist/structure/InstancedAtoms.svelte.d.ts +15 -0
- package/dist/structure/Lattice.svelte +85 -149
- package/dist/structure/SiteLabels.svelte +122 -0
- package/dist/structure/SiteLabels.svelte.d.ts +18 -0
- package/dist/structure/Structure.svelte +725 -735
- package/dist/structure/Structure.svelte.d.ts +8 -16
- package/dist/structure/StructureCarousel.svelte +630 -0
- package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
- package/dist/structure/StructureControls.svelte +298 -325
- package/dist/structure/StructureControls.svelte.d.ts +5 -3
- package/dist/structure/StructureExportPane.svelte +62 -168
- package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
- package/dist/structure/StructureInfoPane.svelte +77 -69
- package/dist/structure/StructureInfoPane.svelte.d.ts +6 -6
- package/dist/structure/StructureScene.svelte +758 -600
- package/dist/structure/StructureScene.svelte.d.ts +24 -20
- package/dist/structure/StructureViewport.svelte +386 -0
- package/dist/structure/StructureViewport.svelte.d.ts +63 -0
- package/dist/structure/atom-label-placement.d.ts +18 -0
- package/dist/structure/atom-label-placement.js +115 -0
- package/dist/structure/atom-properties.d.ts +3 -1
- package/dist/structure/atom-properties.js +115 -54
- package/dist/structure/bond-order-perception.js +2 -4
- package/dist/structure/bonding.d.ts +12 -2
- package/dist/structure/bonding.js +172 -73
- package/dist/structure/edit-history.d.ts +6 -0
- package/dist/structure/edit-history.js +27 -0
- package/dist/structure/export.d.ts +25 -4
- package/dist/structure/export.js +103 -153
- package/dist/structure/format-detect.d.ts +1 -0
- package/dist/structure/format-detect.js +22 -0
- package/dist/structure/geometry.d.ts +9 -0
- package/dist/structure/geometry.js +27 -0
- package/dist/structure/index.d.ts +18 -1
- package/dist/structure/index.js +15 -2
- package/dist/structure/measure.d.ts +1 -1
- package/dist/structure/measure.js +6 -12
- package/dist/structure/parse.d.ts +5 -3
- package/dist/structure/parse.js +551 -567
- package/dist/structure/partial-occupancy.d.ts +0 -1
- package/dist/structure/partial-occupancy.js +5 -3
- package/dist/structure/pbc.d.ts +1 -1
- package/dist/structure/pbc.js +204 -51
- package/dist/structure/polyhedra.d.ts +40 -0
- package/dist/structure/polyhedra.js +587 -0
- package/dist/structure/site.d.ts +4 -0
- package/dist/structure/site.js +1 -0
- package/dist/structure/supercell.d.ts +1 -2
- package/dist/structure/supercell.js +10 -15
- package/dist/structure/validation.js +5 -6
- package/dist/symmetry/SymmetryElementControls.svelte +69 -0
- package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
- package/dist/symmetry/SymmetryElements.svelte +350 -0
- package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
- package/dist/symmetry/SymmetryStats.svelte +142 -49
- package/dist/symmetry/WyckoffTable.svelte +58 -16
- package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
- package/dist/symmetry/cell-transform.js +8 -14
- package/dist/symmetry/index.d.ts +15 -4
- package/dist/symmetry/index.js +308 -81
- package/dist/symmetry/spacegroups.d.ts +5 -1
- package/dist/symmetry/spacegroups.js +18 -3
- package/dist/symmetry/symmetry-elements.d.ts +33 -0
- package/dist/symmetry/symmetry-elements.js +521 -0
- package/dist/symmetry/wyckoff-db.d.ts +9 -0
- package/dist/symmetry/wyckoff-db.js +87 -0
- package/dist/table/HeatmapTable.svelte +1104 -378
- package/dist/table/HeatmapTable.svelte.d.ts +12 -2
- package/dist/table/ToggleMenu.svelte +5 -12
- package/dist/table/index.d.ts +21 -6
- package/dist/table/index.js +34 -21
- package/dist/theme/ThemeControl.svelte +16 -8
- package/dist/theme/index.d.ts +1 -5
- package/dist/theme/index.js +4 -10
- package/dist/theme/themes.mjs +14 -7
- package/dist/tooltip/KCoords.svelte +4 -1
- package/dist/tooltip/TooltipContent.svelte +2 -5
- package/dist/trajectory/Trajectory.svelte +556 -352
- package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
- package/dist/trajectory/TrajectoryError.svelte +11 -8
- package/dist/trajectory/TrajectoryExportPane.svelte +28 -54
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
- package/dist/trajectory/TrajectoryInfoPane.svelte +88 -99
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
- package/dist/trajectory/constants.js +6 -2
- package/dist/trajectory/extract.js +73 -71
- package/dist/trajectory/format-detect.d.ts +0 -1
- package/dist/trajectory/format-detect.js +13 -17
- package/dist/trajectory/frame-reader.d.ts +2 -1
- package/dist/trajectory/frame-reader.js +74 -136
- package/dist/trajectory/helpers.d.ts +12 -2
- package/dist/trajectory/helpers.js +68 -37
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +3 -0
- package/dist/trajectory/parse/ase.d.ts +9 -1
- package/dist/trajectory/parse/ase.js +47 -32
- package/dist/trajectory/parse/diagnostics.d.ts +3 -0
- package/dist/trajectory/parse/diagnostics.js +14 -0
- package/dist/trajectory/parse/h5-utils.d.ts +13 -0
- package/dist/trajectory/parse/h5-utils.js +109 -0
- package/dist/trajectory/parse/hdf5.d.ts +1 -1
- package/dist/trajectory/parse/hdf5.js +116 -106
- package/dist/trajectory/parse/index.d.ts +3 -4
- package/dist/trajectory/parse/index.js +68 -119
- package/dist/trajectory/parse/lammps.d.ts +0 -2
- package/dist/trajectory/parse/lammps.js +14 -16
- package/dist/trajectory/parse/pymatgen.d.ts +2 -0
- package/dist/trajectory/parse/pymatgen.js +74 -0
- package/dist/trajectory/parse/vasp.js +13 -9
- package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
- package/dist/trajectory/parse/vaspout-electronic.js +207 -0
- package/dist/trajectory/parse/vaspout-h5.d.ts +5 -0
- package/dist/trajectory/parse/vaspout-h5.js +284 -0
- package/dist/trajectory/parse/xyz.d.ts +9 -21
- package/dist/trajectory/parse/xyz.js +38 -39
- package/dist/trajectory/plotting.d.ts +8 -10
- package/dist/trajectory/plotting.js +102 -127
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +8 -1
- package/dist/xrd/XrdPlot.svelte +56 -85
- package/dist/xrd/broadening.d.ts +2 -1
- package/dist/xrd/broadening.js +2 -1
- package/dist/xrd/calc-xrd.js +8 -15
- package/dist/xrd/index.d.ts +2 -2
- package/dist/xrd/parse.d.ts +0 -1
- package/dist/xrd/parse.js +56 -73
- package/package.json +77 -36
- package/dist/api/mp.d.ts +0 -6
- package/dist/api/mp.js +0 -22
- package/dist/element/data.json +0 -11864
- package/dist/fermi-surface/marching-cubes.d.ts +0 -2
- package/dist/fermi-surface/marching-cubes.js +0 -2
- package/dist/plot/core/hover-lock.svelte.d.ts +0 -14
- package/dist/plot/core/hover-lock.svelte.js +0 -45
- package/dist/plot/sunburst/SunburstControls.svelte +0 -200
- package/dist/structure/label-placement.d.ts +0 -14
- package/dist/structure/label-placement.js +0 -72
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
// Shared utilities for trajectory parsing
|
|
2
2
|
import { ATOMIC_NUMBER_TO_SYMBOL } from '../composition/parse';
|
|
3
|
-
import {
|
|
3
|
+
import { is_elem_symbol } from '../element/helpers';
|
|
4
4
|
import * as math from '../math';
|
|
5
|
-
|
|
5
|
+
import { make_site } from '../structure/site';
|
|
6
6
|
const is_valid_row = (row) => {
|
|
7
7
|
if (!(Array.isArray(row) || (ArrayBuffer.isView(row) && `length` in row)))
|
|
8
8
|
return false;
|
|
9
9
|
return math.is_finite_vec3_like(row);
|
|
10
10
|
};
|
|
11
11
|
const is_valid_vec3 = (coords) => Array.isArray(coords) && math.is_finite_vec3_like(coords);
|
|
12
|
-
export const is_valid_element_symbol = (symbol) => element_symbol_set.has(symbol);
|
|
13
|
-
export const coerce_element_symbol = (symbol) => is_valid_element_symbol(symbol) ? symbol : undefined;
|
|
14
12
|
// Validate that data is a proper 3x3 matrix
|
|
15
13
|
// Accepts both regular arrays and typed arrays (Float32Array, Float64Array, etc.)
|
|
16
14
|
export function validate_3x3_matrix(data) {
|
|
@@ -24,11 +22,18 @@ export function validate_3x3_matrix(data) {
|
|
|
24
22
|
}
|
|
25
23
|
export const convert_atomic_numbers = (numbers) => numbers.map((num) => {
|
|
26
24
|
const symbol = ATOMIC_NUMBER_TO_SYMBOL[num];
|
|
27
|
-
if (!symbol || !
|
|
25
|
+
if (!symbol || !is_elem_symbol(symbol)) {
|
|
28
26
|
throw new Error(`Unknown atomic number in trajectory data: ${num}`);
|
|
29
27
|
}
|
|
30
28
|
return symbol;
|
|
31
29
|
});
|
|
30
|
+
// Tally per-element atom counts for trajectory metadata.element_counts
|
|
31
|
+
export const count_elements = (elements) => {
|
|
32
|
+
const counts = {};
|
|
33
|
+
for (const element of elements)
|
|
34
|
+
counts[element] = (counts[element] || 0) + 1;
|
|
35
|
+
return counts;
|
|
36
|
+
};
|
|
32
37
|
export const create_structure = (positions, elements, lattice_matrix, pbc, force_data) => {
|
|
33
38
|
if (positions.length !== elements.length) {
|
|
34
39
|
throw new Error(`create_structure requires matching positions and elements lengths, got positions=${positions.length}, elements=${elements.length}`);
|
|
@@ -42,13 +47,7 @@ export const create_structure = (positions, elements, lattice_matrix, pbc, force
|
|
|
42
47
|
const abc = cart_to_frac ? cart_to_frac(xyz) : [0, 0, 0];
|
|
43
48
|
const force = force_data?.[idx];
|
|
44
49
|
const properties = is_valid_vec3(force) ? { force } : {};
|
|
45
|
-
return {
|
|
46
|
-
species: [{ element: elements[idx], occu: 1, oxidation_state: 0 }],
|
|
47
|
-
abc,
|
|
48
|
-
xyz,
|
|
49
|
-
label: `${elements[idx]}${idx + 1}`,
|
|
50
|
-
properties,
|
|
51
|
-
};
|
|
50
|
+
return make_site(elements[idx], abc, xyz, `${elements[idx]}${idx + 1}`, properties);
|
|
52
51
|
});
|
|
53
52
|
return lattice_matrix
|
|
54
53
|
? {
|
|
@@ -126,39 +125,71 @@ export const read_ndarray_from_view = (view, ref) => {
|
|
|
126
125
|
throw new Error(`Unsupported shape`);
|
|
127
126
|
})();
|
|
128
127
|
};
|
|
129
|
-
//
|
|
130
|
-
export
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
// Copy listed fields from source to target when they hold numbers
|
|
129
|
+
export const copy_numeric_fields = (target, source, fields) => {
|
|
130
|
+
for (const field of fields) {
|
|
131
|
+
if (field in source && typeof source[field] === `number`)
|
|
132
|
+
target[field] = source[field];
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
// Max and RMS of per-atom force magnitudes, or null when no forces present. Loop-based
|
|
136
|
+
// rather than Math.max(...spread) to avoid call-stack overflow on very large frames.
|
|
137
|
+
export function calc_force_stats(forces) {
|
|
138
|
+
if (forces.length === 0)
|
|
139
|
+
return null;
|
|
140
|
+
let force_max = -Infinity;
|
|
141
|
+
let sum_sq = 0;
|
|
142
|
+
for (const force of forces) {
|
|
143
|
+
const magnitude = Math.hypot(...force);
|
|
144
|
+
if (magnitude > force_max)
|
|
145
|
+
force_max = magnitude;
|
|
146
|
+
sum_sq += magnitude ** 2;
|
|
147
|
+
}
|
|
148
|
+
return { force_max, force_norm: Math.sqrt(sum_sq / forces.length) };
|
|
149
|
+
}
|
|
150
|
+
// Walk concatenated (ext)XYZ frames in `lines`, yielding each frame's atom-count line
|
|
151
|
+
// True when a whitespace-split line looks like an XYZ atom line: a short
|
|
152
|
+
// non-numeric element token followed by three numeric coordinates. Shared by
|
|
153
|
+
// trajectory frame iteration and structure-format sniffing so both stay in sync.
|
|
154
|
+
export const is_xyz_atom_line = (parts) => parts !== undefined &&
|
|
155
|
+
parts.length >= 4 &&
|
|
156
|
+
isNaN(Number(parts[0])) &&
|
|
157
|
+
parts[0].length <= 3 &&
|
|
158
|
+
parts.slice(1, 4).every((coord) => coord !== `` && !isNaN(Number(coord)));
|
|
159
|
+
// index, parsed atom count, and comment line. A candidate frame is accepted only when its
|
|
160
|
+
// first few atom lines look like "<element> <x> <y> <z>"; otherwise we advance one line and
|
|
161
|
+
// rescan. That validation doubles as content sniffing so numeric-leading non-XYZ formats
|
|
162
|
+
// (e.g. VASP XDATCAR) aren't misread as frames, and keeps count_xyz_frames consistent with
|
|
163
|
+
// the actual parse/index walk (both go through this single source of truth).
|
|
164
|
+
export function* iter_xyz_frames(lines) {
|
|
135
165
|
let line_idx = 0;
|
|
136
166
|
while (line_idx < lines.length) {
|
|
137
|
-
|
|
138
|
-
line_idx++;
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
const num_atoms = parseInt(lines[line_idx].trim(), 10);
|
|
167
|
+
const num_atoms = Math.trunc(Number(lines[line_idx]?.trim()));
|
|
142
168
|
if (isNaN(num_atoms) || num_atoms <= 0 || line_idx + num_atoms + 2 > lines.length) {
|
|
143
|
-
line_idx++;
|
|
169
|
+
line_idx++; // skip blank/invalid lines until the next frame's atom-count line
|
|
144
170
|
continue;
|
|
145
171
|
}
|
|
146
|
-
// Quick validation of first few atom lines
|
|
147
172
|
let valid_coords = 0;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
valid_coords++;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (valid_coords >= Math.min(num_atoms, 3)) {
|
|
156
|
-
frame_count++;
|
|
157
|
-
line_idx += 2 + num_atoms;
|
|
173
|
+
const sample = Math.min(num_atoms, 3);
|
|
174
|
+
for (let idx = 0; idx < sample; idx++) {
|
|
175
|
+
if (is_xyz_atom_line(lines[line_idx + 2 + idx]?.trim().split(/\s+/)))
|
|
176
|
+
valid_coords++;
|
|
158
177
|
}
|
|
159
|
-
|
|
160
|
-
line_idx++;
|
|
178
|
+
if (valid_coords < sample) {
|
|
179
|
+
line_idx++; // count line looks valid but atom lines don't — likely non-XYZ content
|
|
180
|
+
continue;
|
|
161
181
|
}
|
|
182
|
+
yield { start: line_idx, num_atoms, comment: lines[line_idx + 1] || `` };
|
|
183
|
+
line_idx += num_atoms + 2;
|
|
162
184
|
}
|
|
185
|
+
}
|
|
186
|
+
// Count XYZ frames via iter_xyz_frames so total_frames matches what gets indexed/loaded
|
|
187
|
+
export function count_xyz_frames(data) {
|
|
188
|
+
if (!data || typeof data !== `string`)
|
|
189
|
+
return 0;
|
|
190
|
+
const frames = iter_xyz_frames(data.trim().split(/\r?\n/));
|
|
191
|
+
let frame_count = 0;
|
|
192
|
+
while (!frames.next().done)
|
|
193
|
+
frame_count += 1;
|
|
163
194
|
return frame_count;
|
|
164
195
|
}
|
|
@@ -7,6 +7,7 @@ export { default as TrajectoryExportPane } from './TrajectoryExportPane.svelte';
|
|
|
7
7
|
export { default as TrajectoryInfoPane } from './TrajectoryInfoPane.svelte';
|
|
8
8
|
export type TrajectoryFormat = `hdf5` | `json` | `xyz` | `xdatcar` | `traj` | `unknown`;
|
|
9
9
|
export type { AtomTypeMapping } from './types';
|
|
10
|
+
export declare const FRAME_LOAD_DEBOUNCE_MS = 75;
|
|
10
11
|
export interface ParseProgress {
|
|
11
12
|
current: number;
|
|
12
13
|
total: number;
|
package/dist/trajectory/index.js
CHANGED
|
@@ -2,6 +2,9 @@ export { default as Trajectory } from './Trajectory.svelte';
|
|
|
2
2
|
export { default as TrajectoryError } from './TrajectoryError.svelte';
|
|
3
3
|
export { default as TrajectoryExportPane } from './TrajectoryExportPane.svelte';
|
|
4
4
|
export { default as TrajectoryInfoPane } from './TrajectoryInfoPane.svelte';
|
|
5
|
+
// Debounce for on-demand frame loads while scrubbing: skips fetches for steps
|
|
6
|
+
// the user slides past. Exported so tests stay in sync with the real delay.
|
|
7
|
+
export const FRAME_LOAD_DEBOUNCE_MS = 75;
|
|
5
8
|
export function validate_trajectory(trajectory) {
|
|
6
9
|
// with detailed error reporting
|
|
7
10
|
const errors = [];
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
import type { TrajectoryType } from '../index';
|
|
1
|
+
import type { TrajectoryFrame, TrajectoryType } from '../index';
|
|
2
|
+
export declare const read_ase_header: (view: DataView) => {
|
|
3
|
+
n_items: number;
|
|
4
|
+
offsets_pos: number;
|
|
5
|
+
};
|
|
6
|
+
export declare function decode_ase_frame(view: DataView, buffer: ArrayBuffer, frame_offset: number, step: number, fallback_numbers?: number[], max_json_length?: number): {
|
|
7
|
+
frame: TrajectoryFrame;
|
|
8
|
+
numbers: number[];
|
|
9
|
+
};
|
|
2
10
|
export declare function parse_ase_trajectory(buffer: ArrayBuffer, filename?: string): TrajectoryType;
|
|
@@ -1,18 +1,55 @@
|
|
|
1
1
|
// ASE trajectory (.traj) parsing - binary format
|
|
2
|
+
import * as math from '../../math';
|
|
2
3
|
import { MAX_SAFE_STRING_LENGTH } from '../constants';
|
|
3
4
|
import { convert_atomic_numbers, create_trajectory_frame, read_ndarray_from_view, validate_3x3_matrix, } from '../helpers';
|
|
5
|
+
// ULM header: frame count lives at byte 32, frame-offsets table position at byte 40
|
|
6
|
+
export const read_ase_header = (view) => ({
|
|
7
|
+
n_items: Number(view.getBigInt64(32, true)),
|
|
8
|
+
offsets_pos: Number(view.getBigInt64(40, true)),
|
|
9
|
+
});
|
|
10
|
+
// Decode a single ASE/ULM frame (JSON header + optional ndarray payloads) into a
|
|
11
|
+
// TrajectoryFrame. Returns the atomic numbers actually used so callers can cache them
|
|
12
|
+
// as fallback for later frames that omit `numbers` (ASE stores them only once).
|
|
13
|
+
export function decode_ase_frame(view, buffer, frame_offset, step, fallback_numbers, max_json_length) {
|
|
14
|
+
const json_length = Number(view.getBigInt64(frame_offset, true));
|
|
15
|
+
if (max_json_length !== undefined && json_length > max_json_length) {
|
|
16
|
+
throw new Error(`frame JSON too large: ${json_length} bytes`);
|
|
17
|
+
}
|
|
18
|
+
const frame_data = JSON.parse(new TextDecoder().decode(new Uint8Array(buffer, frame_offset + 8, json_length)));
|
|
19
|
+
const positions_ref = frame_data[`positions.`] ?? frame_data.positions;
|
|
20
|
+
const positions = positions_ref?.ndarray
|
|
21
|
+
? read_ndarray_from_view(view, positions_ref)
|
|
22
|
+
: positions_ref;
|
|
23
|
+
const numbers_ref = frame_data[`numbers.`] ?? frame_data.numbers ?? fallback_numbers;
|
|
24
|
+
const numbers = numbers_ref?.ndarray
|
|
25
|
+
? read_ndarray_from_view(view, numbers_ref).flat()
|
|
26
|
+
: numbers_ref;
|
|
27
|
+
if (!numbers || !positions) {
|
|
28
|
+
throw new Error(`missing ${!numbers ? `numbers` : `positions`}`);
|
|
29
|
+
}
|
|
30
|
+
const cell = frame_data.cell ? validate_3x3_matrix(frame_data.cell) : undefined;
|
|
31
|
+
const metadata = {
|
|
32
|
+
step,
|
|
33
|
+
...frame_data.calculator,
|
|
34
|
+
...frame_data.info,
|
|
35
|
+
};
|
|
36
|
+
if (cell) {
|
|
37
|
+
try {
|
|
38
|
+
metadata.volume = Math.abs(math.det_3x3(cell));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.warn(`Failed to calculate volume for frame ${step}:`, error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const frame = create_trajectory_frame(positions, convert_atomic_numbers(numbers), cell, frame_data.pbc ?? [true, true, true], step, metadata);
|
|
45
|
+
return { frame, numbers };
|
|
46
|
+
}
|
|
4
47
|
export function parse_ase_trajectory(buffer, filename) {
|
|
5
48
|
const view = new DataView(buffer);
|
|
6
|
-
let offset = 0;
|
|
7
49
|
const signature = new TextDecoder().decode(new Uint8Array(buffer, 0, 8));
|
|
8
50
|
if (signature !== `- of Ulm`)
|
|
9
51
|
throw new Error(`Invalid ASE trajectory`);
|
|
10
|
-
|
|
11
|
-
// Skip ASE/Ulm version field; current parsing logic is version-independent.
|
|
12
|
-
offset += 8;
|
|
13
|
-
const n_items = Number(view.getBigInt64(offset, true));
|
|
14
|
-
offset += 8;
|
|
15
|
-
const offsets_pos = Number(view.getBigInt64(offset, true));
|
|
52
|
+
const { n_items, offsets_pos } = read_ase_header(view);
|
|
16
53
|
if (n_items <= 0)
|
|
17
54
|
throw new Error(`Invalid frame count`);
|
|
18
55
|
if (offsets_pos < 0 || offsets_pos + n_items * 8 > buffer.byteLength) {
|
|
@@ -23,31 +60,9 @@ export function parse_ase_trajectory(buffer, filename) {
|
|
|
23
60
|
let global_numbers;
|
|
24
61
|
for (let idx = 0; idx < n_items; idx++) {
|
|
25
62
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (json_length > MAX_SAFE_STRING_LENGTH) {
|
|
30
|
-
console.warn(`Skipping frame ${idx + 1}/${n_items}: too large`);
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
const frame_data = JSON.parse(new TextDecoder().decode(new Uint8Array(buffer, offset, json_length)));
|
|
34
|
-
const positions_ref = frame_data[`positions.`] ?? frame_data.positions;
|
|
35
|
-
const positions = positions_ref?.ndarray
|
|
36
|
-
? read_ndarray_from_view(view, positions_ref)
|
|
37
|
-
: positions_ref;
|
|
38
|
-
const numbers_ref = frame_data[`numbers.`] ?? frame_data.numbers ?? global_numbers;
|
|
39
|
-
const numbers = numbers_ref?.ndarray
|
|
40
|
-
? read_ndarray_from_view(view, numbers_ref).flat()
|
|
41
|
-
: numbers_ref;
|
|
42
|
-
if (numbers)
|
|
43
|
-
global_numbers = numbers;
|
|
44
|
-
if (!numbers || !positions) {
|
|
45
|
-
console.warn(`Skipping ASE frame ${idx + 1}/${n_items}: missing ${!numbers ? `numbers` : `positions`}`);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
const elements = convert_atomic_numbers(numbers);
|
|
49
|
-
const metadata = { step: idx, ...frame_data.calculator, ...frame_data.info };
|
|
50
|
-
frames.push(create_trajectory_frame(positions, elements, frame_data.cell ? validate_3x3_matrix(frame_data.cell) : undefined, frame_data.pbc ?? [true, true, true], idx, metadata));
|
|
63
|
+
const { frame, numbers } = decode_ase_frame(view, buffer, frame_offsets[idx], idx, global_numbers, MAX_SAFE_STRING_LENGTH);
|
|
64
|
+
global_numbers = numbers;
|
|
65
|
+
frames.push(frame);
|
|
51
66
|
}
|
|
52
67
|
catch (error) {
|
|
53
68
|
console.warn(`Error processing frame ${idx + 1}/${n_items}:`, error);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { to_error } from '../../utils';
|
|
2
|
+
// Collector for non-fatal trajectory parse warnings (skipped atoms, dropped frames, plot-metadata extraction failures, ...) so they reach the UI not just the console. Reset at the start of each top-level parse call; format parsers append via traj_warn (mirrored to console.warn). Fatal failures throw — see parse_trajectory_data.
|
|
3
|
+
let traj_parse_warnings = [];
|
|
4
|
+
// Read-only snapshot of warnings since the last top-level parse (attached to trajectory metadata by parse/index.ts for UI surfacing)
|
|
5
|
+
export const get_traj_parse_warnings = () => [...traj_parse_warnings];
|
|
6
|
+
export const reset_traj_parse_warnings = () => void (traj_parse_warnings = []);
|
|
7
|
+
export const traj_warn = (message, error) => {
|
|
8
|
+
const detail = error === undefined ? `` : `: ${to_error(error).message}`;
|
|
9
|
+
traj_parse_warnings.push(`${message}${detail}`);
|
|
10
|
+
if (error === undefined)
|
|
11
|
+
console.warn(message);
|
|
12
|
+
else
|
|
13
|
+
console.warn(`${message}:`, error);
|
|
14
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ElementSymbol } from '../../element/types';
|
|
2
|
+
import type { Matrix3x3 } from '../../math';
|
|
3
|
+
import type { Dataset, Entity, Group } from 'h5wasm';
|
|
4
|
+
import * as h5wasm from 'h5wasm';
|
|
5
|
+
export declare const is_hdf5_dataset: (entity: Entity | null) => entity is Dataset;
|
|
6
|
+
export declare const is_hdf5_group: (entity: Entity | null) => entity is Group;
|
|
7
|
+
export declare const read_dataset: (h5_file: h5wasm.File, path: string) => unknown;
|
|
8
|
+
export declare const to_string_array: (data: unknown) => string[] | null;
|
|
9
|
+
export declare const to_number_array: (data: unknown) => number[] | null;
|
|
10
|
+
export declare const to_scalar_number: (data: unknown) => number | null;
|
|
11
|
+
export declare const scale_matrix: (matrix: Matrix3x3, scale: number) => Matrix3x3;
|
|
12
|
+
export declare const expand_ion_types: (ion_types: string[], ion_counts: number[]) => ElementSymbol[];
|
|
13
|
+
export declare function with_h5_file<T>(buffer: ArrayBuffer, filename: string | undefined, callback: (h5_file: h5wasm.File) => T | Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Shared h5wasm plumbing for HDF5 trajectory parsers: type guards plus the
|
|
2
|
+
// write-to-in-memory-FS/open/cleanup lifecycle both torch-sim and vaspout
|
|
3
|
+
// parsing need (the FS write is the expensive part, so parsers share one open
|
|
4
|
+
// file handle instead of re-opening per format probe).
|
|
5
|
+
import { is_elem_symbol } from '../../element/helpers';
|
|
6
|
+
import * as h5wasm from 'h5wasm';
|
|
7
|
+
export const is_hdf5_dataset = (entity) => entity !== null && `to_array` in entity && entity instanceof h5wasm.Dataset;
|
|
8
|
+
export const is_hdf5_group = (entity) => entity !== null && `keys` in entity && entity instanceof h5wasm.Group;
|
|
9
|
+
// Datasets in interrupted files can be torn mid-chunk, making to_array throw —
|
|
10
|
+
// treat unreadable datasets like missing ones so callers keep what parsed so far.
|
|
11
|
+
export const read_dataset = (h5_file, path) => {
|
|
12
|
+
try {
|
|
13
|
+
const entity = h5_file.get(path);
|
|
14
|
+
return is_hdf5_dataset(entity) ? entity.to_array() : null;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
// h5wasm returns JS strings for variable-length UTF-8 but may hand back byte
|
|
21
|
+
// arrays for fixed-length string datasets (like VASP's |S2 ion_types).
|
|
22
|
+
export const to_string_array = (data) => {
|
|
23
|
+
if (!Array.isArray(data))
|
|
24
|
+
return null;
|
|
25
|
+
const decoder = new TextDecoder();
|
|
26
|
+
const strings = [];
|
|
27
|
+
for (const item of data) {
|
|
28
|
+
if (typeof item === `string`)
|
|
29
|
+
strings.push(item.trim());
|
|
30
|
+
else if (item instanceof Uint8Array)
|
|
31
|
+
strings.push(decoder.decode(item).trim());
|
|
32
|
+
else
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return strings;
|
|
36
|
+
};
|
|
37
|
+
// Integer datasets (like int64 number_ion_types) can surface as BigInt
|
|
38
|
+
// values or typed arrays depending on dtype; normalize to plain numbers.
|
|
39
|
+
export const to_number_array = (data) => {
|
|
40
|
+
const values = Array.isArray(data)
|
|
41
|
+
? data
|
|
42
|
+
: ArrayBuffer.isView(data)
|
|
43
|
+
? Array.from(data)
|
|
44
|
+
: null;
|
|
45
|
+
if (!values)
|
|
46
|
+
return null;
|
|
47
|
+
const numbers = values.map((item) => (typeof item === `bigint` ? Number(item) : item));
|
|
48
|
+
return numbers.every((item) => typeof item === `number` && Number.isFinite(item))
|
|
49
|
+
? numbers
|
|
50
|
+
: null;
|
|
51
|
+
};
|
|
52
|
+
// Scalar datasets surface as plain numbers, 1-element arrays, or BigInt
|
|
53
|
+
// depending on dtype; normalize to a finite number or null.
|
|
54
|
+
export const to_scalar_number = (data) => {
|
|
55
|
+
const value = Array.isArray(data) ? data[0] : data;
|
|
56
|
+
if (typeof value === `bigint`)
|
|
57
|
+
return Number(value);
|
|
58
|
+
return typeof value === `number` && Number.isFinite(value) ? value : null;
|
|
59
|
+
};
|
|
60
|
+
// Apply VASP's POSCAR-style universal scaling factor to lattice vectors
|
|
61
|
+
export const scale_matrix = (matrix, scale) => scale === 1 ? matrix : matrix.map((row) => row.map((val) => val * scale));
|
|
62
|
+
// Expand VASP's (ion_types, number_ion_types) pair into per-atom symbols,
|
|
63
|
+
// e.g. ([Ga, Sb], [1, 1]) -> [Ga, Sb]. Throws on unknown symbols and
|
|
64
|
+
// malformed counts so torn/corrupt HDF5 input fails loudly, not by dropping atoms.
|
|
65
|
+
export const expand_ion_types = (ion_types, ion_counts) => {
|
|
66
|
+
if (ion_types.length !== ion_counts.length) {
|
|
67
|
+
throw new Error(`ion_types (${ion_types.length}) and ion_counts (${ion_counts.length}) length mismatch`);
|
|
68
|
+
}
|
|
69
|
+
const elements = [];
|
|
70
|
+
for (const [type_idx, symbol] of ion_types.entries()) {
|
|
71
|
+
if (!is_elem_symbol(symbol)) {
|
|
72
|
+
throw new Error(`Unknown element symbol in ion_types: ${symbol}`);
|
|
73
|
+
}
|
|
74
|
+
const ion_count = ion_counts[type_idx];
|
|
75
|
+
if (!Number.isFinite(ion_count) || !Number.isInteger(ion_count) || ion_count < 0) {
|
|
76
|
+
throw new Error(`Invalid ion count for ${symbol}: ${ion_count}`);
|
|
77
|
+
}
|
|
78
|
+
for (let count = 0; count < ion_count; count++)
|
|
79
|
+
elements.push(symbol);
|
|
80
|
+
}
|
|
81
|
+
return elements;
|
|
82
|
+
};
|
|
83
|
+
// Writes the buffer to h5wasm's in-memory FS under a unique temp name, opens
|
|
84
|
+
// it, runs the callback (awaiting async ones so cleanup can't race reads),
|
|
85
|
+
// and always closes + unlinks afterwards.
|
|
86
|
+
export async function with_h5_file(buffer, filename, callback) {
|
|
87
|
+
const { FS } = await h5wasm.ready;
|
|
88
|
+
const file_basename = filename
|
|
89
|
+
?.split(`/`)
|
|
90
|
+
.at(-1)
|
|
91
|
+
?.replaceAll(/[^\w.-]/g, `_`) ?? `temp`;
|
|
92
|
+
const unique_suffix = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
93
|
+
const temp_filename = `${file_basename}-${unique_suffix}.h5`;
|
|
94
|
+
FS.writeFile(temp_filename, new Uint8Array(buffer));
|
|
95
|
+
let h5_file = null;
|
|
96
|
+
try {
|
|
97
|
+
h5_file = new h5wasm.File(temp_filename, `r`);
|
|
98
|
+
return await callback(h5_file);
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
h5_file?.close();
|
|
102
|
+
try {
|
|
103
|
+
FS.unlink(temp_filename);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
/* temp file cleanup is best-effort */
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { TrajectoryType } from '../index';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function parse_hdf5_trajectory(buffer: ArrayBuffer, filename?: string): Promise<TrajectoryType>;
|