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.
Files changed (286) hide show
  1. package/dist/FilePicker.svelte +37 -20
  2. package/dist/Icon.svelte +2 -2
  3. package/dist/MillerIndexInput.svelte +60 -0
  4. package/dist/MillerIndexInput.svelte.d.ts +7 -0
  5. package/dist/app.css +38 -2
  6. package/dist/brillouin/BrillouinZone.svelte +20 -62
  7. package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
  8. package/dist/brillouin/BrillouinZoneExportPane.svelte +12 -20
  9. package/dist/brillouin/BrillouinZoneScene.svelte +2 -2
  10. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
  11. package/dist/chempot-diagram/ChemPotDiagram.svelte +192 -0
  12. package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
  13. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +677 -0
  14. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
  15. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +2688 -0
  16. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
  17. package/dist/chempot-diagram/ChemPotScene3D.svelte +8 -0
  18. package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
  19. package/dist/chempot-diagram/color.d.ts +10 -0
  20. package/dist/chempot-diagram/color.js +33 -0
  21. package/dist/chempot-diagram/compute.d.ts +38 -0
  22. package/dist/chempot-diagram/compute.js +650 -0
  23. package/dist/chempot-diagram/index.d.ts +5 -0
  24. package/dist/chempot-diagram/index.js +5 -0
  25. package/dist/chempot-diagram/pointer.d.ts +16 -0
  26. package/dist/chempot-diagram/pointer.js +40 -0
  27. package/dist/chempot-diagram/temperature.d.ts +15 -0
  28. package/dist/chempot-diagram/temperature.js +37 -0
  29. package/dist/chempot-diagram/types.d.ts +83 -0
  30. package/dist/chempot-diagram/types.js +27 -0
  31. package/dist/colors/index.d.ts +3 -1
  32. package/dist/colors/index.js +4 -0
  33. package/dist/composition/BarChart.svelte +13 -22
  34. package/dist/composition/BubbleChart.svelte +5 -3
  35. package/dist/composition/FormulaFilter.svelte +770 -90
  36. package/dist/composition/FormulaFilter.svelte.d.ts +37 -1
  37. package/dist/composition/PieChart.svelte +43 -18
  38. package/dist/composition/PieChart.svelte.d.ts +1 -1
  39. package/dist/constants.d.ts +1 -0
  40. package/dist/constants.js +2 -0
  41. package/dist/convex-hull/ConvexHull.svelte +14 -1
  42. package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
  43. package/dist/convex-hull/ConvexHull2D.svelte +14 -45
  44. package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
  45. package/dist/convex-hull/ConvexHull3D.svelte +396 -134
  46. package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
  47. package/dist/convex-hull/ConvexHull4D.svelte +93 -42
  48. package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
  49. package/dist/convex-hull/ConvexHullControls.svelte +94 -31
  50. package/dist/convex-hull/ConvexHullControls.svelte.d.ts +4 -2
  51. package/dist/convex-hull/ConvexHullStats.svelte +697 -128
  52. package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
  53. package/dist/convex-hull/ConvexHullTooltip.svelte +1 -0
  54. package/dist/convex-hull/GasPressureControls.svelte +72 -38
  55. package/dist/convex-hull/GasPressureControls.svelte.d.ts +2 -1
  56. package/dist/convex-hull/TemperatureSlider.svelte +46 -19
  57. package/dist/convex-hull/TemperatureSlider.svelte.d.ts +2 -1
  58. package/dist/convex-hull/demo-temperature.d.ts +6 -0
  59. package/dist/convex-hull/demo-temperature.js +36 -0
  60. package/dist/convex-hull/gas-thermodynamics.js +16 -5
  61. package/dist/convex-hull/helpers.d.ts +7 -1
  62. package/dist/convex-hull/helpers.js +45 -15
  63. package/dist/convex-hull/index.d.ts +15 -1
  64. package/dist/convex-hull/index.js +1 -0
  65. package/dist/convex-hull/thermodynamics.d.ts +8 -21
  66. package/dist/convex-hull/thermodynamics.js +106 -17
  67. package/dist/convex-hull/types.d.ts +7 -0
  68. package/dist/convex-hull/types.js +11 -0
  69. package/dist/coordination/CoordinationBarPlot.svelte +29 -46
  70. package/dist/element/BohrAtom.svelte +1 -1
  71. package/dist/element/data.js +2 -14
  72. package/dist/element/data.json.gz +0 -0
  73. package/dist/element/index.d.ts +1 -1
  74. package/dist/element/index.js +1 -0
  75. package/dist/element/types.d.ts +1 -0
  76. package/dist/fermi-surface/FermiSurface.svelte +21 -65
  77. package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
  78. package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
  79. package/dist/fermi-surface/FermiSurfaceScene.svelte +1 -1
  80. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
  81. package/dist/fermi-surface/compute.js +1 -21
  82. package/dist/fermi-surface/marching-cubes.d.ts +2 -13
  83. package/dist/fermi-surface/marching-cubes.js +2 -519
  84. package/dist/fermi-surface/parse.js +17 -23
  85. package/dist/heatmap-matrix/HeatmapMatrix.svelte +1273 -0
  86. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
  87. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +171 -0
  88. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +31 -0
  89. package/dist/heatmap-matrix/index.d.ts +53 -0
  90. package/dist/heatmap-matrix/index.js +100 -0
  91. package/dist/heatmap-matrix/shared.d.ts +2 -0
  92. package/dist/heatmap-matrix/shared.js +4 -0
  93. package/dist/icons.d.ts +119 -0
  94. package/dist/icons.js +119 -0
  95. package/dist/index.d.ts +6 -1
  96. package/dist/index.js +6 -1
  97. package/dist/io/export.js +15 -3
  98. package/dist/io/file-drop.d.ts +7 -0
  99. package/dist/io/file-drop.js +43 -0
  100. package/dist/io/index.d.ts +2 -2
  101. package/dist/io/index.js +2 -112
  102. package/dist/io/types.d.ts +1 -0
  103. package/dist/io/url-drop.d.ts +2 -0
  104. package/dist/io/url-drop.js +118 -0
  105. package/dist/isosurface/Isosurface.svelte +231 -0
  106. package/dist/isosurface/Isosurface.svelte.d.ts +8 -0
  107. package/dist/isosurface/IsosurfaceControls.svelte +273 -0
  108. package/dist/isosurface/IsosurfaceControls.svelte.d.ts +9 -0
  109. package/dist/isosurface/index.d.ts +5 -0
  110. package/dist/isosurface/index.js +6 -0
  111. package/dist/isosurface/parse.d.ts +6 -0
  112. package/dist/isosurface/parse.js +548 -0
  113. package/dist/isosurface/slice.d.ts +11 -0
  114. package/dist/isosurface/slice.js +145 -0
  115. package/dist/isosurface/types.d.ts +55 -0
  116. package/dist/isosurface/types.js +178 -0
  117. package/dist/labels.d.ts +2 -1
  118. package/dist/labels.js +1 -0
  119. package/dist/layout/InfoTag.svelte +62 -62
  120. package/dist/layout/SubpageGrid.svelte +74 -0
  121. package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
  122. package/dist/layout/index.d.ts +1 -0
  123. package/dist/layout/index.js +1 -0
  124. package/dist/layout/json-tree/JsonNode.svelte +226 -53
  125. package/dist/layout/json-tree/JsonTree.svelte +425 -51
  126. package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
  127. package/dist/layout/json-tree/JsonValue.svelte +218 -97
  128. package/dist/layout/json-tree/types.d.ts +27 -2
  129. package/dist/layout/json-tree/utils.d.ts +14 -1
  130. package/dist/layout/json-tree/utils.js +254 -0
  131. package/dist/marching-cubes.d.ts +14 -0
  132. package/dist/marching-cubes.js +519 -0
  133. package/dist/math.d.ts +8 -0
  134. package/dist/math.js +374 -7
  135. package/dist/overlays/ContextMenu.svelte +3 -2
  136. package/dist/overlays/DraggablePane.svelte +163 -58
  137. package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
  138. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +232 -77
  139. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
  140. package/dist/phase-diagram/PhaseDiagramControls.svelte +32 -11
  141. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
  142. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +103 -0
  143. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
  144. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +102 -95
  145. package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +7 -0
  146. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +100 -26
  147. package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
  148. package/dist/phase-diagram/index.d.ts +2 -0
  149. package/dist/phase-diagram/index.js +2 -0
  150. package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
  151. package/dist/phase-diagram/svg-to-diagram.js +865 -0
  152. package/dist/phase-diagram/types.d.ts +10 -0
  153. package/dist/phase-diagram/utils.d.ts +7 -4
  154. package/dist/phase-diagram/utils.js +149 -59
  155. package/dist/plot/AxisLabel.svelte +26 -0
  156. package/dist/plot/AxisLabel.svelte.d.ts +16 -0
  157. package/dist/plot/BarPlot.svelte +473 -228
  158. package/dist/plot/BarPlot.svelte.d.ts +3 -3
  159. package/dist/plot/BarPlotControls.svelte +3 -2
  160. package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
  161. package/dist/plot/ColorBar.svelte +54 -54
  162. package/dist/plot/ColorBar.svelte.d.ts +1 -1
  163. package/dist/plot/ElementScatter.svelte +4 -3
  164. package/dist/plot/FillArea.svelte +4 -1
  165. package/dist/plot/Histogram.svelte +320 -230
  166. package/dist/plot/Histogram.svelte.d.ts +2 -2
  167. package/dist/plot/HistogramControls.svelte +29 -10
  168. package/dist/plot/HistogramControls.svelte.d.ts +6 -2
  169. package/dist/plot/InteractiveAxisLabel.svelte.d.ts +2 -2
  170. package/dist/plot/PlotControls.svelte +109 -27
  171. package/dist/plot/PlotControls.svelte.d.ts +1 -1
  172. package/dist/plot/PlotLegend.svelte +1 -1
  173. package/dist/plot/PortalSelect.svelte +2 -1
  174. package/dist/plot/ReferenceLine.svelte +2 -1
  175. package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
  176. package/dist/plot/ReferencePlane.svelte +1 -3
  177. package/dist/plot/ScatterPlot.svelte +343 -209
  178. package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
  179. package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
  180. package/dist/plot/ScatterPlot3DControls.svelte +203 -250
  181. package/dist/plot/ScatterPlot3DScene.svelte +4 -7
  182. package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
  183. package/dist/plot/ScatterPlotControls.svelte +95 -55
  184. package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
  185. package/dist/plot/ZeroLines.svelte +44 -0
  186. package/dist/plot/ZeroLines.svelte.d.ts +32 -0
  187. package/dist/plot/ZoomRect.svelte +21 -0
  188. package/dist/plot/ZoomRect.svelte.d.ts +8 -0
  189. package/dist/plot/axis-utils.d.ts +1 -1
  190. package/dist/plot/data-cleaning.js +1 -5
  191. package/dist/plot/index.d.ts +6 -2
  192. package/dist/plot/index.js +6 -2
  193. package/dist/plot/interactions.d.ts +8 -10
  194. package/dist/plot/interactions.js +10 -19
  195. package/dist/plot/layout.d.ts +7 -1
  196. package/dist/plot/layout.js +12 -4
  197. package/dist/plot/reference-line.d.ts +4 -21
  198. package/dist/plot/reference-line.js +7 -81
  199. package/dist/plot/types.d.ts +42 -17
  200. package/dist/plot/types.js +10 -0
  201. package/dist/plot/utils/label-placement.js +14 -11
  202. package/dist/plot/utils.d.ts +1 -0
  203. package/dist/plot/utils.js +14 -0
  204. package/dist/rdf/RdfPlot.svelte +55 -66
  205. package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
  206. package/dist/rdf/index.d.ts +1 -1
  207. package/dist/rdf/index.js +1 -1
  208. package/dist/settings.d.ts +5 -0
  209. package/dist/settings.js +37 -3
  210. package/dist/spectral/Bands.svelte +515 -143
  211. package/dist/spectral/Bands.svelte.d.ts +22 -2
  212. package/dist/spectral/helpers.d.ts +23 -1
  213. package/dist/spectral/helpers.js +65 -9
  214. package/dist/spectral/types.d.ts +2 -0
  215. package/dist/structure/AtomLegend.svelte +31 -10
  216. package/dist/structure/AtomLegend.svelte.d.ts +1 -1
  217. package/dist/structure/CellSelect.svelte +92 -22
  218. package/dist/structure/Lattice.svelte +2 -0
  219. package/dist/structure/Structure.svelte +716 -173
  220. package/dist/structure/Structure.svelte.d.ts +7 -2
  221. package/dist/structure/StructureControls.svelte +26 -14
  222. package/dist/structure/StructureControls.svelte.d.ts +5 -1
  223. package/dist/structure/StructureInfoPane.svelte +7 -1
  224. package/dist/structure/StructureScene.svelte +386 -95
  225. package/dist/structure/StructureScene.svelte.d.ts +15 -4
  226. package/dist/structure/atom-properties.d.ts +6 -2
  227. package/dist/structure/atom-properties.js +38 -25
  228. package/dist/structure/export.js +10 -7
  229. package/dist/structure/ferrox-wasm-types.d.ts +3 -2
  230. package/dist/structure/ferrox-wasm-types.js +0 -3
  231. package/dist/structure/ferrox-wasm.d.ts +3 -2
  232. package/dist/structure/ferrox-wasm.js +1 -2
  233. package/dist/structure/index.d.ts +7 -0
  234. package/dist/structure/index.js +22 -0
  235. package/dist/structure/parse.js +19 -16
  236. package/dist/structure/partial-occupancy.d.ts +25 -0
  237. package/dist/structure/partial-occupancy.js +102 -0
  238. package/dist/structure/validation.js +6 -3
  239. package/dist/symmetry/SymmetryStats.svelte +18 -4
  240. package/dist/symmetry/WyckoffTable.svelte +18 -10
  241. package/dist/symmetry/index.d.ts +7 -4
  242. package/dist/symmetry/index.js +83 -18
  243. package/dist/table/HeatmapTable.svelte +468 -69
  244. package/dist/table/HeatmapTable.svelte.d.ts +13 -1
  245. package/dist/table/ToggleMenu.svelte +291 -44
  246. package/dist/table/ToggleMenu.svelte.d.ts +4 -1
  247. package/dist/table/index.d.ts +3 -0
  248. package/dist/tooltip/index.d.ts +1 -1
  249. package/dist/tooltip/index.js +1 -0
  250. package/dist/trajectory/Trajectory.svelte +147 -145
  251. package/dist/trajectory/TrajectoryExportPane.svelte +13 -9
  252. package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
  253. package/dist/trajectory/constants.d.ts +6 -0
  254. package/dist/trajectory/constants.js +7 -0
  255. package/dist/trajectory/extract.js +3 -5
  256. package/dist/trajectory/format-detect.d.ts +9 -0
  257. package/dist/trajectory/format-detect.js +76 -0
  258. package/dist/trajectory/frame-reader.d.ts +17 -0
  259. package/dist/trajectory/frame-reader.js +339 -0
  260. package/dist/trajectory/helpers.d.ts +15 -0
  261. package/dist/trajectory/helpers.js +187 -0
  262. package/dist/trajectory/index.d.ts +1 -0
  263. package/dist/trajectory/index.js +11 -4
  264. package/dist/trajectory/parse/ase.d.ts +2 -0
  265. package/dist/trajectory/parse/ase.js +76 -0
  266. package/dist/trajectory/parse/hdf5.d.ts +2 -0
  267. package/dist/trajectory/parse/hdf5.js +121 -0
  268. package/dist/trajectory/parse/index.d.ts +12 -0
  269. package/dist/trajectory/parse/index.js +304 -0
  270. package/dist/trajectory/parse/lammps.d.ts +5 -0
  271. package/dist/trajectory/parse/lammps.js +169 -0
  272. package/dist/trajectory/parse/vasp.d.ts +2 -0
  273. package/dist/trajectory/parse/vasp.js +65 -0
  274. package/dist/trajectory/parse/xyz.d.ts +2 -0
  275. package/dist/trajectory/parse/xyz.js +109 -0
  276. package/dist/trajectory/types.d.ts +11 -0
  277. package/dist/trajectory/types.js +1 -0
  278. package/dist/utils.d.ts +2 -0
  279. package/dist/utils.js +4 -0
  280. package/dist/xrd/XrdPlot.svelte +6 -4
  281. package/dist/xrd/calc-xrd.js +0 -1
  282. package/package.json +33 -23
  283. package/readme.md +4 -4
  284. package/dist/trajectory/parse.d.ts +0 -42
  285. package/dist/trajectory/parse.js +0 -1267
  286. /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 { format_num } from '../labels';
2
- import { ELEMENT_COLOR_SCHEMES, pick_contrast_color } from '../colors';
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
- // use 359.99° to avoid 360° for single-element compositions which cause SVG arc issues
25
- const angle_span = fraction === 1 ? 359.99 : fraction * 360;
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={hovered_element === segment.element ? stroke_width + 1 : 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="{10 * segment.font_scale}px">
159
- {segment.amount}
160
- </sub>{/if}
161
- {#if show_percentages}
162
- <sub class="percentage" style:font-size="{11 * segment.font_scale}px">
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(9pt);
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';
@@ -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(0.3), 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
+ 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" | "fullscreen" | "show_hull_faces" | "hull_face_opacity" | "color_mode" | "color_scale" | "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">;
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: group by x, use lowest energy per x
156
- // eslint-disable-next-line svelte/prefer-svelte-reactivity -- local var in derived
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 group = by_x.get(entry.x);
160
- if (group)
161
- group.push(entry);
162
- else
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 = [...by_x].map(([x_coord, entries]) => ({
134
+ const hull_input = [...min_y_by_x].map(([x_coord, min_y]) => ({
166
135
  x: x_coord,
167
- y: Math.min(...entries.map((e) => e.y)),
136
+ y: min_y,
168
137
  }));
169
- const hull_points = compute_lower_hull(hull_input);
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 = interpolate_on_hull(hull_points, entry.x);
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 <= 1e-9,
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, 2.5em);
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" | "fullscreen" | "color_mode" | "color_scale" | "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">;
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;