matterviz 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brillouin/BrillouinZone.svelte +68 -145
- package/dist/brillouin/BrillouinZone.svelte.d.ts +5 -14
- package/dist/brillouin/BrillouinZoneExportPane.svelte +43 -96
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +9 -32
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +49 -203
- 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.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +100 -191
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +176 -464
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -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.js +2 -2
- package/dist/composition/FormulaFilter.svelte +6 -5
- package/dist/composition/PieChart.svelte +5 -5
- package/dist/composition/chem-sys.js +3 -2
- package/dist/composition/format.js +3 -2
- package/dist/composition/parse.d.ts +0 -1
- package/dist/composition/parse.js +17 -19
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +0 -1
- package/dist/convex-hull/ConvexHull.svelte +8 -10
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
- package/dist/convex-hull/ConvexHull2D.svelte +94 -175
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +176 -680
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +180 -680
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +268 -0
- package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
- package/dist/convex-hull/ConvexHullControls.svelte +88 -7
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
- package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
- package/dist/convex-hull/ConvexHullStats.svelte +29 -168
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +11 -2
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
- package/dist/convex-hull/barycentric-coords.d.ts +2 -4
- package/dist/convex-hull/barycentric-coords.js +6 -33
- package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
- package/dist/convex-hull/canvas-interactions.svelte.js +278 -0
- package/dist/convex-hull/helpers.d.ts +39 -7
- package/dist/convex-hull/helpers.js +154 -69
- 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 +91 -920
- package/dist/convex-hull/types.d.ts +12 -4
- package/dist/convex-hull/types.js +12 -0
- package/dist/coordination/CoordinationBarPlot.svelte +4 -11
- package/dist/element/BohrAtom.svelte +2 -1
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/element/index.d.ts +4 -0
- package/dist/element/index.js +18 -0
- package/dist/feedback/DragOverlay.svelte +3 -1
- package/dist/feedback/DragOverlay.svelte.d.ts +1 -0
- package/dist/feedback/StatusMessage.svelte +13 -3
- package/dist/fermi-surface/FermiSurface.svelte +67 -146
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +5 -14
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +72 -224
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
- package/dist/fermi-surface/compute.js +11 -10
- 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 +64 -75
- package/dist/fermi-surface/types.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +55 -40
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +4 -3
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +3 -2
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
- package/dist/heatmap-matrix/index.d.ts +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/ExportPane.svelte +166 -0
- package/dist/io/ExportPane.svelte.d.ts +17 -0
- package/dist/io/decompress.js +1 -2
- package/dist/io/export.d.ts +5 -1
- package/dist/io/export.js +32 -28
- package/dist/io/fetch.d.ts +2 -1
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +13 -0
- package/dist/io/index.d.ts +2 -0
- package/dist/io/index.js +10 -0
- package/dist/io/types.d.ts +13 -0
- package/dist/isosurface/parse.js +46 -44
- package/dist/labels.js +1 -1
- package/dist/layout/FullscreenButton.svelte +33 -0
- package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
- package/dist/layout/FullscreenToggle.svelte +8 -14
- package/dist/layout/ViewerChrome.svelte +116 -0
- package/dist/layout/ViewerChrome.svelte.d.ts +17 -0
- package/dist/layout/fullscreen.d.ts +4 -0
- package/dist/layout/fullscreen.svelte.d.ts +8 -0
- package/dist/layout/fullscreen.svelte.js +37 -0
- package/dist/layout/index.d.ts +3 -0
- package/dist/layout/index.js +3 -0
- package/dist/math.d.ts +7 -3
- package/dist/math.js +18 -21
- package/dist/overlays/index.d.ts +4 -0
- package/dist/periodic-table/PeriodicTable.svelte +9 -8
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramControls.svelte +3 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +47 -132
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
- package/dist/phase-diagram/colors.js +1 -1
- package/dist/phase-diagram/parse.d.ts +2 -1
- package/dist/plot/bar/BarPlot.svelte +79 -316
- package/dist/plot/bar/BarPlot.svelte.d.ts +7 -15
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/bar/SpacegroupBarPlot.svelte +2 -1
- package/dist/plot/box/BoxPlot.svelte +76 -246
- package/dist/plot/box/BoxPlot.svelte.d.ts +4 -3
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
- package/dist/plot/box/Violin.svelte.d.ts +1 -1
- package/dist/plot/box/box-plot.d.ts +3 -2
- package/dist/plot/box/box-plot.js +5 -2
- 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 +4 -1
- package/dist/plot/core/components/ColorBar.svelte +5 -5
- package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
- package/dist/plot/core/components/Line.svelte +3 -2
- package/dist/plot/core/components/Line.svelte.d.ts +3 -2
- package/dist/plot/core/components/PlotAxis.svelte +2 -1
- package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
- package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/core/components/ReferenceLine3D.svelte +2 -2
- package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
- package/dist/plot/core/components/ReferencePlane.svelte +2 -2
- package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
- package/dist/plot/core/data-cleaning.js +18 -18
- package/dist/plot/core/fill-utils.d.ts +4 -3
- package/dist/plot/core/fill-utils.js +6 -3
- package/dist/plot/core/interactions.d.ts +5 -1
- package/dist/plot/core/interactions.js +14 -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 +6 -6
- package/dist/plot/core/scales.d.ts +17 -25
- package/dist/plot/core/scales.js +10 -8
- package/dist/plot/core/svg.d.ts +2 -1
- package/dist/plot/core/types.d.ts +18 -7
- package/dist/plot/core/utils/label-placement.d.ts +1 -1
- package/dist/plot/core/utils/label-placement.js +3 -3
- package/dist/plot/core/utils.d.ts +2 -1
- package/dist/plot/histogram/Histogram.svelte +77 -314
- package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/sankey/Sankey.svelte +2 -5
- package/dist/plot/sankey/Sankey.svelte.d.ts +1 -1
- package/dist/plot/sankey/sankey.js +3 -1
- package/dist/plot/scatter/BinnedScatterPlot.svelte +3 -5
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +4 -4
- package/dist/plot/scatter/ScatterPlot.svelte +160 -450
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +7 -15
- package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/scatter/binned-scatter-types.d.ts +4 -11
- package/dist/plot/scatter/index.d.ts +1 -1
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte +15 -26
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +9 -10
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +122 -121
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
- package/dist/plot/scatter-3d/Surface3D.svelte +6 -5
- package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
- package/dist/plot/sunburst/Sunburst.svelte +16 -20
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
- package/dist/plot/sunburst/SunburstControls.svelte.d.ts +1 -1
- package/dist/plot/sunburst/sunburst.js +4 -1
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/sanitize.js +13 -2
- package/dist/scene/SceneCamera.svelte +62 -0
- package/dist/scene/SceneCamera.svelte.d.ts +19 -0
- package/dist/scene/bind-renderer.svelte.d.ts +2 -0
- package/dist/scene/bind-renderer.svelte.js +14 -0
- package/dist/scene/index.d.ts +4 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/props.js +52 -0
- package/dist/scene/types.d.ts +26 -0
- package/dist/scene/types.js +1 -0
- package/dist/settings.d.ts +14 -2
- package/dist/settings.js +59 -1
- package/dist/spectral/Bands.svelte +8 -7
- package/dist/spectral/Bands.svelte.d.ts +3 -2
- package/dist/spectral/BandsAndDos.svelte +22 -24
- package/dist/spectral/BrillouinBandsDos.svelte +3 -3
- package/dist/spectral/Dos.svelte +5 -4
- package/dist/spectral/Dos.svelte.d.ts +2 -1
- package/dist/spectral/helpers.d.ts +6 -6
- package/dist/spectral/helpers.js +43 -37
- package/dist/state.svelte.d.ts +0 -7
- package/dist/state.svelte.js +0 -6
- package/dist/structure/Arrow.svelte +2 -4
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/CanvasTooltip.svelte +1 -0
- package/dist/structure/CellSelect.svelte +11 -3
- package/dist/structure/CellSelect.svelte.d.ts +2 -1
- package/dist/structure/Lattice.svelte +2 -2
- package/dist/structure/Structure.svelte +291 -355
- package/dist/structure/Structure.svelte.d.ts +5 -15
- package/dist/structure/StructureControls.svelte +217 -2
- package/dist/structure/StructureControls.svelte.d.ts +5 -3
- package/dist/structure/StructureExportPane.svelte +54 -156
- package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
- package/dist/structure/StructureInfoPane.svelte +5 -3
- package/dist/structure/StructureInfoPane.svelte.d.ts +5 -5
- package/dist/structure/StructureScene.svelte +365 -198
- package/dist/structure/StructureScene.svelte.d.ts +22 -20
- package/dist/structure/{label-placement.d.ts → atom-label-placement.d.ts} +3 -3
- package/dist/structure/{label-placement.js → atom-label-placement.js} +12 -2
- package/dist/structure/atom-properties.d.ts +1 -1
- package/dist/structure/atom-properties.js +11 -16
- package/dist/structure/bond-order-perception.js +2 -4
- package/dist/structure/bonding.d.ts +3 -0
- package/dist/structure/bonding.js +91 -48
- package/dist/structure/export.d.ts +24 -4
- package/dist/structure/export.js +64 -122
- package/dist/structure/index.d.ts +2 -0
- package/dist/structure/index.js +2 -0
- package/dist/structure/parse.d.ts +3 -2
- package/dist/structure/parse.js +333 -370
- package/dist/structure/partial-occupancy.d.ts +0 -1
- package/dist/structure/partial-occupancy.js +1 -1
- package/dist/structure/pbc.d.ts +1 -1
- package/dist/structure/pbc.js +186 -13
- package/dist/structure/polyhedra.d.ts +41 -0
- package/dist/structure/polyhedra.js +602 -0
- package/dist/structure/site.d.ts +4 -0
- package/dist/structure/site.js +1 -0
- package/dist/structure/supercell.js +3 -2
- package/dist/structure/validation.js +5 -6
- package/dist/symmetry/SymmetryElementControls.svelte +69 -0
- package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
- package/dist/symmetry/SymmetryElements.svelte +354 -0
- package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
- package/dist/symmetry/SymmetryStats.svelte +111 -6
- package/dist/symmetry/WyckoffTable.svelte +68 -7
- package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
- package/dist/symmetry/cell-transform.js +7 -14
- package/dist/symmetry/index.d.ts +14 -4
- package/dist/symmetry/index.js +301 -80
- package/dist/symmetry/spacegroups.d.ts +5 -1
- package/dist/symmetry/spacegroups.js +15 -1
- 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 +4 -15
- package/dist/table/HeatmapTable.svelte.d.ts +1 -1
- package/dist/trajectory/Trajectory.svelte +58 -61
- package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
- package/dist/trajectory/TrajectoryExportPane.svelte +15 -24
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
- package/dist/trajectory/TrajectoryInfoPane.svelte +3 -2
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
- package/dist/trajectory/constants.js +6 -2
- package/dist/trajectory/extract.js +17 -37
- package/dist/trajectory/format-detect.d.ts +0 -1
- package/dist/trajectory/format-detect.js +3 -9
- package/dist/trajectory/frame-reader.d.ts +0 -1
- package/dist/trajectory/frame-reader.js +62 -128
- package/dist/trajectory/helpers.d.ts +10 -2
- package/dist/trajectory/helpers.js +56 -36
- 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/index.d.ts +1 -1
- package/dist/trajectory/parse/index.js +54 -102
- package/dist/trajectory/parse/lammps.d.ts +0 -2
- package/dist/trajectory/parse/lammps.js +8 -6
- package/dist/trajectory/parse/pymatgen.d.ts +2 -0
- package/dist/trajectory/parse/pymatgen.js +74 -0
- package/dist/trajectory/parse/vasp.js +4 -3
- package/dist/trajectory/parse/xyz.d.ts +9 -21
- package/dist/trajectory/parse/xyz.js +28 -33
- package/dist/trajectory/plotting.d.ts +0 -1
- package/dist/trajectory/plotting.js +3 -100
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -1
- package/dist/xrd/XrdPlot.svelte +14 -29
- package/dist/xrd/broadening.d.ts +2 -1
- package/dist/xrd/calc-xrd.js +6 -11
- package/dist/xrd/index.d.ts +2 -2
- package/package.json +29 -16
- 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
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type
|
|
3
|
-
import { normalize_show_controls } from '../controls'
|
|
2
|
+
import { normalize_show_controls, type ShowControlsProp } from '../controls'
|
|
4
3
|
import type { ElementSymbol } from '../element'
|
|
5
4
|
import EmptyState from '../EmptyState.svelte'
|
|
5
|
+
import { StatusMessage } from '../feedback'
|
|
6
6
|
import Spinner from '../feedback/Spinner.svelte'
|
|
7
7
|
import Icon from '../Icon.svelte'
|
|
8
|
-
import { handle_url_drop, load_from_url } from '../io'
|
|
8
|
+
import { drag_over_handlers, handle_url_drop, load_from_url } from '../io'
|
|
9
9
|
import { forward_window_keydown, handle_and_prevent } from '../keyboard'
|
|
10
10
|
import { format_num, trajectory_property_config } from '../labels'
|
|
11
|
+
import type { Vec2 } from '../math'
|
|
11
12
|
import { sanitize_html } from '../sanitize'
|
|
12
|
-
import { toggle_fullscreen } from '../layout'
|
|
13
|
+
import { FullscreenButton, type FullscreenToggleProp, toggle_fullscreen } from '../layout'
|
|
14
|
+
import { sync_fullscreen } from '../layout/fullscreen.svelte'
|
|
13
15
|
import type { ControlsConfig, DataSeries, Orientation, Point } from '../plot'
|
|
14
16
|
import type { ScatterHandlerProps } from '../plot/core/types'
|
|
15
17
|
import { Histogram, ScatterPlot } from '../plot'
|
|
@@ -99,6 +101,10 @@
|
|
|
99
101
|
atom_type_mapping,
|
|
100
102
|
plot_skimming = true,
|
|
101
103
|
hovered = $bindable(false),
|
|
104
|
+
controls_open = $bindable(false),
|
|
105
|
+
info_pane_open = $bindable(false),
|
|
106
|
+
wrapper = $bindable(),
|
|
107
|
+
fullscreen = $bindable(false),
|
|
102
108
|
...rest
|
|
103
109
|
}: EventHandlers & HTMLAttributes<HTMLDivElement> & {
|
|
104
110
|
// trajectory data - can be provided directly or loaded from file
|
|
@@ -134,7 +140,7 @@
|
|
|
134
140
|
// Control names: 'filename', 'nav', 'step', 'fps', 'info-pane', 'export-pane', 'view-mode', 'fullscreen'
|
|
135
141
|
show_controls?: ShowControlsProp
|
|
136
142
|
// show/hide the fullscreen button
|
|
137
|
-
fullscreen_toggle?:
|
|
143
|
+
fullscreen_toggle?: FullscreenToggleProp
|
|
138
144
|
// automatically start playing when trajectory data is loaded
|
|
139
145
|
auto_play?: boolean
|
|
140
146
|
// display mode: 'structure+scatter' (default), 'structure' (only structure), 'scatter' (only scatter), 'histogram' (only histogram), 'structure+histogram' (structure with histogram)
|
|
@@ -160,24 +166,7 @@
|
|
|
160
166
|
// - e.g. {energy: 'Total Energy', volume: 'Cell Volume', force_max: 'Max Force'}
|
|
161
167
|
// - merged with built-in trajectory_property_config
|
|
162
168
|
ELEM_PROPERTY_LABELS?: Record<string, string>
|
|
163
|
-
|
|
164
|
-
units?: {
|
|
165
|
-
energy?: string
|
|
166
|
-
energy_per_atom?: string
|
|
167
|
-
force_max?: string
|
|
168
|
-
force_norm?: string
|
|
169
|
-
stress_max?: string
|
|
170
|
-
volume?: string
|
|
171
|
-
density?: string
|
|
172
|
-
temperature?: string
|
|
173
|
-
pressure?: string
|
|
174
|
-
length?: string
|
|
175
|
-
a?: string
|
|
176
|
-
b?: string
|
|
177
|
-
c?: string
|
|
178
|
-
[key: string]: string | undefined
|
|
179
|
-
}
|
|
180
|
-
fps_range?: [number, number] // allowed FPS range [min_fps, max_fps]
|
|
169
|
+
fps_range?: Vec2 // allowed FPS range [min_fps, max_fps]
|
|
181
170
|
fps?: number // frame rate for playback
|
|
182
171
|
// Loading options for large files
|
|
183
172
|
loading_options?: LoadingOptions
|
|
@@ -187,11 +176,29 @@
|
|
|
187
176
|
plot_skimming?: boolean
|
|
188
177
|
// bindable: true while the pointer is over the viewer (drives hover-scoped shortcuts)
|
|
189
178
|
hovered?: boolean
|
|
179
|
+
// bindable: whether the (structure) controls pane is currently open
|
|
180
|
+
controls_open?: boolean
|
|
181
|
+
// bindable: whether the trajectory info pane is currently open
|
|
182
|
+
info_pane_open?: boolean
|
|
183
|
+
// bindable: top-level wrapper element
|
|
184
|
+
wrapper?: HTMLDivElement
|
|
185
|
+
// bindable: fullscreen state
|
|
186
|
+
fullscreen?: boolean
|
|
190
187
|
} = $props()
|
|
191
188
|
|
|
192
189
|
let dragover = $state(false)
|
|
193
190
|
let loading = $state(false)
|
|
194
191
|
let error_msg = $state<string | null>(null)
|
|
192
|
+
// Non-fatal parse warnings from trajectory metadata (set by parser via attach_parse_warnings); dismissible
|
|
193
|
+
let parse_warning_msg = $state<string | undefined>(undefined)
|
|
194
|
+
$effect(() => {
|
|
195
|
+
const warnings = trajectory?.metadata?.parse_warnings
|
|
196
|
+
parse_warning_msg = Array.isArray(warnings) && warnings.length > 0
|
|
197
|
+
? `${warnings.length} parse warning${warnings.length > 1 ? `s` : ``}: ${
|
|
198
|
+
warnings.join(`; `)
|
|
199
|
+
}`
|
|
200
|
+
: undefined
|
|
201
|
+
})
|
|
195
202
|
let is_playing = $state(false)
|
|
196
203
|
let play_interval: ReturnType<typeof setInterval> | undefined = $state(undefined)
|
|
197
204
|
|
|
@@ -207,8 +214,6 @@
|
|
|
207
214
|
let current_file_path = $state<string | null>(null)
|
|
208
215
|
let file_size = $state<number | undefined>(undefined)
|
|
209
216
|
let file_object = $state<File | null>(null)
|
|
210
|
-
let wrapper = $state<HTMLDivElement | undefined>(undefined)
|
|
211
|
-
let info_pane_open = $state(false)
|
|
212
217
|
let parsing_progress = $state<ParseProgress | null>(null)
|
|
213
218
|
let element_size = $state({ width: 0, height: 0 })
|
|
214
219
|
let filename_copied = $state(false)
|
|
@@ -868,24 +873,23 @@
|
|
|
868
873
|
|
|
869
874
|
// Separate state variables for each pane to match component prop types
|
|
870
875
|
let structure_info_open = $state(false)
|
|
871
|
-
let structure_controls_open = $state(false)
|
|
872
876
|
let scatter_controls = $state<ControlsConfig>({ open: false })
|
|
873
877
|
let trajectory_export_open = $state(false)
|
|
874
|
-
let fullscreen = $state(false)
|
|
875
|
-
</script>
|
|
876
878
|
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
879
|
+
sync_fullscreen({
|
|
880
|
+
get_wrapper: () => wrapper,
|
|
881
|
+
get_fullscreen: () => fullscreen,
|
|
882
|
+
set_fullscreen: (val) => (fullscreen = val),
|
|
883
|
+
bg_css_var: `--traj-bg-fullscreen`,
|
|
884
|
+
on_change: (val) => on_fullscreen_change?.({ trajectory, fullscreen: val }),
|
|
885
|
+
})
|
|
886
|
+
</script>
|
|
883
887
|
|
|
884
888
|
<svelte:window onkeydown={forward_window_keydown(() => hovered, onkeydown)} />
|
|
885
889
|
|
|
886
890
|
<div
|
|
887
891
|
class:dragover
|
|
888
|
-
class:active={is_playing || structure_info_open ||
|
|
892
|
+
class:active={is_playing || structure_info_open || controls_open ||
|
|
889
893
|
scatter_controls.open || trajectory_export_open || info_pane_open}
|
|
890
894
|
bind:this={wrapper}
|
|
891
895
|
bind:clientWidth={element_size.width}
|
|
@@ -896,15 +900,7 @@
|
|
|
896
900
|
onmouseenter={() => (hovered = true)}
|
|
897
901
|
onmouseleave={() => (hovered = false)}
|
|
898
902
|
ondrop={handle_file_drop}
|
|
899
|
-
|
|
900
|
-
event.preventDefault()
|
|
901
|
-
if (!allow_file_drop) return
|
|
902
|
-
dragover = true
|
|
903
|
-
}}
|
|
904
|
-
ondragleave={(event) => {
|
|
905
|
-
event.preventDefault()
|
|
906
|
-
dragover = false
|
|
907
|
-
}}
|
|
903
|
+
{...drag_over_handlers({ allow: () => allow_file_drop, set_dragover: (over) => dragover = over })}
|
|
908
904
|
onclick={handle_click_outside}
|
|
909
905
|
onkeydown={handle_and_prevent(onkeydown)}
|
|
910
906
|
{...rest}
|
|
@@ -928,6 +924,14 @@
|
|
|
928
924
|
{error_snippet}
|
|
929
925
|
/>
|
|
930
926
|
{:else if trajectory}
|
|
927
|
+
{#if parse_warning_msg}
|
|
928
|
+
<StatusMessage
|
|
929
|
+
bind:message={parse_warning_msg}
|
|
930
|
+
type="warning"
|
|
931
|
+
dismissible
|
|
932
|
+
style="position: absolute; bottom: 4pt; left: 4pt; right: 4pt; z-index: 2; font-size: 0.85em"
|
|
933
|
+
/>
|
|
934
|
+
{/if}
|
|
931
935
|
<!-- Trajectory Controls -->
|
|
932
936
|
{#if controls_config.mode !== `never`}
|
|
933
937
|
<div
|
|
@@ -1150,22 +1154,14 @@
|
|
|
1150
1154
|
</div>
|
|
1151
1155
|
{/if}
|
|
1152
1156
|
<!-- Fullscreen button - rightmost position -->
|
|
1153
|
-
{#if fullscreen_toggle &&
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
title="{fullscreen ? `Exit` : `Enter`} fullscreen"
|
|
1157
|
+
{#if fullscreen_toggle && controls_config.visible(`fullscreen`)}
|
|
1158
|
+
<FullscreenButton
|
|
1159
|
+
{fullscreen}
|
|
1160
|
+
toggle={fullscreen_toggle}
|
|
1161
|
+
{wrapper}
|
|
1159
1162
|
aria-label="{fullscreen ? `Exit` : `Enter`} fullscreen"
|
|
1160
|
-
aria-pressed={fullscreen}
|
|
1161
1163
|
class="fullscreen-button"
|
|
1162
|
-
|
|
1163
|
-
{#if typeof fullscreen_toggle === `function`}
|
|
1164
|
-
{@render fullscreen_toggle({ fullscreen })}
|
|
1165
|
-
{:else}
|
|
1166
|
-
<Icon icon="{fullscreen ? `Exit` : ``}Fullscreen" />
|
|
1167
|
-
{/if}
|
|
1168
|
-
</button>
|
|
1164
|
+
/>
|
|
1169
1165
|
{/if}
|
|
1170
1166
|
</div>
|
|
1171
1167
|
{/if}
|
|
@@ -1189,7 +1185,7 @@
|
|
|
1189
1185
|
show_image_atoms: false, // Default to false to avoid atoms popping in/out at cell edges
|
|
1190
1186
|
...structure_props,
|
|
1191
1187
|
}}
|
|
1192
|
-
bind:controls_open
|
|
1188
|
+
bind:controls_open
|
|
1193
1189
|
bind:info_pane_open={structure_info_open}
|
|
1194
1190
|
bind:hidden_elements
|
|
1195
1191
|
/>
|
|
@@ -1316,7 +1312,7 @@
|
|
|
1316
1312
|
height: 100vh !important;
|
|
1317
1313
|
width: 100vw !important;
|
|
1318
1314
|
border-radius: 0 !important;
|
|
1319
|
-
background: var(--surface-bg);
|
|
1315
|
+
background: var(--traj-bg-fullscreen, var(--surface-bg));
|
|
1320
1316
|
overflow: hidden;
|
|
1321
1317
|
}
|
|
1322
1318
|
&.horizontal .content-area {
|
|
@@ -1458,7 +1454,8 @@
|
|
|
1458
1454
|
opacity: 0;
|
|
1459
1455
|
}
|
|
1460
1456
|
}
|
|
1461
|
-
.
|
|
1457
|
+
/* :global pierces into FullscreenButton's markup (anchored on local .info-section) */
|
|
1458
|
+
.info-section :global(.fullscreen-button) {
|
|
1462
1459
|
background: transparent !important;
|
|
1463
1460
|
padding: 0;
|
|
1464
1461
|
&:hover:not(:disabled) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ShowControlsProp } from '../controls';
|
|
2
2
|
import Spinner from '../feedback/Spinner.svelte';
|
|
3
|
+
import type { Vec2 } from '../math';
|
|
4
|
+
import { type FullscreenToggleProp } from '../layout';
|
|
3
5
|
import type { Orientation } from '../plot';
|
|
4
6
|
import { Histogram, ScatterPlot } from '../plot';
|
|
5
7
|
import Structure from '../structure/Structure.svelte';
|
|
@@ -42,37 +44,23 @@ type $$ComponentProps = EventHandlers & HTMLAttributes<HTMLDivElement> & {
|
|
|
42
44
|
on_dismiss: () => void;
|
|
43
45
|
}]>;
|
|
44
46
|
show_controls?: ShowControlsProp;
|
|
45
|
-
fullscreen_toggle?:
|
|
46
|
-
fullscreen: boolean;
|
|
47
|
-
}]> | boolean;
|
|
47
|
+
fullscreen_toggle?: FullscreenToggleProp;
|
|
48
48
|
auto_play?: boolean;
|
|
49
49
|
display_mode?: `structure+scatter` | `structure` | `scatter` | `histogram` | `structure+histogram`;
|
|
50
50
|
step_labels?: number | number[];
|
|
51
51
|
visible_properties?: string[];
|
|
52
52
|
ELEM_PROPERTY_LABELS?: Record<string, string>;
|
|
53
|
-
|
|
54
|
-
energy?: string;
|
|
55
|
-
energy_per_atom?: string;
|
|
56
|
-
force_max?: string;
|
|
57
|
-
force_norm?: string;
|
|
58
|
-
stress_max?: string;
|
|
59
|
-
volume?: string;
|
|
60
|
-
density?: string;
|
|
61
|
-
temperature?: string;
|
|
62
|
-
pressure?: string;
|
|
63
|
-
length?: string;
|
|
64
|
-
a?: string;
|
|
65
|
-
b?: string;
|
|
66
|
-
c?: string;
|
|
67
|
-
[key: string]: string | undefined;
|
|
68
|
-
};
|
|
69
|
-
fps_range?: [number, number];
|
|
53
|
+
fps_range?: Vec2;
|
|
70
54
|
fps?: number;
|
|
71
55
|
loading_options?: LoadingOptions;
|
|
72
56
|
atom_type_mapping?: AtomTypeMapping;
|
|
73
57
|
plot_skimming?: boolean;
|
|
74
58
|
hovered?: boolean;
|
|
59
|
+
controls_open?: boolean;
|
|
60
|
+
info_pane_open?: boolean;
|
|
61
|
+
wrapper?: HTMLDivElement;
|
|
62
|
+
fullscreen?: boolean;
|
|
75
63
|
};
|
|
76
|
-
declare const Trajectory: import("svelte").Component<$$ComponentProps, {}, "trajectory" | "hovered" | "fps" | "display_mode" | "current_step_idx" | "visible_properties">;
|
|
64
|
+
declare const Trajectory: import("svelte").Component<$$ComponentProps, {}, "trajectory" | "fullscreen" | "wrapper" | "hovered" | "controls_open" | "fps" | "info_pane_open" | "display_mode" | "current_step_idx" | "visible_properties">;
|
|
77
65
|
type Trajectory = ReturnType<typeof Trajectory>;
|
|
78
66
|
export default Trajectory;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { PaneProps, PaneToggleProps } from '../overlays'
|
|
2
3
|
import {
|
|
4
|
+
estimate_video_bitrate,
|
|
3
5
|
export_trajectory_video,
|
|
4
6
|
get_ffmpeg_conversion_command,
|
|
7
|
+
observe_canvas_presence,
|
|
5
8
|
} from '../io/export'
|
|
9
|
+
import ExportPane from '../io/ExportPane.svelte'
|
|
6
10
|
import SettingsSection from '../layout/SettingsSection.svelte'
|
|
7
|
-
import DraggablePane from '../overlays/DraggablePane.svelte'
|
|
8
11
|
import type { TrajectoryType } from './'
|
|
9
12
|
import type { ComponentProps } from 'svelte'
|
|
10
13
|
import { tooltip } from 'svelte-multiselect/attachments'
|
|
@@ -36,8 +39,8 @@
|
|
|
36
39
|
// Function to change trajectory step during export
|
|
37
40
|
on_step_change?: (step_idx: number) => Promise<void> | void
|
|
38
41
|
// Pane customization
|
|
39
|
-
pane_props?:
|
|
40
|
-
toggle_props?:
|
|
42
|
+
pane_props?: PaneProps
|
|
43
|
+
toggle_props?: PaneToggleProps
|
|
41
44
|
} = $props()
|
|
42
45
|
|
|
43
46
|
let is_exporting = $state(false)
|
|
@@ -58,7 +61,7 @@
|
|
|
58
61
|
let file_size_mb = $derived.by(() => {
|
|
59
62
|
if (!canvas) return 0
|
|
60
63
|
const pixels = canvas.width * canvas.height * resolution_multiplier ** 2
|
|
61
|
-
const bitrate =
|
|
64
|
+
const bitrate = estimate_video_bitrate(pixels, video_fps)
|
|
62
65
|
return (bitrate * export_frame_count / video_fps) / 8 / 1024 / 1024
|
|
63
66
|
})
|
|
64
67
|
|
|
@@ -138,24 +141,12 @@
|
|
|
138
141
|
|
|
139
142
|
let has_canvas = $state(false)
|
|
140
143
|
|
|
141
|
-
$effect(() =>
|
|
142
|
-
if (!wrapper) {
|
|
143
|
-
has_canvas = false
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
const check = () => (has_canvas = Boolean(wrapper.querySelector(`canvas`)))
|
|
147
|
-
check()
|
|
148
|
-
const observer = new MutationObserver(check)
|
|
149
|
-
observer.observe(wrapper, { childList: true, subtree: true })
|
|
150
|
-
return () => observer.disconnect()
|
|
151
|
-
})
|
|
144
|
+
$effect(() => observe_canvas_presence(wrapper, (val) => (has_canvas = val)))
|
|
152
145
|
</script>
|
|
153
146
|
|
|
154
|
-
<
|
|
155
|
-
bind:
|
|
156
|
-
|
|
157
|
-
closed_icon="Export"
|
|
158
|
-
pane_props={{ ...pane_props, class: `export-pane ${pane_props?.class ?? ``}` }}
|
|
147
|
+
<ExportPane
|
|
148
|
+
bind:export_pane_open
|
|
149
|
+
{pane_props}
|
|
159
150
|
toggle_props={{
|
|
160
151
|
title: export_pane_open ? `` : `Export Trajectory`,
|
|
161
152
|
...toggle_props,
|
|
@@ -194,14 +185,14 @@
|
|
|
194
185
|
Resolution
|
|
195
186
|
<div class="resolution-buttons">
|
|
196
187
|
{#each [0.5, 1, 2, 4, 8] as multiplier (multiplier)}
|
|
197
|
-
{@const
|
|
198
|
-
{@const
|
|
188
|
+
{@const width_px = canvas ? Math.round(canvas.width * multiplier) : 0}
|
|
189
|
+
{@const height_px = canvas ? Math.round(canvas.height * multiplier) : 0}
|
|
199
190
|
<button
|
|
200
191
|
type="button"
|
|
201
192
|
class:active={resolution_multiplier === multiplier}
|
|
202
193
|
onclick={() => (resolution_multiplier = multiplier)}
|
|
203
194
|
{@attach tooltip({
|
|
204
|
-
content: canvas ? `${multiplier}x (${
|
|
195
|
+
content: canvas ? `${multiplier}x (${width_px}×${height_px})` : `${multiplier}x`,
|
|
205
196
|
})}
|
|
206
197
|
>
|
|
207
198
|
{multiplier}x
|
|
@@ -292,7 +283,7 @@
|
|
|
292
283
|
<div class="warning">Waiting for canvas...</div>
|
|
293
284
|
{/if}
|
|
294
285
|
{/if}
|
|
295
|
-
</
|
|
286
|
+
</ExportPane>
|
|
296
287
|
|
|
297
288
|
<style>
|
|
298
289
|
.field-label {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { PaneProps, PaneToggleProps } from '../overlays';
|
|
2
2
|
import type { TrajectoryType } from './';
|
|
3
|
-
import type { ComponentProps } from 'svelte';
|
|
4
3
|
type $$ComponentProps = {
|
|
5
4
|
export_pane_open?: boolean;
|
|
6
5
|
trajectory?: TrajectoryType;
|
|
@@ -9,9 +8,9 @@ type $$ComponentProps = {
|
|
|
9
8
|
video_fps?: number;
|
|
10
9
|
resolution_multiplier?: number;
|
|
11
10
|
on_step_change?: (step_idx: number) => Promise<void> | void;
|
|
12
|
-
pane_props?:
|
|
13
|
-
toggle_props?:
|
|
11
|
+
pane_props?: PaneProps;
|
|
12
|
+
toggle_props?: PaneToggleProps;
|
|
14
13
|
};
|
|
15
|
-
declare const TrajectoryExportPane: import("svelte").Component<$$ComponentProps, {}, "
|
|
14
|
+
declare const TrajectoryExportPane: import("svelte").Component<$$ComponentProps, {}, "resolution_multiplier" | "export_pane_open" | "video_fps">;
|
|
16
15
|
type TrajectoryExportPane = ReturnType<typeof TrajectoryExportPane>;
|
|
17
16
|
export default TrajectoryExportPane;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { PaneProps, PaneToggleProps } from '../overlays'
|
|
2
3
|
import type { InfoItem } from '../layout'
|
|
3
4
|
import InfoPaneCards from '../overlays/InfoPaneCards.svelte'
|
|
4
5
|
import { format_num } from '../labels'
|
|
@@ -28,8 +29,8 @@
|
|
|
28
29
|
file_size?: number | null
|
|
29
30
|
file_object?: File | null
|
|
30
31
|
pane_open?: boolean
|
|
31
|
-
toggle_props?:
|
|
32
|
-
pane_props?:
|
|
32
|
+
toggle_props?: PaneToggleProps
|
|
33
|
+
pane_props?: PaneProps
|
|
33
34
|
} = $props()
|
|
34
35
|
|
|
35
36
|
// Helper functions
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PaneProps, PaneToggleProps } from '../overlays';
|
|
1
2
|
import DraggablePane from '../overlays/DraggablePane.svelte';
|
|
2
3
|
import type { ComponentProps } from 'svelte';
|
|
3
4
|
import type { TrajectoryType } from './index';
|
|
@@ -9,8 +10,8 @@ type $$ComponentProps = Omit<ComponentProps<typeof DraggablePane>, `children`> &
|
|
|
9
10
|
file_size?: number | null;
|
|
10
11
|
file_object?: File | null;
|
|
11
12
|
pane_open?: boolean;
|
|
12
|
-
toggle_props?:
|
|
13
|
-
pane_props?:
|
|
13
|
+
toggle_props?: PaneToggleProps;
|
|
14
|
+
pane_props?: PaneProps;
|
|
14
15
|
};
|
|
15
16
|
declare const TrajectoryInfoPane: import("svelte").Component<$$ComponentProps, {}, "pane_open">;
|
|
16
17
|
type TrajectoryInfoPane = ReturnType<typeof TrajectoryInfoPane>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// Constants for trajectory parsing and large file handling
|
|
2
|
+
import { DEFAULTS } from '../settings';
|
|
2
3
|
export const MAX_SAFE_STRING_LENGTH = 0x1fffffe8 * 0.5; // 50% of JS max string length as safety
|
|
3
4
|
export const MAX_METADATA_SIZE = 50 * 1024 * 1024; // 50MB limit for metadata
|
|
4
5
|
export const LARGE_FILE_THRESHOLD = 400 * 1024 * 1024; // 400MB
|
|
5
6
|
export const INDEX_SAMPLE_RATE = 100; // Default sample rate for frame indexing
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
// Fallback thresholds for component usage without loading_options, derived from the
|
|
8
|
+
// settings schema so settings-driven contexts (e.g. the VSCode extension) and direct
|
|
9
|
+
// component use agree on when large-file/indexed loading kicks in.
|
|
10
|
+
export const MAX_BIN_FILE_SIZE = DEFAULTS.trajectory.bin_file_threshold; // 50MB
|
|
11
|
+
export const MAX_TEXT_FILE_SIZE = DEFAULTS.trajectory.text_file_threshold; // 25MB
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Data extraction functions for trajectory analysis and plotting
|
|
2
2
|
import { get_density } from '../structure/index';
|
|
3
|
+
import { calc_force_stats, copy_numeric_fields } from './helpers';
|
|
3
4
|
// Common data extractor that extracts energy and structural properties
|
|
4
5
|
export const energy_data_extractor = (frame) => {
|
|
5
6
|
const data = {
|
|
@@ -7,18 +8,13 @@ export const energy_data_extractor = (frame) => {
|
|
|
7
8
|
};
|
|
8
9
|
if (frame.metadata) {
|
|
9
10
|
// Extract energy-related properties
|
|
10
|
-
|
|
11
|
+
copy_numeric_fields(data, frame.metadata, [
|
|
11
12
|
`energy`,
|
|
12
13
|
`energy_per_atom`,
|
|
13
14
|
`potential_energy`,
|
|
14
15
|
`kinetic_energy`,
|
|
15
16
|
`total_energy`,
|
|
16
|
-
];
|
|
17
|
-
for (const field of energy_fields) {
|
|
18
|
-
if (field in frame.metadata && typeof frame.metadata[field] === `number`) {
|
|
19
|
-
data[field] = frame.metadata[field];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
17
|
+
]);
|
|
22
18
|
}
|
|
23
19
|
return data;
|
|
24
20
|
};
|
|
@@ -30,13 +26,8 @@ export const force_stress_data_extractor = (frame) => {
|
|
|
30
26
|
if (frame.metadata) {
|
|
31
27
|
// Calculate force properties from forces array if available (preferred)
|
|
32
28
|
if (frame.metadata.forces && Array.isArray(frame.metadata.forces)) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const force_magnitudes = forces.map((force) => Math.hypot(...force));
|
|
36
|
-
data.force_max = Math.max(...force_magnitudes);
|
|
37
|
-
// Calculate RMS (root mean square) of force magnitudes
|
|
38
|
-
data.force_norm = Math.sqrt(force_magnitudes.reduce((sum, f) => sum + f ** 2, 0) / force_magnitudes.length);
|
|
39
|
-
}
|
|
29
|
+
// Object.assign ignores the null calc_force_stats returns for empty forces
|
|
30
|
+
Object.assign(data, calc_force_stats(frame.metadata.forces));
|
|
40
31
|
}
|
|
41
32
|
else {
|
|
42
33
|
// Fallback to metadata values if forces array not available
|
|
@@ -52,12 +43,12 @@ export const force_stress_data_extractor = (frame) => {
|
|
|
52
43
|
}
|
|
53
44
|
}
|
|
54
45
|
// Extract other stress and pressure properties (no duplicates expected)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
copy_numeric_fields(data, frame.metadata, [
|
|
47
|
+
`stress_max`,
|
|
48
|
+
`stress_frobenius`,
|
|
49
|
+
`stress_trace`,
|
|
50
|
+
`pressure`,
|
|
51
|
+
]);
|
|
61
52
|
}
|
|
62
53
|
return data;
|
|
63
54
|
};
|
|
@@ -79,31 +70,20 @@ export const structural_data_extractor = (frame) => {
|
|
|
79
70
|
}
|
|
80
71
|
if (frame.metadata) {
|
|
81
72
|
// Extract other structural properties, avoiding volume duplicate
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// Handle density separately - prefer metadata, but calculate if not available
|
|
88
|
-
if (frame.metadata.density && typeof frame.metadata.density === `number`) {
|
|
73
|
+
copy_numeric_fields(data, frame.metadata, [`temperature`]);
|
|
74
|
+
// Prefer metadata density (fall back to calculating from structure below).
|
|
75
|
+
// Finite-number check (not truthiness) so a legitimate density of 0 is kept.
|
|
76
|
+
if (typeof frame.metadata.density === `number` &&
|
|
77
|
+
Number.isFinite(frame.metadata.density)) {
|
|
89
78
|
data.density = frame.metadata.density;
|
|
90
79
|
}
|
|
91
|
-
else if (`lattice` in frame.structure) {
|
|
92
|
-
try {
|
|
93
|
-
data.density = get_density(frame.structure);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
console.warn(`Failed to calculate density for frame ${frame.step}:`, error);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
80
|
// Only use metadata volume if lattice volume is not available
|
|
100
81
|
if (!data.volume && frame.metadata.volume && typeof frame.metadata.volume === `number`) {
|
|
101
82
|
data.volume = frame.metadata.volume;
|
|
102
83
|
}
|
|
103
84
|
// Note: pressure is handled by force_stress_data_extractor to avoid duplication
|
|
104
85
|
}
|
|
105
|
-
|
|
106
|
-
// Calculate density even when no metadata is available
|
|
86
|
+
if (data.density === undefined && `lattice` in frame.structure) {
|
|
107
87
|
try {
|
|
108
88
|
data.density = get_density(frame.structure);
|
|
109
89
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare function strip_compression_extensions(filename: string): string;
|
|
2
1
|
export declare function ext_hint(filename: string | undefined, ext_regex: RegExp): boolean | null;
|
|
3
2
|
export declare const FORMAT_PATTERNS: {
|
|
4
3
|
readonly ase: (data: unknown, filename?: string) => boolean;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
// Format detection for trajectory files
|
|
2
|
-
import {
|
|
2
|
+
import { CONFIG_DIRS_REGEX, MD_SIM_EXCLUDE_REGEX, TRAJ_EXTENSIONS_REGEX, TRAJ_FALLBACK_EXTENSIONS_REGEX, TRAJ_KEYWORDS_SIMPLE_REGEX, XDATCAR_REGEX, } from '../constants';
|
|
3
|
+
import { strip_compression_extensions } from '../io';
|
|
3
4
|
import { count_xyz_frames } from './helpers';
|
|
4
|
-
export function strip_compression_extensions(filename) {
|
|
5
|
-
let base_name = filename.toLowerCase();
|
|
6
|
-
while (COMPRESSION_EXTENSIONS_REGEX.test(base_name)) {
|
|
7
|
-
base_name = base_name.replace(COMPRESSION_EXTENSIONS_REGEX, ``);
|
|
8
|
-
}
|
|
9
|
-
return base_name;
|
|
10
|
-
}
|
|
11
5
|
// Extensions that explicitly identify a format — when present, format detection trusts
|
|
12
6
|
// the extension instead of sniffing content
|
|
13
7
|
const KNOWN_FORMAT_EXT_REGEX = /\.(xyz|extxyz|traj|h5|hdf5|lammpstrj|json|cif|poscar|vasp|yaml|yml|xml|csv)$/;
|
|
@@ -40,7 +34,7 @@ export const FORMAT_PATTERNS = {
|
|
|
40
34
|
if (!(data instanceof ArrayBuffer) || data.byteLength < 8)
|
|
41
35
|
return false;
|
|
42
36
|
const signature = new Uint8Array(data.slice(0, 8));
|
|
43
|
-
return [0x89, 0x48, 0x44, 0x46, 0x0d, 0x0a, 0x1a, 0x0a].every((
|
|
37
|
+
return [0x89, 0x48, 0x44, 0x46, 0x0d, 0x0a, 0x1a, 0x0a].every((byte, idx) => signature[idx] === byte);
|
|
44
38
|
},
|
|
45
39
|
vasp: (data, filename) => {
|
|
46
40
|
const basename = filename?.toLowerCase().split(`/`).pop() ?? ``;
|
|
@@ -12,6 +12,5 @@ export declare class TrajFrameReader implements FrameLoader {
|
|
|
12
12
|
}, on_progress?: (progress: ParseProgress) => void): Promise<TrajectoryMetadata[]>;
|
|
13
13
|
private load_xyz_frame;
|
|
14
14
|
private load_ase_frame;
|
|
15
|
-
private parse_xyz_metadata;
|
|
16
15
|
private parse_ase_metadata;
|
|
17
16
|
}
|