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
package/dist/spectral/helpers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Helper utilities for band structure and DOS data processing
|
|
2
2
|
import { SUBSCRIPT_MAP } from '../labels';
|
|
3
|
-
import {
|
|
3
|
+
import { is_plain_object } from '../utils';
|
|
4
|
+
import { euclidean_dist, is_square_matrix } from '../math';
|
|
4
5
|
const is_subscript_key = (key) => key in SUBSCRIPT_MAP;
|
|
5
6
|
// Check if range is a valid [min, max] tuple (strict 2-element array of finite numbers)
|
|
6
7
|
export const is_valid_range = (range) => Array.isArray(range) &&
|
|
@@ -204,7 +205,7 @@ export function normalize_densities(densities, freqs_or_energies, mode) {
|
|
|
204
205
|
return normalized.map((dens) => dens / max_val);
|
|
205
206
|
}
|
|
206
207
|
else if (mode === `sum`) {
|
|
207
|
-
const sum = normalized.reduce((acc,
|
|
208
|
+
const sum = normalized.reduce((acc, dens) => acc + dens, 0);
|
|
208
209
|
if (sum === 0)
|
|
209
210
|
return normalized;
|
|
210
211
|
return normalized.map((dens) => dens / sum);
|
|
@@ -215,7 +216,7 @@ export function normalize_densities(densities, freqs_or_energies, mode) {
|
|
|
215
216
|
const bin_width = freqs_or_energies[1] - freqs_or_energies[0];
|
|
216
217
|
if (bin_width === 0)
|
|
217
218
|
return normalized;
|
|
218
|
-
const sum = normalized.reduce((acc,
|
|
219
|
+
const sum = normalized.reduce((acc, dens) => acc + dens, 0);
|
|
219
220
|
if (sum === 0)
|
|
220
221
|
return normalized;
|
|
221
222
|
return normalized.map((dens) => dens / (sum * bin_width));
|
|
@@ -250,7 +251,7 @@ function generate_smearing_cache_key(freqs_or_energies, densities, sigma) {
|
|
|
250
251
|
}
|
|
251
252
|
// Core Gaussian smearing computation (unmemoized)
|
|
252
253
|
function apply_gaussian_smearing_core(freqs_or_energies, densities, sigma) {
|
|
253
|
-
const orig_sum = densities.reduce((acc,
|
|
254
|
+
const orig_sum = densities.reduce((acc, dens) => acc + dens, 0);
|
|
254
255
|
if (sigma <= 0 || orig_sum === 0)
|
|
255
256
|
return densities;
|
|
256
257
|
const smeared = Array(densities.length).fill(0);
|
|
@@ -269,7 +270,7 @@ function apply_gaussian_smearing_core(freqs_or_energies, densities, sigma) {
|
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
272
|
// Normalize to preserve integral
|
|
272
|
-
const smeared_sum = smeared.reduce((acc,
|
|
273
|
+
const smeared_sum = smeared.reduce((acc, dens) => acc + dens, 0);
|
|
273
274
|
if (smeared_sum === 0)
|
|
274
275
|
return densities;
|
|
275
276
|
const normalization = orig_sum / smeared_sum;
|
|
@@ -491,10 +492,9 @@ function convert_pymatgen_band_structure(pmg) {
|
|
|
491
492
|
},
|
|
492
493
|
};
|
|
493
494
|
}
|
|
494
|
-
export function normalize_band_structure(
|
|
495
|
-
if (!
|
|
495
|
+
export function normalize_band_structure(band_struct) {
|
|
496
|
+
if (!is_plain_object(band_struct))
|
|
496
497
|
return null;
|
|
497
|
-
const band_struct = bs;
|
|
498
498
|
// Check if this is pymatgen format and convert if so
|
|
499
499
|
if (is_pymatgen_format(band_struct)) {
|
|
500
500
|
return convert_pymatgen_band_structure(band_struct);
|
|
@@ -516,27 +516,42 @@ export function normalize_band_structure(bs) {
|
|
|
516
516
|
branch.end_index >= n_qpts ||
|
|
517
517
|
branch.start_index > branch.end_index))
|
|
518
518
|
return null;
|
|
519
|
-
|
|
519
|
+
// Fill required defaults (recip_lattice/labels_dict/nb_bands) not covered above so the cast below is sound
|
|
520
|
+
const recip_lattice = band_struct.recip_lattice;
|
|
521
|
+
const normalized = {
|
|
522
|
+
...band_struct,
|
|
523
|
+
nb_bands: typeof band_struct.nb_bands === `number` ? band_struct.nb_bands : bands.length,
|
|
524
|
+
labels_dict: band_struct.labels_dict ?? {},
|
|
525
|
+
recip_lattice: is_square_matrix(recip_lattice?.matrix, 3)
|
|
526
|
+
? recip_lattice
|
|
527
|
+
: {
|
|
528
|
+
matrix: [
|
|
529
|
+
[1, 0, 0],
|
|
530
|
+
[0, 1, 0],
|
|
531
|
+
[0, 0, 1],
|
|
532
|
+
],
|
|
533
|
+
},
|
|
534
|
+
};
|
|
535
|
+
return normalized;
|
|
520
536
|
}
|
|
521
537
|
// Validate and normalize a DOS object.
|
|
522
538
|
// Supports both matterviz and pymatgen formats.
|
|
523
539
|
// Also auto-detects and converts cm⁻¹ to THz for legacy data (disable with auto_convert_units: false).
|
|
524
540
|
export function normalize_dos(dos, options = {}) {
|
|
525
541
|
const { auto_convert_units = true } = options;
|
|
526
|
-
if (!dos
|
|
542
|
+
if (!is_plain_object(dos))
|
|
527
543
|
return null;
|
|
528
|
-
const dos_obj = dos;
|
|
529
544
|
// Check for pymatgen format (has @class or @module)
|
|
530
|
-
const is_pymatgen = typeof
|
|
531
|
-
const { frequencies, energies, spin_polarized } =
|
|
545
|
+
const is_pymatgen = typeof dos[`@class`] === `string` || typeof dos[`@module`] === `string`;
|
|
546
|
+
const { frequencies, energies, spin_polarized } = dos;
|
|
532
547
|
// Handle densities as either array or dict with spin keys (pymatgen format)
|
|
533
548
|
// Pymatgen stores densities as {1: [...], -1: [...]} or {"Spin.up": [...], ...}
|
|
534
|
-
const spin_channels = extract_spin_channels(
|
|
549
|
+
const spin_channels = extract_spin_channels(dos.densities);
|
|
535
550
|
if (!spin_channels)
|
|
536
551
|
return null;
|
|
537
552
|
const densities = spin_channels.up;
|
|
538
553
|
// Use extracted spin-down or fallback to explicit field (for already-normalized DosData)
|
|
539
|
-
const spin_down_densities = spin_channels.down ??
|
|
554
|
+
const spin_down_densities = spin_channels.down ?? dos.spin_down_densities ?? null;
|
|
540
555
|
if (!Array.isArray(densities))
|
|
541
556
|
return null;
|
|
542
557
|
// Phonon DOS: has frequencies
|
|
@@ -743,13 +758,12 @@ export function find_qpoint_at_rescaled_x(band_struct, rescaled_x, x_positions)
|
|
|
743
758
|
// Returns a dict of label → DosData for each atom or orbital.
|
|
744
759
|
// filter_keys: optional list of keys to include (e.g., ["Fe", "O"] for atoms or ["s", "p", "d"] for orbitals)
|
|
745
760
|
export function extract_pdos(dos, pdos_type, filter_keys) {
|
|
746
|
-
if (!dos
|
|
761
|
+
if (!is_plain_object(dos))
|
|
747
762
|
return null;
|
|
748
|
-
const dos_obj = dos;
|
|
749
763
|
// Get the appropriate projected DOS dict
|
|
750
764
|
const pdos_dict = pdos_type === `atom`
|
|
751
|
-
?
|
|
752
|
-
:
|
|
765
|
+
? dos.atom_dos
|
|
766
|
+
: dos.spd_dos;
|
|
753
767
|
if (!pdos_dict || typeof pdos_dict !== `object`)
|
|
754
768
|
return null;
|
|
755
769
|
const result = {};
|
|
@@ -852,21 +866,15 @@ export function generate_ribbon_path(x_values, y_values, width_values, x_scale_f
|
|
|
852
866
|
// Handles both single objects with an efermi field and dicts of objects.
|
|
853
867
|
// Returns undefined if no valid efermi is found or if the source is empty.
|
|
854
868
|
export function extract_efermi(data) {
|
|
855
|
-
if (!data
|
|
869
|
+
if (!is_plain_object(data))
|
|
856
870
|
return undefined;
|
|
857
|
-
const obj = data;
|
|
858
871
|
// Direct efermi field on the object
|
|
859
|
-
if (
|
|
860
|
-
return
|
|
872
|
+
if (typeof data.efermi === `number`)
|
|
873
|
+
return data.efermi;
|
|
861
874
|
// Dict of objects - try to get efermi from first value
|
|
862
|
-
const
|
|
863
|
-
if (
|
|
864
|
-
return
|
|
865
|
-
const first_val = values[0];
|
|
866
|
-
if (first_val && typeof first_val === `object`) {
|
|
867
|
-
const efermi = first_val.efermi;
|
|
868
|
-
if (typeof efermi === `number`)
|
|
869
|
-
return efermi;
|
|
875
|
+
const first_val = Object.values(data)[0];
|
|
876
|
+
if (is_plain_object(first_val) && typeof first_val.efermi === `number`) {
|
|
877
|
+
return first_val.efermi;
|
|
870
878
|
}
|
|
871
879
|
return undefined;
|
|
872
880
|
}
|
|
@@ -886,18 +894,16 @@ export function negative_fraction(values) {
|
|
|
886
894
|
// Check if raw band structure input has electronic markers (efermi, kpoints, or electronic @class).
|
|
887
895
|
// Must be called on raw input before normalization since these fields aren't preserved.
|
|
888
896
|
function is_electronic_band_struct(bs) {
|
|
889
|
-
if (!bs
|
|
897
|
+
if (!is_plain_object(bs))
|
|
890
898
|
return false;
|
|
891
|
-
const obj = bs;
|
|
892
899
|
// Electronic band structures have efermi field
|
|
893
|
-
if (
|
|
900
|
+
if (typeof bs.efermi === `number`)
|
|
894
901
|
return true;
|
|
895
902
|
// Pymatgen electronic format uses kpoints (not qpoints)
|
|
896
|
-
if (
|
|
903
|
+
if (Array.isArray(bs.kpoints) && bs.kpoints.length > 0)
|
|
897
904
|
return true;
|
|
898
|
-
}
|
|
899
905
|
// Pymatgen @class: BandStructure* but not Phonon*
|
|
900
|
-
const raw_class =
|
|
906
|
+
const raw_class = bs[`@class`];
|
|
901
907
|
const py_class_name = typeof raw_class === `string` ? raw_class : ``;
|
|
902
908
|
if (py_class_name.startsWith(`BandStructure`) && !py_class_name.includes(`Phonon`)) {
|
|
903
909
|
return true;
|
package/dist/state.svelte.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ChemicalElement, ElementCategory } from './element/types';
|
|
2
2
|
import { DEFAULT_CATEGORY_COLORS, default_element_colors } from './colors';
|
|
3
|
-
import type { Tooltip } from './plot';
|
|
4
3
|
import { type ThemeMode, type ThemeType } from './theme';
|
|
5
4
|
export declare const selected: {
|
|
6
5
|
category: ElementCategory | null;
|
|
@@ -12,12 +11,6 @@ export declare const colors: {
|
|
|
12
11
|
category: typeof DEFAULT_CATEGORY_COLORS;
|
|
13
12
|
element: typeof default_element_colors;
|
|
14
13
|
};
|
|
15
|
-
export declare const tooltip: Tooltip;
|
|
16
|
-
export declare const periodic_table_state: {
|
|
17
|
-
show_bonding_info: boolean;
|
|
18
|
-
show_oxidation_state: boolean;
|
|
19
|
-
highlighted_elements: string[];
|
|
20
|
-
};
|
|
21
14
|
export declare const theme_state: {
|
|
22
15
|
mode: ThemeMode;
|
|
23
16
|
system_mode: ThemeType;
|
package/dist/state.svelte.js
CHANGED
|
@@ -11,12 +11,6 @@ export const colors = $state({
|
|
|
11
11
|
category: { ...DEFAULT_CATEGORY_COLORS },
|
|
12
12
|
element: { ...default_element_colors },
|
|
13
13
|
});
|
|
14
|
-
export const tooltip = $state({ show: false, x: 0, y: 0, title: ``, items: [] });
|
|
15
|
-
export const periodic_table_state = $state({
|
|
16
|
-
show_bonding_info: false,
|
|
17
|
-
show_oxidation_state: false,
|
|
18
|
-
highlighted_elements: [],
|
|
19
|
-
});
|
|
20
14
|
// Theme state with safe initialization
|
|
21
15
|
let initial_theme_mode = AUTO_THEME;
|
|
22
16
|
let initial_system_mode = COLOR_THEMES.light;
|
|
@@ -42,11 +42,9 @@
|
|
|
42
42
|
arrow_head_radius < 0 ? shaft_len * -arrow_head_radius : arrow_head_radius,
|
|
43
43
|
)
|
|
44
44
|
|
|
45
|
-
const shaft_pos = $derived(
|
|
46
|
-
math.add(position, math.scale(dir, shaft_len * 0.5)) as Vec3,
|
|
47
|
-
)
|
|
45
|
+
const shaft_pos = $derived(math.add(position, math.scale(dir, shaft_len * 0.5)))
|
|
48
46
|
const head_pos = $derived(
|
|
49
|
-
math.add(position, math.scale(dir, shaft_len + head_len * 0.5))
|
|
47
|
+
math.add(position, math.scale(dir, shaft_len + head_len * 0.5)),
|
|
50
48
|
)
|
|
51
49
|
|
|
52
50
|
const rotation = $derived.by((): Vec3 => {
|
|
@@ -30,6 +30,6 @@ type $$ComponentProps = Omit<HTMLAttributes<HTMLDivElement>, `children`> & {
|
|
|
30
30
|
structure?: AnyStructure | null;
|
|
31
31
|
}]>;
|
|
32
32
|
};
|
|
33
|
-
declare const AtomLegend: import("svelte").Component<$$ComponentProps, {}, "labels" | "
|
|
33
|
+
declare const AtomLegend: import("svelte").Component<$$ComponentProps, {}, "labels" | "atom_color_config" | "hidden_elements" | "hidden_prop_vals" | "element_mapping" | "element_radius_overrides" | "site_radius_overrides">;
|
|
34
34
|
type AtomLegend = ReturnType<typeof AtomLegend>;
|
|
35
35
|
export default AtomLegend;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
loading = $bindable(false),
|
|
15
15
|
direction = `down`,
|
|
16
16
|
align = `right`,
|
|
17
|
+
suppress_hover = false,
|
|
17
18
|
}: {
|
|
18
19
|
supercell_scaling: string
|
|
19
20
|
cell_type?: CellType
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
loading?: boolean
|
|
22
23
|
direction?: `up` | `down`
|
|
23
24
|
align?: `left` | `right`
|
|
25
|
+
suppress_hover?: boolean // don't auto-open the menu on hover/focus (e.g. while a sibling popover is open)
|
|
24
26
|
} = $props()
|
|
25
27
|
|
|
26
28
|
let menu_open = $state(false)
|
|
@@ -80,20 +82,26 @@
|
|
|
80
82
|
input_value = supercell_scaling
|
|
81
83
|
}
|
|
82
84
|
})
|
|
85
|
+
|
|
86
|
+
// Close + keep closed while suppressed so the menu can't obscure a sibling popover
|
|
87
|
+
// (e.g. the atom color-mode dropdown) the user is actively interacting with
|
|
88
|
+
$effect(() => {
|
|
89
|
+
if (suppress_hover) menu_open = false
|
|
90
|
+
})
|
|
83
91
|
</script>
|
|
84
92
|
|
|
85
93
|
<div
|
|
86
94
|
class="cell-select"
|
|
87
95
|
role="group"
|
|
88
96
|
{@attach click_outside({ callback: () => (menu_open = false) })}
|
|
89
|
-
onmouseenter={() => (menu_open =
|
|
97
|
+
onmouseenter={() => (menu_open = !suppress_hover)}
|
|
90
98
|
onmouseleave={() => (menu_open = false)}
|
|
91
|
-
onfocusin={() => (menu_open =
|
|
99
|
+
onfocusin={() => (menu_open = !suppress_hover)}
|
|
92
100
|
onfocusout={handle_focus_out}
|
|
93
101
|
>
|
|
94
102
|
<button
|
|
95
103
|
type="button"
|
|
96
|
-
onclick={() => (menu_open = !menu_open)}
|
|
104
|
+
onclick={() => (menu_open = !suppress_hover && !menu_open)}
|
|
97
105
|
onkeydown={handle_key_down}
|
|
98
106
|
class="toggle-btn"
|
|
99
107
|
class:active={menu_open}
|
|
@@ -7,7 +7,8 @@ type $$ComponentProps = {
|
|
|
7
7
|
loading?: boolean;
|
|
8
8
|
direction?: `up` | `down`;
|
|
9
9
|
align?: `left` | `right`;
|
|
10
|
+
suppress_hover?: boolean;
|
|
10
11
|
};
|
|
11
|
-
declare const CellSelect: import("svelte").Component<$$ComponentProps, {}, "
|
|
12
|
+
declare const CellSelect: import("svelte").Component<$$ComponentProps, {}, "supercell_scaling" | "cell_type" | "loading">;
|
|
12
13
|
type CellSelect = ReturnType<typeof CellSelect>;
|
|
13
14
|
export default CellSelect;
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
{#each matrix as vec, idx (vec)}
|
|
147
147
|
{@const shaft_length = Math.hypot(...vec) * 0.85}
|
|
148
148
|
<!-- Shaft goes to 85% of vector length -->
|
|
149
|
-
{@const tip_start_position = math.scale(vec, 0.85)
|
|
149
|
+
{@const tip_start_position = math.scale(vec, 0.85)}
|
|
150
150
|
<!-- Calculate rotation to align with vector direction -->
|
|
151
151
|
{@const quaternion = new Quaternion().setFromUnitVectors(
|
|
152
152
|
new Vector3(0, 1, 0), // Default up direction for cylinder/cone
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
.toArray()
|
|
158
158
|
.slice(0, 3) as Vec3}
|
|
159
159
|
<!-- Arrow shaft - position at center of shaft length -->
|
|
160
|
-
{@const shaft_center = math.scale(vec, 0.425)
|
|
160
|
+
{@const shaft_center = math.scale(vec, 0.425)}
|
|
161
161
|
<!-- Center at 42.5% = half of 85% -->
|
|
162
162
|
<T.Mesh
|
|
163
163
|
position={shaft_center}
|