matterviz 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FilePicker.svelte +37 -20
- package/dist/Icon.svelte +2 -2
- package/dist/MillerIndexInput.svelte +60 -0
- package/dist/MillerIndexInput.svelte.d.ts +7 -0
- package/dist/app.css +38 -2
- package/dist/brillouin/BrillouinZone.svelte +20 -62
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneExportPane.svelte +12 -20
- package/dist/brillouin/BrillouinZoneScene.svelte +2 -2
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram.svelte +192 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +677 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +2688 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +8 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- package/dist/chempot-diagram/color.d.ts +10 -0
- package/dist/chempot-diagram/color.js +33 -0
- package/dist/chempot-diagram/compute.d.ts +38 -0
- package/dist/chempot-diagram/compute.js +650 -0
- package/dist/chempot-diagram/index.d.ts +5 -0
- package/dist/chempot-diagram/index.js +5 -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 +37 -0
- package/dist/chempot-diagram/types.d.ts +83 -0
- package/dist/chempot-diagram/types.js +27 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +4 -0
- package/dist/composition/BarChart.svelte +13 -22
- package/dist/composition/BubbleChart.svelte +5 -3
- package/dist/composition/FormulaFilter.svelte +770 -90
- package/dist/composition/FormulaFilter.svelte.d.ts +37 -1
- package/dist/composition/PieChart.svelte +43 -18
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -0
- package/dist/convex-hull/ConvexHull.svelte +14 -1
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +14 -45
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +396 -134
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +93 -42
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullControls.svelte +94 -31
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +4 -2
- package/dist/convex-hull/ConvexHullStats.svelte +697 -128
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +1 -0
- package/dist/convex-hull/GasPressureControls.svelte +72 -38
- package/dist/convex-hull/GasPressureControls.svelte.d.ts +2 -1
- package/dist/convex-hull/TemperatureSlider.svelte +46 -19
- package/dist/convex-hull/TemperatureSlider.svelte.d.ts +2 -1
- package/dist/convex-hull/demo-temperature.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +36 -0
- package/dist/convex-hull/gas-thermodynamics.js +16 -5
- package/dist/convex-hull/helpers.d.ts +7 -1
- package/dist/convex-hull/helpers.js +45 -15
- package/dist/convex-hull/index.d.ts +15 -1
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +106 -17
- package/dist/convex-hull/types.d.ts +7 -0
- package/dist/convex-hull/types.js +11 -0
- package/dist/coordination/CoordinationBarPlot.svelte +29 -46
- package/dist/element/BohrAtom.svelte +1 -1
- package/dist/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/index.d.ts +1 -1
- package/dist/element/index.js +1 -0
- package/dist/element/types.d.ts +1 -0
- package/dist/fermi-surface/FermiSurface.svelte +21 -65
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/compute.js +1 -21
- package/dist/fermi-surface/marching-cubes.d.ts +2 -13
- package/dist/fermi-surface/marching-cubes.js +2 -519
- package/dist/fermi-surface/parse.js +17 -23
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1273 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +171 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +31 -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 +119 -0
- package/dist/icons.js +119 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/io/export.js +15 -3
- 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/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +118 -0
- package/dist/isosurface/Isosurface.svelte +231 -0
- package/dist/isosurface/Isosurface.svelte.d.ts +8 -0
- package/dist/isosurface/IsosurfaceControls.svelte +273 -0
- package/dist/isosurface/IsosurfaceControls.svelte.d.ts +9 -0
- package/dist/isosurface/index.d.ts +5 -0
- package/dist/isosurface/index.js +6 -0
- package/dist/isosurface/parse.d.ts +6 -0
- package/dist/isosurface/parse.js +548 -0
- package/dist/isosurface/slice.d.ts +11 -0
- package/dist/isosurface/slice.js +145 -0
- package/dist/isosurface/types.d.ts +55 -0
- package/dist/isosurface/types.js +178 -0
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +1 -0
- package/dist/layout/InfoTag.svelte +62 -62
- package/dist/layout/SubpageGrid.svelte +74 -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 +226 -53
- package/dist/layout/json-tree/JsonTree.svelte +425 -51
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +218 -97
- package/dist/layout/json-tree/types.d.ts +27 -2
- package/dist/layout/json-tree/utils.d.ts +14 -1
- package/dist/layout/json-tree/utils.js +254 -0
- package/dist/marching-cubes.d.ts +14 -0
- package/dist/marching-cubes.js +519 -0
- package/dist/math.d.ts +8 -0
- package/dist/math.js +374 -7
- package/dist/overlays/ContextMenu.svelte +3 -2
- package/dist/overlays/DraggablePane.svelte +163 -58
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +232 -77
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +32 -11
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +103 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +102 -95
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +7 -0
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +100 -26
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- package/dist/phase-diagram/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +865 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +7 -4
- package/dist/phase-diagram/utils.js +149 -59
- package/dist/plot/AxisLabel.svelte +26 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +473 -228
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +3 -2
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +54 -54
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ElementScatter.svelte +4 -3
- package/dist/plot/FillArea.svelte +4 -1
- package/dist/plot/Histogram.svelte +320 -230
- package/dist/plot/Histogram.svelte.d.ts +2 -2
- package/dist/plot/HistogramControls.svelte +29 -10
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +2 -2
- package/dist/plot/PlotControls.svelte +109 -27
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +1 -1
- package/dist/plot/PortalSelect.svelte +2 -1
- package/dist/plot/ReferenceLine.svelte +2 -1
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferencePlane.svelte +1 -3
- package/dist/plot/ScatterPlot.svelte +343 -209
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +203 -250
- package/dist/plot/ScatterPlot3DScene.svelte +4 -7
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +95 -55
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ZeroLines.svelte +44 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +21 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- package/dist/plot/data-cleaning.js +1 -5
- 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 +10 -19
- package/dist/plot/layout.d.ts +7 -1
- package/dist/plot/layout.js +12 -4
- package/dist/plot/reference-line.d.ts +4 -21
- package/dist/plot/reference-line.js +7 -81
- package/dist/plot/types.d.ts +42 -17
- package/dist/plot/types.js +10 -0
- package/dist/plot/utils/label-placement.js +14 -11
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +55 -66
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/index.d.ts +1 -1
- package/dist/rdf/index.js +1 -1
- package/dist/settings.d.ts +5 -0
- package/dist/settings.js +37 -3
- package/dist/spectral/Bands.svelte +515 -143
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- package/dist/spectral/helpers.d.ts +23 -1
- package/dist/spectral/helpers.js +65 -9
- package/dist/spectral/types.d.ts +2 -0
- package/dist/structure/AtomLegend.svelte +31 -10
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/CellSelect.svelte +92 -22
- package/dist/structure/Lattice.svelte +2 -0
- package/dist/structure/Structure.svelte +716 -173
- package/dist/structure/Structure.svelte.d.ts +7 -2
- package/dist/structure/StructureControls.svelte +26 -14
- package/dist/structure/StructureControls.svelte.d.ts +5 -1
- package/dist/structure/StructureInfoPane.svelte +7 -1
- package/dist/structure/StructureScene.svelte +386 -95
- package/dist/structure/StructureScene.svelte.d.ts +15 -4
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +38 -25
- package/dist/structure/export.js +10 -7
- 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 +1 -2
- package/dist/structure/index.d.ts +7 -0
- package/dist/structure/index.js +22 -0
- package/dist/structure/parse.js +19 -16
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +102 -0
- package/dist/structure/validation.js +6 -3
- package/dist/symmetry/SymmetryStats.svelte +18 -4
- package/dist/symmetry/WyckoffTable.svelte +18 -10
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +83 -18
- package/dist/table/HeatmapTable.svelte +468 -69
- package/dist/table/HeatmapTable.svelte.d.ts +13 -1
- package/dist/table/ToggleMenu.svelte +291 -44
- package/dist/table/ToggleMenu.svelte.d.ts +4 -1
- package/dist/table/index.d.ts +3 -0
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tooltip/index.js +1 -0
- package/dist/trajectory/Trajectory.svelte +147 -145
- package/dist/trajectory/TrajectoryExportPane.svelte +13 -9
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +3 -5
- 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 +339 -0
- package/dist/trajectory/helpers.d.ts +15 -0
- package/dist/trajectory/helpers.js +187 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +11 -4
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +76 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +121 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +304 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +169 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +65 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +109 -0
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +4 -0
- package/dist/xrd/XrdPlot.svelte +6 -4
- package/dist/xrd/calc-xrd.js +0 -1
- package/package.json +33 -23
- 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
|
@@ -1,15 +1,51 @@
|
|
|
1
1
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
2
|
import type { FormulaSearchMode } from './index';
|
|
3
|
+
type SearchExampleCategory = {
|
|
4
|
+
label: string;
|
|
5
|
+
description: string;
|
|
6
|
+
examples: string[];
|
|
7
|
+
};
|
|
8
|
+
export type FormulaFilterToken = {
|
|
9
|
+
raw: string;
|
|
10
|
+
element: string;
|
|
11
|
+
operator: `include` | `exclude`;
|
|
12
|
+
constraint: string | null;
|
|
13
|
+
is_wildcard: boolean;
|
|
14
|
+
is_valid: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type FormulaFilterParseResult = {
|
|
17
|
+
value: string;
|
|
18
|
+
normalized_value: string;
|
|
19
|
+
search_mode: FormulaSearchMode;
|
|
20
|
+
tokens: FormulaFilterToken[];
|
|
21
|
+
has_wildcards: boolean;
|
|
22
|
+
is_valid: boolean;
|
|
23
|
+
error_message: string | null;
|
|
24
|
+
};
|
|
25
|
+
export type FormulaFilterValidation = {
|
|
26
|
+
state: `valid` | `warning` | `invalid`;
|
|
27
|
+
message: string | null;
|
|
28
|
+
};
|
|
3
29
|
type $$ComponentProps = {
|
|
4
30
|
value: string;
|
|
5
31
|
search_mode?: FormulaSearchMode;
|
|
6
32
|
input_element?: HTMLInputElement | null;
|
|
7
33
|
show_clear_button?: boolean;
|
|
8
34
|
show_examples?: boolean;
|
|
35
|
+
show_mode_lock?: boolean;
|
|
36
|
+
show_chip_editor?: boolean;
|
|
37
|
+
normalize_exact?: boolean;
|
|
38
|
+
examples?: SearchExampleCategory[];
|
|
9
39
|
disabled?: boolean;
|
|
40
|
+
mode_locked?: boolean;
|
|
41
|
+
max_history?: number;
|
|
42
|
+
history_key?: string;
|
|
43
|
+
validate?: (value: string, search_mode: FormulaSearchMode, parsed: FormulaFilterParseResult) => FormulaFilterValidation | null;
|
|
44
|
+
onparse?: (parsed: FormulaFilterParseResult) => void;
|
|
45
|
+
on_validation?: (validation: FormulaFilterValidation) => void;
|
|
10
46
|
onchange?: (value: string, search_mode: FormulaSearchMode) => void;
|
|
11
47
|
onclear?: () => void;
|
|
12
48
|
} & HTMLAttributes<HTMLDivElement>;
|
|
13
|
-
declare const FormulaFilter: import("svelte").Component<$$ComponentProps, {}, "value" | "search_mode" | "input_element">;
|
|
49
|
+
declare const FormulaFilter: import("svelte").Component<$$ComponentProps, {}, "value" | "search_mode" | "input_element" | "mode_locked">;
|
|
14
50
|
type FormulaFilter = ReturnType<typeof FormulaFilter>;
|
|
15
51
|
export default FormulaFilter;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script lang="ts">import {
|
|
2
|
-
import {
|
|
1
|
+
<script lang="ts">import { ELEMENT_COLOR_SCHEMES, pick_contrast_color } from '../colors';
|
|
2
|
+
import { format_num } from '../labels';
|
|
3
3
|
import { get_chart_font_scale } from './index';
|
|
4
4
|
import { count_atoms_in_composition, fractional_composition } from './parse';
|
|
5
5
|
// Constants for pie chart calculations
|
|
@@ -21,8 +21,34 @@ let segments = $derived.by(() => {
|
|
|
21
21
|
.map(([element_key, amount]) => {
|
|
22
22
|
const element = element_key;
|
|
23
23
|
const fraction = fractions[element] || 0;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const color = element_colors[element] || `#cccccc`;
|
|
25
|
+
// Single element: full circle with no radial stroke line, label at center
|
|
26
|
+
if (fraction === 1) {
|
|
27
|
+
const r = outer_radius;
|
|
28
|
+
const ir = inner_radius_adjusted;
|
|
29
|
+
// Two semicircular arcs to form a full circle (avoids SVG 360° arc bug)
|
|
30
|
+
const outer_arc = `M ${center} ${center - r} A ${r} ${r} 0 1 1 ${center} ${center + r} A ${r} ${r} 0 1 1 ${center} ${center - r} Z`;
|
|
31
|
+
const path = ir > 0
|
|
32
|
+
? `${outer_arc} M ${center} ${center - ir} A ${ir} ${ir} 0 1 0 ${center} ${center + ir} A ${ir} ${ir} 0 1 0 ${center} ${center - ir} Z`
|
|
33
|
+
: outer_arc;
|
|
34
|
+
const label_text = element + (show_amounts ? String(amount) : ``) +
|
|
35
|
+
(show_percentages ? `${format_num(fraction, `.1~%`)}` : ``);
|
|
36
|
+
return {
|
|
37
|
+
element,
|
|
38
|
+
amount,
|
|
39
|
+
fraction,
|
|
40
|
+
color,
|
|
41
|
+
start_angle: -90,
|
|
42
|
+
end_angle: 270,
|
|
43
|
+
path,
|
|
44
|
+
label_x: center,
|
|
45
|
+
label_y: center,
|
|
46
|
+
is_outside_slice: false,
|
|
47
|
+
font_scale: get_chart_font_scale(2.6, label_text, r * 2),
|
|
48
|
+
text_color: pick_contrast_color({ bg_color: color }),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const angle_span = fraction * 360;
|
|
26
52
|
const start_angle = current_angle;
|
|
27
53
|
const end_angle = current_angle + angle_span;
|
|
28
54
|
current_angle = end_angle;
|
|
@@ -78,7 +104,6 @@ let segments = $derived.by(() => {
|
|
|
78
104
|
: Math.min(outer_radius - inner_radius_adjusted, // Radial space
|
|
79
105
|
(angle_span * Math.PI / 180) * label_radius * 0.8);
|
|
80
106
|
const font_scale = get_chart_font_scale(base_scale, label_text, available_space);
|
|
81
|
-
const color = element_colors[element] || `#cccccc`;
|
|
82
107
|
return {
|
|
83
108
|
element,
|
|
84
109
|
amount,
|
|
@@ -102,6 +127,7 @@ let hovered_element = $state(null);
|
|
|
102
127
|
|
|
103
128
|
<svg
|
|
104
129
|
viewBox="0 0 {size} {size}"
|
|
130
|
+
style:max-width="{size}px"
|
|
105
131
|
{...rest}
|
|
106
132
|
class="pie-chart {rest.class ?? ``}"
|
|
107
133
|
bind:this={svg_node}
|
|
@@ -111,7 +137,11 @@ let hovered_element = $state(null);
|
|
|
111
137
|
d={segment.path}
|
|
112
138
|
fill={segment.color}
|
|
113
139
|
stroke="white"
|
|
114
|
-
stroke-width={
|
|
140
|
+
stroke-width={segments.length === 1
|
|
141
|
+
? 0
|
|
142
|
+
: hovered_element === segment.element
|
|
143
|
+
? stroke_width + 1
|
|
144
|
+
: stroke_width}
|
|
115
145
|
class="pie-segment"
|
|
116
146
|
class:interactive
|
|
117
147
|
class:hovered={hovered_element === segment.element}
|
|
@@ -154,14 +184,12 @@ let hovered_element = $state(null);
|
|
|
154
184
|
<span class="element-symbol" style:font-size="{14 * segment.font_scale}px">{
|
|
155
185
|
segment.element
|
|
156
186
|
}</span>
|
|
157
|
-
{#if show_amounts}
|
|
158
|
-
<sub class="amount" style:font-size="{
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
{format_num(segment.fraction, `.1~%`)}
|
|
164
|
-
</sub>
|
|
187
|
+
{#if show_amounts || show_percentages}
|
|
188
|
+
<sub class="amount" style:font-size="{8 * segment.font_scale}px">{
|
|
189
|
+
show_amounts ? segment.amount : ``
|
|
190
|
+
}{show_amounts && show_percentages ? `=` : ``}{
|
|
191
|
+
show_percentages ? format_num(segment.fraction, `.1~%`) : ``
|
|
192
|
+
}</sub>
|
|
165
193
|
{/if}
|
|
166
194
|
</div>
|
|
167
195
|
</foreignObject>
|
|
@@ -215,9 +243,6 @@ let hovered_element = $state(null);
|
|
|
215
243
|
}
|
|
216
244
|
.amount {
|
|
217
245
|
margin-left: 1px;
|
|
218
|
-
transform: translateY(
|
|
219
|
-
}
|
|
220
|
-
.percentage {
|
|
221
|
-
transform: translateY(4px);
|
|
246
|
+
transform: translateY(5pt);
|
|
222
247
|
}
|
|
223
248
|
</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { ColorSchemeName } from '../colors';
|
|
1
2
|
import type { CompositionType } from './';
|
|
2
3
|
import type { ElementSymbol } from '../element';
|
|
3
|
-
import type { ColorSchemeName } from '../colors';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import type { SVGAttributes } from 'svelte/elements';
|
|
6
6
|
import { type ChartSegmentData } from './index';
|
package/dist/constants.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare const STRUCTURE_EXTENSIONS_REGEX: RegExp;
|
|
|
21
21
|
export declare const TRAJ_FALLBACK_EXTENSIONS: readonly string[];
|
|
22
22
|
export declare const TRAJ_FALLBACK_EXTENSIONS_REGEX: RegExp;
|
|
23
23
|
export declare const VASP_FILES_REGEX: RegExp;
|
|
24
|
+
export declare const VASP_VOLUMETRIC_REGEX: RegExp;
|
|
24
25
|
export declare const XDATCAR_REGEX: RegExp;
|
|
25
26
|
export declare const CONFIG_DIRS_REGEX: RegExp;
|
|
26
27
|
export declare const MD_SIM_EXCLUDE_REGEX: RegExp;
|
package/dist/constants.js
CHANGED
|
@@ -75,6 +75,7 @@ export const STRUCTURE_EXTENSIONS = Object.freeze([
|
|
|
75
75
|
`.mcif`,
|
|
76
76
|
`.poscar`,
|
|
77
77
|
`.vasp`,
|
|
78
|
+
`.cube`,
|
|
78
79
|
`.lmp`,
|
|
79
80
|
`.data`,
|
|
80
81
|
`.dump`,
|
|
@@ -95,6 +96,7 @@ export const TRAJ_FALLBACK_EXTENSIONS = Object.freeze([
|
|
|
95
96
|
export const TRAJ_FALLBACK_EXTENSIONS_REGEX = new RegExp(`\\.(${TRAJ_FALLBACK_EXTENSIONS.map((ext) => ext.slice(1)).join(`|`)})$`, `i`);
|
|
96
97
|
// Special regex patterns
|
|
97
98
|
export const VASP_FILES_REGEX = /(?:^|[\\/_.-])(poscar|contcar|potcar|incar|kpoints|outcar)(?:[\\/_.-]|$)/i;
|
|
99
|
+
export const VASP_VOLUMETRIC_REGEX = /(?:^|[\\/_.-])(chgcar|aeccar[012]?|elfcar|locpot|parchg)(?:[\\/_.-]|$)/i;
|
|
98
100
|
export const XDATCAR_REGEX = /xdatcar/i;
|
|
99
101
|
export const CONFIG_DIRS_REGEX = /(?:^|[\\/])(\.vscode|\.idea|\.nyc_output|\.cache|\.tmp|\.temp|node_modules|dist|build|coverage)(?:[\\/]|$)/i;
|
|
100
102
|
export const MD_SIM_EXCLUDE_REGEX = /md_simulation\.(out|txt|yml|py|csv|html|css|md|js|ts)$/i;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script lang="ts">import { extract_formula_elements } from '../composition/parse';
|
|
2
|
+
import { DEFAULTS } from '../settings';
|
|
2
3
|
import { SvelteSet } from 'svelte/reactivity';
|
|
3
4
|
import ConvexHull2D from './ConvexHull2D.svelte';
|
|
4
5
|
import ConvexHull3D from './ConvexHull3D.svelte';
|
|
5
6
|
import ConvexHull4D from './ConvexHull4D.svelte';
|
|
6
7
|
let { entries = [],
|
|
7
8
|
// bindable props not part of rest because Svelte 5 doesn't support spreading bindable props.
|
|
8
|
-
fullscreen = $bindable(false), wrapper = $bindable(), show_stable = $bindable(true), show_unstable = $bindable(true), show_hull_faces = $bindable(true), hull_face_opacity = $bindable(
|
|
9
|
+
fullscreen = $bindable(false), wrapper = $bindable(), show_stable = $bindable(true), show_unstable = $bindable(true), show_hull_faces = $bindable(true), hull_face_opacity: hull_face_opacity_prop = $bindable(undefined), color_mode = $bindable(`energy`), color_scale = $bindable(`interpolateViridis`), info_pane_open = $bindable(false), legend_pane_open = $bindable(false), max_hull_dist_show_phases = $bindable(0.1), max_hull_dist_show_labels = $bindable(0.1), show_stable_labels = $bindable(true), show_unstable_labels = $bindable(false), energy_source_mode = $bindable(`precomputed`), phase_stats = $bindable(null), display = $bindable({ x_grid: false, y_grid: false }), stable_entries = $bindable([]), unstable_entries = $bindable([]), highlighted_entries = $bindable([]), selected_entry = $bindable(null), temperature = $bindable(), gas_pressures = $bindable({}), ...rest } = $props();
|
|
9
10
|
// Lightweight element extraction - count unique elements, stripping oxidation states
|
|
10
11
|
// (e.g. "V4+" -> "V") to avoid counting the same element multiple times
|
|
11
12
|
function extract_unique_elements(entries) {
|
|
@@ -23,6 +24,18 @@ function extract_unique_elements(entries) {
|
|
|
23
24
|
// Detect dimensionality by counting unique elements (lightweight operation)
|
|
24
25
|
const elements = $derived(extract_unique_elements(entries));
|
|
25
26
|
const element_count = $derived(elements.length);
|
|
27
|
+
// Resolve hull face opacity: use caller's value if provided,
|
|
28
|
+
// otherwise pick the right default for the dimensionality (ternary=30%, quaternary=3%).
|
|
29
|
+
// Use writable derived so child bind updates can sync back to parent.
|
|
30
|
+
const default_opacity = $derived(element_count === 4
|
|
31
|
+
? DEFAULTS.convex_hull.quaternary.hull_face_opacity
|
|
32
|
+
: DEFAULTS.convex_hull.ternary.hull_face_opacity);
|
|
33
|
+
let hull_face_opacity = $derived(hull_face_opacity_prop ?? default_opacity);
|
|
34
|
+
$effect(() => {
|
|
35
|
+
if (hull_face_opacity_prop === hull_face_opacity)
|
|
36
|
+
return;
|
|
37
|
+
hull_face_opacity_prop = hull_face_opacity;
|
|
38
|
+
});
|
|
26
39
|
// Map element count to corresponding component
|
|
27
40
|
// Note: Type assertion needed because TypeScript can't infer that all components
|
|
28
41
|
// accept a compatible superset of props (BaseConvexHullProps + dimension-specific)
|
|
@@ -8,6 +8,6 @@ type ConvexHullProps = BaseConvexHullProps & Hull3DProps & {
|
|
|
8
8
|
gas_config?: GasThermodynamicsConfig;
|
|
9
9
|
gas_pressures?: Partial<Record<GasSpecies, number>>;
|
|
10
10
|
};
|
|
11
|
-
declare const ConvexHull: Component<ConvexHullProps, {}, "temperature" | "display" | "
|
|
11
|
+
declare const ConvexHull: Component<ConvexHullProps, {}, "temperature" | "display" | "color_scale" | "fullscreen" | "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" | "info_pane_open" | "legend_pane_open" | "wrapper" | "energy_source_mode" | "stable_entries" | "unstable_entries" | "phase_stats" | "highlighted_entries" | "selected_entry" | "gas_pressures">;
|
|
12
12
|
type ConvexHull = ReturnType<typeof ConvexHull>;
|
|
13
13
|
export default ConvexHull;
|
|
@@ -5,6 +5,7 @@ import { symbol_map } from '../labels';
|
|
|
5
5
|
import { set_fullscreen_bg, setup_fullscreen_effect } from '../layout';
|
|
6
6
|
import { ScatterPlot } from '../plot';
|
|
7
7
|
import { DEFAULTS } from '../settings';
|
|
8
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
8
9
|
import ConvexHullControls from './ConvexHullControls.svelte';
|
|
9
10
|
import ConvexHullInfoPane from './ConvexHullInfoPane.svelte';
|
|
10
11
|
import ConvexHullTooltip from './ConvexHullTooltip.svelte';
|
|
@@ -14,7 +15,7 @@ import { CONVEX_HULL_STYLE, default_controls, default_hull_config } from './inde
|
|
|
14
15
|
import StructurePopup from './StructurePopup.svelte';
|
|
15
16
|
import TemperatureSlider from './TemperatureSlider.svelte';
|
|
16
17
|
import * as thermo from './thermodynamics';
|
|
17
|
-
import { is_unary_entry } from './types';
|
|
18
|
+
import { HULL_STABILITY_TOL, is_unary_entry } from './types';
|
|
18
19
|
// Binary convex hull rendered as energy vs composition (x in [0, 1])
|
|
19
20
|
let { entries = [], controls = {}, config = {}, on_point_click, on_point_hover, fullscreen = $bindable(DEFAULTS.convex_hull.binary.fullscreen), enable_info_pane = true, wrapper = $bindable(), label_threshold = 50, show_stable = $bindable(DEFAULTS.convex_hull.binary.show_stable), show_unstable = $bindable(DEFAULTS.convex_hull.binary.show_unstable), color_mode = $bindable(DEFAULTS.convex_hull.binary.color_mode), color_scale = $bindable(DEFAULTS.convex_hull.binary.color_scale), info_pane_open = $bindable(DEFAULTS.convex_hull.binary.info_pane_open), legend_pane_open = $bindable(DEFAULTS.convex_hull.binary.legend_pane_open), max_hull_dist_show_phases = $bindable(DEFAULTS.convex_hull.binary.max_hull_dist_show_phases), max_hull_dist_show_labels = $bindable(DEFAULTS.convex_hull.binary.max_hull_dist_show_labels), show_stable_labels = $bindable(DEFAULTS.convex_hull.binary.show_stable_labels), show_unstable_labels = $bindable(DEFAULTS.convex_hull.binary.show_unstable_labels), on_file_drop, enable_click_selection = true, enable_structure_preview = true, energy_source_mode = $bindable(`precomputed`), phase_stats = $bindable(null), display = $bindable({ x_grid: false, y_grid: false }), stable_entries = $bindable([]), unstable_entries = $bindable([]), highlighted_entries = $bindable([]), highlight_style = {}, x_axis = {}, y_axis = {}, selected_entry = $bindable(null), temperature = $bindable(), interpolate_temperature = true, max_interpolation_gap = 500, gas_config, gas_pressures = $bindable({}), children, tooltip: custom_tooltip, ...rest } = $props();
|
|
20
21
|
const merged_controls = $derived({ ...default_controls, ...controls });
|
|
@@ -106,36 +107,6 @@ function compute_binary_coordinates(raw_entries, elems) {
|
|
|
106
107
|
}
|
|
107
108
|
return coords;
|
|
108
109
|
}
|
|
109
|
-
function compute_lower_hull(points) {
|
|
110
|
-
// Andrew's monotone chain for lower hull
|
|
111
|
-
const sorted = [...points].sort((p1, p2) => (p1.x - p2.x) || (p1.y - p2.y));
|
|
112
|
-
const lower = [];
|
|
113
|
-
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
|
114
|
-
for (const p of sorted) {
|
|
115
|
-
while (lower.length >= 2 &&
|
|
116
|
-
cross(lower[lower.length - 2], lower[lower.length - 1], p) <= 0)
|
|
117
|
-
lower.pop();
|
|
118
|
-
lower.push(p);
|
|
119
|
-
}
|
|
120
|
-
return lower;
|
|
121
|
-
}
|
|
122
|
-
function interpolate_on_hull(hull, x) {
|
|
123
|
-
if (hull.length < 2)
|
|
124
|
-
return null;
|
|
125
|
-
if (x <= hull[0].x)
|
|
126
|
-
return hull[0].y;
|
|
127
|
-
if (x >= hull[hull.length - 1].x)
|
|
128
|
-
return hull[hull.length - 1].y;
|
|
129
|
-
for (let i = 0; i < hull.length - 1; i++) {
|
|
130
|
-
const p1 = hull[i];
|
|
131
|
-
const p2 = hull[i + 1];
|
|
132
|
-
if (x >= p1.x && x <= p2.x) {
|
|
133
|
-
const t = (x - p1.x) / Math.max(1e-12, p2.x - p1.x);
|
|
134
|
-
return p1.y * (1 - t) + p2.y * t;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
110
|
const coords_entries = $derived.by(() => {
|
|
140
111
|
if (elements.length !== 2)
|
|
141
112
|
return [];
|
|
@@ -152,28 +123,26 @@ const { all_enriched_entries, hull_points } = $derived.by(() => {
|
|
|
152
123
|
if (coords_entries.length === 0) {
|
|
153
124
|
return { all_enriched_entries: [], hull_points: [] };
|
|
154
125
|
}
|
|
155
|
-
// Build lower hull:
|
|
156
|
-
|
|
157
|
-
const by_x = new Map();
|
|
126
|
+
// Build lower hull input: one minimum-energy point per composition x.
|
|
127
|
+
const min_y_by_x = new SvelteMap();
|
|
158
128
|
for (const entry of coords_entries) {
|
|
159
|
-
const
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
by_x.set(entry.x, [entry]);
|
|
129
|
+
const current_min_y = min_y_by_x.get(entry.x);
|
|
130
|
+
if (current_min_y === undefined || entry.y < current_min_y) {
|
|
131
|
+
min_y_by_x.set(entry.x, entry.y);
|
|
132
|
+
}
|
|
164
133
|
}
|
|
165
|
-
const hull_input = [...
|
|
134
|
+
const hull_input = [...min_y_by_x].map(([x_coord, min_y]) => ({
|
|
166
135
|
x: x_coord,
|
|
167
|
-
y:
|
|
136
|
+
y: min_y,
|
|
168
137
|
}));
|
|
169
|
-
const hull_points =
|
|
138
|
+
const hull_points = thermo.compute_lower_hull_2d(hull_input);
|
|
170
139
|
const all_enriched_entries = coords_entries.map((entry) => {
|
|
171
|
-
const y_hull =
|
|
140
|
+
const y_hull = thermo.interpolate_hull_2d(hull_points, entry.x);
|
|
172
141
|
const e_above_hull = y_hull == null ? 0 : Math.max(0, entry.y - y_hull);
|
|
173
142
|
return {
|
|
174
143
|
...entry,
|
|
175
144
|
e_above_hull,
|
|
176
|
-
is_stable: e_above_hull <=
|
|
145
|
+
is_stable: e_above_hull <= HULL_STABILITY_TOL,
|
|
177
146
|
visible: true,
|
|
178
147
|
};
|
|
179
148
|
});
|
|
@@ -647,7 +616,7 @@ let style = $derived(`--hull-stable-color:${merged_config.colors?.stable || `#00
|
|
|
647
616
|
color: var(--text-color, currentColor);
|
|
648
617
|
transition: background-color 0.2s, opacity 0.2s;
|
|
649
618
|
display: flex;
|
|
650
|
-
font-size: clamp(0.85em, 2cqmin,
|
|
619
|
+
font-size: clamp(0.85em, 2cqmin, 1.3em);
|
|
651
620
|
}
|
|
652
621
|
:global(.convex-hull-2d .control-btn:hover) {
|
|
653
622
|
background-color: color-mix(in srgb, currentColor 8%, transparent);
|
|
@@ -6,6 +6,6 @@ type $$ComponentProps = BaseConvexHullProps<ConvexHullEntry> & {
|
|
|
6
6
|
x_axis?: AxisConfig;
|
|
7
7
|
y_axis?: AxisConfig;
|
|
8
8
|
};
|
|
9
|
-
declare const ConvexHull2D: import("svelte").Component<$$ComponentProps, {}, "temperature" | "display" | "
|
|
9
|
+
declare const ConvexHull2D: import("svelte").Component<$$ComponentProps, {}, "temperature" | "display" | "color_scale" | "fullscreen" | "color_mode" | "show_stable" | "show_unstable" | "show_stable_labels" | "show_unstable_labels" | "max_hull_dist_show_phases" | "max_hull_dist_show_labels" | "info_pane_open" | "legend_pane_open" | "wrapper" | "energy_source_mode" | "stable_entries" | "unstable_entries" | "phase_stats" | "highlighted_entries" | "selected_entry" | "gas_pressures">;
|
|
10
10
|
type ConvexHull2D = ReturnType<typeof ConvexHull2D>;
|
|
11
11
|
export default ConvexHull2D;
|