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,4 +1,4 @@
|
|
|
1
|
-
import { element_data } from '../element';
|
|
1
|
+
import { element_data, is_elem_symbol } from '../element';
|
|
2
2
|
import { ELEM_SYMBOLS } from '../labels';
|
|
3
3
|
// Create symbol/number/mass/electronegativity lookup maps for O(1) access
|
|
4
4
|
export const ATOMIC_NUMBER_TO_SYMBOL = {};
|
|
@@ -16,8 +16,6 @@ for (const element of element_data) {
|
|
|
16
16
|
ELEM_NAME_TO_SYMBOL[element.name] = element.symbol;
|
|
17
17
|
ELEM_SYMBOL_TO_NAME[element.symbol] = element.name;
|
|
18
18
|
}
|
|
19
|
-
// Type guard: check if a string is a valid element symbol
|
|
20
|
-
export const is_valid_element = (sym) => ELEM_SYMBOLS.includes(sym);
|
|
21
19
|
// Check if object has atomic numbers as keys (1-118)
|
|
22
20
|
const is_atomic_number_composition = (obj) => {
|
|
23
21
|
const keys = Object.keys(obj);
|
|
@@ -51,7 +49,7 @@ export const atomic_num_to_symbols = (atomic_composition) => {
|
|
|
51
49
|
export const atomic_symbol_to_num = (symbol_composition) => {
|
|
52
50
|
const atomic_composition = {};
|
|
53
51
|
for (const [symbol, amount] of Object.entries(symbol_composition)) {
|
|
54
|
-
if (!
|
|
52
|
+
if (!is_elem_symbol(symbol))
|
|
55
53
|
throw new Error(`Invalid element symbol: ${symbol}`);
|
|
56
54
|
const atomic_num = SYMBOL_TO_ATOMIC_NUMBER[symbol];
|
|
57
55
|
if (!atomic_num)
|
|
@@ -93,7 +91,7 @@ export const parse_formula = (formula) => {
|
|
|
93
91
|
const expanded = expand_parentheses(segment.slice(coeff?.length ?? 0));
|
|
94
92
|
for (const match of expanded.matchAll(/([A-Z][a-z]?)(\d+(?:\.\d+)?|\.\d+)?/g)) {
|
|
95
93
|
const [, element, count] = match;
|
|
96
|
-
if (!
|
|
94
|
+
if (!is_elem_symbol(element))
|
|
97
95
|
throw new Error(`Invalid element symbol: ${element}`);
|
|
98
96
|
composition[element] = (composition[element] ?? 0) + parse_count(count) * multiplier;
|
|
99
97
|
}
|
|
@@ -107,7 +105,7 @@ export const normalize_composition = (composition) => {
|
|
|
107
105
|
}
|
|
108
106
|
const normalized = {};
|
|
109
107
|
for (const [element, amount] of Object.entries(composition)) {
|
|
110
|
-
if (typeof amount === `number` && amount > 0 &&
|
|
108
|
+
if (typeof amount === `number` && amount > 0 && is_elem_symbol(element)) {
|
|
111
109
|
normalized[element] = amount;
|
|
112
110
|
}
|
|
113
111
|
}
|
|
@@ -125,7 +123,7 @@ export const sanitize_composition_keys = (composition) => {
|
|
|
125
123
|
if (typeof amount !== `number` || amount <= 0)
|
|
126
124
|
continue;
|
|
127
125
|
// Extract first valid element symbol from key (e.g. "B0." -> "B", "Fe2+" -> "Fe")
|
|
128
|
-
const elem = (key.match(/[A-Z][a-z]?/g) ?? []).find(
|
|
126
|
+
const elem = (key.match(/[A-Z][a-z]?/g) ?? []).find(is_elem_symbol);
|
|
129
127
|
if (elem)
|
|
130
128
|
sanitized[elem] = (sanitized[elem] || 0) + amount;
|
|
131
129
|
}
|
|
@@ -139,7 +137,7 @@ export const fractional_composition = (composition, by_weight = false) => {
|
|
|
139
137
|
const filtered = Object.fromEntries(Object.entries(composition).filter(([, amount]) => amount > 0));
|
|
140
138
|
if (by_weight) {
|
|
141
139
|
const element_weights = Object.fromEntries(Object.entries(filtered).map(([element, amount]) => {
|
|
142
|
-
if (!
|
|
140
|
+
if (!is_elem_symbol(element))
|
|
143
141
|
throw new Error(`Unknown element: ${element}`);
|
|
144
142
|
const atomic_mass = ATOMIC_WEIGHTS.get(element);
|
|
145
143
|
if (!atomic_mass)
|
|
@@ -191,14 +189,14 @@ export const get_reduced_formula = (composition) => {
|
|
|
191
189
|
return composition;
|
|
192
190
|
const reduced = {};
|
|
193
191
|
for (const [elem, amt] of Object.entries(composition)) {
|
|
194
|
-
if (
|
|
192
|
+
if (is_elem_symbol(elem))
|
|
195
193
|
reduced[elem] = amt / divisor;
|
|
196
194
|
}
|
|
197
195
|
return reduced;
|
|
198
196
|
};
|
|
199
197
|
// Calculate molecular weight (sum of atomic masses * amounts)
|
|
200
198
|
export const get_molecular_weight = (composition) => Object.entries(composition).reduce((total, [elem, amount]) => {
|
|
201
|
-
const mass =
|
|
199
|
+
const mass = is_elem_symbol(elem) ? (ATOMIC_WEIGHTS.get(elem) ?? 0) : 0;
|
|
202
200
|
return total + mass * amount;
|
|
203
201
|
}, 0);
|
|
204
202
|
// Parse oxidation state string (e.g. "+2", "2+", "-", "[2-]") to number
|
|
@@ -241,7 +239,7 @@ export const parse_formula_with_oxidation = (formula, strict = false) => {
|
|
|
241
239
|
const oxidation_str = match[2] || match[3] || match[6] || match[7];
|
|
242
240
|
const count_str = match[4] || match[5];
|
|
243
241
|
const count = parse_count(count_str);
|
|
244
|
-
if (!
|
|
242
|
+
if (!is_elem_symbol(element))
|
|
245
243
|
throw new Error(`Invalid element symbol: ${element}`);
|
|
246
244
|
const oxidation_state = oxidation_str ? parse_oxidation_state(oxidation_str) : undefined;
|
|
247
245
|
// Find or add element entry
|
|
@@ -269,7 +267,7 @@ export const parse_formula_with_oxidation = (formula, strict = false) => {
|
|
|
269
267
|
};
|
|
270
268
|
// Convert OxiComposition to ElementWithOxidation array
|
|
271
269
|
// Does not preserve original order since objects don't have a defined order
|
|
272
|
-
export const oxi_composition_to_elements = (composition) => Object.entries(composition).flatMap(([element, { amount, oxidation_state }], idx) =>
|
|
270
|
+
export const oxi_composition_to_elements = (composition) => Object.entries(composition).flatMap(([element, { amount, oxidation_state }], idx) => is_elem_symbol(element) ? [{ element, amount, oxidation_state, orig_idx: idx }] : []);
|
|
273
271
|
// Extract element symbols from a chemical formula.
|
|
274
272
|
// Default (unique=true, sorted=true): "NbZr2Nb" -> ["Nb", "Zr"]
|
|
275
273
|
// unique=false: Fast token extraction preserving order without parentheses expansion
|
|
@@ -283,12 +281,12 @@ export function extract_formula_elements(formula, { unique = true, sorted = true
|
|
|
283
281
|
const matches = formula.match(/[A-Z][a-z]?/g) ?? [];
|
|
284
282
|
const elements = [];
|
|
285
283
|
for (const match of matches) {
|
|
286
|
-
if (
|
|
284
|
+
if (is_elem_symbol(match))
|
|
287
285
|
elements.push(match);
|
|
288
286
|
}
|
|
289
287
|
return elements;
|
|
290
288
|
}
|
|
291
|
-
const symbols = Object.keys(parse_formula(formula)).filter(
|
|
289
|
+
const symbols = Object.keys(parse_formula(formula)).filter(is_elem_symbol);
|
|
292
290
|
return sorted ? symbols.sort() : symbols;
|
|
293
291
|
}
|
|
294
292
|
// Generate all non-empty subsets of a chemical system as hyphenated strings.
|
|
@@ -302,7 +300,7 @@ export function generate_chem_sys_subspaces(input) {
|
|
|
302
300
|
else if (Array.isArray(input)) {
|
|
303
301
|
const uniq = [...new Set(input)];
|
|
304
302
|
for (const elem of uniq) {
|
|
305
|
-
if (!
|
|
303
|
+
if (!is_elem_symbol(elem))
|
|
306
304
|
throw new Error(`Invalid element symbol: ${elem}`);
|
|
307
305
|
}
|
|
308
306
|
elements = uniq;
|
|
@@ -310,7 +308,7 @@ export function generate_chem_sys_subspaces(input) {
|
|
|
310
308
|
else {
|
|
311
309
|
elements = [];
|
|
312
310
|
for (const elem of Object.keys(input)) {
|
|
313
|
-
if (!
|
|
311
|
+
if (!is_elem_symbol(elem))
|
|
314
312
|
throw new Error(`Invalid element symbol: ${elem}`);
|
|
315
313
|
elements.push(elem);
|
|
316
314
|
}
|
|
@@ -354,7 +352,7 @@ export function parse_chemsys_with_wildcards(input) {
|
|
|
354
352
|
if (token === `*`) {
|
|
355
353
|
wildcard_count++;
|
|
356
354
|
}
|
|
357
|
-
else if (
|
|
355
|
+
else if (is_elem_symbol(token)) {
|
|
358
356
|
elements.push(token);
|
|
359
357
|
}
|
|
360
358
|
else {
|
|
@@ -401,7 +399,7 @@ export function parse_formula_with_wildcards(formula) {
|
|
|
401
399
|
// Element symbol match
|
|
402
400
|
const element = match[1];
|
|
403
401
|
const count = parse_count(match[2]);
|
|
404
|
-
if (!
|
|
402
|
+
if (!is_elem_symbol(element)) {
|
|
405
403
|
throw new Error(`Invalid element symbol: ${element}`);
|
|
406
404
|
}
|
|
407
405
|
tokens.push({ element, count });
|
|
@@ -422,7 +420,7 @@ export function matches_chemsys_wildcard(formula, explicit_elements, wildcard_co
|
|
|
422
420
|
// Must contain all explicit elements
|
|
423
421
|
const formula_set = new Set(formula_elements);
|
|
424
422
|
for (const elem of explicit_elements) {
|
|
425
|
-
if (!
|
|
423
|
+
if (!is_elem_symbol(elem) || !formula_set.has(elem))
|
|
426
424
|
return false;
|
|
427
425
|
}
|
|
428
426
|
return true;
|
package/dist/controls.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type ShowControlsConfig = {
|
|
|
5
5
|
style?: string;
|
|
6
6
|
};
|
|
7
7
|
export type ShowControlsProp = ControlsVisibility | ShowControlsConfig | boolean;
|
|
8
|
+
export type ShowControlsState = ReturnType<typeof normalize_show_controls>;
|
|
8
9
|
export declare function normalize_show_controls(prop: ShowControlsProp | undefined): {
|
|
9
10
|
mode: ControlsVisibility;
|
|
10
11
|
hidden: Set<string>;
|
package/dist/controls.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Controls visibility configuration for visualization components
|
|
2
2
|
// Manages visibility of control buttons in Structure, Trajectory, BrillouinZone
|
|
3
|
-
// Normalize show_controls prop into consistent config with helper methods
|
|
4
3
|
export function normalize_show_controls(prop) {
|
|
5
4
|
// Extract mode, hidden, style from various prop forms
|
|
6
5
|
let mode = `hover`;
|
|
@@ -8,17 +8,13 @@
|
|
|
8
8
|
import ConvexHull3D from './ConvexHull3D.svelte'
|
|
9
9
|
import ConvexHull4D from './ConvexHull4D.svelte'
|
|
10
10
|
import type { BaseConvexHullProps, Hull3DProps } from './index'
|
|
11
|
-
import type { GasSpecies, GasThermodynamicsConfig } from './types'
|
|
12
11
|
|
|
13
12
|
// Union type combining all possible props from 2D, 3D, and 4D components
|
|
14
13
|
// each specific component will only use its relevant props from this super set
|
|
14
|
+
// (gas_config/gas_pressures already come from BaseConvexHullProps)
|
|
15
15
|
type ConvexHullProps = BaseConvexHullProps & Hull3DProps & {
|
|
16
16
|
x_axis?: AxisConfig
|
|
17
17
|
y_axis?: AxisConfig
|
|
18
|
-
// Gas thermodynamics config - enables atmosphere-controlled phase diagrams
|
|
19
|
-
gas_config?: GasThermodynamicsConfig
|
|
20
|
-
// Gas pressure binding - enables two-way binding for atmosphere control
|
|
21
|
-
gas_pressures?: Partial<Record<GasSpecies, number>>
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
let {
|
|
@@ -28,6 +24,7 @@
|
|
|
28
24
|
wrapper = $bindable(),
|
|
29
25
|
show_stable = $bindable(true),
|
|
30
26
|
show_unstable = $bindable(true),
|
|
27
|
+
hidden_categories = $bindable([]),
|
|
31
28
|
show_hull_faces = $bindable(true),
|
|
32
29
|
hull_face_opacity: hull_face_opacity_prop = $bindable(
|
|
33
30
|
undefined as number | undefined,
|
|
@@ -35,7 +32,7 @@
|
|
|
35
32
|
color_mode = $bindable(`energy`),
|
|
36
33
|
color_scale = $bindable(`interpolateViridis`),
|
|
37
34
|
info_pane_open = $bindable(false),
|
|
38
|
-
|
|
35
|
+
controls_open = $bindable(false),
|
|
39
36
|
max_hull_dist_show_phases = $bindable(0.1),
|
|
40
37
|
max_hull_dist_show_labels = $bindable(0.1),
|
|
41
38
|
show_stable_labels = $bindable(true),
|
|
@@ -87,9 +84,9 @@
|
|
|
87
84
|
hull_face_opacity_prop = hull_face_opacity
|
|
88
85
|
})
|
|
89
86
|
|
|
90
|
-
// Map element count to
|
|
91
|
-
//
|
|
92
|
-
//
|
|
87
|
+
// Map element count to component. Deliberate cast: the wrapper passes the prop superset
|
|
88
|
+
// while each component declares only its dimension's props (2D lacks Hull3DProps, 3D/4D
|
|
89
|
+
// lack x/y_axis), so a constructor union wouldn't compile. Svelte ignores extra props.
|
|
93
90
|
const ConvexHullComponent = $derived(
|
|
94
91
|
{ 2: ConvexHull2D, 3: ConvexHull3D, 4: ConvexHull4D }[element_count] ??
|
|
95
92
|
null,
|
|
@@ -104,12 +101,13 @@
|
|
|
104
101
|
bind:wrapper
|
|
105
102
|
bind:show_stable
|
|
106
103
|
bind:show_unstable
|
|
104
|
+
bind:hidden_categories
|
|
107
105
|
bind:show_hull_faces
|
|
108
106
|
bind:hull_face_opacity
|
|
109
107
|
bind:color_mode
|
|
110
108
|
bind:color_scale
|
|
111
109
|
bind:info_pane_open
|
|
112
|
-
bind:
|
|
110
|
+
bind:controls_open
|
|
113
111
|
bind:max_hull_dist_show_phases
|
|
114
112
|
bind:max_hull_dist_show_labels
|
|
115
113
|
bind:show_stable_labels
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { AxisConfig } from '../plot';
|
|
2
2
|
import type { Component } from 'svelte';
|
|
3
3
|
import type { BaseConvexHullProps, Hull3DProps } from './index';
|
|
4
|
-
import type { GasSpecies, GasThermodynamicsConfig } from './types';
|
|
5
4
|
type ConvexHullProps = BaseConvexHullProps & Hull3DProps & {
|
|
6
5
|
x_axis?: AxisConfig;
|
|
7
6
|
y_axis?: AxisConfig;
|
|
8
|
-
gas_config?: GasThermodynamicsConfig;
|
|
9
|
-
gas_pressures?: Partial<Record<GasSpecies, number>>;
|
|
10
7
|
};
|
|
11
|
-
declare const ConvexHull: Component<ConvexHullProps, {}, "
|
|
8
|
+
declare const ConvexHull: Component<ConvexHullProps, {}, "display" | "temperature" | "fullscreen" | "wrapper" | "controls_open" | "color_scale" | "info_pane_open" | "show_hull_faces" | "hull_face_opacity" | "color_mode" | "show_stable" | "show_unstable" | "show_stable_labels" | "show_unstable_labels" | "max_hull_dist_show_phases" | "max_hull_dist_show_labels" | "hidden_categories" | "energy_source_mode" | "stable_entries" | "unstable_entries" | "phase_stats" | "highlighted_entries" | "selected_entry" | "gas_pressures">;
|
|
12
9
|
type ConvexHull = ReturnType<typeof ConvexHull>;
|
|
13
10
|
export default ConvexHull;
|