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,78 +1,96 @@
|
|
|
1
|
-
// HDF5 trajectory parsing
|
|
1
|
+
// HDF5 trajectory parsing: dispatches between VASP vaspout.h5 and the
|
|
2
|
+
// torch-sim / generic dataset-alias layout after a single file open.
|
|
2
3
|
import { calc_lattice_params, transpose_3x3_matrix } from '../../math';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
if (result)
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
4
|
+
import { convert_atomic_numbers, count_elements, create_trajectory_frame, validate_3x3_matrix, } from '../helpers';
|
|
5
|
+
import { is_hdf5_dataset, is_hdf5_group, read_dataset, with_h5_file } from './h5-utils';
|
|
6
|
+
import { is_vaspout_h5_file, parse_vaspout_h5_file } from './vaspout-h5';
|
|
7
|
+
// Routes an opened HDF5 file to the right parser: vaspout.h5 has the VASP 6.x
|
|
8
|
+
// root-group layout, everything else falls through to the torch-sim recursive
|
|
9
|
+
// dataset-name search. One FS write + open, no parse-and-fallback.
|
|
10
|
+
export async function parse_hdf5_trajectory(buffer, filename) {
|
|
11
|
+
return with_h5_file(buffer, filename, (h5_file) => is_vaspout_h5_file(h5_file)
|
|
12
|
+
? parse_vaspout_h5_file(h5_file)
|
|
13
|
+
: parse_torch_sim_h5_file(h5_file));
|
|
14
|
+
}
|
|
15
|
+
// Dataset-name aliases searched (in order) across the whole group tree
|
|
16
|
+
const POSITION_ALIASES = [`positions`, `coords`, `coordinates`];
|
|
17
|
+
const ATOMIC_NUMBER_ALIASES = [`atomic_numbers`, `numbers`, `Z`, `species`];
|
|
18
|
+
const CELL_ALIASES = [`cell`, `cells`, `lattice`];
|
|
19
|
+
const ENERGY_ALIASES = [`potential_energy`, `energy`];
|
|
20
|
+
function parse_torch_sim_h5_file(h5_file) {
|
|
21
|
+
const alias_groups = [POSITION_ALIASES, ATOMIC_NUMBER_ALIASES, CELL_ALIASES, ENERGY_ALIASES];
|
|
22
|
+
const all_aliases = new Set(alias_groups.flat());
|
|
23
|
+
const found_paths = {};
|
|
24
|
+
const found_alias_groups = new Set();
|
|
25
|
+
let total_groups_found = 0;
|
|
26
|
+
const discover = (parent, path = ``) => {
|
|
27
|
+
total_groups_found++;
|
|
28
|
+
for (const name of parent.keys()) {
|
|
29
|
+
const item = parent.get(name);
|
|
30
|
+
const full_path = path ? `${path}/${name}` : `/${name}`;
|
|
31
|
+
if (is_hdf5_dataset(item) && all_aliases.has(name)) {
|
|
32
|
+
found_paths[name] ??= full_path;
|
|
33
|
+
for (const [group_idx, aliases] of alias_groups.entries()) {
|
|
34
|
+
if (aliases.includes(name))
|
|
35
|
+
found_alias_groups.add(group_idx);
|
|
38
36
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return discover(h5_file);
|
|
42
|
-
};
|
|
43
|
-
const positions_data = find_dataset([`positions`, `coords`, `coordinates`])?.to_array();
|
|
44
|
-
const atomic_numbers_data = find_dataset([
|
|
45
|
-
`atomic_numbers`,
|
|
46
|
-
`numbers`,
|
|
47
|
-
`Z`,
|
|
48
|
-
`species`,
|
|
49
|
-
])?.to_array();
|
|
50
|
-
const cells_data = find_dataset([`cell`, `cells`, `lattice`])?.to_array();
|
|
51
|
-
const energies_data = find_dataset([`potential_energy`, `energy`])?.to_array();
|
|
52
|
-
if (!positions_data || !atomic_numbers_data) {
|
|
53
|
-
const missing_datasets = [];
|
|
54
|
-
if (!positions_data) {
|
|
55
|
-
missing_datasets.push(`positions (tried: positions, coords, coordinates)`);
|
|
37
|
+
if (found_alias_groups.size === alias_groups.length)
|
|
38
|
+
return;
|
|
56
39
|
}
|
|
57
|
-
if (
|
|
58
|
-
|
|
40
|
+
else if (is_hdf5_group(item)) {
|
|
41
|
+
discover(item, full_path);
|
|
42
|
+
if (found_alias_groups.size === alias_groups.length)
|
|
43
|
+
return;
|
|
59
44
|
}
|
|
60
|
-
const missing_str = missing_datasets.join(`, `);
|
|
61
|
-
const available_str = Array.from(h5_file.keys()).join(`, `);
|
|
62
|
-
throw new Error(`Missing required dataset(s) in HDF5 file: ${missing_str}. Available datasets: ${available_str}`);
|
|
63
45
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
46
|
+
};
|
|
47
|
+
discover(h5_file);
|
|
48
|
+
const first_path = (names) => names.map((name) => found_paths[name]).find(Boolean);
|
|
49
|
+
const find_dataset = (names) => {
|
|
50
|
+
const path = first_path(names);
|
|
51
|
+
return path ? read_dataset(h5_file, path) : null;
|
|
52
|
+
};
|
|
53
|
+
const positions_data = find_dataset(POSITION_ALIASES);
|
|
54
|
+
const atomic_numbers_data = find_dataset(ATOMIC_NUMBER_ALIASES);
|
|
55
|
+
const cells_data = find_dataset(CELL_ALIASES);
|
|
56
|
+
const energies_data = find_dataset(ENERGY_ALIASES);
|
|
57
|
+
if (!positions_data || !atomic_numbers_data) {
|
|
58
|
+
const missing_datasets = [];
|
|
59
|
+
if (!positions_data) {
|
|
60
|
+
missing_datasets.push(`positions (tried: ${POSITION_ALIASES.join(`, `)})`);
|
|
61
|
+
}
|
|
62
|
+
if (!atomic_numbers_data) {
|
|
63
|
+
missing_datasets.push(`atomic numbers (tried: ${ATOMIC_NUMBER_ALIASES.join(`, `)})`);
|
|
64
|
+
}
|
|
65
|
+
const missing_str = missing_datasets.join(`, `);
|
|
66
|
+
const available_str = [...h5_file.keys()].join(`, `);
|
|
67
|
+
throw new Error(`Missing required dataset(s) in HDF5 file: ${missing_str}. Available datasets: ${available_str}`);
|
|
68
|
+
}
|
|
69
|
+
const positions_are_frames = positions_data.length > 0 &&
|
|
70
|
+
positions_data.every((entry) => Array.isArray(entry) && entry.every((coord) => Array.isArray(coord)));
|
|
71
|
+
const positions = positions_are_frames ? positions_data : [positions_data];
|
|
72
|
+
const atomic_numbers_are_frames = atomic_numbers_data.length > 0 &&
|
|
73
|
+
atomic_numbers_data.every((entry) => Array.isArray(entry));
|
|
74
|
+
const atomic_numbers = atomic_numbers_are_frames
|
|
75
|
+
? atomic_numbers_data
|
|
76
|
+
: [atomic_numbers_data];
|
|
77
|
+
// A constant cell may be stored as a single 3x3 matrix; normalize to a
|
|
78
|
+
// per-frame array so cells[idx] always yields a full lattice (indexing a bare
|
|
79
|
+
// 3x3 with a frame index would hand a single row to validate_3x3_matrix)
|
|
80
|
+
const cells_are_frames = cells_data?.every((entry) => Array.isArray(entry) && entry.every((row) => Array.isArray(row)));
|
|
81
|
+
const cells = cells_data
|
|
82
|
+
? cells_are_frames
|
|
83
|
+
? cells_data
|
|
84
|
+
: [cells_data]
|
|
85
|
+
: null;
|
|
86
|
+
const frames = [];
|
|
87
|
+
let dropped_steps = 0;
|
|
88
|
+
for (const [idx, frame_pos] of positions.entries()) {
|
|
89
|
+
try {
|
|
73
90
|
const frame_atomic_numbers = atomic_numbers[idx] || atomic_numbers[0];
|
|
74
91
|
const frame_elements = convert_atomic_numbers(frame_atomic_numbers);
|
|
75
|
-
|
|
92
|
+
// constant-cell files reuse the single normalized cell for every frame
|
|
93
|
+
const cell = cells_are_frames ? cells?.[idx] : cells?.[0];
|
|
76
94
|
const lattice_mat = cell ? transpose_3x3_matrix(validate_3x3_matrix(cell)) : undefined;
|
|
77
95
|
const energy_entry = energies_data?.[idx];
|
|
78
96
|
const energy = Array.isArray(energy_entry) ? energy_entry[0] : energy_entry;
|
|
@@ -83,45 +101,37 @@ export async function parse_torch_sim_hdf5(buffer, filename) {
|
|
|
83
101
|
metadata.volume = calc_lattice_params(lattice_mat).volume;
|
|
84
102
|
}
|
|
85
103
|
const pbc = lattice_mat ? [true, true, true] : [false, false, false];
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
const first_frame_elements = frames[0]?.structure.sites.map((site) => site.species[0].element) ?? [];
|
|
89
|
-
return {
|
|
90
|
-
frames,
|
|
91
|
-
metadata: {
|
|
92
|
-
source_format: `hdf5_trajectory`,
|
|
93
|
-
frame_count: frames.length,
|
|
94
|
-
num_atoms: first_frame_elements.length,
|
|
95
|
-
periodic_boundary_conditions: cells_data ? [true, true, true] : [false, false, false],
|
|
96
|
-
element_counts: first_frame_elements.reduce((counts, element) => {
|
|
97
|
-
counts[element] = (counts[element] || 0) + 1;
|
|
98
|
-
return counts;
|
|
99
|
-
}, {}),
|
|
100
|
-
discovered_datasets: {
|
|
101
|
-
positions: found_paths.positions ||
|
|
102
|
-
found_paths.coords ||
|
|
103
|
-
found_paths.coordinates ||
|
|
104
|
-
`unknown`,
|
|
105
|
-
atomic_numbers: found_paths.atomic_numbers ||
|
|
106
|
-
found_paths.numbers ||
|
|
107
|
-
found_paths.Z ||
|
|
108
|
-
found_paths.species ||
|
|
109
|
-
`unknown`,
|
|
110
|
-
cells: found_paths.cell || found_paths.cells || found_paths.lattice,
|
|
111
|
-
energies: found_paths.potential_energy || found_paths.energy,
|
|
112
|
-
},
|
|
113
|
-
total_groups_found,
|
|
114
|
-
has_cell_info: Boolean(cells_data),
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
finally {
|
|
119
|
-
h5_file?.close();
|
|
120
|
-
try {
|
|
121
|
-
FS.unlink(temp_filename);
|
|
104
|
+
frames.push(create_trajectory_frame(frame_pos, frame_elements, lattice_mat, pbc, idx, metadata));
|
|
122
105
|
}
|
|
123
|
-
catch {
|
|
124
|
-
|
|
106
|
+
catch (err) {
|
|
107
|
+
// Same torn-tail resiliency as the vaspout parser: interrupted writers
|
|
108
|
+
// zero-fill trailing chunks (atomic number 0, degenerate cells), which
|
|
109
|
+
// fails validation — keep the frames parsed so far and report the rest
|
|
110
|
+
// as dropped. A file whose very first frame is unparsable still throws.
|
|
111
|
+
if (frames.length === 0)
|
|
112
|
+
throw err;
|
|
113
|
+
dropped_steps = positions.length - idx;
|
|
114
|
+
break;
|
|
125
115
|
}
|
|
126
116
|
}
|
|
117
|
+
const first_frame_elements = frames[0]?.structure.sites.map((site) => site.species[0].element) ?? [];
|
|
118
|
+
return {
|
|
119
|
+
frames,
|
|
120
|
+
metadata: {
|
|
121
|
+
source_format: `hdf5_trajectory`,
|
|
122
|
+
frame_count: frames.length,
|
|
123
|
+
num_atoms: first_frame_elements.length,
|
|
124
|
+
periodic_boundary_conditions: cells_data ? [true, true, true] : [false, false, false],
|
|
125
|
+
element_counts: count_elements(first_frame_elements),
|
|
126
|
+
discovered_datasets: {
|
|
127
|
+
positions: first_path(POSITION_ALIASES) ?? `unknown`,
|
|
128
|
+
atomic_numbers: first_path(ATOMIC_NUMBER_ALIASES) ?? `unknown`,
|
|
129
|
+
cells: first_path(CELL_ALIASES),
|
|
130
|
+
energies: first_path(ENERGY_ALIASES),
|
|
131
|
+
},
|
|
132
|
+
total_groups_found,
|
|
133
|
+
has_cell_info: Boolean(cells_data),
|
|
134
|
+
...(dropped_steps > 0 ? { dropped_steps } : {}),
|
|
135
|
+
},
|
|
136
|
+
};
|
|
127
137
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { is_trajectory_file } from '../format-detect';
|
|
2
|
-
import { TrajFrameReader } from '../frame-reader';
|
|
3
1
|
import type { FrameLoader, ParseProgress, TrajectoryType } from '../index';
|
|
4
2
|
import type { AtomTypeMapping, LoadingOptions } from '../types';
|
|
5
|
-
export {
|
|
3
|
+
export { LARGE_FILE_THRESHOLD, MAX_BIN_FILE_SIZE, MAX_TEXT_FILE_SIZE, } from '../constants';
|
|
6
4
|
export type { AtomTypeMapping, LoadingOptions } from '../types';
|
|
7
|
-
export { is_trajectory_file
|
|
5
|
+
export { is_trajectory_file } from '../format-detect';
|
|
6
|
+
export { TrajFrameReader } from '../frame-reader';
|
|
8
7
|
export declare function parse_trajectory_data(data: unknown, filename?: string, atom_type_mapping?: AtomTypeMapping): Promise<TrajectoryType>;
|
|
9
8
|
export declare function get_unsupported_format_message(filename: string, content: string): string | null;
|
|
10
9
|
export declare function parse_trajectory_async(data: ArrayBuffer | string, filename: string, on_progress?: (progress: ParseProgress) => void, options?: LoadingOptions): Promise<TrajectoryType>;
|
|
@@ -1,26 +1,37 @@
|
|
|
1
|
+
// Parsing functions for trajectory data from various formats
|
|
1
2
|
import { is_binary } from '../../io/is-binary';
|
|
2
|
-
import
|
|
3
|
-
import { parse_xyz } from '../../structure/parse';
|
|
3
|
+
import { is_plain_object } from '../../utils';
|
|
4
|
+
import { is_parsed_structure, parse_xyz } from '../../structure/parse';
|
|
4
5
|
import { INDEX_SAMPLE_RATE, LARGE_FILE_THRESHOLD } from '../constants';
|
|
5
|
-
import {
|
|
6
|
+
import { strip_compression_extensions } from '../../io/decompress';
|
|
7
|
+
import { ext_hint, FORMAT_PATTERNS } from '../format-detect';
|
|
6
8
|
import { TrajFrameReader } from '../frame-reader';
|
|
7
|
-
import { count_xyz_frames
|
|
9
|
+
import { count_xyz_frames } from '../helpers';
|
|
8
10
|
import { parse_ase_trajectory } from './ase';
|
|
9
|
-
import {
|
|
11
|
+
import { get_traj_parse_warnings, reset_traj_parse_warnings, traj_warn } from './diagnostics';
|
|
12
|
+
import { parse_hdf5_trajectory } from './hdf5';
|
|
10
13
|
import { parse_lammps_trajectory } from './lammps';
|
|
14
|
+
import { parse_pymatgen_trajectory } from './pymatgen';
|
|
11
15
|
import { parse_vasp_xdatcar } from './vasp';
|
|
12
16
|
import { parse_xyz_trajectory } from './xyz';
|
|
13
|
-
//
|
|
14
|
-
const
|
|
17
|
+
// Throw on a trajectory frame whose structure isn't a valid parsed structure (non-empty sites with species + coords)
|
|
18
|
+
const assert_frame_structure = (structure, label) => {
|
|
19
|
+
if (!is_parsed_structure(structure)) {
|
|
20
|
+
const context = typeof label === `number` ? `trajectory frame ${label}` : label;
|
|
21
|
+
throw new Error(`Invalid structure in ${context}: expected non-empty 'sites' array with species and coordinates`);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
15
24
|
// Re-export constants and types for consumers
|
|
16
|
-
export {
|
|
17
|
-
export { is_trajectory_file
|
|
25
|
+
export { LARGE_FILE_THRESHOLD, MAX_BIN_FILE_SIZE, MAX_TEXT_FILE_SIZE, } from '../constants';
|
|
26
|
+
export { is_trajectory_file } from '../format-detect';
|
|
27
|
+
export { TrajFrameReader } from '../frame-reader';
|
|
18
28
|
export async function parse_trajectory_data(data, filename, atom_type_mapping) {
|
|
29
|
+
reset_traj_parse_warnings();
|
|
19
30
|
if (data instanceof ArrayBuffer) {
|
|
20
31
|
if (FORMAT_PATTERNS.ase(data, filename))
|
|
21
32
|
return parse_ase_trajectory(data, filename);
|
|
22
33
|
if (FORMAT_PATTERNS.hdf5(data, filename))
|
|
23
|
-
return
|
|
34
|
+
return parse_hdf5_trajectory(data, filename);
|
|
24
35
|
throw new Error(`Unsupported binary format${filename ? `: ${filename}` : ``}`);
|
|
25
36
|
}
|
|
26
37
|
if (typeof data === `string`) {
|
|
@@ -35,138 +46,69 @@ export async function parse_trajectory_data(data, filename, atom_type_mapping) {
|
|
|
35
46
|
}
|
|
36
47
|
// Single XYZ fallback (content-sniffed when the filename gives no format hint,
|
|
37
48
|
// e.g. blob: object URLs whose basenames are UUIDs)
|
|
38
|
-
const xyz_hint = ext_hint(filename, /\.(xyz|extxyz)$/);
|
|
49
|
+
const xyz_hint = ext_hint(filename, /\.(?:xyz|extxyz)$/);
|
|
39
50
|
if (xyz_hint || (xyz_hint === null && count_xyz_frames(content) === 1)) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
// Single-frame XYZ parsing failed, continue to JSON parsing.
|
|
51
|
-
log_parse_debug(`Single XYZ parse fallback failed for ${filename ?? `unknown file`}:`, error);
|
|
51
|
+
// parse_xyz never throws (it returns null); fall through to JSON parsing.
|
|
52
|
+
const structure = parse_xyz(content);
|
|
53
|
+
if (structure) {
|
|
54
|
+
return {
|
|
55
|
+
frames: [{ structure, step: 0, metadata: {} }],
|
|
56
|
+
metadata: { source_format: `single_xyz`, frame_count: 1 },
|
|
57
|
+
};
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
try {
|
|
55
61
|
data = JSON.parse(content);
|
|
56
62
|
}
|
|
57
63
|
catch (error) {
|
|
58
|
-
log_parse_debug(`JSON parse failed for ${filename ?? `unknown file`}:`, error);
|
|
59
64
|
throw new Error(`Unsupported text format`, { cause: error });
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
|
-
if (!data || typeof data !== `object`)
|
|
63
|
-
throw new Error(`Invalid data format`);
|
|
64
67
|
// Handle JSON formats
|
|
65
68
|
if (Array.isArray(data)) {
|
|
66
69
|
const frames = data.map((frame_data, idx) => {
|
|
67
70
|
const frame_obj = frame_data;
|
|
68
71
|
const frame_step = frame_obj.step;
|
|
72
|
+
const structure = frame_obj.structure ?? frame_obj;
|
|
73
|
+
assert_frame_structure(structure, idx);
|
|
69
74
|
return {
|
|
70
|
-
structure:
|
|
75
|
+
structure: structure,
|
|
71
76
|
step: typeof frame_step === `number` ? frame_step : idx,
|
|
72
77
|
metadata: frame_obj.metadata || {},
|
|
73
78
|
};
|
|
74
79
|
});
|
|
75
80
|
return { frames, metadata: { source_format: `array`, frame_count: frames.length } };
|
|
76
81
|
}
|
|
77
|
-
|
|
82
|
+
if (!is_plain_object(data))
|
|
83
|
+
throw new Error(`Invalid data format`);
|
|
78
84
|
// Pymatgen format
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
const frame_elements = species.map((specie) => specie.element);
|
|
82
|
-
const coords = obj.coords;
|
|
83
|
-
const matrix = validate_3x3_matrix(obj.lattice);
|
|
84
|
-
const frame_properties = obj.frame_properties || [];
|
|
85
|
-
const frac_to_cart = math.create_frac_to_cart(matrix);
|
|
86
|
-
const frames = coords.map((frame_coords, idx) => {
|
|
87
|
-
const positions = frame_coords.map((abc) => frac_to_cart(abc));
|
|
88
|
-
// Process frame properties to extract numpy arrays
|
|
89
|
-
const raw_properties = frame_properties[idx] || {};
|
|
90
|
-
const processed_properties = {};
|
|
91
|
-
Object.entries(raw_properties).forEach(([key, value]) => {
|
|
92
|
-
if (value &&
|
|
93
|
-
typeof value === `object` &&
|
|
94
|
-
value[`@class`] === `array`) {
|
|
95
|
-
// Extract numpy array data
|
|
96
|
-
const array_obj = value;
|
|
97
|
-
processed_properties[key] = array_obj.data;
|
|
98
|
-
// Calculate force statistics for forces
|
|
99
|
-
if (key === `forces` && Array.isArray(array_obj.data)) {
|
|
100
|
-
const forces = array_obj.data;
|
|
101
|
-
const force_magnitudes = forces.map((force) => Math.hypot(...force));
|
|
102
|
-
if (force_magnitudes.length > 0) {
|
|
103
|
-
processed_properties.force_max = force_magnitudes.reduce((max_val, magnitude) => (magnitude > max_val ? magnitude : max_val), force_magnitudes[0]);
|
|
104
|
-
processed_properties.force_norm = Math.sqrt(force_magnitudes.reduce((sum, f) => sum + f ** 2, 0) / force_magnitudes.length);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// Calculate stress statistics for stress tensor
|
|
108
|
-
if (key === `stress` && Array.isArray(array_obj.data)) {
|
|
109
|
-
const stress_tensor = array_obj.data;
|
|
110
|
-
if (!math.is_square_matrix(stress_tensor, 3)) {
|
|
111
|
-
console.warn(`Invalid stress tensor structure in frame ${idx}`);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
// Calculate stress components (diagonal elements represent normal stresses)
|
|
115
|
-
const normal_stresses = [
|
|
116
|
-
stress_tensor[0][0],
|
|
117
|
-
stress_tensor[1][1],
|
|
118
|
-
stress_tensor[2][2],
|
|
119
|
-
];
|
|
120
|
-
processed_properties.stress_max = Math.max(...normal_stresses.map(Math.abs));
|
|
121
|
-
// Calculate hydrostatic pressure (negative of mean normal stress)
|
|
122
|
-
processed_properties.pressure =
|
|
123
|
-
-(normal_stresses[0] + normal_stresses[1] + normal_stresses[2]) / 3;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
processed_properties[key] = value;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
return create_trajectory_frame(positions, frame_elements, matrix, [true, true, true], idx, processed_properties);
|
|
132
|
-
});
|
|
133
|
-
return {
|
|
134
|
-
frames,
|
|
135
|
-
metadata: {
|
|
136
|
-
filename,
|
|
137
|
-
source_format: `pymatgen_trajectory`,
|
|
138
|
-
frame_count: frames.length,
|
|
139
|
-
species_list: [...new Set(species.map((specie) => specie.element))],
|
|
140
|
-
periodic_boundary_conditions: [true, true, true],
|
|
141
|
-
},
|
|
142
|
-
};
|
|
85
|
+
if (data[`@class`] === `Trajectory` && data.species && data.coords && data.lattice) {
|
|
86
|
+
return parse_pymatgen_trajectory(data, filename);
|
|
143
87
|
}
|
|
144
88
|
// Object with frames
|
|
145
|
-
if (Array.isArray(
|
|
146
|
-
const metadata = (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
};
|
|
89
|
+
if (Array.isArray(data.frames)) {
|
|
90
|
+
const metadata = (data.metadata ?? {});
|
|
91
|
+
const frames = data.frames;
|
|
92
|
+
frames.forEach((frame, idx) => assert_frame_structure(frame?.structure, idx));
|
|
93
|
+
return { frames, metadata: { ...metadata, source_format: `object_with_frames` } };
|
|
151
94
|
}
|
|
152
|
-
// Single structure
|
|
153
|
-
if (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
95
|
+
// Single structure (treated as a 1-frame trajectory)
|
|
96
|
+
if (data.sites) {
|
|
97
|
+
assert_frame_structure(data, `single structure`);
|
|
98
|
+
const frames = [{ structure: data, step: 0, metadata: {} }];
|
|
99
|
+
const metadata = { source_format: `single_structure`, frame_count: 1 };
|
|
100
|
+
return { frames, metadata };
|
|
158
101
|
}
|
|
159
102
|
throw new Error(`Unrecognized trajectory format`);
|
|
160
103
|
}
|
|
161
104
|
export function get_unsupported_format_message(filename, content) {
|
|
162
105
|
const lower = filename.toLowerCase();
|
|
163
106
|
// Check for unsupported compression formats first
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
]
|
|
169
|
-
for (const { ext, name } of unsupported_compression) {
|
|
107
|
+
for (const [ext, name] of [
|
|
108
|
+
[`.bz2`, `BZ2`],
|
|
109
|
+
[`.xz`, `XZ`],
|
|
110
|
+
[`.zip`, `ZIP`],
|
|
111
|
+
]) {
|
|
170
112
|
if (lower.endsWith(ext)) {
|
|
171
113
|
return `🚫 ${name} compression not supported in browser\nPlease decompress the file first`;
|
|
172
114
|
}
|
|
@@ -187,10 +129,20 @@ export function get_unsupported_format_message(filename, content) {
|
|
|
187
129
|
? `🚫 Binary format not supported${filename ? `: ${filename}` : ``}`
|
|
188
130
|
: null;
|
|
189
131
|
}
|
|
132
|
+
// Attach non-fatal parse warnings (skipped atoms, dropped frames, plot-metadata
|
|
133
|
+
// extraction failures, ...) collected during parsing to the trajectory metadata so
|
|
134
|
+
// the UI can surface them instead of leaving them in the console only.
|
|
135
|
+
function attach_parse_warnings(trajectory) {
|
|
136
|
+
const parse_warnings = get_traj_parse_warnings();
|
|
137
|
+
if (parse_warnings.length === 0)
|
|
138
|
+
return trajectory;
|
|
139
|
+
return { ...trajectory, metadata: { ...trajectory.metadata, parse_warnings } };
|
|
140
|
+
}
|
|
190
141
|
// Unified async parser with streaming support
|
|
191
142
|
export async function parse_trajectory_async(data, filename, on_progress, options = {}) {
|
|
192
143
|
const { use_indexing, index_sample_rate = INDEX_SAMPLE_RATE, extract_plot_metadata = true, atom_type_mapping, } = options;
|
|
193
144
|
const update_progress = (current, stage) => on_progress?.({ current, total: 100, stage });
|
|
145
|
+
reset_traj_parse_warnings();
|
|
194
146
|
try {
|
|
195
147
|
update_progress(0, `Detecting format...`);
|
|
196
148
|
const data_size = data instanceof ArrayBuffer ? data.byteLength : new TextEncoder().encode(data).byteLength;
|
|
@@ -203,21 +155,18 @@ export async function parse_trajectory_async(data, filename, on_progress, option
|
|
|
203
155
|
// When the filename gives no format hint (e.g. blob: URLs), sniff a content
|
|
204
156
|
// prefix for XYZ frames so large extensionless files still get indexed.
|
|
205
157
|
const base_filename = strip_compression_extensions(filename);
|
|
206
|
-
const can_index = /\.(xyz|extxyz|traj)$/.test(base_filename) ||
|
|
158
|
+
const can_index = /\.(?:xyz|extxyz|traj)$/.test(base_filename) ||
|
|
207
159
|
(typeof data === `string` &&
|
|
208
|
-
ext_hint(filename, /\.(xyz|extxyz)$/) === null &&
|
|
160
|
+
ext_hint(filename, /\.(?:xyz|extxyz)$/) === null &&
|
|
209
161
|
count_xyz_frames(data.slice(0, 2 ** 20)) >= 1);
|
|
210
162
|
if (should_use_indexing && can_index) {
|
|
211
|
-
return await parse_with_unified_loader(data, filename, {
|
|
212
|
-
index_sample_rate,
|
|
213
|
-
extract_plot_metadata,
|
|
214
|
-
}, on_progress);
|
|
163
|
+
return attach_parse_warnings(await parse_with_unified_loader(data, filename, { index_sample_rate, extract_plot_metadata }, on_progress));
|
|
215
164
|
}
|
|
216
165
|
// Fallback to direct parsing
|
|
217
166
|
update_progress(10, `Parsing trajectory...`);
|
|
218
167
|
const result = await parse_trajectory_data(data, filename, atom_type_mapping);
|
|
219
168
|
update_progress(100, `Complete`);
|
|
220
|
-
return result;
|
|
169
|
+
return attach_parse_warnings(result);
|
|
221
170
|
}
|
|
222
171
|
catch (error) {
|
|
223
172
|
const error_message = error instanceof Error ? error.message : `Unknown error`;
|
|
@@ -259,7 +208,7 @@ async function parse_with_unified_loader(data, filename, options, on_progress) {
|
|
|
259
208
|
});
|
|
260
209
|
}
|
|
261
210
|
catch (error) {
|
|
262
|
-
|
|
211
|
+
traj_warn(`Failed to extract plot metadata`, error);
|
|
263
212
|
}
|
|
264
213
|
}
|
|
265
214
|
const stage = `Ready: ${total_frames} frames indexed`;
|
|
@@ -279,7 +228,7 @@ async function parse_with_unified_loader(data, filename, options, on_progress) {
|
|
|
279
228
|
}
|
|
280
229
|
// Factory function for frame loader (simplified)
|
|
281
230
|
export function create_frame_loader(filename) {
|
|
282
|
-
if (!/\.(xyz|extxyz|traj)$/.
|
|
231
|
+
if (!/\.(?:xyz|extxyz|traj)$/.test(filename.toLowerCase())) {
|
|
283
232
|
throw new Error(`Unsupported format for frame loading: ${filename}`);
|
|
284
233
|
}
|
|
285
234
|
return new TrajFrameReader(filename);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as math from '../../math';
|
|
2
1
|
import type { TrajectoryType } from '../index';
|
|
3
2
|
import type { AtomTypeMapping } from '../types';
|
|
4
|
-
export declare function parse_lammps_box(box_lines: string[], is_triclinic: boolean): math.Matrix3x3 | null;
|
|
5
3
|
export declare function parse_lammps_trajectory(content: string, filename?: string, atom_type_mapping?: AtomTypeMapping): TrajectoryType;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ELEM_SYMBOLS } from '../../labels';
|
|
2
2
|
import * as math from '../../math';
|
|
3
|
-
import {
|
|
3
|
+
import { coerce_elem_symbol } from '../../element/helpers';
|
|
4
|
+
import { count_elements, create_trajectory_frame } from '../helpers';
|
|
5
|
+
import { traj_warn } from './diagnostics';
|
|
4
6
|
const is_periodic = (token) => token.toLowerCase().startsWith(`p`);
|
|
5
7
|
// Parse LAMMPS box bounds → lattice matrix. Handles orthogonal and triclinic boxes.
|
|
6
8
|
// Triclinic: converts bounding box to actual dims per https://docs.lammps.org/Howto_triclinic.html
|
|
7
9
|
// Lattice vectors: a=(lx,0,0), b=(xy,ly,0), c=(xz,yz,lz)
|
|
8
|
-
|
|
10
|
+
function parse_lammps_box(box_lines, is_triclinic) {
|
|
9
11
|
if (box_lines.length !== 3)
|
|
10
12
|
return null;
|
|
11
13
|
const bounds = box_lines.map((line) => line.split(/\s+/).map(Number));
|
|
@@ -58,11 +60,11 @@ export function parse_lammps_trajectory(content, filename, atom_type_mapping) {
|
|
|
58
60
|
if (!skip_to(`ITEM: TIMESTEP`))
|
|
59
61
|
break;
|
|
60
62
|
idx++;
|
|
61
|
-
const timestep =
|
|
63
|
+
const timestep = Math.trunc(Number(read_line())) || 0;
|
|
62
64
|
if (!skip_to(`ITEM: NUMBER OF ATOMS`))
|
|
63
65
|
break;
|
|
64
66
|
idx++;
|
|
65
|
-
const num_atoms =
|
|
67
|
+
const num_atoms = Math.trunc(Number(read_line()));
|
|
66
68
|
if (!num_atoms || num_atoms <= 0)
|
|
67
69
|
continue;
|
|
68
70
|
// BOX BOUNDS: orthogonal="pp pp pp", triclinic="xy xz yz pp pp pp"
|
|
@@ -100,7 +102,7 @@ export function parse_lammps_trajectory(content, filename, atom_type_mapping) {
|
|
|
100
102
|
if (pos_cols.some((col_idx) => col_idx === undefined))
|
|
101
103
|
continue;
|
|
102
104
|
if (type_col === undefined && element_col === undefined && id_col === undefined) {
|
|
103
|
-
|
|
105
|
+
traj_warn(`Skipping LAMMPS frame at timestep ${timestep}: missing type/element/id column`);
|
|
104
106
|
continue;
|
|
105
107
|
}
|
|
106
108
|
// Parse atom data
|
|
@@ -109,7 +111,7 @@ export function parse_lammps_trajectory(content, filename, atom_type_mapping) {
|
|
|
109
111
|
const frac_to_cart = use_scaled ? math.create_frac_to_cart(lattice_matrix) : null;
|
|
110
112
|
for (let atom = 0; atom < num_atoms && idx < lines.length; atom++) {
|
|
111
113
|
const parts = read_line().split(/\s+/);
|
|
112
|
-
const coords = pos_cols.map((col_idx) =>
|
|
114
|
+
const coords = pos_cols.map((col_idx) => Number(parts[col_idx]));
|
|
113
115
|
if (coords.some(isNaN) || parts.length <= max_col_idx)
|
|
114
116
|
continue;
|
|
115
117
|
// Convert scaled coordinates to Cartesian if needed
|
|
@@ -117,7 +119,7 @@ export function parse_lammps_trajectory(content, filename, atom_type_mapping) {
|
|
|
117
119
|
let element_symbol;
|
|
118
120
|
if (type_col !== undefined) {
|
|
119
121
|
// Map atom type to element using custom mapping or default (type 1 -> H, etc.)
|
|
120
|
-
const atom_type =
|
|
122
|
+
const atom_type = Math.trunc(Number(parts[type_col])) || 1;
|
|
121
123
|
atom_types_found.add(atom_type);
|
|
122
124
|
element_symbol = get_element(atom_type);
|
|
123
125
|
}
|
|
@@ -125,17 +127,17 @@ export function parse_lammps_trajectory(content, filename, atom_type_mapping) {
|
|
|
125
127
|
const raw_symbol = parts[element_col];
|
|
126
128
|
if (!raw_symbol)
|
|
127
129
|
continue;
|
|
128
|
-
element_symbol =
|
|
130
|
+
element_symbol = coerce_elem_symbol(raw_symbol);
|
|
129
131
|
if (!element_symbol) {
|
|
130
|
-
|
|
132
|
+
traj_warn(`Skipping LAMMPS atom with unknown element symbol "${raw_symbol}" at timestep ${timestep}`);
|
|
131
133
|
continue;
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
136
|
else if (id_col !== undefined) {
|
|
135
|
-
const atom_id =
|
|
137
|
+
const atom_id = Math.trunc(Number(parts[id_col])) || 1;
|
|
136
138
|
atom_types_found.add(atom_id);
|
|
137
139
|
if (!id_fallback_warning_emitted) {
|
|
138
|
-
|
|
140
|
+
traj_warn(`LAMMPS parser fallback: mapping atom IDs to elements from ID column; this may be incorrect for large or sequential IDs. Prefer a TYPE column when available.`);
|
|
139
141
|
id_fallback_warning_emitted = true;
|
|
140
142
|
}
|
|
141
143
|
element_symbol = get_element(atom_id);
|
|
@@ -157,11 +159,7 @@ export function parse_lammps_trajectory(content, filename, atom_type_mapping) {
|
|
|
157
159
|
throw new Error(`No valid frames found in LAMMPS trajectory`);
|
|
158
160
|
}
|
|
159
161
|
const first_frame = frames[0];
|
|
160
|
-
const element_counts = first_frame.structure.sites.
|
|
161
|
-
const elem = site.species[0].element;
|
|
162
|
-
counts[elem] = (counts[elem] || 0) + 1;
|
|
163
|
-
return counts;
|
|
164
|
-
}, {});
|
|
162
|
+
const element_counts = count_elements(first_frame.structure.sites.map((site) => site.species[0].element));
|
|
165
163
|
return {
|
|
166
164
|
frames,
|
|
167
165
|
metadata: {
|