matterviz 0.4.2 → 0.4.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.
Files changed (244) hide show
  1. package/dist/FilePicker.svelte +40 -50
  2. package/dist/api/optimade.js +10 -7
  3. package/dist/app.css +15 -0
  4. package/dist/brillouin/BrillouinZone.svelte +18 -9
  5. package/dist/brillouin/BrillouinZoneScene.svelte +20 -29
  6. package/dist/brillouin/compute.js +10 -16
  7. package/dist/brillouin/geometry.js +2 -2
  8. package/dist/chempot-diagram/ChemPotDiagram.svelte +18 -15
  9. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +17 -113
  10. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +104 -264
  11. package/dist/chempot-diagram/async-compute.svelte.js +12 -13
  12. package/dist/chempot-diagram/color.d.ts +21 -1
  13. package/dist/chempot-diagram/color.js +70 -1
  14. package/dist/chempot-diagram/compute.d.ts +7 -0
  15. package/dist/chempot-diagram/compute.js +85 -26
  16. package/dist/chempot-diagram/export.js +1 -6
  17. package/dist/chempot-diagram/temperature.js +9 -10
  18. package/dist/composition/BarChart.svelte +7 -9
  19. package/dist/composition/Composition.svelte +3 -8
  20. package/dist/composition/Formula.svelte +2 -2
  21. package/dist/composition/FormulaFilter.svelte +27 -93
  22. package/dist/composition/format.js +6 -8
  23. package/dist/composition/parse.js +50 -105
  24. package/dist/constants.d.ts +0 -1
  25. package/dist/constants.js +6 -17
  26. package/dist/convex-hull/ConvexHull2D.svelte +0 -2
  27. package/dist/convex-hull/ConvexHull3D.svelte +19 -47
  28. package/dist/convex-hull/ConvexHull4D.svelte +65 -95
  29. package/dist/convex-hull/StructurePopup.svelte +1 -1
  30. package/dist/convex-hull/gas-thermodynamics.js +21 -53
  31. package/dist/convex-hull/helpers.js +1 -7
  32. package/dist/convex-hull/thermodynamics.js +19 -27
  33. package/dist/coordination/CoordinationBarPlot.svelte +12 -21
  34. package/dist/element/BohrAtom.svelte +0 -1
  35. package/dist/element/ElementTile.svelte +26 -44
  36. package/dist/element/data.d.ts +2 -0
  37. package/dist/element/data.js +5 -1
  38. package/dist/element/index.d.ts +1 -1
  39. package/dist/element/index.js +1 -1
  40. package/dist/fermi-surface/FermiSurface.svelte +22 -23
  41. package/dist/fermi-surface/FermiSurface.svelte.d.ts +2 -6
  42. package/dist/fermi-surface/FermiSurfaceScene.svelte +32 -77
  43. package/dist/fermi-surface/compute.js +22 -55
  44. package/dist/fermi-surface/parse.js +38 -70
  45. package/dist/file-viewer/JsonBrowser.svelte +1043 -0
  46. package/dist/file-viewer/JsonBrowser.svelte.d.ts +9 -0
  47. package/dist/file-viewer/PlotPanel.svelte +350 -0
  48. package/dist/file-viewer/PlotPanel.svelte.d.ts +9 -0
  49. package/dist/file-viewer/TrajectoryWithDos.svelte +30 -0
  50. package/dist/file-viewer/TrajectoryWithDos.svelte.d.ts +10 -0
  51. package/dist/file-viewer/detect.d.ts +11 -0
  52. package/dist/file-viewer/detect.js +381 -0
  53. package/dist/file-viewer/eligibility.d.ts +4 -0
  54. package/dist/file-viewer/eligibility.js +53 -0
  55. package/dist/file-viewer/host-protocol.d.ts +50 -0
  56. package/dist/file-viewer/host-transfer.d.ts +25 -0
  57. package/dist/file-viewer/host-transfer.js +42 -0
  58. package/dist/file-viewer/index.d.ts +5 -0
  59. package/dist/file-viewer/index.js +5 -0
  60. package/dist/file-viewer/main.d.ts +44 -0
  61. package/dist/file-viewer/main.js +535 -0
  62. package/dist/file-viewer/parse.d.ts +9 -0
  63. package/dist/file-viewer/parse.js +170 -0
  64. package/dist/file-viewer/plot-utils.d.ts +24 -0
  65. package/dist/file-viewer/plot-utils.js +191 -0
  66. package/dist/file-viewer/types.d.ts +4 -0
  67. package/dist/file-viewer/types.js +5 -0
  68. package/dist/heatmap-matrix/HeatmapMatrix.svelte +57 -84
  69. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +1 -1
  70. package/dist/index.d.ts +2 -2
  71. package/dist/index.js +1 -1
  72. package/dist/io/ExportPane.svelte +1 -1
  73. package/dist/io/decompress.d.ts +2 -0
  74. package/dist/io/decompress.js +3 -2
  75. package/dist/io/export.d.ts +7 -4
  76. package/dist/io/export.js +70 -18
  77. package/dist/io/file-drop.js +60 -35
  78. package/dist/io/url-drop.d.ts +2 -0
  79. package/dist/io/url-drop.js +28 -16
  80. package/dist/isosurface/Isosurface.svelte +687 -196
  81. package/dist/isosurface/Isosurface.svelte.d.ts +7 -1
  82. package/dist/isosurface/IsosurfaceControls.svelte +564 -85
  83. package/dist/isosurface/IsosurfaceControls.svelte.d.ts +1 -1
  84. package/dist/isosurface/VolumeSlice.svelte +224 -0
  85. package/dist/isosurface/VolumeSlice.svelte.d.ts +28 -0
  86. package/dist/isosurface/coloring.d.ts +20 -0
  87. package/dist/isosurface/coloring.js +118 -0
  88. package/dist/isosurface/geometry-worker-types.d.ts +38 -0
  89. package/dist/isosurface/geometry.worker.d.ts +1 -0
  90. package/dist/isosurface/geometry.worker.js +59 -0
  91. package/dist/isosurface/grid.d.ts +10 -0
  92. package/dist/isosurface/grid.js +31 -0
  93. package/dist/isosurface/index.d.ts +4 -0
  94. package/dist/isosurface/index.js +4 -0
  95. package/dist/isosurface/profile.d.ts +12 -0
  96. package/dist/isosurface/profile.js +19 -0
  97. package/dist/isosurface/sampling.d.ts +34 -0
  98. package/dist/isosurface/sampling.js +408 -0
  99. package/dist/isosurface/slice-rendering.d.ts +13 -0
  100. package/dist/isosurface/slice-rendering.js +79 -0
  101. package/dist/isosurface/slice.d.ts +22 -2
  102. package/dist/isosurface/slice.js +200 -116
  103. package/dist/isosurface/types.d.ts +24 -1
  104. package/dist/isosurface/types.js +120 -8
  105. package/dist/json-path.d.ts +4 -0
  106. package/dist/json-path.js +89 -0
  107. package/dist/labels.js +1 -1
  108. package/dist/layout/InfoCard.svelte +1 -3
  109. package/dist/layout/SettingsSection.svelte +52 -61
  110. package/dist/layout/SettingsSection.svelte.d.ts +6 -7
  111. package/dist/layout/ViewerChrome.svelte +7 -1
  112. package/dist/layout/json-tree/JsonNode.svelte +14 -48
  113. package/dist/layout/json-tree/JsonTree.svelte +48 -95
  114. package/dist/layout/json-tree/JsonValue.svelte +3 -18
  115. package/dist/layout/json-tree/utils.d.ts +0 -3
  116. package/dist/layout/json-tree/utils.js +50 -179
  117. package/dist/marching-cubes.d.ts +8 -1
  118. package/dist/marching-cubes.js +115 -48
  119. package/dist/math.d.ts +3 -2
  120. package/dist/math.js +29 -38
  121. package/dist/overlays/ContextMenu.svelte +15 -32
  122. package/dist/overlays/DraggablePane.svelte +39 -58
  123. package/dist/overlays/DraggablePane.svelte.d.ts +1 -1
  124. package/dist/overlays/GlassChip.svelte +3 -1
  125. package/dist/periodic-table/PeriodicTableControls.svelte +26 -52
  126. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +18 -34
  127. package/dist/phase-diagram/build-diagram.js +1 -6
  128. package/dist/phase-diagram/svg-to-diagram.js +9 -14
  129. package/dist/plot/bar/BarPlot.svelte +38 -42
  130. package/dist/plot/bar/SpacegroupBarPlot.svelte +18 -42
  131. package/dist/plot/box/BoxPlot.svelte +27 -23
  132. package/dist/plot/core/auto-place.d.ts +1 -1
  133. package/dist/plot/core/auto-place.js +1 -1
  134. package/dist/plot/core/data-transform.d.ts +1 -2
  135. package/dist/plot/core/data-transform.js +0 -10
  136. package/dist/plot/core/layout.d.ts +12 -5
  137. package/dist/plot/core/layout.js +37 -27
  138. package/dist/plot/core/pan-zoom.svelte.d.ts +2 -4
  139. package/dist/plot/core/pan-zoom.svelte.js +34 -17
  140. package/dist/plot/core/placed-tween.svelte.d.ts +3 -0
  141. package/dist/plot/core/placed-tween.svelte.js +68 -21
  142. package/dist/plot/core/svg.js +0 -1
  143. package/dist/plot/core/utils/hierarchy-chart.d.ts +1 -0
  144. package/dist/plot/core/utils/hierarchy-chart.js +12 -0
  145. package/dist/plot/core/utils/hierarchy-labels.js +3 -2
  146. package/dist/plot/histogram/Histogram.svelte +21 -26
  147. package/dist/plot/sankey/sankey.js +13 -9
  148. package/dist/plot/scatter/BinnedScatterPlot.svelte +59 -43
  149. package/dist/plot/scatter/ScatterPlot.svelte +67 -52
  150. package/dist/plot/scatter/adaptive-density.d.ts +1 -1
  151. package/dist/plot/scatter/adaptive-density.js +36 -20
  152. package/dist/plot/sunburst/Sunburst.svelte +20 -20
  153. package/dist/plot/treemap/Treemap.svelte +175 -60
  154. package/dist/plot/treemap/Treemap.svelte.d.ts +6 -0
  155. package/dist/plot/treemap/index.d.ts +1 -0
  156. package/dist/plot/treemap/labels.d.ts +38 -0
  157. package/dist/plot/treemap/labels.js +80 -0
  158. package/dist/plot/treemap/treemap.d.ts +4 -2
  159. package/dist/plot/treemap/treemap.js +5 -2
  160. package/dist/rdf/RdfPlot.svelte +17 -35
  161. package/dist/rdf/calc-rdf.js +59 -44
  162. package/dist/rdf/index.d.ts +0 -1
  163. package/dist/sanitize.js +84 -26
  164. package/dist/scene/SceneCamera.svelte +1 -1
  165. package/dist/scene/SceneCamera.svelte.d.ts +1 -1
  166. package/dist/scene/index.d.ts +1 -2
  167. package/dist/scene/index.js +1 -1
  168. package/dist/scene/{props.js → props.svelte.js} +15 -1
  169. package/dist/settings.js +159 -482
  170. package/dist/spectral/Bands.svelte +151 -158
  171. package/dist/spectral/BrillouinBandsDos.svelte +4 -19
  172. package/dist/spectral/Dos.svelte +26 -24
  173. package/dist/spectral/helpers.js +40 -105
  174. package/dist/structure/AtomLegend.svelte +8 -13
  175. package/dist/structure/AtomLegend.svelte.d.ts +2 -3
  176. package/dist/structure/CellSelect.svelte +35 -10
  177. package/dist/structure/Structure.svelte +177 -99
  178. package/dist/structure/Structure.svelte.d.ts +1 -1
  179. package/dist/structure/StructureCarousel.svelte +10 -3
  180. package/dist/structure/StructureControls.svelte +8 -26
  181. package/dist/structure/StructureControls.svelte.d.ts +1 -1
  182. package/dist/structure/StructureInfoPane.svelte +65 -76
  183. package/dist/structure/StructureScene.svelte +75 -109
  184. package/dist/structure/StructureScene.svelte.d.ts +3 -1
  185. package/dist/structure/StructureViewport.svelte +120 -55
  186. package/dist/structure/StructureViewport.svelte.d.ts +3 -1
  187. package/dist/structure/atom-properties.d.ts +1 -1
  188. package/dist/structure/atom-properties.js +4 -3
  189. package/dist/structure/bond-order-perception.js +3 -8
  190. package/dist/structure/bonding.d.ts +0 -1
  191. package/dist/structure/bonding.js +16 -23
  192. package/dist/structure/export.js +50 -74
  193. package/dist/structure/format-detect.js +5 -7
  194. package/dist/structure/index.js +6 -12
  195. package/dist/structure/parse.js +38 -100
  196. package/dist/structure/partial-occupancy.js +7 -4
  197. package/dist/structure/pbc.js +8 -10
  198. package/dist/structure/polyhedra.js +5 -4
  199. package/dist/structure/prop-groups.d.ts +85 -0
  200. package/dist/structure/prop-groups.js +18 -0
  201. package/dist/symmetry/SymmetryStats.svelte +0 -4
  202. package/dist/symmetry/WyckoffTable.svelte +5 -4
  203. package/dist/symmetry/cell-transform.js +5 -14
  204. package/dist/symmetry/index.js +6 -9
  205. package/dist/table/HeatmapTable.svelte +61 -103
  206. package/dist/table/ToggleMenu.svelte +166 -44
  207. package/dist/table/ToggleMenu.svelte.d.ts +1 -1
  208. package/dist/theme/embedded.d.ts +18 -0
  209. package/dist/theme/embedded.js +206 -0
  210. package/dist/theme/index.d.ts +4 -0
  211. package/dist/theme/index.js +1 -2
  212. package/dist/theme/themes.mjs +31 -60
  213. package/dist/tooltip/TooltipContent.svelte +1 -1
  214. package/dist/tooltip/TooltipContent.svelte.d.ts +1 -1
  215. package/dist/tooltip/index.d.ts +8 -1
  216. package/dist/trajectory/Trajectory.svelte +140 -120
  217. package/dist/trajectory/TrajectoryError.svelte +1 -66
  218. package/dist/trajectory/TrajectoryExportPane.svelte +0 -1
  219. package/dist/trajectory/TrajectoryInfoPane.svelte +55 -80
  220. package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +2 -1
  221. package/dist/trajectory/extract.js +19 -29
  222. package/dist/trajectory/format-detect.d.ts +2 -0
  223. package/dist/trajectory/format-detect.js +7 -5
  224. package/dist/trajectory/frame-reader.js +3 -4
  225. package/dist/trajectory/helpers.js +16 -49
  226. package/dist/trajectory/index.js +2 -8
  227. package/dist/trajectory/parse/ase.js +1 -1
  228. package/dist/trajectory/parse/index.d.ts +4 -3
  229. package/dist/trajectory/parse/index.js +12 -17
  230. package/dist/trajectory/parse/vaspout-h5.d.ts +0 -1
  231. package/dist/trajectory/parse/vaspout-h5.js +1 -4
  232. package/dist/trajectory/parse/xyz.js +48 -2
  233. package/dist/trajectory/plotting.js +14 -37
  234. package/dist/xrd/XrdPlot.svelte +43 -68
  235. package/dist/xrd/calc-xrd.js +22 -58
  236. package/dist/xrd/parse.js +13 -22
  237. package/package.json +40 -8
  238. package/readme.md +6 -5
  239. package/dist/scene/types.d.ts +0 -26
  240. package/dist/tooltip/types.d.ts +0 -8
  241. package/dist/trajectory/constants.d.ts +0 -6
  242. package/dist/trajectory/constants.js +0 -11
  243. /package/dist/{scene/types.js → file-viewer/host-protocol.js} +0 -0
  244. /package/dist/{tooltip/types.js → isosurface/geometry-worker-types.js} +0 -0
@@ -38,7 +38,7 @@
38
38
  popup_div?: HTMLDivElement
39
39
  } = $props()
40
40
 
41
- const formula_html = $derived.by(() =>
41
+ const formula_html = $derived(
42
42
  sanitize_formula(get_electro_neg_formula(stats?.formula ?? structure, true)),
43
43
  )
44
44
  const context = $derived({ structure, stats, formula_html })
@@ -24,47 +24,23 @@ export const GAS_STOICHIOMETRY = {
24
24
  CO2: { C: 1, O: 2 },
25
25
  H2O: { H: 2, O: 1 },
26
26
  };
27
- // Default T*S data for common gases (in eV/molecule)
27
+ // Default Thermodynamic Data (abstracted - users can provide their own)
28
+ // Temperature grid (K) shared by all tabulated T*S data below
29
+ // oxfmt-ignore
30
+ const TS_TEMPERATURES = [0, 298, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000];
31
+ // Default T*S values (eV/molecule) at TS_TEMPERATURES, interpolated between grid points.
28
32
  // Source: Barin Thermochemical Tables and NBS Thermochemical Tables
29
33
  // Data compiled to match PIRO (https://github.com/GENESIS-EFRC/piro)
30
- // Note: These values are T*S in eV/molecule
34
+ // F2 not in Barin/NBS tables used by PIRO - approximated from similar homonuclear diatomics (O2, N2)
31
35
  // oxfmt-ignore
32
36
  const DEFAULT_TS_DATA = {
33
- O2: {
34
- temperatures: [0, 298, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],
35
- values: [0, 0.317, 0.3192, 0.4433, 0.5718, 0.7041, 0.8396, 0.9781, 1.119, 1.2623, 1.4075, 1.5547, 1.7036, 1.8541, 2.006, 2.1594, 2.3141, 2.47, 2.6271, 2.7854],
36
- },
37
- H2: {
38
- temperatures: [0, 298, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],
39
- values: [0, 0.2019, 0.2034, 0.2886, 0.3776, 0.4697, 0.5645, 0.6614, 0.7605, 0.8614, 0.964, 1.0683, 1.1741, 1.2815, 1.3902, 1.5003, 1.6116, 1.7242, 1.838, 1.9528],
40
- },
41
- N2: {
42
- temperatures: [0, 298, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],
43
- values: [0, 0.2959, 0.2981, 0.4149, 0.5356, 0.6596, 0.7866, 0.9161, 1.0481, 1.1822, 1.3184, 1.4563, 1.596, 1.7372, 1.8799, 2.0239, 2.1693, 2.3158, 2.4634, 2.6122],
44
- },
45
- CO: {
46
- temperatures: [0, 298, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],
47
- values: [0, 0.3054, 0.3076, 0.4275, 0.5515, 0.6788, 0.8092, 0.9423, 1.0778, 1.2155, 1.3552, 1.4967, 1.64, 1.7848, 1.9311, 2.0788, 2.2277, 2.3779, 2.5291, 2.6815],
48
- },
49
- CO2: {
50
- temperatures: [0, 298, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],
51
- values: [0, 0.2202, 0.2218, 0.3113, 0.4057, 0.5042, 0.6064, 0.7116, 0.8197, 0.9303, 1.0432, 1.1582, 1.2751, 1.3938, 1.5141, 1.636, 1.7593, 1.8839, 2.0098, 2.1369],
52
- },
53
- H2O: {
54
- temperatures: [0, 298, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],
55
- values: [0, 0.1946, 0.1961, 0.2749, 0.357, 0.4419, 0.5293, 0.6189, 0.7107, 0.8045, 0.9001, 0.9975, 1.0966, 1.1972, 1.2994, 1.403, 1.5079, 1.6142, 1.7216, 1.8303],
56
- },
57
- F2: {
58
- // F2 not in Barin/NBS tables used by PIRO - approximated from similar homonuclear diatomics (O2, N2)
59
- temperatures: [
60
- 0, 298, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600,
61
- 1700, 1800, 1900, 2000,
62
- ],
63
- values: [
64
- 0, 0.31, 0.312, 0.435, 0.56, 0.69, 0.82, 0.96, 1.1, 1.24, 1.38, 1.53, 1.68, 1.83,
65
- 1.98, 2.13, 2.29, 2.45, 2.61, 2.77,
66
- ],
67
- },
37
+ O2: [0, 0.317, 0.3192, 0.4433, 0.5718, 0.7041, 0.8396, 0.9781, 1.119, 1.2623, 1.4075, 1.5547, 1.7036, 1.8541, 2.006, 2.1594, 2.3141, 2.47, 2.6271, 2.7854],
38
+ H2: [0, 0.2019, 0.2034, 0.2886, 0.3776, 0.4697, 0.5645, 0.6614, 0.7605, 0.8614, 0.964, 1.0683, 1.1741, 1.2815, 1.3902, 1.5003, 1.6116, 1.7242, 1.838, 1.9528],
39
+ N2: [0, 0.2959, 0.2981, 0.4149, 0.5356, 0.6596, 0.7866, 0.9161, 1.0481, 1.1822, 1.3184, 1.4563, 1.596, 1.7372, 1.8799, 2.0239, 2.1693, 2.3158, 2.4634, 2.6122],
40
+ CO: [0, 0.3054, 0.3076, 0.4275, 0.5515, 0.6788, 0.8092, 0.9423, 1.0778, 1.2155, 1.3552, 1.4967, 1.64, 1.7848, 1.9311, 2.0788, 2.2277, 2.3779, 2.5291, 2.6815],
41
+ CO2: [0, 0.2202, 0.2218, 0.3113, 0.4057, 0.5042, 0.6064, 0.7116, 0.8197, 0.9303, 1.0432, 1.1582, 1.2751, 1.3938, 1.5141, 1.636, 1.7593, 1.8839, 2.0098, 2.1369],
42
+ H2O: [0, 0.1946, 0.1961, 0.2749, 0.357, 0.4419, 0.5293, 0.6189, 0.7107, 0.8045, 0.9001, 0.9975, 1.0966, 1.1972, 1.2994, 1.403, 1.5079, 1.6142, 1.7216, 1.8303],
43
+ F2: [0, 0.31, 0.312, 0.435, 0.56, 0.69, 0.82, 0.96, 1.1, 1.24, 1.38, 1.53, 1.68, 1.83, 1.98, 2.13, 2.29, 2.45, 2.61, 2.77],
68
44
  };
69
45
  // Formation enthalpies H_f at 0K in eV/molecule
70
46
  // These are the reference energies for formation from elements
@@ -76,27 +52,19 @@ const DEFAULT_ENTHALPY = {
76
52
  H2O: -0.82547,
77
53
  // O2, N2, H2, F2 are reference states with H_f = 0
78
54
  };
79
- // Interpolation Helpers
80
- // Linearly interpolate T*S value at given temperature
81
- function interpolate_ts(data, T) {
82
- const { temperatures, values } = data;
83
- // Clamp to valid range
84
- if (T <= temperatures[0])
55
+ // Linearly interpolate T*S value at given temperature (clamped to the tabulated range)
56
+ function interpolate_ts(values, T) {
57
+ const temps = TS_TEMPERATURES;
58
+ if (T <= temps[0])
85
59
  return values[0];
86
- if (T >= temperatures[temperatures.length - 1]) {
60
+ if (T >= temps[temps.length - 1])
87
61
  return values[values.length - 1];
88
- }
89
62
  // Find bracketing indices
90
63
  let idx = 0;
91
- while (idx < temperatures.length - 1 && temperatures[idx + 1] < T)
64
+ while (idx < temps.length - 1 && temps[idx + 1] < T)
92
65
  idx++;
93
- const T_low = temperatures[idx];
94
- const T_high = temperatures[idx + 1];
95
- const v_low = values[idx];
96
- const v_high = values[idx + 1];
97
- // Linear interpolation
98
- const fraction = (T - T_low) / (T_high - T_low);
99
- return v_low + fraction * (v_high - v_low);
66
+ const fraction = (T - temps[idx]) / (temps[idx + 1] - temps[idx]);
67
+ return values[idx] + fraction * (values[idx + 1] - values[idx]);
100
68
  }
101
69
  // Default Provider Implementation
102
70
  // Create the default gas thermodynamics provider using built-in data
@@ -290,13 +290,7 @@ energy_source_mode) {
290
290
  for (const el of Object.keys(entry.composition))
291
291
  elements_in_entries.add(el);
292
292
  }
293
- let can_compute_e_form = true;
294
- for (const el of elements_in_entries) {
295
- if (!unary_refs[el]) {
296
- can_compute_e_form = false;
297
- break;
298
- }
299
- }
293
+ const can_compute_e_form = [...elements_in_entries].every((el) => el in unary_refs);
300
294
  // Resolve mode to avoid inconsistent states:
301
295
  // - If full precomputed available, honor user toggle
302
296
  // - Else if we can compute, use on-the-fly automatically
@@ -442,40 +442,32 @@ export function compute_lower_hull_triangles(points) {
442
442
  return compute_quickhull_triangles(points).filter((face) => face.normal.z < 0 - EPS);
443
443
  }
444
444
  export const build_lower_hull_model = (faces) => faces.map((tri) => {
445
- const [p1, p2, p3] = tri.vertices;
446
- const plane = (() => {
447
- const x1 = p1.x, y1 = p1.y, z1 = p1.z;
448
- const x2 = p2.x, y2 = p2.y, z2 = p2.z;
449
- const x3 = p3.x, y3 = p3.y, z3 = p3.z;
450
- const det = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
451
- if (Math.abs(det) < 1e-12)
452
- return { a: 0, b: 0, c: (z1 + z2 + z3) / 3 };
453
- const a = (z1 * (y2 - y3) + z2 * (y3 - y1) + z3 * (y1 - y2)) / det;
454
- const b = (z1 * (x3 - x2) + z2 * (x1 - x3) + z3 * (x2 - x1)) / det;
455
- const c = (z1 * (x2 * y3 - x3 * y2) + z2 * (x3 * y1 - x1 * y3) + z3 * (x1 * y2 - x2 * y1)) / det;
456
- return { a, b, c };
457
- })();
458
- const [min_x, _mx, max_x] = [p1.x, p2.x, p3.x].sort((a, b) => a - b);
459
- const [min_y, _my, max_y] = [p1.y, p2.y, p3.y].sort((a, b) => a - b);
460
- const { x: x1, y: y1 } = p1;
461
- const { x: x2, y: y2 } = p2;
462
- const { x: x3, y: y3 } = p3;
463
- const denom = (y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3);
445
+ const [{ x: x1, y: y1, z: z1 }, { x: x2, y: y2, z: z2 }, { x: x3, y: y3, z: z3 }] = tri.vertices;
446
+ // Fit plane z = a*x + b*y + c through the three vertices (flat fallback if degenerate)
447
+ const det = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
448
+ const plane = Math.abs(det) < 1e-12
449
+ ? { a: 0, b: 0, c: (z1 + z2 + z3) / 3 }
450
+ : {
451
+ a: (z1 * (y2 - y3) + z2 * (y3 - y1) + z3 * (y1 - y2)) / det,
452
+ b: (z1 * (x3 - x2) + z2 * (x1 - x3) + z3 * (x2 - x1)) / det,
453
+ c: (z1 * (x2 * y3 - x3 * y2) +
454
+ z2 * (x3 * y1 - x1 * y3) +
455
+ z3 * (x1 * y2 - x2 * y1)) /
456
+ det,
457
+ };
464
458
  return {
465
- a: plane.a,
466
- b: plane.b,
467
- c: plane.c,
459
+ ...plane,
468
460
  x1,
469
461
  y1,
470
462
  x2,
471
463
  y2,
472
464
  x3,
473
465
  y3,
474
- min_x,
475
- max_x,
476
- min_y,
477
- max_y,
478
- denom,
466
+ min_x: Math.min(x1, x2, x3),
467
+ max_x: Math.max(x1, x2, x3),
468
+ min_y: Math.min(y1, y2, y3),
469
+ max_y: Math.max(y1, y2, y3),
470
+ denom: det,
479
471
  };
480
472
  });
481
473
  function point_in_triangle_xy(model, x, y) {
@@ -97,29 +97,21 @@
97
97
  })),
98
98
  )
99
99
 
100
- // Compute appropriate ranges
101
- const ranges = $derived.by(() => {
102
- // CN axis should always start at 0 and show at least [0,4]
103
- let max_cn = 4 // minimum max value
104
- for (const entry of entries_with_data) {
105
- for (const [cn] of entry.data.cn_histogram) max_cn = Math.max(max_cn, cn)
106
- }
107
- const cn_range: Vec2 = [-0.5, max_cn + 0.5]
108
-
109
- return { count: [0, null] as [number, null], cn: cn_range } // Count axis should always start at 0
110
- })
111
-
112
100
  // Derive integer CN ticks for axis labels
113
101
  const cn_ticks = $derived.by(() => {
114
- const all_cns = new SvelteSet<number>()
115
- // Always include minimum CN values 0-4
116
- for (let idx = 0; idx <= 4; idx++) all_cns.add(idx)
117
- // Add actual CN values from data
102
+ // Always include minimum CN values 0-4, then actual CN values from data
103
+ const all_cns = new SvelteSet<number>([0, 1, 2, 3, 4])
118
104
  for (const entry of entries_with_data) {
119
105
  for (const [cn] of entry.data.cn_histogram) all_cns.add(cn)
120
106
  }
121
107
  return Array.from(all_cns).sort((cn1, cn2) => cn1 - cn2)
122
108
  })
109
+
110
+ // CN axis spans all ticks with half-bar margin; count axis always starts at 0
111
+ const ranges = $derived({
112
+ count: [0, null] as [number, null],
113
+ cn: [-0.5, (cn_ticks.at(-1) ?? 4) + 0.5] as Vec2,
114
+ })
123
115
  // Build BarPlot series based on split_mode
124
116
  const bar_series = $derived.by<BarSeries<CoordinationMetadata>[]>(() => {
125
117
  if (split_mode === `by_element`) {
@@ -131,12 +123,11 @@
131
123
 
132
124
  for (const entry of entries_with_data) {
133
125
  for (const [element, cn_histogram] of entry.data.cn_histogram_by_element) {
134
- if (!element_series_map.has(element)) {
135
- element_series_map.set(element, new SvelteMap())
126
+ let element_map = element_series_map.get(element)
127
+ if (!element_map) {
128
+ element_map = new SvelteMap()
129
+ element_series_map.set(element, element_map)
136
130
  }
137
- const element_map = element_series_map.get(element)
138
- if (!element_map) continue
139
-
140
131
  for (const [cn, count] of cn_histogram) {
141
132
  all_cns.add(cn)
142
133
  element_map.set(cn, (element_map.get(cn) ?? 0) + count)
@@ -109,7 +109,6 @@
109
109
  {number_electrons(elec_idx)}
110
110
  {:else if number_electrons === `hierarchical`}
111
111
  {shell_idx + 1}.{elec_idx + 1}
112
- <!-- {:else if [`sequential`, true].includes(number_electrons)} -->
113
112
  {:else}
114
113
  {@const nth_electron =
115
114
  shells.slice(0, shell_idx).reduce((sum, count) => sum + count, 0) +
@@ -94,57 +94,39 @@
94
94
  return !is_color(value)
95
95
  })
96
96
 
97
+ // CSS classes for segments and value positions, keyed by `layout-count`
98
+ const layout_classes: Record<string, { segments: string[]; positions: string[] }> = {
99
+ 'diagonal-2': {
100
+ segments: [`diagonal-top`, `diagonal-bottom`],
101
+ positions: [`top-left`, `bottom-right`],
102
+ },
103
+ 'horizontal-3': {
104
+ segments: [`horizontal-top`, `horizontal-middle`, `horizontal-bottom`],
105
+ positions: [`bar-top-left`, `bar-middle-right`, `bar-bottom-left`],
106
+ },
107
+ 'vertical-3': {
108
+ segments: [`vertical-left`, `vertical-middle`, `vertical-right`],
109
+ positions: [`bar-left-top`, `bar-middle-bottom`, `bar-right-top`],
110
+ },
111
+ 'triangular-4': {
112
+ segments: [`top`, `right`, `bottom`, `left`].map((pos) => `triangle-${pos}`),
113
+ positions: [`top`, `right`, `bottom`, `left`].map((pos) => `triangle-${pos}-pos`),
114
+ },
115
+ 'quadrant-4': {
116
+ segments: [`tl`, `tr`, `bl`, `br`].map((pos) => `quadrant-${pos}`),
117
+ positions: [`tl`, `tr`, `bl`, `br`].map((pos) => `value-quadrant-${pos}`),
118
+ },
119
+ }
120
+
97
121
  // Get the appropriate CSS classes for segments and positions based on layout
98
122
  const layout_config = $derived.by(() => {
99
123
  if (!Array.isArray(value)) return null
100
-
101
124
  const count = value.length
102
125
  // Use explicit split_layout or auto-determine based on count
103
126
  const layout =
104
127
  split_layout ??
105
- ({
106
- 2: `diagonal`,
107
- 3: `horizontal`,
108
- 4: `quadrant`,
109
- }[count] as SplitLayout | undefined)
110
-
111
- if (!layout) return null
112
-
113
- if (layout === `diagonal` && count === 2) {
114
- return {
115
- segments: [`diagonal-top`, `diagonal-bottom`],
116
- positions: [`top-left`, `bottom-right`],
117
- }
118
- }
119
-
120
- if (layout === `horizontal` && count === 3) {
121
- return {
122
- segments: [`horizontal-top`, `horizontal-middle`, `horizontal-bottom`],
123
- positions: [`bar-top-left`, `bar-middle-right`, `bar-bottom-left`],
124
- }
125
- }
126
-
127
- if (layout === `vertical` && count === 3) {
128
- return {
129
- segments: [`vertical-left`, `vertical-middle`, `vertical-right`],
130
- positions: [`bar-left-top`, `bar-middle-bottom`, `bar-right-top`],
131
- }
132
- }
133
-
134
- if (layout === `triangular` && count === 4) {
135
- return {
136
- segments: [`top`, `right`, `bottom`, `left`].map((pos) => `triangle-${pos}`),
137
- positions: [`top`, `right`, `bottom`, `left`].map((pos) => `triangle-${pos}-pos`),
138
- }
139
- }
140
-
141
- if (layout === `quadrant` && count === 4) {
142
- const segments = [`tl`, `tr`, `bl`, `br`].map((pos) => `quadrant-${pos}`)
143
- const positions = [`tl`, `tr`, `bl`, `br`].map((pos) => `value-quadrant-${pos}`)
144
- return { segments, positions }
145
- }
146
-
147
- return null
128
+ ({ 2: `diagonal`, 3: `horizontal`, 4: `quadrant` }[count] as SplitLayout | undefined)
129
+ return layout ? (layout_classes[`${layout}-${count}`] ?? null) : null
148
130
  })
149
131
  </script>
150
132
 
@@ -1 +1,3 @@
1
+ import type { ChemicalElement, ElementSymbol } from './types';
2
+ export declare const element_by_symbol: ReadonlyMap<ElementSymbol, ChemicalElement>;
1
3
  export { default } from './data.json.gz';