matterviz 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/dist/EmptyState.svelte +10 -2
  2. package/dist/FilePicker.svelte +154 -96
  3. package/dist/Icon.svelte +20 -14
  4. package/dist/MillerIndexInput.svelte +27 -21
  5. package/dist/api/optimade.js +6 -6
  6. package/dist/app.css +216 -178
  7. package/dist/brillouin/BrillouinZone.svelte +299 -198
  8. package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
  9. package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
  10. package/dist/brillouin/BrillouinZoneExportPane.svelte +74 -55
  11. package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
  12. package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
  13. package/dist/brillouin/BrillouinZoneScene.svelte +277 -165
  14. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
  15. package/dist/brillouin/BrillouinZoneTooltip.svelte +17 -7
  16. package/dist/brillouin/compute.js +11 -6
  17. package/dist/chempot-diagram/ChemPotDiagram.svelte +327 -0
  18. package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
  19. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +847 -0
  20. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
  21. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +3194 -0
  22. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
  23. package/dist/chempot-diagram/ChemPotScene3D.svelte +11 -0
  24. package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
  25. package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
  26. package/dist/chempot-diagram/async-compute.svelte.js +77 -0
  27. package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
  28. package/dist/chempot-diagram/chempot-worker.js +11 -0
  29. package/dist/chempot-diagram/color.d.ts +10 -0
  30. package/dist/chempot-diagram/color.js +32 -0
  31. package/dist/chempot-diagram/compute.d.ts +48 -0
  32. package/dist/chempot-diagram/compute.js +812 -0
  33. package/dist/chempot-diagram/index.d.ts +6 -0
  34. package/dist/chempot-diagram/index.js +6 -0
  35. package/dist/chempot-diagram/pointer.d.ts +16 -0
  36. package/dist/chempot-diagram/pointer.js +40 -0
  37. package/dist/chempot-diagram/temperature.d.ts +15 -0
  38. package/dist/chempot-diagram/temperature.js +36 -0
  39. package/dist/chempot-diagram/types.d.ts +86 -0
  40. package/dist/chempot-diagram/types.js +28 -0
  41. package/dist/colors/index.d.ts +3 -1
  42. package/dist/colors/index.js +9 -3
  43. package/dist/composition/BarChart.svelte +141 -77
  44. package/dist/composition/BubbleChart.svelte +107 -52
  45. package/dist/composition/Composition.svelte +100 -79
  46. package/dist/composition/Formula.svelte +108 -62
  47. package/dist/composition/FormulaFilter.svelte +973 -353
  48. package/dist/composition/FormulaFilter.svelte.d.ts +35 -1
  49. package/dist/composition/PieChart.svelte +199 -99
  50. package/dist/composition/PieChart.svelte.d.ts +1 -1
  51. package/dist/composition/format.d.ts +5 -0
  52. package/dist/composition/format.js +20 -3
  53. package/dist/composition/parse.js +14 -9
  54. package/dist/convex-hull/ConvexHull.svelte +93 -38
  55. package/dist/convex-hull/ConvexHull2D.svelte +551 -393
  56. package/dist/convex-hull/ConvexHull3D.svelte +1303 -825
  57. package/dist/convex-hull/ConvexHull4D.svelte +1012 -686
  58. package/dist/convex-hull/ConvexHullControls.svelte +115 -28
  59. package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
  60. package/dist/convex-hull/ConvexHullStats.svelte +821 -249
  61. package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
  62. package/dist/convex-hull/ConvexHullTooltip.svelte +41 -16
  63. package/dist/convex-hull/GasPressureControls.svelte +104 -61
  64. package/dist/convex-hull/StructurePopup.svelte +25 -4
  65. package/dist/convex-hull/TemperatureSlider.svelte +45 -25
  66. package/dist/convex-hull/barycentric-coords.js +13 -7
  67. package/dist/convex-hull/demo-temperature.d.ts +6 -0
  68. package/dist/convex-hull/demo-temperature.js +40 -0
  69. package/dist/convex-hull/gas-thermodynamics.js +17 -12
  70. package/dist/convex-hull/helpers.d.ts +10 -1
  71. package/dist/convex-hull/helpers.js +79 -38
  72. package/dist/convex-hull/index.d.ts +1 -0
  73. package/dist/convex-hull/index.js +1 -0
  74. package/dist/convex-hull/thermodynamics.d.ts +8 -21
  75. package/dist/convex-hull/thermodynamics.js +163 -69
  76. package/dist/convex-hull/types.d.ts +12 -12
  77. package/dist/convex-hull/types.js +0 -12
  78. package/dist/coordination/CoordinationBarPlot.svelte +232 -176
  79. package/dist/element/BohrAtom.svelte +56 -13
  80. package/dist/element/ElementHeading.svelte +7 -2
  81. package/dist/element/ElementPhoto.svelte +15 -9
  82. package/dist/element/ElementStats.svelte +10 -4
  83. package/dist/element/ElementTile.svelte +137 -73
  84. package/dist/element/Nucleus.svelte +39 -11
  85. package/dist/element/data.js +2 -14
  86. package/dist/element/data.json.gz +0 -0
  87. package/dist/element/types.d.ts +1 -0
  88. package/dist/feedback/ClickFeedback.svelte +16 -5
  89. package/dist/feedback/DragOverlay.svelte +10 -2
  90. package/dist/feedback/Spinner.svelte +4 -2
  91. package/dist/feedback/StatusMessage.svelte +8 -2
  92. package/dist/fermi-surface/FermiSlice.svelte +118 -88
  93. package/dist/fermi-surface/FermiSurface.svelte +336 -239
  94. package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
  95. package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
  96. package/dist/fermi-surface/FermiSurfaceScene.svelte +536 -343
  97. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
  98. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
  99. package/dist/fermi-surface/compute.js +16 -20
  100. package/dist/fermi-surface/parse.js +37 -33
  101. package/dist/fermi-surface/symmetry.js +2 -7
  102. package/dist/fermi-surface/types.d.ts +3 -5
  103. package/dist/heatmap-matrix/HeatmapMatrix.svelte +1527 -0
  104. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
  105. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
  106. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +30 -0
  107. package/dist/heatmap-matrix/index.d.ts +53 -0
  108. package/dist/heatmap-matrix/index.js +100 -0
  109. package/dist/heatmap-matrix/shared.d.ts +2 -0
  110. package/dist/heatmap-matrix/shared.js +4 -0
  111. package/dist/icons.d.ts +111 -0
  112. package/dist/icons.js +158 -0
  113. package/dist/index.d.ts +5 -2
  114. package/dist/index.js +5 -2
  115. package/dist/io/decompress.js +1 -1
  116. package/dist/io/export.d.ts +3 -0
  117. package/dist/io/export.js +138 -140
  118. package/dist/io/file-drop.d.ts +7 -0
  119. package/dist/io/file-drop.js +43 -0
  120. package/dist/io/index.d.ts +2 -2
  121. package/dist/io/index.js +2 -112
  122. package/dist/io/is-binary.js +2 -3
  123. package/dist/io/types.d.ts +1 -0
  124. package/dist/io/url-drop.d.ts +2 -0
  125. package/dist/io/url-drop.js +117 -0
  126. package/dist/isosurface/Isosurface.svelte +220 -110
  127. package/dist/isosurface/IsosurfaceControls.svelte +65 -28
  128. package/dist/isosurface/parse.js +104 -56
  129. package/dist/isosurface/slice.d.ts +2 -1
  130. package/dist/isosurface/slice.js +8 -13
  131. package/dist/isosurface/types.d.ts +14 -1
  132. package/dist/isosurface/types.js +152 -5
  133. package/dist/labels.d.ts +2 -1
  134. package/dist/labels.js +12 -8
  135. package/dist/layout/FullscreenToggle.svelte +11 -2
  136. package/dist/layout/InfoCard.svelte +38 -6
  137. package/dist/layout/InfoTag.svelte +125 -94
  138. package/dist/layout/PropertyFilter.svelte +82 -37
  139. package/dist/layout/SettingsSection.svelte +85 -55
  140. package/dist/layout/SubpageGrid.svelte +82 -0
  141. package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
  142. package/dist/layout/index.d.ts +1 -0
  143. package/dist/layout/index.js +1 -0
  144. package/dist/layout/json-tree/JsonNode.svelte +266 -223
  145. package/dist/layout/json-tree/JsonTree.svelte +516 -429
  146. package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
  147. package/dist/layout/json-tree/JsonValue.svelte +281 -173
  148. package/dist/layout/json-tree/types.d.ts +10 -2
  149. package/dist/layout/json-tree/utils.d.ts +2 -0
  150. package/dist/layout/json-tree/utils.js +37 -2
  151. package/dist/marching-cubes.js +25 -2
  152. package/dist/math.d.ts +20 -17
  153. package/dist/math.js +474 -57
  154. package/dist/overlays/ContextMenu.svelte +66 -40
  155. package/dist/overlays/DraggablePane.svelte +331 -154
  156. package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
  157. package/dist/periodic-table/PeriodicTable.svelte +278 -145
  158. package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
  159. package/dist/periodic-table/PropertySelect.svelte +25 -7
  160. package/dist/periodic-table/TableInset.svelte +8 -3
  161. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +559 -267
  162. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
  163. package/dist/phase-diagram/PhaseDiagramControls.svelte +131 -51
  164. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
  165. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
  166. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
  167. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +160 -110
  168. package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +8 -1
  169. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +217 -86
  170. package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
  171. package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
  172. package/dist/phase-diagram/build-diagram.js +9 -9
  173. package/dist/phase-diagram/colors.js +1 -3
  174. package/dist/phase-diagram/index.d.ts +2 -0
  175. package/dist/phase-diagram/index.js +2 -0
  176. package/dist/phase-diagram/parse.js +10 -9
  177. package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
  178. package/dist/phase-diagram/svg-to-diagram.js +869 -0
  179. package/dist/phase-diagram/types.d.ts +10 -0
  180. package/dist/phase-diagram/utils.d.ts +8 -4
  181. package/dist/phase-diagram/utils.js +219 -74
  182. package/dist/plot/AxisLabel.svelte +51 -0
  183. package/dist/plot/AxisLabel.svelte.d.ts +16 -0
  184. package/dist/plot/BarPlot.svelte +1461 -768
  185. package/dist/plot/BarPlot.svelte.d.ts +3 -3
  186. package/dist/plot/BarPlotControls.svelte +33 -6
  187. package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
  188. package/dist/plot/ColorBar.svelte +533 -383
  189. package/dist/plot/ColorBar.svelte.d.ts +1 -1
  190. package/dist/plot/ColorScaleSelect.svelte +28 -7
  191. package/dist/plot/ElementScatter.svelte +38 -16
  192. package/dist/plot/FillArea.svelte +152 -92
  193. package/dist/plot/Histogram.svelte +1162 -709
  194. package/dist/plot/Histogram.svelte.d.ts +1 -1
  195. package/dist/plot/HistogramControls.svelte +81 -18
  196. package/dist/plot/HistogramControls.svelte.d.ts +6 -2
  197. package/dist/plot/InteractiveAxisLabel.svelte +34 -11
  198. package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
  199. package/dist/plot/Line.svelte +63 -28
  200. package/dist/plot/PlotControls.svelte +221 -96
  201. package/dist/plot/PlotControls.svelte.d.ts +1 -1
  202. package/dist/plot/PlotLegend.svelte +174 -91
  203. package/dist/plot/PlotTooltip.svelte +45 -6
  204. package/dist/plot/PortalSelect.svelte +175 -146
  205. package/dist/plot/ReferenceLine.svelte +77 -22
  206. package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
  207. package/dist/plot/ReferenceLine3D.svelte +132 -107
  208. package/dist/plot/ReferencePlane.svelte +146 -123
  209. package/dist/plot/ScatterPlot.svelte +1880 -1156
  210. package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
  211. package/dist/plot/ScatterPlot3D.svelte +256 -131
  212. package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
  213. package/dist/plot/ScatterPlot3DControls.svelte +300 -297
  214. package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
  215. package/dist/plot/ScatterPlot3DScene.svelte +608 -406
  216. package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
  217. package/dist/plot/ScatterPlotControls.svelte +150 -70
  218. package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
  219. package/dist/plot/ScatterPoint.svelte +98 -26
  220. package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
  221. package/dist/plot/SpacegroupBarPlot.svelte +142 -85
  222. package/dist/plot/Surface3D.svelte +159 -108
  223. package/dist/plot/ZeroLines.svelte +96 -0
  224. package/dist/plot/ZeroLines.svelte.d.ts +32 -0
  225. package/dist/plot/ZoomRect.svelte +23 -0
  226. package/dist/plot/ZoomRect.svelte.d.ts +8 -0
  227. package/dist/plot/axis-utils.d.ts +1 -1
  228. package/dist/plot/axis-utils.js +1 -3
  229. package/dist/plot/data-cleaning.js +12 -28
  230. package/dist/plot/data-transform.js +2 -1
  231. package/dist/plot/fill-utils.js +2 -0
  232. package/dist/plot/index.d.ts +6 -2
  233. package/dist/plot/index.js +6 -2
  234. package/dist/plot/interactions.d.ts +8 -10
  235. package/dist/plot/interactions.js +2 -3
  236. package/dist/plot/layout.d.ts +11 -2
  237. package/dist/plot/layout.js +44 -17
  238. package/dist/plot/reference-line.d.ts +5 -22
  239. package/dist/plot/reference-line.js +12 -84
  240. package/dist/plot/scales.js +24 -36
  241. package/dist/plot/types.d.ts +53 -40
  242. package/dist/plot/types.js +12 -7
  243. package/dist/plot/utils/label-placement.d.ts +32 -15
  244. package/dist/plot/utils/label-placement.js +227 -63
  245. package/dist/plot/utils/series-visibility.js +2 -3
  246. package/dist/plot/utils.d.ts +1 -0
  247. package/dist/plot/utils.js +14 -0
  248. package/dist/rdf/RdfPlot.svelte +173 -132
  249. package/dist/rdf/calc-rdf.js +4 -5
  250. package/dist/sanitize.d.ts +4 -0
  251. package/dist/sanitize.js +107 -0
  252. package/dist/settings.d.ts +21 -6
  253. package/dist/settings.js +63 -19
  254. package/dist/spectral/Bands.svelte +963 -412
  255. package/dist/spectral/Bands.svelte.d.ts +22 -2
  256. package/dist/spectral/BandsAndDos.svelte +90 -49
  257. package/dist/spectral/BrillouinBandsDos.svelte +151 -93
  258. package/dist/spectral/Dos.svelte +389 -258
  259. package/dist/spectral/helpers.d.ts +23 -1
  260. package/dist/spectral/helpers.js +119 -51
  261. package/dist/spectral/types.d.ts +2 -0
  262. package/dist/state.svelte.d.ts +1 -1
  263. package/dist/state.svelte.js +3 -2
  264. package/dist/structure/Arrow.svelte +59 -20
  265. package/dist/structure/AtomLegend.svelte +231 -129
  266. package/dist/structure/AtomLegend.svelte.d.ts +1 -1
  267. package/dist/structure/Bond.svelte +73 -47
  268. package/dist/structure/CanvasTooltip.svelte +10 -2
  269. package/dist/structure/CellSelect.svelte +148 -51
  270. package/dist/structure/Cylinder.svelte +33 -17
  271. package/dist/structure/Lattice.svelte +88 -33
  272. package/dist/structure/Structure.svelte +1077 -821
  273. package/dist/structure/Structure.svelte.d.ts +1 -1
  274. package/dist/structure/StructureControls.svelte +373 -139
  275. package/dist/structure/StructureControls.svelte.d.ts +1 -1
  276. package/dist/structure/StructureExportPane.svelte +124 -89
  277. package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
  278. package/dist/structure/StructureInfoPane.svelte +304 -231
  279. package/dist/structure/StructureScene.svelte +919 -445
  280. package/dist/structure/StructureScene.svelte.d.ts +16 -7
  281. package/dist/structure/atom-properties.d.ts +6 -2
  282. package/dist/structure/atom-properties.js +42 -29
  283. package/dist/structure/bonding.js +6 -7
  284. package/dist/structure/export.js +22 -34
  285. package/dist/structure/ferrox-wasm-types.d.ts +3 -2
  286. package/dist/structure/ferrox-wasm-types.js +0 -3
  287. package/dist/structure/ferrox-wasm.d.ts +3 -2
  288. package/dist/structure/ferrox-wasm.js +2 -3
  289. package/dist/structure/index.d.ts +16 -0
  290. package/dist/structure/index.js +88 -6
  291. package/dist/structure/measure.d.ts +2 -2
  292. package/dist/structure/measure.js +4 -44
  293. package/dist/structure/parse.js +130 -155
  294. package/dist/structure/partial-occupancy.d.ts +25 -0
  295. package/dist/structure/partial-occupancy.js +99 -0
  296. package/dist/structure/pbc.d.ts +1 -0
  297. package/dist/structure/pbc.js +16 -6
  298. package/dist/structure/supercell.d.ts +2 -2
  299. package/dist/structure/supercell.js +12 -22
  300. package/dist/structure/validation.js +5 -3
  301. package/dist/symmetry/SymmetryStats.svelte +94 -37
  302. package/dist/symmetry/WyckoffTable.svelte +42 -14
  303. package/dist/symmetry/cell-transform.js +5 -3
  304. package/dist/symmetry/index.d.ts +7 -4
  305. package/dist/symmetry/index.js +87 -21
  306. package/dist/symmetry/spacegroups.js +148 -148
  307. package/dist/table/HeatmapTable.svelte +1112 -516
  308. package/dist/table/HeatmapTable.svelte.d.ts +12 -1
  309. package/dist/table/ToggleMenu.svelte +125 -90
  310. package/dist/table/index.d.ts +2 -0
  311. package/dist/table/index.js +2 -4
  312. package/dist/theme/ThemeControl.svelte +21 -12
  313. package/dist/time.js +4 -1
  314. package/dist/tooltip/TooltipContent.svelte +33 -8
  315. package/dist/trajectory/Trajectory.svelte +889 -687
  316. package/dist/trajectory/TrajectoryError.svelte +14 -3
  317. package/dist/trajectory/TrajectoryExportPane.svelte +148 -90
  318. package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
  319. package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
  320. package/dist/trajectory/constants.d.ts +6 -0
  321. package/dist/trajectory/constants.js +7 -0
  322. package/dist/trajectory/extract.js +13 -31
  323. package/dist/trajectory/format-detect.d.ts +9 -0
  324. package/dist/trajectory/format-detect.js +76 -0
  325. package/dist/trajectory/frame-reader.d.ts +17 -0
  326. package/dist/trajectory/frame-reader.js +332 -0
  327. package/dist/trajectory/helpers.d.ts +14 -0
  328. package/dist/trajectory/helpers.js +172 -0
  329. package/dist/trajectory/index.d.ts +1 -0
  330. package/dist/trajectory/index.js +23 -14
  331. package/dist/trajectory/parse/ase.d.ts +2 -0
  332. package/dist/trajectory/parse/ase.js +77 -0
  333. package/dist/trajectory/parse/hdf5.d.ts +2 -0
  334. package/dist/trajectory/parse/hdf5.js +129 -0
  335. package/dist/trajectory/parse/index.d.ts +12 -0
  336. package/dist/trajectory/parse/index.js +299 -0
  337. package/dist/trajectory/parse/lammps.d.ts +5 -0
  338. package/dist/trajectory/parse/lammps.js +179 -0
  339. package/dist/trajectory/parse/vasp.d.ts +2 -0
  340. package/dist/trajectory/parse/vasp.js +68 -0
  341. package/dist/trajectory/parse/xyz.d.ts +2 -0
  342. package/dist/trajectory/parse/xyz.js +110 -0
  343. package/dist/trajectory/plotting.js +13 -8
  344. package/dist/trajectory/types.d.ts +11 -0
  345. package/dist/trajectory/types.js +1 -0
  346. package/dist/utils.d.ts +3 -0
  347. package/dist/utils.js +17 -0
  348. package/dist/xrd/XrdPlot.svelte +337 -245
  349. package/dist/xrd/broadening.js +14 -9
  350. package/dist/xrd/calc-xrd.js +12 -19
  351. package/dist/xrd/parse.d.ts +1 -1
  352. package/dist/xrd/parse.js +17 -17
  353. package/package.json +103 -101
  354. package/readme.md +4 -4
  355. package/dist/trajectory/parse.d.ts +0 -42
  356. package/dist/trajectory/parse.js +0 -1267
  357. /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
  358. /package/dist/theme/{themes.js → themes.mjs} +0 -0
@@ -0,0 +1,99 @@
1
+ export const PARTIAL_OCCUPANCY_SLICE_GAP_RAD = 1e-3;
2
+ const OCCUPANCY_EPS = 1e-6;
3
+ const MIN_PHI_LENGTH = 1e-4;
4
+ const MERGE_DISTANCE_TOLERANCE = 1e-8;
5
+ const CAP_ARC_START = Math.PI / 2;
6
+ const is_image_atom = (site) => typeof site.properties?.orig_site_idx === `number`;
7
+ const make_render_site = (sites, site_idx, source_site_indices, site_override) => ({
8
+ site_idx,
9
+ site: site_override ?? sites[site_idx],
10
+ is_image_atom: source_site_indices.some((source_site_idx) => is_image_atom(sites[source_site_idx])),
11
+ source_site_indices,
12
+ });
13
+ const sq_dist = (xyz_1, xyz_2) => (xyz_1[0] - xyz_2[0]) ** 2 + (xyz_1[1] - xyz_2[1]) ** 2 + (xyz_1[2] - xyz_2[2]) ** 2;
14
+ const is_split_partial_site = (site, hidden_elements) => {
15
+ const visible_species = site.species.filter(({ element }) => !hidden_elements.has(element));
16
+ const total_visible_occupancy = visible_species.reduce((occupancy_sum, { occu }) => occupancy_sum + occu, 0);
17
+ return visible_species.length === 1 && total_visible_occupancy < 1 - OCCUPANCY_EPS;
18
+ };
19
+ const group_split_partial_indices = (sites, hidden_elements) => {
20
+ const grouped_centers = [];
21
+ const grouped_site_indices = [];
22
+ const non_grouped_site_indices = [];
23
+ for (const [site_idx, site] of sites.entries()) {
24
+ if (!is_split_partial_site(site, hidden_elements)) {
25
+ non_grouped_site_indices.push(site_idx);
26
+ continue;
27
+ }
28
+ const matched_group_idx = grouped_centers.findIndex((center_xyz) => sq_dist(center_xyz, site.xyz) <= MERGE_DISTANCE_TOLERANCE ** 2);
29
+ if (matched_group_idx === -1) {
30
+ grouped_centers.push(site.xyz);
31
+ grouped_site_indices.push([site_idx]);
32
+ continue;
33
+ }
34
+ grouped_site_indices[matched_group_idx].push(site_idx);
35
+ }
36
+ return { non_grouped_site_indices, grouped_site_indices };
37
+ };
38
+ const build_render_sites = (sites, non_grouped_site_indices, grouped_site_indices) => {
39
+ const render_sites = non_grouped_site_indices.map((site_idx) => make_render_site(sites, site_idx, [site_idx]));
40
+ for (const grouped_indices of grouped_site_indices) {
41
+ if (grouped_indices.length === 1) {
42
+ const site_idx = grouped_indices[0];
43
+ render_sites.push(make_render_site(sites, site_idx, [site_idx]));
44
+ continue;
45
+ }
46
+ const representative_site_idx = grouped_indices[0];
47
+ const representative_site = sites[representative_site_idx];
48
+ const merged_species = grouped_indices.flatMap((grouped_site_idx) => sites[grouped_site_idx].species);
49
+ render_sites.push(make_render_site(sites, representative_site_idx, [...grouped_indices], {
50
+ ...representative_site,
51
+ species: merged_species,
52
+ }));
53
+ }
54
+ return render_sites;
55
+ };
56
+ export const PARTIAL_OCCUPANCY_CAP_ARC = {
57
+ start_cap_arc_start: CAP_ARC_START,
58
+ end_cap_arc_start: CAP_ARC_START,
59
+ arc_length: Math.PI,
60
+ };
61
+ export const merge_split_partial_sites = (sites, hidden_elements = new Set()) => {
62
+ const grouped_indices = group_split_partial_indices(sites, hidden_elements);
63
+ return build_render_sites(sites, grouped_indices.non_grouped_site_indices, grouped_indices.grouped_site_indices);
64
+ };
65
+ export const compute_slice_geometry = (visible_species, slice_gap_rad = PARTIAL_OCCUPANCY_SLICE_GAP_RAD) => {
66
+ if (visible_species.length === 0)
67
+ return [];
68
+ const total_visible_occupancy = visible_species.reduce((occupancy_sum, { occu }) => occupancy_sum + occu, 0);
69
+ // Preserve total angular coverage at one full turn for invalid overfull inputs.
70
+ const occupancy_scale_factor = total_visible_occupancy > 1 + OCCUPANCY_EPS ? 1 / total_visible_occupancy : 1;
71
+ const normalized_species = visible_species.map(({ element, occu }) => ({
72
+ element,
73
+ occu: occu * occupancy_scale_factor,
74
+ }));
75
+ const normalized_total_occupancy = normalized_species.reduce((occupancy_sum, { occu }) => occupancy_sum + occu, 0);
76
+ const has_vacancy_gap = normalized_total_occupancy < 1 - OCCUPANCY_EPS;
77
+ const last_visible_species_idx = normalized_species.length - 1;
78
+ let start_angle = 0;
79
+ return normalized_species.map(({ element, occu }, species_idx) => {
80
+ const start_phi_raw = 2 * Math.PI * start_angle;
81
+ const end_phi_raw = 2 * Math.PI * (start_angle += occu);
82
+ // Keep neighboring wedges from sharing the exact same plane (z-fighting).
83
+ const phi_span_raw = Math.max(0, end_phi_raw - start_phi_raw);
84
+ const max_safe_gap = Math.max(0, phi_span_raw - MIN_PHI_LENGTH);
85
+ const desired_gap = visible_species.length > 1 ? Math.min(slice_gap_rad, phi_span_raw * 0.25) : 0;
86
+ const phi_gap = Math.min(desired_gap, max_safe_gap);
87
+ const start_phi = start_phi_raw + phi_gap / 2;
88
+ const end_phi = end_phi_raw - phi_gap / 2;
89
+ return {
90
+ element,
91
+ occupancy: occu,
92
+ start_phi,
93
+ end_phi,
94
+ phi_length: Math.max(MIN_PHI_LENGTH, end_phi - start_phi),
95
+ render_start_cap: has_vacancy_gap && species_idx === 0,
96
+ render_end_cap: has_vacancy_gap && species_idx === last_visible_species_idx,
97
+ };
98
+ });
99
+ };
@@ -1,6 +1,7 @@
1
1
  import type { Vec3 } from '../math';
2
2
  import type { ParsedStructure } from './parse';
3
3
  export type Pbc = readonly [boolean, boolean, boolean];
4
+ export declare const wrap_frac_coord: (coord: number) => number;
4
5
  export declare const wrap_to_unit_cell: (frac: Vec3) => Vec3;
5
6
  export declare function find_image_atoms(structure: ParsedStructure, { tolerance }?: {
6
7
  tolerance?: number;
@@ -1,9 +1,18 @@
1
1
  import * as math from '../math';
2
+ // Wrap a single fractional coordinate to [0, 1), clamping near-1 values to 0
3
+ // and rounding to 15 digits to suppress floating-point noise.
4
+ export const wrap_frac_coord = (coord) => {
5
+ const wrapped = coord - Math.floor(coord);
6
+ if (wrapped >= 1 - 1e-10)
7
+ return 0;
8
+ return Number(wrapped.toFixed(15));
9
+ };
2
10
  // Wrap fractional coordinates to [0, 1) range for periodicity.
3
- export const wrap_to_unit_cell = (frac) => frac.map((coord) => {
4
- const wrapped = ((coord % 1) + 1) % 1;
5
- return wrapped >= 1 - 1e-10 ? 0 : wrapped; // clamp near-1 to 0 for float precision
6
- });
11
+ export const wrap_to_unit_cell = (frac) => [
12
+ wrap_frac_coord(frac[0]),
13
+ wrap_frac_coord(frac[1]),
14
+ wrap_frac_coord(frac[2]),
15
+ ];
7
16
  export function find_image_atoms(structure, { tolerance } = {}) {
8
17
  // Find image atoms for PBC. Returns [atom_idx, image_xyz, image_abc] tuples.
9
18
  // Skips image generation for trajectory data with scattered atoms.
@@ -47,7 +56,7 @@ export function find_image_atoms(structure, { tolerance } = {}) {
47
56
  edge_dims.push({ dim, direction: -1 });
48
57
  }
49
58
  // Generate all translation combinations
50
- for (let mask = 1; mask < (1 << edge_dims.length); mask++) {
59
+ for (let mask = 1; mask < 1 << edge_dims.length; mask++) {
51
60
  // Track selected translation per dimension. If both +1 and -1 are selected for a dim,
52
61
  // the net shift is zero and we skip because it yields no image.
53
62
  const selected_shift = [0, 0, 0];
@@ -69,7 +78,8 @@ export function find_image_atoms(structure, { tolerance } = {}) {
69
78
  site.abc[2] + selected_shift[2],
70
79
  ];
71
80
  // If no dimension actually shifted, continue
72
- if (img_abc[0] === site.abc[0] && img_abc[1] === site.abc[1] &&
81
+ if (img_abc[0] === site.abc[0] &&
82
+ img_abc[1] === site.abc[1] &&
73
83
  img_abc[2] === site.abc[2])
74
84
  continue;
75
85
  // Compute xyz from img_abc to ensure consistency
@@ -1,8 +1,8 @@
1
1
  import type { Vec3 } from '../math';
2
- import * as math from '../math';
2
+ import { scale_lattice_matrix } from '../math';
3
3
  import type { Crystal } from './index';
4
4
  export declare function parse_supercell_scaling(scaling: string | number | Vec3): Vec3;
5
5
  export declare function generate_lattice_points(scaling_factors: Vec3): Vec3[];
6
- export declare function scale_lattice_matrix(orig_matrix: math.Matrix3x3, scaling_factors: Vec3): math.Matrix3x3;
6
+ export { scale_lattice_matrix };
7
7
  export declare function make_supercell(structure: Crystal, scaling: string | number | Vec3, to_unit_cell?: boolean): Crystal;
8
8
  export declare function is_valid_supercell_input(input: string): boolean;
@@ -1,9 +1,6 @@
1
1
  import * as math from '../math';
2
- // Wrap fractional coordinates to [0, 1) range, clamping near-1 values to 0
3
- const wrap_frac = (coord) => {
4
- const wrapped = ((coord % 1) + 1) % 1;
5
- return wrapped >= 1 - 1e-10 ? 0 : wrapped;
6
- };
2
+ import { scale_lattice_matrix } from '../math';
3
+ import { wrap_frac_coord } from './pbc';
7
4
  // Parse supercell scaling input from various formats. Can be "2x2x2", "2", [2,2,2], or a single number.
8
5
  // Returns [x, y, z] scaling factors.
9
6
  export function parse_supercell_scaling(scaling) {
@@ -21,7 +18,11 @@ export function parse_supercell_scaling(scaling) {
21
18
  }
22
19
  if (typeof scaling === `string`) {
23
20
  // Parse "2x2x2" format
24
- const parts = scaling.trim().toLowerCase().split(/[x×,\s]+/).filter((part) => part.length > 0);
21
+ const parts = scaling
22
+ .trim()
23
+ .toLowerCase()
24
+ .split(/[x×,\s]+/)
25
+ .filter((part) => part.length > 0);
25
26
  if (parts.length === 1 || parts.length === 3) {
26
27
  // Check that all parts are strictly digits to avoid scientific notation/hex/etc per tests
27
28
  if (parts.every((part) => /^\d+$/.test(part))) {
@@ -51,19 +52,8 @@ export function generate_lattice_points(scaling_factors) {
51
52
  }
52
53
  return points;
53
54
  }
54
- // Scale a lattice matrix by supercell factors
55
- // Takes original 3x3 lattice matrix and [scale_x, scale_y, scale_z] scaling factors
56
- // Returns new scaled lattice matrix
57
- export function scale_lattice_matrix(orig_matrix, scaling_factors) {
58
- const [nx, ny, nz] = scaling_factors;
59
- const [a, b, c] = orig_matrix;
60
- // Scale each lattice vector by its corresponding factor
61
- return [
62
- [a[0] * nx, a[1] * nx, a[2] * nx],
63
- [b[0] * ny, b[1] * ny, b[2] * ny],
64
- [c[0] * nz, c[1] * nz, c[2] * nz],
65
- ];
66
- }
55
+ // Re-export from $lib/math for backward compatibility
56
+ export { scale_lattice_matrix };
67
57
  // Create a supercell from a Crystal
68
58
  // Takes original structure, scaling factors, and whether to fold coordinates back to unit cell (default: true)
69
59
  // Returns new supercell structure
@@ -111,9 +101,9 @@ export function make_supercell(structure, scaling, to_unit_cell = true) {
111
101
  let new_b = (site.abc[1] + jj) / sy;
112
102
  let new_c = (site.abc[2] + kk) / sz;
113
103
  if (to_unit_cell) {
114
- new_a = wrap_frac(new_a);
115
- new_b = wrap_frac(new_b);
116
- new_c = wrap_frac(new_c);
104
+ new_a = wrap_frac_coord(new_a);
105
+ new_b = wrap_frac_coord(new_b);
106
+ new_c = wrap_frac_coord(new_c);
117
107
  }
118
108
  new_sites[write_idx++] = {
119
109
  species: site.species,
@@ -1,8 +1,10 @@
1
1
  export function is_crystal(obj) {
2
2
  if (obj === null || typeof obj !== `object`)
3
3
  return false;
4
- const input = obj;
5
- const has_sites = Array.isArray(input.sites) && input.sites.length > 0;
6
- const has_lattice = Boolean(input.lattice) && typeof input.lattice === `object`;
4
+ const structure_obj = obj;
5
+ const sites = structure_obj.sites;
6
+ const lattice = structure_obj.lattice;
7
+ const has_sites = Array.isArray(sites) && sites.length > 0;
8
+ const has_lattice = lattice !== undefined && lattice !== null && typeof lattice === `object`;
7
9
  return has_sites && has_lattice;
8
10
  }
@@ -1,41 +1,92 @@
1
- <script lang="ts">import { tooltip } from 'svelte-multiselect';
2
- import { SETTINGS_CONFIG } from '../settings';
3
- import { default_sym_settings, wyckoff_positions_from_moyo } from './index';
4
- import * as spg from './spacegroups';
5
- let { sym_data, settings = $bindable(default_sym_settings), show_tooltips = true, children, label = `Symmetry`, header, ...rest } = $props();
6
- const wyckoff_count = $derived(sym_data ? wyckoff_positions_from_moyo(sym_data).length : 0);
7
- const sym_ops_counts = $derived.by(() => {
8
- const EPS = 1e-10;
1
+ <script lang="ts">
2
+ import type { MoyoDataset } from '@spglib/moyo-wasm'
3
+ import type { Snippet } from 'svelte'
4
+ import { tooltip } from 'svelte-multiselect'
5
+ import type { HTMLAttributes } from 'svelte/elements'
6
+ import { SETTINGS_CONFIG } from '../settings'
7
+ import type { SymmetrySettings } from './index'
8
+ import { default_sym_settings, wyckoff_positions_from_moyo } from './index'
9
+ import * as spg from './spacegroups'
10
+
11
+ type SymmetrySnippet = Snippet<
12
+ [{ sym_data?: MoyoDataset | null; settings: SymmetrySettings }]
13
+ >
14
+
15
+ let {
16
+ sym_data,
17
+ settings = $bindable(default_sym_settings),
18
+ show_tooltips = true,
19
+ children,
20
+ label = `Symmetry`,
21
+ header,
22
+ ...rest
23
+ }: HTMLAttributes<HTMLDivElement> & {
24
+ sym_data?: MoyoDataset | null
25
+ settings?: SymmetrySettings
26
+ show_tooltips?: boolean
27
+ children?: SymmetrySnippet
28
+ label?: SymmetrySnippet | string
29
+ header?: SymmetrySnippet
30
+ } = $props()
31
+
32
+ const wyckoff_count = $derived(
33
+ sym_data ? wyckoff_positions_from_moyo(sym_data).length : 0,
34
+ )
35
+ const display_hm_symbol = $derived(sym_data?.hm_symbol?.replace(/\s+/g, ``) ?? `?`)
36
+
37
+ const sym_ops_counts = $derived.by(() => {
38
+ const EPS = 1e-10
9
39
  if (!sym_data?.operations) {
10
- return { translations: 0, rotations: 0, roto_translations: 0 };
40
+ return { translations: 0, rotations: 0, roto_translations: 0 }
11
41
  }
12
- return sym_data.operations.reduce((acc, op) => {
13
- const has_translation = op.translation.some((coord) => Math.abs(coord) > EPS);
14
- const is_identity = String(op.rotation) === `1,0,0,0,1,0,0,0,1`;
15
- if (is_identity && has_translation)
16
- acc.translations++;
17
- else if (!has_translation)
18
- acc.rotations++;
19
- else
20
- acc.roto_translations++;
21
- return acc;
22
- }, { translations: 0, rotations: 0, roto_translations: 0 });
23
- });
24
- const titles = {
25
- symprec: `Symmetry precision control in spglib/moyo. Lower values (e.g. 1e-4, the default) are more strict, higher values (e.g. 1e-1) are more tolerant of numerical errors in atomic positions.`,
26
- algo: `Symmetry detection algorithm: Moyo uses moyo's newer recommended settings, Spglib is useful if you need compatible results to an existing set of spglib-detected symmetries.`,
27
- space_group: `International Tables Space group number (1-230) - unique identifier for each space group. Higher numbers indicate more symmetries in the crystal.`,
28
- crystal_system: `Crystal system classification based on the unit cell symmetry. Seven systems: triclinic, monoclinic, orthorhombic, tetragonal, trigonal, hexagonal, and cubic.`,
29
- hermann_mauguin: `Hermann-Mauguin symbol describes symmetry operations. Format: Lattice type + Point group symmetry. Example: P4/mmm = Primitive + 4-fold rotation + mirror planes`,
30
- hall_number: `Hall number: alternative numbering system for space groups. Useful for crystallographic software compatibility.`,
31
- pearson_symbol: `Pearson symbol. Format: Crystal system + Number of atoms per unit cell. Example: tP2 = tetragonal primitive with 2 atoms`,
32
- symmetry_operations: `Total symmetry operations that map the crystal structure onto itself. Includes rotations, translations, and combinations.`,
33
- distinct_orbits: `Number of unique Wyckoff positions (symmetry-equivalent atomic sites) in the crystal structure.`,
42
+
43
+ return sym_data.operations.reduce(
44
+ (acc, op) => {
45
+ const has_translation = op.translation.some((coord) => Math.abs(coord) > EPS)
46
+ const is_identity = String(op.rotation) === `1,0,0,0,1,0,0,0,1`
47
+
48
+ if (is_identity && has_translation) acc.translations++
49
+ else if (!has_translation) acc.rotations++
50
+ else acc.roto_translations++
51
+
52
+ return acc
53
+ },
54
+ { translations: 0, rotations: 0, roto_translations: 0 },
55
+ )
56
+ })
57
+
58
+ const titles = {
59
+ symprec:
60
+ `Symmetry precision control in spglib/moyo. Lower values (e.g. 1e-4, the default) are more strict, higher values (e.g. 1e-1) are more tolerant of numerical errors in atomic positions.`,
61
+ algo:
62
+ `Symmetry detection algorithm: Moyo uses moyo's newer recommended settings, Spglib is useful if you need compatible results to an existing set of spglib-detected symmetries.`,
63
+ space_group:
64
+ `International Tables Space group number (1-230) - unique identifier for each space group. Higher numbers indicate more symmetries in the crystal.`,
65
+ crystal_system:
66
+ `Crystal system classification based on the unit cell symmetry. Seven systems: triclinic, monoclinic, orthorhombic, tetragonal, trigonal, hexagonal, and cubic.`,
67
+ hermann_mauguin:
68
+ `Hermann-Mauguin symbol describes symmetry operations. Format: Lattice type + Point group symmetry. Example: P4/mmm = Primitive + 4-fold rotation + mirror planes`,
69
+ hall_number:
70
+ `Hall number: alternative numbering system for space groups. Useful for crystallographic software compatibility.`,
71
+ pearson_symbol:
72
+ `Pearson symbol. Format: Crystal system + Number of atoms per unit cell. Example: tP2 = tetragonal primitive with 2 atoms`,
73
+ symmetry_operations:
74
+ `Total symmetry operations that map the crystal structure onto itself. Includes rotations, translations, and combinations.`,
75
+ distinct_orbits:
76
+ `Number of unique Wyckoff positions (symmetry-equivalent atomic sites) in the crystal structure.`,
34
77
  translations: `Number of translations in the crystal structure.`,
35
78
  rotations: `Number of rotations in the crystal structure.`,
36
79
  roto_translations: `Number of roto-translations in the crystal structure.`,
37
- };
38
- const tooltips = $derived(show_tooltips ? titles : {});
80
+ }
81
+ const tooltips: Record<string, string> = $derived(show_tooltips ? titles : {})
82
+
83
+ function get_step_from_order_of_magnitude(value: number): number {
84
+ if (!Number.isFinite(value) || value <= 0) return 1e-5
85
+ const exponent = Math.floor(Math.log10(value))
86
+ return Math.pow(10, exponent)
87
+ }
88
+
89
+ const symprec_step = $derived(get_step_from_order_of_magnitude(settings.symprec))
39
90
  </script>
40
91
 
41
92
  <div {...rest} class="symmetry-stats {rest.class ?? ``}">
@@ -55,15 +106,21 @@ const tooltips = $derived(show_tooltips ? titles : {});
55
106
  <span {@attach tooltip()} title={tooltips?.symprec}>Precision</span>
56
107
  <input
57
108
  type="number"
58
- step="1e-5"
109
+ step={symprec_step}
59
110
  value={settings.symprec}
60
- onchange={(evt) => {
111
+ oninput={(evt) => {
61
112
  const { value } = evt.currentTarget
62
- const parsed = parseFloat(value)
113
+ if (value === ``) return
114
+ const parsed = Number(value)
63
115
  if (Number.isFinite(parsed)) {
64
116
  settings = { ...settings, symprec: parsed }
65
117
  }
66
118
  }}
119
+ onkeydown={(evt) => {
120
+ if (evt.key === `Escape`) {
121
+ evt.currentTarget.blur()
122
+ }
123
+ }}
67
124
  />
68
125
  </label>
69
126
  <label>
@@ -91,7 +148,7 @@ const tooltips = $derived(show_tooltips ? titles : {});
91
148
  title="{tooltips?.space_group} at {settings.symprec} (using {settings.algo} algo). {tooltips?.hermann_mauguin}"
92
149
  {@attach tooltip()}
93
150
  >
94
- Space Group <strong>{sym_data.number} ({sym_data.hm_symbol ?? `?`})</strong>
151
+ Space Group <strong>{sym_data.number} ({display_hm_symbol})</strong>
95
152
  </div>
96
153
  <div title={tooltips?.crystal_system} {@attach tooltip()}>
97
154
  Crystal System <strong>{spg.spacegroup_to_crystal_sys(sym_data.number)}</strong>
@@ -1,8 +1,29 @@
1
- <script lang="ts">import { contrast_color } from '../colors';
2
- import { format_fractional } from '../labels';
3
- import { colors } from '../state.svelte';
4
- let { wyckoff_positions, on_hover, on_click, active_color = `#2563eb`, ...rest } = $props();
5
- let selected_wyckoff = $state(null);
1
+ <script lang="ts">
2
+ import { contrast_color } from '../colors'
3
+ import { format_fractional } from '../labels'
4
+ import { colors } from '../state.svelte'
5
+ import type { HTMLAttributes } from 'svelte/elements'
6
+ import type { WyckoffPos } from '.'
7
+
8
+ let {
9
+ wyckoff_positions,
10
+ on_hover,
11
+ on_click,
12
+ active_color = `#2563eb`,
13
+ ...rest
14
+ }: HTMLAttributes<HTMLTableElement> & {
15
+ wyckoff_positions: WyckoffPos[]
16
+ on_hover?: (site_indices: number[] | null) => void
17
+ on_click?: (site_indices: number[] | null) => void
18
+ active_color?: string
19
+ } = $props()
20
+
21
+ let selected_key = $state<string | null>(null)
22
+
23
+ const get_row_key = (wyckoff_pos: WyckoffPos, row_idx: number) =>
24
+ `${wyckoff_pos.wyckoff}-${wyckoff_pos.elem}-${
25
+ wyckoff_pos.site_indices?.join(`,`) ?? `none`
26
+ }-${row_idx}`
6
27
  </script>
7
28
 
8
29
  {#if wyckoff_positions && wyckoff_positions.length > 0}
@@ -22,10 +43,14 @@ let selected_wyckoff = $state(null);
22
43
  </tr>
23
44
  </thead>
24
45
  <tbody>
25
- {#each wyckoff_positions as wyckoff_pos (JSON.stringify(wyckoff_pos))}
46
+ {#each wyckoff_positions as
47
+ wyckoff_pos,
48
+ row_idx
49
+ (get_row_key(wyckoff_pos, row_idx))
50
+ }
26
51
  {@const { wyckoff, elem, abc, site_indices } = wyckoff_pos}
27
- {@const is_selected =
28
- JSON.stringify(selected_wyckoff) === JSON.stringify(wyckoff_pos)}
52
+ {@const row_key = get_row_key(wyckoff_pos, row_idx)}
53
+ {@const is_selected = selected_key === row_key}
29
54
  <tr
30
55
  class="wyckoff-row"
31
56
  tabindex="0"
@@ -35,16 +60,14 @@ let selected_wyckoff = $state(null);
35
60
  onmouseenter={() => on_hover?.(site_indices ?? null)}
36
61
  onmouseleave={() => on_hover?.(null)}
37
62
  onclick={() => {
38
- selected_wyckoff = is_selected ? null : wyckoff_pos
39
- on_click?.(selected_wyckoff?.site_indices ?? null)
63
+ selected_key = is_selected ? null : row_key
64
+ on_click?.(is_selected ? null : (wyckoff_pos.site_indices ?? null))
40
65
  }}
41
66
  onkeydown={(event) => {
42
67
  if ([`Enter`, ` `].includes(event.key)) {
43
68
  event.preventDefault()
44
- const is_selected =
45
- JSON.stringify(selected_wyckoff) === JSON.stringify(wyckoff_pos)
46
- selected_wyckoff = is_selected ? null : wyckoff_pos
47
- on_click?.(selected_wyckoff?.site_indices ?? null)
69
+ selected_key = is_selected ? null : row_key
70
+ on_click?.(is_selected ? null : (wyckoff_pos.site_indices ?? null))
48
71
  }
49
72
  }}
50
73
  >
@@ -69,6 +92,11 @@ let selected_wyckoff = $state(null);
69
92
  .wyckoff-table {
70
93
  margin-top: 1em;
71
94
  }
95
+ .wyckoff-table :is(th, td) {
96
+ padding: 2px 6px;
97
+ text-align: center;
98
+ vertical-align: middle;
99
+ }
72
100
  .wyckoff-row {
73
101
  cursor: pointer;
74
102
  transition: background-color 0.2s ease;
@@ -19,7 +19,7 @@ original_structure) {
19
19
  ];
20
20
  // Calculate lattice parameters from matrix
21
21
  const lattice_params = math.calc_lattice_params(lattice_matrix);
22
- const lattice_T = math.transpose_3x3_matrix(lattice_matrix);
22
+ const frac_to_cart = math.create_frac_to_cart(lattice_matrix);
23
23
  // Build sites from positions and atomic numbers
24
24
  const sites = cell.positions.map((abc, idx) => {
25
25
  const atomic_number = cell.numbers[idx];
@@ -29,8 +29,7 @@ original_structure) {
29
29
  }
30
30
  // Wrap fractional coordinates to [0, 1) range (moyo-wasm may return outside)
31
31
  const wrapped_abc = wrap_to_unit_cell(abc);
32
- // Convert fractional to Cartesian: xyz = lattice_T · abc
33
- const xyz = math.mat3x3_vec3_multiply(lattice_T, wrapped_abc);
32
+ const xyz = frac_to_cart(wrapped_abc);
34
33
  // Oxidation state is set to 0 (unknown) because moyo-wasm only provides atomic numbers.
35
34
  // transformed cell may have different/reordered sites, making it non-trivial to
36
35
  // map oxidation states from original structure.
@@ -48,12 +47,14 @@ original_structure) {
48
47
  // The conventional cell is the standard crystallographic setting for the space group.
49
48
  export function get_conventional_cell(original_structure, // The original input structure
50
49
  sym_data) {
50
+ // The conventional cell as a Crystal
51
51
  return moyo_cell_to_structure(sym_data.std_cell, original_structure);
52
52
  }
53
53
  // Get the primitive cell from symmetry analysis data.
54
54
  // The primitive cell is the smallest unit cell with one lattice point.
55
55
  export function get_primitive_cell(original_structure, // The original input structure
56
56
  sym_data) {
57
+ // The primitive cell as a Crystal
57
58
  return moyo_cell_to_structure(sym_data.prim_std_cell, original_structure);
58
59
  }
59
60
  // Transform a structure based on the selected cell type.
@@ -61,6 +62,7 @@ sym_data) {
61
62
  export function transform_cell(structure, // The original structure
62
63
  cell_type, // The desired cell type ('original', 'conventional', or 'primitive')
63
64
  sym_data) {
65
+ //transformed structure (or original if no transformation needed)
64
66
  if (cell_type === `original` || !sym_data) {
65
67
  return structure;
66
68
  }
@@ -29,12 +29,15 @@ export type WyckoffPos = {
29
29
  abc: Vec3;
30
30
  site_indices?: number[];
31
31
  };
32
+ export type SymmetryDataset = MoyoDataset & {
33
+ orig_indices?: number[];
34
+ orig_site_indices_by_std_idx?: number[][];
35
+ };
32
36
  export declare function ensure_moyo_wasm_ready(wasm_url?: string): Promise<void>;
33
37
  export declare function to_cell_json(structure: Crystal): string;
34
- export declare function analyze_structure_symmetry(struct_or_mol: AnyStructure, settings: Partial<SymmetrySettings>): Promise<MoyoDataset>;
38
+ export declare function map_std_to_orig_site_indices(std_positions: Vec3[], std_numbers: number[], input_positions: Vec3[], input_numbers: number[], orig_site_indices_by_input_idx: number[][]): number[][];
39
+ export declare function analyze_structure_symmetry(struct_or_mol: AnyStructure, settings: Partial<SymmetrySettings>): Promise<SymmetryDataset>;
35
40
  export declare function simplicity_score(vec: number[]): number;
36
- export declare function wyckoff_positions_from_moyo(sym_data: (MoyoDataset & {
37
- orig_indices?: number[];
38
- }) | null): WyckoffPos[];
41
+ export declare function wyckoff_positions_from_moyo(sym_data: SymmetryDataset | null): WyckoffPos[];
39
42
  export declare function apply_symmetry_operations(position: Vec3, operations: MoyoDataset[`operations`], _tolerance?: number): Vec3[];
40
43
  export declare function map_wyckoff_to_all_atoms(wyckoff_positions: WyckoffPos[], displayed_structure: Crystal, orig_structure: Crystal, sym_data: MoyoDataset | null, tolerance?: number): WyckoffPos[];