matterviz 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EmptyState.svelte +10 -2
- package/dist/FilePicker.svelte +154 -96
- package/dist/Icon.svelte +20 -14
- package/dist/MillerIndexInput.svelte +27 -21
- package/dist/api/optimade.js +6 -6
- package/dist/app.css +216 -178
- package/dist/brillouin/BrillouinZone.svelte +299 -198
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
- package/dist/brillouin/BrillouinZoneExportPane.svelte +74 -55
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
- package/dist/brillouin/BrillouinZoneScene.svelte +277 -165
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneTooltip.svelte +17 -7
- package/dist/brillouin/compute.js +11 -6
- package/dist/chempot-diagram/ChemPotDiagram.svelte +327 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +847 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +3194 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +11 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
- package/dist/chempot-diagram/async-compute.svelte.js +77 -0
- package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
- package/dist/chempot-diagram/chempot-worker.js +11 -0
- package/dist/chempot-diagram/color.d.ts +10 -0
- package/dist/chempot-diagram/color.js +32 -0
- package/dist/chempot-diagram/compute.d.ts +48 -0
- package/dist/chempot-diagram/compute.js +812 -0
- package/dist/chempot-diagram/index.d.ts +6 -0
- package/dist/chempot-diagram/index.js +6 -0
- package/dist/chempot-diagram/pointer.d.ts +16 -0
- package/dist/chempot-diagram/pointer.js +40 -0
- package/dist/chempot-diagram/temperature.d.ts +15 -0
- package/dist/chempot-diagram/temperature.js +36 -0
- package/dist/chempot-diagram/types.d.ts +86 -0
- package/dist/chempot-diagram/types.js +28 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +9 -3
- package/dist/composition/BarChart.svelte +141 -77
- package/dist/composition/BubbleChart.svelte +107 -52
- package/dist/composition/Composition.svelte +100 -79
- package/dist/composition/Formula.svelte +108 -62
- package/dist/composition/FormulaFilter.svelte +973 -353
- package/dist/composition/FormulaFilter.svelte.d.ts +35 -1
- package/dist/composition/PieChart.svelte +199 -99
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- package/dist/composition/format.d.ts +5 -0
- package/dist/composition/format.js +20 -3
- package/dist/composition/parse.js +14 -9
- package/dist/convex-hull/ConvexHull.svelte +93 -38
- package/dist/convex-hull/ConvexHull2D.svelte +551 -393
- package/dist/convex-hull/ConvexHull3D.svelte +1303 -825
- package/dist/convex-hull/ConvexHull4D.svelte +1012 -686
- package/dist/convex-hull/ConvexHullControls.svelte +115 -28
- package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
- package/dist/convex-hull/ConvexHullStats.svelte +821 -249
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +41 -16
- package/dist/convex-hull/GasPressureControls.svelte +104 -61
- package/dist/convex-hull/StructurePopup.svelte +25 -4
- package/dist/convex-hull/TemperatureSlider.svelte +45 -25
- package/dist/convex-hull/barycentric-coords.js +13 -7
- package/dist/convex-hull/demo-temperature.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +40 -0
- package/dist/convex-hull/gas-thermodynamics.js +17 -12
- package/dist/convex-hull/helpers.d.ts +10 -1
- package/dist/convex-hull/helpers.js +79 -38
- package/dist/convex-hull/index.d.ts +1 -0
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +163 -69
- package/dist/convex-hull/types.d.ts +12 -12
- package/dist/convex-hull/types.js +0 -12
- package/dist/coordination/CoordinationBarPlot.svelte +232 -176
- package/dist/element/BohrAtom.svelte +56 -13
- package/dist/element/ElementHeading.svelte +7 -2
- package/dist/element/ElementPhoto.svelte +15 -9
- package/dist/element/ElementStats.svelte +10 -4
- package/dist/element/ElementTile.svelte +137 -73
- package/dist/element/Nucleus.svelte +39 -11
- package/dist/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/types.d.ts +1 -0
- package/dist/feedback/ClickFeedback.svelte +16 -5
- package/dist/feedback/DragOverlay.svelte +10 -2
- package/dist/feedback/Spinner.svelte +4 -2
- package/dist/feedback/StatusMessage.svelte +8 -2
- package/dist/fermi-surface/FermiSlice.svelte +118 -88
- package/dist/fermi-surface/FermiSurface.svelte +336 -239
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
- package/dist/fermi-surface/FermiSurfaceScene.svelte +536 -343
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
- package/dist/fermi-surface/compute.js +16 -20
- package/dist/fermi-surface/parse.js +37 -33
- package/dist/fermi-surface/symmetry.js +2 -7
- package/dist/fermi-surface/types.d.ts +3 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1527 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +30 -0
- package/dist/heatmap-matrix/index.d.ts +53 -0
- package/dist/heatmap-matrix/index.js +100 -0
- package/dist/heatmap-matrix/shared.d.ts +2 -0
- package/dist/heatmap-matrix/shared.js +4 -0
- package/dist/icons.d.ts +111 -0
- package/dist/icons.js +158 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.d.ts +3 -0
- package/dist/io/export.js +138 -140
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +43 -0
- package/dist/io/index.d.ts +2 -2
- package/dist/io/index.js +2 -112
- package/dist/io/is-binary.js +2 -3
- package/dist/io/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +117 -0
- package/dist/isosurface/Isosurface.svelte +220 -110
- package/dist/isosurface/IsosurfaceControls.svelte +65 -28
- package/dist/isosurface/parse.js +104 -56
- package/dist/isosurface/slice.d.ts +2 -1
- package/dist/isosurface/slice.js +8 -13
- package/dist/isosurface/types.d.ts +14 -1
- package/dist/isosurface/types.js +152 -5
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +12 -8
- package/dist/layout/FullscreenToggle.svelte +11 -2
- package/dist/layout/InfoCard.svelte +38 -6
- package/dist/layout/InfoTag.svelte +125 -94
- package/dist/layout/PropertyFilter.svelte +82 -37
- package/dist/layout/SettingsSection.svelte +85 -55
- package/dist/layout/SubpageGrid.svelte +82 -0
- package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +266 -223
- package/dist/layout/json-tree/JsonTree.svelte +516 -429
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +281 -173
- package/dist/layout/json-tree/types.d.ts +10 -2
- package/dist/layout/json-tree/utils.d.ts +2 -0
- package/dist/layout/json-tree/utils.js +37 -2
- package/dist/marching-cubes.js +25 -2
- package/dist/math.d.ts +20 -17
- package/dist/math.js +474 -57
- package/dist/overlays/ContextMenu.svelte +66 -40
- package/dist/overlays/DraggablePane.svelte +331 -154
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- package/dist/periodic-table/PeriodicTable.svelte +278 -145
- package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
- package/dist/periodic-table/PropertySelect.svelte +25 -7
- package/dist/periodic-table/TableInset.svelte +8 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +559 -267
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +131 -51
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +160 -110
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +8 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +217 -86
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
- package/dist/phase-diagram/build-diagram.js +9 -9
- package/dist/phase-diagram/colors.js +1 -3
- package/dist/phase-diagram/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/parse.js +10 -9
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +869 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +8 -4
- package/dist/phase-diagram/utils.js +219 -74
- package/dist/plot/AxisLabel.svelte +51 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +1461 -768
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +33 -6
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +533 -383
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ColorScaleSelect.svelte +28 -7
- package/dist/plot/ElementScatter.svelte +38 -16
- package/dist/plot/FillArea.svelte +152 -92
- package/dist/plot/Histogram.svelte +1162 -709
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +81 -18
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- package/dist/plot/InteractiveAxisLabel.svelte +34 -11
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/Line.svelte +63 -28
- package/dist/plot/PlotControls.svelte +221 -96
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +174 -91
- package/dist/plot/PlotTooltip.svelte +45 -6
- package/dist/plot/PortalSelect.svelte +175 -146
- package/dist/plot/ReferenceLine.svelte +77 -22
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferenceLine3D.svelte +132 -107
- package/dist/plot/ReferencePlane.svelte +146 -123
- package/dist/plot/ScatterPlot.svelte +1880 -1156
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte +256 -131
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +300 -297
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot3DScene.svelte +608 -406
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +150 -70
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ScatterPoint.svelte +98 -26
- package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
- package/dist/plot/SpacegroupBarPlot.svelte +142 -85
- package/dist/plot/Surface3D.svelte +159 -108
- package/dist/plot/ZeroLines.svelte +96 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +23 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- package/dist/plot/axis-utils.js +1 -3
- package/dist/plot/data-cleaning.js +12 -28
- package/dist/plot/data-transform.js +2 -1
- package/dist/plot/fill-utils.js +2 -0
- package/dist/plot/index.d.ts +6 -2
- package/dist/plot/index.js +6 -2
- package/dist/plot/interactions.d.ts +8 -10
- package/dist/plot/interactions.js +2 -3
- package/dist/plot/layout.d.ts +11 -2
- package/dist/plot/layout.js +44 -17
- package/dist/plot/reference-line.d.ts +5 -22
- package/dist/plot/reference-line.js +12 -84
- package/dist/plot/scales.js +24 -36
- package/dist/plot/types.d.ts +53 -40
- package/dist/plot/types.js +12 -7
- package/dist/plot/utils/label-placement.d.ts +32 -15
- package/dist/plot/utils/label-placement.js +227 -63
- package/dist/plot/utils/series-visibility.js +2 -3
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +173 -132
- package/dist/rdf/calc-rdf.js +4 -5
- package/dist/sanitize.d.ts +4 -0
- package/dist/sanitize.js +107 -0
- package/dist/settings.d.ts +21 -6
- package/dist/settings.js +63 -19
- package/dist/spectral/Bands.svelte +963 -412
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- package/dist/spectral/BandsAndDos.svelte +90 -49
- package/dist/spectral/BrillouinBandsDos.svelte +151 -93
- package/dist/spectral/Dos.svelte +389 -258
- package/dist/spectral/helpers.d.ts +23 -1
- package/dist/spectral/helpers.js +119 -51
- package/dist/spectral/types.d.ts +2 -0
- package/dist/state.svelte.d.ts +1 -1
- package/dist/state.svelte.js +3 -2
- package/dist/structure/Arrow.svelte +59 -20
- package/dist/structure/AtomLegend.svelte +231 -129
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +73 -47
- package/dist/structure/CanvasTooltip.svelte +10 -2
- package/dist/structure/CellSelect.svelte +148 -51
- package/dist/structure/Cylinder.svelte +33 -17
- package/dist/structure/Lattice.svelte +88 -33
- package/dist/structure/Structure.svelte +1077 -821
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureControls.svelte +373 -139
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +124 -89
- package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +304 -231
- package/dist/structure/StructureScene.svelte +919 -445
- package/dist/structure/StructureScene.svelte.d.ts +16 -7
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +42 -29
- package/dist/structure/bonding.js +6 -7
- package/dist/structure/export.js +22 -34
- package/dist/structure/ferrox-wasm-types.d.ts +3 -2
- package/dist/structure/ferrox-wasm-types.js +0 -3
- package/dist/structure/ferrox-wasm.d.ts +3 -2
- package/dist/structure/ferrox-wasm.js +2 -3
- package/dist/structure/index.d.ts +16 -0
- package/dist/structure/index.js +88 -6
- package/dist/structure/measure.d.ts +2 -2
- package/dist/structure/measure.js +4 -44
- package/dist/structure/parse.js +130 -155
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +99 -0
- package/dist/structure/pbc.d.ts +1 -0
- package/dist/structure/pbc.js +16 -6
- package/dist/structure/supercell.d.ts +2 -2
- package/dist/structure/supercell.js +12 -22
- package/dist/structure/validation.js +5 -3
- package/dist/symmetry/SymmetryStats.svelte +94 -37
- package/dist/symmetry/WyckoffTable.svelte +42 -14
- package/dist/symmetry/cell-transform.js +5 -3
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +87 -21
- package/dist/symmetry/spacegroups.js +148 -148
- package/dist/table/HeatmapTable.svelte +1112 -516
- package/dist/table/HeatmapTable.svelte.d.ts +12 -1
- package/dist/table/ToggleMenu.svelte +125 -90
- package/dist/table/index.d.ts +2 -0
- package/dist/table/index.js +2 -4
- package/dist/theme/ThemeControl.svelte +21 -12
- package/dist/time.js +4 -1
- package/dist/tooltip/TooltipContent.svelte +33 -8
- package/dist/trajectory/Trajectory.svelte +889 -687
- package/dist/trajectory/TrajectoryError.svelte +14 -3
- package/dist/trajectory/TrajectoryExportPane.svelte +148 -90
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +13 -31
- package/dist/trajectory/format-detect.d.ts +9 -0
- package/dist/trajectory/format-detect.js +76 -0
- package/dist/trajectory/frame-reader.d.ts +17 -0
- package/dist/trajectory/frame-reader.js +332 -0
- package/dist/trajectory/helpers.d.ts +14 -0
- package/dist/trajectory/helpers.js +172 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +23 -14
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +77 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +129 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +299 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +179 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +68 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +110 -0
- package/dist/trajectory/plotting.js +13 -8
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +17 -0
- package/dist/xrd/XrdPlot.svelte +337 -245
- package/dist/xrd/broadening.js +14 -9
- package/dist/xrd/calc-xrd.js +12 -19
- package/dist/xrd/parse.d.ts +1 -1
- package/dist/xrd/parse.js +17 -17
- package/package.json +103 -101
- package/readme.md +4 -4
- package/dist/trajectory/parse.d.ts +0 -42
- package/dist/trajectory/parse.js +0 -1267
- /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
- /package/dist/theme/{themes.js → themes.mjs} +0 -0
|
@@ -1,33 +1,47 @@
|
|
|
1
|
+
import { get_d3_interpolator } from '../colors';
|
|
1
2
|
import { ELEM_SYMBOL_TO_NAME } from '../composition';
|
|
2
3
|
import { format_fractional, format_num, symbol_map } from '../labels';
|
|
3
4
|
import { scaleSequential } from 'd3-scale';
|
|
4
|
-
import * as d3_sc from 'd3-scale-chromatic';
|
|
5
5
|
import { symbol } from 'd3-shape';
|
|
6
6
|
import { analyze_gas_data as _analyze_gas_data, apply_gas_corrections as _apply_gas_corrections, } from './gas-thermodynamics';
|
|
7
|
-
import { DEFAULT_GAS_TEMP
|
|
7
|
+
import { DEFAULT_GAS_TEMP } from './types';
|
|
8
8
|
export { DEFAULT_GAS_TEMP };
|
|
9
|
+
// Tolerance for classifying a phase as on the convex hull (eV/atom)
|
|
10
|
+
export const HULL_STABILITY_TOL = 1e-6;
|
|
11
|
+
// Clamp raw hull distance and compute stability for a single entry.
|
|
12
|
+
// Excluded entries keep their raw (possibly negative) distance and are never stable.
|
|
13
|
+
export function compute_hull_stability(raw_distance, exclude_from_hull, tol = HULL_STABILITY_TOL) {
|
|
14
|
+
if (exclude_from_hull)
|
|
15
|
+
return { e_above_hull: raw_distance, is_stable: false };
|
|
16
|
+
const e_above_hull = Math.abs(raw_distance) < tol ? 0 : Math.max(0, raw_distance);
|
|
17
|
+
return { e_above_hull, is_stable: e_above_hull <= tol };
|
|
18
|
+
}
|
|
19
|
+
// Check if entry is on the convex hull (stable or e_above_hull ≈ 0)
|
|
20
|
+
export const is_on_hull = (entry, tol = HULL_STABILITY_TOL) => !entry.exclude_from_hull &&
|
|
21
|
+
(entry.is_stable === true ||
|
|
22
|
+
(typeof entry.e_above_hull === `number` && entry.e_above_hull < tol));
|
|
23
|
+
export const get_arity = (entry) => Object.values(entry.composition).filter((count) => count > 0).length;
|
|
24
|
+
export const is_unary_entry = (entry) => get_arity(entry) === 1;
|
|
9
25
|
// Energy color scale factory (shared)
|
|
10
26
|
export function get_energy_color_scale(color_mode, color_scale, plot_entries) {
|
|
11
27
|
if (color_mode !== `energy` || plot_entries.length === 0)
|
|
12
28
|
return null;
|
|
13
29
|
const hull_distances = plot_entries
|
|
14
30
|
.map((entry) => entry.e_above_hull)
|
|
15
|
-
.filter((
|
|
31
|
+
.filter((val) => typeof val === `number`);
|
|
16
32
|
if (hull_distances.length === 0)
|
|
17
33
|
return null;
|
|
18
34
|
const lo = Math.min(...hull_distances);
|
|
19
35
|
const hi_raw = Math.max(...hull_distances, 0.1);
|
|
20
36
|
const hi = Math.max(hi_raw, lo + 1e-6);
|
|
21
|
-
|
|
22
|
-
const interpolator = d3_sc[color_scale] ||
|
|
23
|
-
d3_sc.interpolateViridis;
|
|
37
|
+
const interpolator = get_d3_interpolator(color_scale);
|
|
24
38
|
return scaleSequential(interpolator).domain([lo, hi]);
|
|
25
39
|
}
|
|
26
40
|
// Point color resolver (shared)
|
|
27
41
|
export function get_point_color_for_entry(entry, color_mode, colors, energy_scale) {
|
|
28
42
|
const is_stable = Boolean(entry.is_stable) || entry.e_above_hull === 0;
|
|
29
43
|
if (color_mode === `stability`) {
|
|
30
|
-
return is_stable ?
|
|
44
|
+
return is_stable ? colors?.stable || `#0072B2` : colors?.unstable || `#E69F00`;
|
|
31
45
|
}
|
|
32
46
|
return energy_scale && typeof entry.e_above_hull === `number`
|
|
33
47
|
? energy_scale(entry.e_above_hull)
|
|
@@ -57,10 +71,9 @@ export function calc_max_hull_dist_in_data(processed_entries) {
|
|
|
57
71
|
if (processed_entries.length === 0)
|
|
58
72
|
return 0.5;
|
|
59
73
|
const hull_distances = processed_entries
|
|
60
|
-
.map((
|
|
61
|
-
.filter((
|
|
62
|
-
const max_val = (hull_distances.length ? Math.max(...hull_distances) : 0) +
|
|
63
|
-
0.001;
|
|
74
|
+
.map((entry) => entry.e_above_hull)
|
|
75
|
+
.filter((val) => typeof val === `number` && Number.isFinite(val));
|
|
76
|
+
const max_val = (hull_distances.length ? Math.max(...hull_distances) : 0) + 0.001;
|
|
64
77
|
return Math.max(0.1, max_val);
|
|
65
78
|
}
|
|
66
79
|
// Smart threshold for showing unstable entries based on entry count.
|
|
@@ -78,9 +91,7 @@ export function compute_auto_hull_dist_threshold(n_entries, max_hull_dist_in_dat
|
|
|
78
91
|
export function build_entry_tooltip_text(entry) {
|
|
79
92
|
const is_element = is_unary_entry(entry);
|
|
80
93
|
const elem_symbol = is_element ? Object.keys(entry.composition)[0] : ``;
|
|
81
|
-
const elem_name = is_element
|
|
82
|
-
? ELEM_SYMBOL_TO_NAME[elem_symbol] ?? ``
|
|
83
|
-
: ``;
|
|
94
|
+
const elem_name = is_element ? (ELEM_SYMBOL_TO_NAME[elem_symbol] ?? ``) : ``;
|
|
84
95
|
let text = is_element
|
|
85
96
|
? `${elem_symbol}${elem_name ? ` (${elem_name})` : ``}\n`
|
|
86
97
|
: `${entry.name || entry.reduced_formula || ``}\n`;
|
|
@@ -100,9 +111,7 @@ export function build_entry_tooltip_text(entry) {
|
|
|
100
111
|
text += `E<sub>above hull</sub>: ${e_hull_str} eV/atom\n`;
|
|
101
112
|
}
|
|
102
113
|
// Fallback to energy_per_atom if e_form_per_atom is absent
|
|
103
|
-
const e_form_display = entry.e_form_per_atom !== undefined
|
|
104
|
-
? entry.e_form_per_atom
|
|
105
|
-
: entry.energy_per_atom;
|
|
114
|
+
const e_form_display = entry.e_form_per_atom !== undefined ? entry.e_form_per_atom : entry.energy_per_atom;
|
|
106
115
|
if (e_form_display !== undefined) {
|
|
107
116
|
const e_form_str = format_num(e_form_display, `.3~`);
|
|
108
117
|
text += `E<sub>form</sub>: ${e_form_str} eV/atom`;
|
|
@@ -124,8 +133,7 @@ export function find_hull_entry_at_mouse(canvas, event, plot_entries, project_po
|
|
|
124
133
|
continue;
|
|
125
134
|
const projected = project_point(entry.x, entry.y, entry.z);
|
|
126
135
|
const distance = Math.hypot(mouse_x - projected.x, mouse_y - projected.y);
|
|
127
|
-
const base = entry.size ??
|
|
128
|
-
((entry.is_stable || entry.e_above_hull === 0) ? 6 : 4);
|
|
136
|
+
const base = entry.size ?? (entry.is_stable || entry.e_above_hull === 0 ? 6 : 4);
|
|
129
137
|
if (distance < base * container_scale + 5)
|
|
130
138
|
return entry;
|
|
131
139
|
}
|
|
@@ -146,12 +154,10 @@ export function calculate_modal_side(wrapper) {
|
|
|
146
154
|
export function compute_energy_mode_info(entries, // Array of phase entries to analyze
|
|
147
155
|
find_lowest_energy_unary_refs_fn, // Function to find unary references
|
|
148
156
|
energy_source_mode) {
|
|
149
|
-
const has_precomputed_e_form = entries.length > 0 &&
|
|
150
|
-
|
|
151
|
-
const has_precomputed_hull = entries.length > 0 &&
|
|
152
|
-
entries.every((e) => typeof e.e_above_hull === `number`);
|
|
157
|
+
const has_precomputed_e_form = entries.length > 0 && entries.every((entry) => typeof entry.e_form_per_atom === `number`);
|
|
158
|
+
const has_precomputed_hull = entries.length > 0 && entries.every((entry) => typeof entry.e_above_hull === `number`);
|
|
153
159
|
const unary_refs = find_lowest_energy_unary_refs_fn(entries);
|
|
154
|
-
const elements_in_entries = Array.from(new Set(entries.flatMap((
|
|
160
|
+
const elements_in_entries = Array.from(new Set(entries.flatMap((entry) => Object.keys(entry.composition))));
|
|
155
161
|
const can_compute_e_form = elements_in_entries.every((el) => Boolean(unary_refs[el]));
|
|
156
162
|
const can_compute_hull = can_compute_e_form;
|
|
157
163
|
// Resolve mode to avoid inconsistent states:
|
|
@@ -261,6 +267,42 @@ function get_entry_energy_by_metric(entry, metric) {
|
|
|
261
267
|
}
|
|
262
268
|
return null;
|
|
263
269
|
}
|
|
270
|
+
function get_label_representative_energy(entry) {
|
|
271
|
+
if (is_finite(entry.e_form_per_atom))
|
|
272
|
+
return entry.e_form_per_atom;
|
|
273
|
+
if (is_finite(entry.energy_per_atom))
|
|
274
|
+
return entry.energy_per_atom;
|
|
275
|
+
const energy_per_atom = compute_energy_per_atom(entry);
|
|
276
|
+
if (energy_per_atom !== null)
|
|
277
|
+
return energy_per_atom;
|
|
278
|
+
if (is_finite(entry.energy))
|
|
279
|
+
return entry.energy;
|
|
280
|
+
if (is_finite(entry.e_above_hull))
|
|
281
|
+
return entry.e_above_hull;
|
|
282
|
+
return Number.POSITIVE_INFINITY;
|
|
283
|
+
}
|
|
284
|
+
function get_fractional_composition_key(composition) {
|
|
285
|
+
return Object.entries(get_fractional_composition(composition))
|
|
286
|
+
.sort(([elem_a], [elem_b]) => elem_a.localeCompare(elem_b))
|
|
287
|
+
.map(([elem, frac]) => `${elem}:${frac.toFixed(6)}`)
|
|
288
|
+
.join(`|`);
|
|
289
|
+
}
|
|
290
|
+
// Pick one label target per normalized composition. Multiple polymorphs, supercell
|
|
291
|
+
// formulas, or same-composition entries often project to the same screen position.
|
|
292
|
+
export function get_composition_label_entries(entries) {
|
|
293
|
+
const label_entry_by_composition = new Map();
|
|
294
|
+
for (const entry of entries) {
|
|
295
|
+
const comp_key = get_fractional_composition_key(entry.composition);
|
|
296
|
+
if (!comp_key)
|
|
297
|
+
continue;
|
|
298
|
+
const existing = label_entry_by_composition.get(comp_key);
|
|
299
|
+
if (!existing ||
|
|
300
|
+
get_label_representative_energy(entry) < get_label_representative_energy(existing)) {
|
|
301
|
+
label_entry_by_composition.set(comp_key, entry);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return Array.from(label_entry_by_composition.values());
|
|
305
|
+
}
|
|
264
306
|
// Determine which energy metric to use for a composition group
|
|
265
307
|
// Returns the first metric that ALL entries in the group can provide
|
|
266
308
|
function select_group_energy_metric(polymorphs) {
|
|
@@ -269,8 +311,7 @@ function select_group_energy_metric(polymorphs) {
|
|
|
269
311
|
return `e_form_per_atom`;
|
|
270
312
|
}
|
|
271
313
|
// Try energy_per_atom (either direct field or computed from total energy)
|
|
272
|
-
if (polymorphs.every((entry) => is_finite(entry.energy_per_atom) ||
|
|
273
|
-
compute_energy_per_atom(entry) !== null))
|
|
314
|
+
if (polymorphs.every((entry) => is_finite(entry.energy_per_atom) || compute_energy_per_atom(entry) !== null))
|
|
274
315
|
return `energy_per_atom`;
|
|
275
316
|
// Last resort: e_above_hull (will fail to differentiate stable polymorphs with e_above_hull=0)
|
|
276
317
|
if (polymorphs.every((entry) => is_finite(entry.e_above_hull))) {
|
|
@@ -286,11 +327,7 @@ export function compute_all_polymorph_stats(all_entries) {
|
|
|
286
327
|
// Group entries by fractional composition (normalized stoichiometry)
|
|
287
328
|
const composition_groups = new Map();
|
|
288
329
|
for (const entry of all_entries) {
|
|
289
|
-
const
|
|
290
|
-
const comp_key = Object.entries(fractional)
|
|
291
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
292
|
-
.map(([elem, frac]) => `${elem}:${frac.toFixed(6)}`)
|
|
293
|
-
.join(`|`);
|
|
330
|
+
const comp_key = get_fractional_composition_key(entry.composition);
|
|
294
331
|
const group = composition_groups.get(comp_key) ?? [];
|
|
295
332
|
if (group.length === 0)
|
|
296
333
|
composition_groups.set(comp_key, group);
|
|
@@ -341,15 +378,19 @@ function apply_alpha_to_color(color, alpha) {
|
|
|
341
378
|
// Handle existing rgba format
|
|
342
379
|
if (color.includes(`rgba`))
|
|
343
380
|
return color.replace(/[\d.]+\)$/, `${alpha})`);
|
|
344
|
-
if (color.includes(`rgb(`)) {
|
|
381
|
+
if (color.includes(`rgb(`)) {
|
|
382
|
+
// Convert rgb to rgba
|
|
345
383
|
return color.replace(/rgb\(/, `rgba(`).replace(/\)$/, `, ${alpha})`);
|
|
346
384
|
}
|
|
347
|
-
const hex_match =
|
|
385
|
+
const hex_match = /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(color); // Convert hex to rgba
|
|
348
386
|
if (hex_match) {
|
|
349
387
|
let hex = hex_match[1];
|
|
350
388
|
// Expand short form (e.g. "03F") to full form (e.g. "0033FF")
|
|
351
389
|
if (hex.length === 3)
|
|
352
|
-
hex =
|
|
390
|
+
hex = hex
|
|
391
|
+
.split(``)
|
|
392
|
+
.map((char) => char + char)
|
|
393
|
+
.join(``);
|
|
353
394
|
const red = parseInt(hex.slice(0, 2), 16);
|
|
354
395
|
const green = parseInt(hex.slice(2, 4), 16);
|
|
355
396
|
const blue = parseInt(hex.slice(4, 6), 16);
|
|
@@ -419,7 +460,8 @@ export function get_canvas_text_color(dark_mode, element) {
|
|
|
419
460
|
if (typeof document === `undefined`)
|
|
420
461
|
return fallback;
|
|
421
462
|
const css_value = getComputedStyle(element ?? document.documentElement)
|
|
422
|
-
.getPropertyValue(`--text-color`)
|
|
463
|
+
.getPropertyValue(`--text-color`)
|
|
464
|
+
?.trim();
|
|
423
465
|
// Check for unsupported CSS functions that canvas can't render
|
|
424
466
|
return css_value && !/light-dark|var\(/i.test(css_value) ? css_value : fallback;
|
|
425
467
|
}
|
|
@@ -463,8 +505,7 @@ function entry_has_temp_data(entry) {
|
|
|
463
505
|
}
|
|
464
506
|
// Check if entry has data at exact temperature T
|
|
465
507
|
export function entry_has_temperature(entry, T) {
|
|
466
|
-
return entry_has_temp_data(entry) &&
|
|
467
|
-
(entry.temperatures?.includes(T) ?? false);
|
|
508
|
+
return entry_has_temp_data(entry) && (entry.temperatures?.includes(T) ?? false);
|
|
468
509
|
}
|
|
469
510
|
// Get energy at temperature T (throws if T not found - validate with entry_has_temperature first)
|
|
470
511
|
export function get_energy_at_temperature(entry, T) {
|
|
@@ -625,6 +666,6 @@ export function get_entry_label(entry, elements) {
|
|
|
625
666
|
pairs = pairs.sort(([el1], [el2]) => elements.indexOf(el1) - elements.indexOf(el2));
|
|
626
667
|
}
|
|
627
668
|
return pairs
|
|
628
|
-
.map(([el, amt]) => Math.abs(amt - 1) < 1e-6 ? el : `${el}${format_num(amt, `.2~`)}`)
|
|
669
|
+
.map(([el, amt]) => (Math.abs(amt - 1) < 1e-6 ? el : `${el}${format_num(amt, `.2~`)}`))
|
|
629
670
|
.join(``);
|
|
630
671
|
}
|
|
@@ -11,6 +11,7 @@ export { default as ConvexHullControls } from './ConvexHullControls.svelte';
|
|
|
11
11
|
export { default as ConvexHullInfoPane } from './ConvexHullInfoPane.svelte';
|
|
12
12
|
export { default as ConvexHullStats } from './ConvexHullStats.svelte';
|
|
13
13
|
export { default as ConvexHullTooltip } from './ConvexHullTooltip.svelte';
|
|
14
|
+
export * from './demo-temperature';
|
|
14
15
|
export * from './gas-thermodynamics';
|
|
15
16
|
export { default as GasPressureControls } from './GasPressureControls.svelte';
|
|
16
17
|
export * from './helpers';
|
|
@@ -7,6 +7,7 @@ export { default as ConvexHullControls } from './ConvexHullControls.svelte';
|
|
|
7
7
|
export { default as ConvexHullInfoPane } from './ConvexHullInfoPane.svelte';
|
|
8
8
|
export { default as ConvexHullStats } from './ConvexHullStats.svelte';
|
|
9
9
|
export { default as ConvexHullTooltip } from './ConvexHullTooltip.svelte';
|
|
10
|
+
export * from './demo-temperature';
|
|
10
11
|
export * from './gas-thermodynamics';
|
|
11
12
|
export { default as GasPressureControls } from './GasPressureControls.svelte';
|
|
12
13
|
export * from './helpers';
|
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
import type { ElementSymbol } from '../element';
|
|
2
|
-
import type { ConvexHullTriangle, PhaseData, Point2D, Point3D, ProcessedPhaseData } from './types';
|
|
2
|
+
import type { ConvexHullEntry, ConvexHullTriangle, PhaseData, PhaseStats, Point2D, Point3D, ProcessedPhaseData } from './types';
|
|
3
3
|
export declare function normalize_hull_composition_keys(composition: Record<string, number>): Partial<Record<ElementSymbol, number>>;
|
|
4
4
|
export declare function process_hull_entries(entries: PhaseData[]): ProcessedPhaseData;
|
|
5
5
|
export declare function compute_e_form_per_atom(entry: PhaseData, el_refs: Record<string, PhaseData>): number | null;
|
|
6
6
|
export declare function find_lowest_energy_unary_refs(entries: PhaseData[]): Record<string, PhaseData>;
|
|
7
7
|
export declare function calculate_e_above_hull(entry: PhaseData, reference_entries: PhaseData[]): number;
|
|
8
8
|
export declare function calculate_e_above_hull(entries: PhaseData[], reference_entries: PhaseData[]): Record<string, number>;
|
|
9
|
-
export declare function get_convex_hull_stats(processed_entries: PhaseData[], elements: ElementSymbol[], max_arity:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
unstable: number;
|
|
17
|
-
energy_range: {
|
|
18
|
-
min: number;
|
|
19
|
-
max: number;
|
|
20
|
-
avg: number;
|
|
21
|
-
};
|
|
22
|
-
hull_distance: {
|
|
23
|
-
max: number;
|
|
24
|
-
avg: number;
|
|
25
|
-
};
|
|
26
|
-
elements: number;
|
|
27
|
-
chemical_system: string;
|
|
28
|
-
} | null;
|
|
9
|
+
export declare function get_convex_hull_stats(processed_entries: PhaseData[], elements: ElementSymbol[], max_arity?: number): PhaseStats | null;
|
|
10
|
+
export interface HighDimHullResult {
|
|
11
|
+
stable_entries: ConvexHullEntry[];
|
|
12
|
+
unstable_entries: ConvexHullEntry[];
|
|
13
|
+
phase_stats: PhaseStats | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function process_hull_for_stats(entries: PhaseData[], elements?: ElementSymbol[]): HighDimHullResult | null;
|
|
29
16
|
export declare function compute_lower_hull_2d(points: Point2D[]): Point2D[];
|
|
30
17
|
export declare function interpolate_hull_2d(hull: Point2D[], x: number): number | null;
|
|
31
18
|
export declare function compute_quickhull_triangles(points: Point3D[]): ConvexHullTriangle[];
|