react-cheminfo 0.134.1 → 0.136.0

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 (454) hide show
  1. package/README.md +13 -0
  2. package/lib/crystal/core/bondGrid.d.ts +26 -0
  3. package/lib/crystal/core/bondGrid.d.ts.map +1 -0
  4. package/lib/crystal/core/bondGrid.js +76 -0
  5. package/lib/crystal/core/bondGrid.js.map +1 -0
  6. package/lib/crystal/core/cellAtoms.d.ts +43 -0
  7. package/lib/crystal/core/cellAtoms.d.ts.map +1 -0
  8. package/lib/crystal/core/cellAtoms.js +70 -0
  9. package/lib/crystal/core/cellAtoms.js.map +1 -0
  10. package/lib/crystal/core/cellBonds.d.ts +21 -0
  11. package/lib/crystal/core/cellBonds.d.ts.map +1 -0
  12. package/lib/crystal/core/cellBonds.js +100 -0
  13. package/lib/crystal/core/cellBonds.js.map +1 -0
  14. package/lib/crystal/core/cif/element.d.ts +9 -0
  15. package/lib/crystal/core/cif/element.d.ts.map +1 -0
  16. package/lib/crystal/core/cif/element.js +41 -0
  17. package/lib/crystal/core/cif/element.js.map +1 -0
  18. package/lib/crystal/core/cif/index.d.ts +4 -0
  19. package/lib/crystal/core/cif/index.d.ts.map +1 -0
  20. package/lib/crystal/core/cif/index.js +3 -0
  21. package/lib/crystal/core/cif/index.js.map +1 -0
  22. package/lib/crystal/core/cif/number.d.ts +27 -0
  23. package/lib/crystal/core/cif/number.d.ts.map +1 -0
  24. package/lib/crystal/core/cif/number.js +57 -0
  25. package/lib/crystal/core/cif/number.js.map +1 -0
  26. package/lib/crystal/core/cif/read.d.ts +12 -0
  27. package/lib/crystal/core/cif/read.d.ts.map +1 -0
  28. package/lib/crystal/core/cif/read.js +183 -0
  29. package/lib/crystal/core/cif/read.js.map +1 -0
  30. package/lib/crystal/core/cif/readGeometry.d.ts +17 -0
  31. package/lib/crystal/core/cif/readGeometry.d.ts.map +1 -0
  32. package/lib/crystal/core/cif/readGeometry.js +93 -0
  33. package/lib/crystal/core/cif/readGeometry.js.map +1 -0
  34. package/lib/crystal/core/cif/tags.d.ts +62 -0
  35. package/lib/crystal/core/cif/tags.d.ts.map +1 -0
  36. package/lib/crystal/core/cif/tags.js +115 -0
  37. package/lib/crystal/core/cif/tags.js.map +1 -0
  38. package/lib/crystal/core/cif/types.d.ts +158 -0
  39. package/lib/crystal/core/cif/types.d.ts.map +1 -0
  40. package/lib/crystal/core/cif/types.js +2 -0
  41. package/lib/crystal/core/cif/types.js.map +1 -0
  42. package/lib/crystal/core/components.d.ts +56 -0
  43. package/lib/crystal/core/components.d.ts.map +1 -0
  44. package/lib/crystal/core/components.js +132 -0
  45. package/lib/crystal/core/components.js.map +1 -0
  46. package/lib/crystal/core/covalentRadii.d.ts +24 -0
  47. package/lib/crystal/core/covalentRadii.d.ts.map +1 -0
  48. package/lib/crystal/core/covalentRadii.js +55 -0
  49. package/lib/crystal/core/covalentRadii.js.map +1 -0
  50. package/lib/crystal/core/disorder.d.ts +59 -0
  51. package/lib/crystal/core/disorder.d.ts.map +1 -0
  52. package/lib/crystal/core/disorder.js +168 -0
  53. package/lib/crystal/core/disorder.js.map +1 -0
  54. package/lib/crystal/core/expand.d.ts +62 -0
  55. package/lib/crystal/core/expand.d.ts.map +1 -0
  56. package/lib/crystal/core/expand.js +61 -0
  57. package/lib/crystal/core/expand.js.map +1 -0
  58. package/lib/crystal/core/index.d.ts +20 -0
  59. package/lib/crystal/core/index.d.ts.map +1 -0
  60. package/lib/crystal/core/index.js +13 -0
  61. package/lib/crystal/core/index.js.map +1 -0
  62. package/lib/crystal/core/moleculeOf.d.ts +31 -0
  63. package/lib/crystal/core/moleculeOf.d.ts.map +1 -0
  64. package/lib/crystal/core/moleculeOf.js +128 -0
  65. package/lib/crystal/core/moleculeOf.js.map +1 -0
  66. package/lib/crystal/core/moleculeTypes.d.ts +80 -0
  67. package/lib/crystal/core/moleculeTypes.d.ts.map +1 -0
  68. package/lib/crystal/core/moleculeTypes.js +2 -0
  69. package/lib/crystal/core/moleculeTypes.js.map +1 -0
  70. package/lib/crystal/core/molecules.d.ts +39 -0
  71. package/lib/crystal/core/molecules.d.ts.map +1 -0
  72. package/lib/crystal/core/molecules.js +106 -0
  73. package/lib/crystal/core/molecules.js.map +1 -0
  74. package/lib/crystal/core/operations.d.ts +19 -0
  75. package/lib/crystal/core/operations.d.ts.map +1 -0
  76. package/lib/crystal/core/operations.js +68 -0
  77. package/lib/crystal/core/operations.js.map +1 -0
  78. package/lib/crystal/core/packing.d.ts +43 -0
  79. package/lib/crystal/core/packing.d.ts.map +1 -0
  80. package/lib/crystal/core/packing.js +89 -0
  81. package/lib/crystal/core/packing.js.map +1 -0
  82. package/lib/crystal/core/periodicBonds.d.ts +57 -0
  83. package/lib/crystal/core/periodicBonds.d.ts.map +1 -0
  84. package/lib/crystal/core/periodicBonds.js +167 -0
  85. package/lib/crystal/core/periodicBonds.js.map +1 -0
  86. package/lib/crystal/core/resolve.d.ts +61 -0
  87. package/lib/crystal/core/resolve.d.ts.map +1 -0
  88. package/lib/crystal/core/resolve.js +149 -0
  89. package/lib/crystal/core/resolve.js.map +1 -0
  90. package/lib/crystal/core/spaceGroups/index.d.ts +5 -0
  91. package/lib/crystal/core/spaceGroups/index.d.ts.map +1 -0
  92. package/lib/crystal/core/spaceGroups/index.js +4 -0
  93. package/lib/crystal/core/spaceGroups/index.js.map +1 -0
  94. package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts +14 -0
  95. package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts.map +1 -0
  96. package/lib/crystal/core/spaceGroups/spaceGroupOperations.js +24 -0
  97. package/lib/crystal/core/spaceGroups/spaceGroupOperations.js.map +1 -0
  98. package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts +3 -0
  99. package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts.map +1 -0
  100. package/lib/crystal/core/spaceGroups/spaceGroupRows.js +536 -0
  101. package/lib/crystal/core/spaceGroups/spaceGroupRows.js.map +1 -0
  102. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts +43 -0
  103. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts.map +1 -0
  104. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js +169 -0
  105. package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js.map +1 -0
  106. package/lib/crystal/core/spaceGroups/spaceGroups.d.ts +78 -0
  107. package/lib/crystal/core/spaceGroups/spaceGroups.d.ts.map +1 -0
  108. package/lib/crystal/core/spaceGroups/spaceGroups.js +83 -0
  109. package/lib/crystal/core/spaceGroups/spaceGroups.js.map +1 -0
  110. package/lib/crystal/core/symmetry/group.d.ts +15 -0
  111. package/lib/crystal/core/symmetry/group.d.ts.map +1 -0
  112. package/lib/crystal/core/symmetry/group.js +37 -0
  113. package/lib/crystal/core/symmetry/group.js.map +1 -0
  114. package/lib/crystal/core/symmetry/index.d.ts +8 -0
  115. package/lib/crystal/core/symmetry/index.d.ts.map +1 -0
  116. package/lib/crystal/core/symmetry/index.js +6 -0
  117. package/lib/crystal/core/symmetry/index.js.map +1 -0
  118. package/lib/crystal/core/symmetry/integerMatrix.d.ts +45 -0
  119. package/lib/crystal/core/symmetry/integerMatrix.d.ts.map +1 -0
  120. package/lib/crystal/core/symmetry/integerMatrix.js +139 -0
  121. package/lib/crystal/core/symmetry/integerMatrix.js.map +1 -0
  122. package/lib/crystal/core/symmetry/lattice.d.ts +64 -0
  123. package/lib/crystal/core/symmetry/lattice.d.ts.map +1 -0
  124. package/lib/crystal/core/symmetry/lattice.js +113 -0
  125. package/lib/crystal/core/symmetry/lattice.js.map +1 -0
  126. package/lib/crystal/core/symmetry/operation.d.ts +91 -0
  127. package/lib/crystal/core/symmetry/operation.d.ts.map +1 -0
  128. package/lib/crystal/core/symmetry/operation.js +184 -0
  129. package/lib/crystal/core/symmetry/operation.js.map +1 -0
  130. package/lib/crystal/core/symmetry/parseOperation.d.ts +18 -0
  131. package/lib/crystal/core/symmetry/parseOperation.d.ts.map +1 -0
  132. package/lib/crystal/core/symmetry/parseOperation.js +145 -0
  133. package/lib/crystal/core/symmetry/parseOperation.js.map +1 -0
  134. package/lib/crystal/core/symmetry/types.d.ts +29 -0
  135. package/lib/crystal/core/symmetry/types.d.ts.map +1 -0
  136. package/lib/crystal/core/symmetry/types.js +5 -0
  137. package/lib/crystal/core/symmetry/types.js.map +1 -0
  138. package/lib/crystal/core/symmetryClasses.d.ts +28 -0
  139. package/lib/crystal/core/symmetryClasses.d.ts.map +1 -0
  140. package/lib/crystal/core/symmetryClasses.js +93 -0
  141. package/lib/crystal/core/symmetryClasses.js.map +1 -0
  142. package/lib/crystal.d.ts +12 -0
  143. package/lib/crystal.d.ts.map +1 -0
  144. package/lib/crystal.js +12 -0
  145. package/lib/crystal.js.map +1 -0
  146. package/lib/crystal3d/core/cellClip.d.ts +46 -0
  147. package/lib/crystal3d/core/cellClip.d.ts.map +1 -0
  148. package/lib/crystal3d/core/cellClip.js +198 -0
  149. package/lib/crystal3d/core/cellClip.js.map +1 -0
  150. package/lib/crystal3d/core/cellGeometry.d.ts +63 -0
  151. package/lib/crystal3d/core/cellGeometry.d.ts.map +1 -0
  152. package/lib/crystal3d/core/cellGeometry.js +153 -0
  153. package/lib/crystal3d/core/cellGeometry.js.map +1 -0
  154. package/lib/crystal3d/core/cellStack.d.ts +51 -0
  155. package/lib/crystal3d/core/cellStack.d.ts.map +1 -0
  156. package/lib/crystal3d/core/cellStack.js +79 -0
  157. package/lib/crystal3d/core/cellStack.js.map +1 -0
  158. package/lib/crystal3d/core/crystalView.d.ts +71 -0
  159. package/lib/crystal3d/core/crystalView.d.ts.map +1 -0
  160. package/lib/crystal3d/core/crystalView.js +48 -0
  161. package/lib/crystal3d/core/crystalView.js.map +1 -0
  162. package/lib/crystal3d/core/drawingSet.d.ts +31 -0
  163. package/lib/crystal3d/core/drawingSet.d.ts.map +1 -0
  164. package/lib/crystal3d/core/drawingSet.js +63 -0
  165. package/lib/crystal3d/core/drawingSet.js.map +1 -0
  166. package/lib/crystal3d/core/elementDrawing.d.ts +50 -0
  167. package/lib/crystal3d/core/elementDrawing.d.ts.map +1 -0
  168. package/lib/crystal3d/core/elementDrawing.js +100 -0
  169. package/lib/crystal3d/core/elementDrawing.js.map +1 -0
  170. package/lib/crystal3d/core/elementExtent.d.ts +42 -0
  171. package/lib/crystal3d/core/elementExtent.d.ts.map +1 -0
  172. package/lib/crystal3d/core/elementExtent.js +56 -0
  173. package/lib/crystal3d/core/elementExtent.js.map +1 -0
  174. package/lib/crystal3d/core/elementLabels.d.ts +31 -0
  175. package/lib/crystal3d/core/elementLabels.d.ts.map +1 -0
  176. package/lib/crystal3d/core/elementLabels.js +99 -0
  177. package/lib/crystal3d/core/elementLabels.js.map +1 -0
  178. package/lib/crystal3d/core/elementShapes.d.ts +43 -0
  179. package/lib/crystal3d/core/elementShapes.d.ts.map +1 -0
  180. package/lib/crystal3d/core/elementShapes.js +115 -0
  181. package/lib/crystal3d/core/elementShapes.js.map +1 -0
  182. package/lib/crystal3d/core/frame.d.ts +36 -0
  183. package/lib/crystal3d/core/frame.d.ts.map +1 -0
  184. package/lib/crystal3d/core/frame.js +35 -0
  185. package/lib/crystal3d/core/frame.js.map +1 -0
  186. package/lib/crystal3d/core/framing.d.ts +41 -0
  187. package/lib/crystal3d/core/framing.d.ts.map +1 -0
  188. package/lib/crystal3d/core/framing.js +79 -0
  189. package/lib/crystal3d/core/framing.js.map +1 -0
  190. package/lib/crystal3d/core/index.d.ts +42 -0
  191. package/lib/crystal3d/core/index.d.ts.map +1 -0
  192. package/lib/crystal3d/core/index.js +29 -0
  193. package/lib/crystal3d/core/index.js.map +1 -0
  194. package/lib/crystal3d/core/labelText.d.ts +19 -0
  195. package/lib/crystal3d/core/labelText.d.ts.map +1 -0
  196. package/lib/crystal3d/core/labelText.js +42 -0
  197. package/lib/crystal3d/core/labelText.js.map +1 -0
  198. package/lib/crystal3d/core/latticeBasis.d.ts +49 -0
  199. package/lib/crystal3d/core/latticeBasis.d.ts.map +1 -0
  200. package/lib/crystal3d/core/latticeBasis.js +89 -0
  201. package/lib/crystal3d/core/latticeBasis.js.map +1 -0
  202. package/lib/crystal3d/core/mat3.d.ts +68 -0
  203. package/lib/crystal3d/core/mat3.d.ts.map +1 -0
  204. package/lib/crystal3d/core/mat3.js +146 -0
  205. package/lib/crystal3d/core/mat3.js.map +1 -0
  206. package/lib/crystal3d/core/operationMatrix.d.ts +44 -0
  207. package/lib/crystal3d/core/operationMatrix.d.ts.map +1 -0
  208. package/lib/crystal3d/core/operationMatrix.js +172 -0
  209. package/lib/crystal3d/core/operationMatrix.js.map +1 -0
  210. package/lib/crystal3d/core/orientation.d.ts +62 -0
  211. package/lib/crystal3d/core/orientation.d.ts.map +1 -0
  212. package/lib/crystal3d/core/orientation.js +166 -0
  213. package/lib/crystal3d/core/orientation.js.map +1 -0
  214. package/lib/crystal3d/core/palette.d.ts +24 -0
  215. package/lib/crystal3d/core/palette.d.ts.map +1 -0
  216. package/lib/crystal3d/core/palette.js +34 -0
  217. package/lib/crystal3d/core/palette.js.map +1 -0
  218. package/lib/crystal3d/core/primitives.d.ts +133 -0
  219. package/lib/crystal3d/core/primitives.d.ts.map +1 -0
  220. package/lib/crystal3d/core/primitives.js +80 -0
  221. package/lib/crystal3d/core/primitives.js.map +1 -0
  222. package/lib/crystal3d/core/structureText.d.ts +20 -0
  223. package/lib/crystal3d/core/structureText.d.ts.map +1 -0
  224. package/lib/crystal3d/core/structureText.js +37 -0
  225. package/lib/crystal3d/core/structureText.js.map +1 -0
  226. package/lib/crystal3d/core/supercell.d.ts +20 -0
  227. package/lib/crystal3d/core/supercell.d.ts.map +1 -0
  228. package/lib/crystal3d/core/supercell.js +35 -0
  229. package/lib/crystal3d/core/supercell.js.map +1 -0
  230. package/lib/crystal3d/core/types.d.ts +166 -0
  231. package/lib/crystal3d/core/types.d.ts.map +1 -0
  232. package/lib/crystal3d/core/types.js +10 -0
  233. package/lib/crystal3d/core/types.js.map +1 -0
  234. package/lib/crystal3d/core/vec3.d.ts +75 -0
  235. package/lib/crystal3d/core/vec3.d.ts.map +1 -0
  236. package/lib/crystal3d/core/vec3.js +119 -0
  237. package/lib/crystal3d/core/vec3.js.map +1 -0
  238. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +52 -0
  239. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -0
  240. package/lib/crystal3d/ui/CrystalCanvas3D.js +242 -0
  241. package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -0
  242. package/lib/crystal3d/ui/CrystalStructureView.d.ts +17 -0
  243. package/lib/crystal3d/ui/CrystalStructureView.d.ts.map +1 -0
  244. package/lib/crystal3d/ui/CrystalStructureView.js +76 -0
  245. package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -0
  246. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts +22 -0
  247. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts.map +1 -0
  248. package/lib/crystal3d/ui/CrystalStructureViewer.js +29 -0
  249. package/lib/crystal3d/ui/CrystalStructureViewer.js.map +1 -0
  250. package/lib/crystal3d/ui/CrystalViewControls.d.ts +25 -0
  251. package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -0
  252. package/lib/crystal3d/ui/CrystalViewControls.js +22 -0
  253. package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -0
  254. package/lib/crystal3d/ui/CrystalViewer3D.d.ts +72 -0
  255. package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -0
  256. package/lib/crystal3d/ui/CrystalViewer3D.js +70 -0
  257. package/lib/crystal3d/ui/CrystalViewer3D.js.map +1 -0
  258. package/lib/crystal3d/ui/crystalScene.d.ts +91 -0
  259. package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -0
  260. package/lib/crystal3d/ui/crystalScene.js +10 -0
  261. package/lib/crystal3d/ui/crystalScene.js.map +1 -0
  262. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +52 -0
  263. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -0
  264. package/lib/crystal3d/ui/crystalStructureViewerProps.js +2 -0
  265. package/lib/crystal3d/ui/crystalStructureViewerProps.js.map +1 -0
  266. package/lib/crystal3d/ui/index.d.ts +16 -0
  267. package/lib/crystal3d/ui/index.d.ts.map +1 -0
  268. package/lib/crystal3d/ui/index.js +12 -0
  269. package/lib/crystal3d/ui/index.js.map +1 -0
  270. package/lib/crystal3d/ui/useCrystalCaption.d.ts +14 -0
  271. package/lib/crystal3d/ui/useCrystalCaption.d.ts.map +1 -0
  272. package/lib/crystal3d/ui/useCrystalCaption.js +32 -0
  273. package/lib/crystal3d/ui/useCrystalCaption.js.map +1 -0
  274. package/lib/crystal3d/viewer/animate.d.ts +49 -0
  275. package/lib/crystal3d/viewer/animate.d.ts.map +1 -0
  276. package/lib/crystal3d/viewer/animate.js +83 -0
  277. package/lib/crystal3d/viewer/animate.js.map +1 -0
  278. package/lib/crystal3d/viewer/camera.d.ts +44 -0
  279. package/lib/crystal3d/viewer/camera.d.ts.map +1 -0
  280. package/lib/crystal3d/viewer/camera.js +103 -0
  281. package/lib/crystal3d/viewer/camera.js.map +1 -0
  282. package/lib/crystal3d/viewer/index.d.ts +13 -0
  283. package/lib/crystal3d/viewer/index.d.ts.map +1 -0
  284. package/lib/crystal3d/viewer/index.js +8 -0
  285. package/lib/crystal3d/viewer/index.js.map +1 -0
  286. package/lib/crystal3d/viewer/layerRegistry.d.ts +24 -0
  287. package/lib/crystal3d/viewer/layerRegistry.d.ts.map +1 -0
  288. package/lib/crystal3d/viewer/layerRegistry.js +39 -0
  289. package/lib/crystal3d/viewer/layerRegistry.js.map +1 -0
  290. package/lib/crystal3d/viewer/meshPrimitives.d.ts +13 -0
  291. package/lib/crystal3d/viewer/meshPrimitives.d.ts.map +1 -0
  292. package/lib/crystal3d/viewer/meshPrimitives.js +76 -0
  293. package/lib/crystal3d/viewer/meshPrimitives.js.map +1 -0
  294. package/lib/crystal3d/viewer/plugin.d.ts +133 -0
  295. package/lib/crystal3d/viewer/plugin.d.ts.map +1 -0
  296. package/lib/crystal3d/viewer/plugin.js +181 -0
  297. package/lib/crystal3d/viewer/plugin.js.map +1 -0
  298. package/lib/crystal3d/viewer/renderCell.d.ts +43 -0
  299. package/lib/crystal3d/viewer/renderCell.d.ts.map +1 -0
  300. package/lib/crystal3d/viewer/renderCell.js +53 -0
  301. package/lib/crystal3d/viewer/renderCell.js.map +1 -0
  302. package/lib/crystal3d/viewer/renderElements.d.ts +54 -0
  303. package/lib/crystal3d/viewer/renderElements.d.ts.map +1 -0
  304. package/lib/crystal3d/viewer/renderElements.js +77 -0
  305. package/lib/crystal3d/viewer/renderElements.js.map +1 -0
  306. package/lib/crystal3d/viewer/renderStructure.d.ts +55 -0
  307. package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -0
  308. package/lib/crystal3d/viewer/renderStructure.js +103 -0
  309. package/lib/crystal3d/viewer/renderStructure.js.map +1 -0
  310. package/lib/crystal3d/viewer/sceneParts.d.ts +32 -0
  311. package/lib/crystal3d/viewer/sceneParts.d.ts.map +1 -0
  312. package/lib/crystal3d/viewer/sceneParts.js +77 -0
  313. package/lib/crystal3d/viewer/sceneParts.js.map +1 -0
  314. package/lib/crystal3d/viewer/shapeLayer.d.ts +41 -0
  315. package/lib/crystal3d/viewer/shapeLayer.d.ts.map +1 -0
  316. package/lib/crystal3d/viewer/shapeLayer.js +57 -0
  317. package/lib/crystal3d/viewer/shapeLayer.js.map +1 -0
  318. package/lib/crystal3d/viewer/textLayer.d.ts +21 -0
  319. package/lib/crystal3d/viewer/textLayer.d.ts.map +1 -0
  320. package/lib/crystal3d/viewer/textLayer.js +59 -0
  321. package/lib/crystal3d/viewer/textLayer.js.map +1 -0
  322. package/lib/crystal3d/viewer/viewer.d.ts +110 -0
  323. package/lib/crystal3d/viewer/viewer.d.ts.map +1 -0
  324. package/lib/crystal3d/viewer/viewer.js +157 -0
  325. package/lib/crystal3d/viewer/viewer.js.map +1 -0
  326. package/lib/crystal3d.d.ts +12 -0
  327. package/lib/crystal3d.d.ts.map +1 -0
  328. package/lib/crystal3d.js +12 -0
  329. package/lib/crystal3d.js.map +1 -0
  330. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  331. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  332. package/lib/locales/de.json +19 -1
  333. package/lib/locales/en.json +19 -1
  334. package/lib/locales/es.json +19 -1
  335. package/lib/locales/fr.json +19 -1
  336. package/lib/locales/it.json +19 -1
  337. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  338. package/lib/molecule3d/ui/MoleculeCanvas3D.js +16 -27
  339. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  340. package/lib/molstar/bonds/bondRule.d.ts +16 -0
  341. package/lib/molstar/bonds/bondRule.d.ts.map +1 -0
  342. package/lib/molstar/bonds/bondRule.js +23 -0
  343. package/lib/molstar/bonds/bondRule.js.map +1 -0
  344. package/lib/molstar/bonds/index.d.ts +9 -0
  345. package/lib/molstar/bonds/index.d.ts.map +1 -0
  346. package/lib/molstar/bonds/index.js +9 -0
  347. package/lib/molstar/bonds/index.js.map +1 -0
  348. package/lib/molstar/ui/MolstarToolbar.d.ts +47 -0
  349. package/lib/molstar/ui/MolstarToolbar.d.ts.map +1 -0
  350. package/lib/molstar/ui/MolstarToolbar.js +28 -0
  351. package/lib/molstar/ui/MolstarToolbar.js.map +1 -0
  352. package/lib/molstar/ui/index.d.ts +10 -0
  353. package/lib/molstar/ui/index.d.ts.map +1 -0
  354. package/lib/molstar/ui/index.js +8 -0
  355. package/lib/molstar/ui/index.js.map +1 -0
  356. package/lib/molstar/ui/useMolstarTools.d.ts +63 -0
  357. package/lib/molstar/ui/useMolstarTools.d.ts.map +1 -0
  358. package/lib/molstar/ui/useMolstarTools.js +36 -0
  359. package/lib/molstar/ui/useMolstarTools.js.map +1 -0
  360. package/package.json +4 -1
  361. package/src/crystal/core/bondGrid.ts +98 -0
  362. package/src/crystal/core/cellAtoms.ts +106 -0
  363. package/src/crystal/core/cellBonds.ts +121 -0
  364. package/src/crystal/core/cif/element.ts +40 -0
  365. package/src/crystal/core/cif/index.ts +12 -0
  366. package/src/crystal/core/cif/number.ts +62 -0
  367. package/src/crystal/core/cif/read.ts +218 -0
  368. package/src/crystal/core/cif/readGeometry.ts +104 -0
  369. package/src/crystal/core/cif/tags.ts +143 -0
  370. package/src/crystal/core/cif/types.ts +164 -0
  371. package/src/crystal/core/components.ts +183 -0
  372. package/src/crystal/core/covalentRadii.ts +56 -0
  373. package/src/crystal/core/disorder.ts +190 -0
  374. package/src/crystal/core/expand.ts +105 -0
  375. package/src/crystal/core/index.ts +46 -0
  376. package/src/crystal/core/moleculeOf.ts +169 -0
  377. package/src/crystal/core/moleculeTypes.ts +85 -0
  378. package/src/crystal/core/molecules.ts +128 -0
  379. package/src/crystal/core/operations.ts +79 -0
  380. package/src/crystal/core/packing.ts +116 -0
  381. package/src/crystal/core/periodicBonds.ts +234 -0
  382. package/src/crystal/core/resolve.ts +187 -0
  383. package/src/crystal/core/spaceGroups/index.ts +16 -0
  384. package/src/crystal/core/spaceGroups/spaceGroupOperations.ts +32 -0
  385. package/src/crystal/core/spaceGroups/spaceGroupRows.ts +536 -0
  386. package/src/crystal/core/spaceGroups/spaceGroupSymbols.ts +179 -0
  387. package/src/crystal/core/spaceGroups/spaceGroups.ts +154 -0
  388. package/src/crystal/core/symmetry/group.ts +42 -0
  389. package/src/crystal/core/symmetry/index.ts +23 -0
  390. package/src/crystal/core/symmetry/integerMatrix.ts +153 -0
  391. package/src/crystal/core/symmetry/lattice.ts +152 -0
  392. package/src/crystal/core/symmetry/operation.ts +223 -0
  393. package/src/crystal/core/symmetry/parseOperation.ts +180 -0
  394. package/src/crystal/core/symmetry/types.ts +32 -0
  395. package/src/crystal/core/symmetryClasses.ts +105 -0
  396. package/src/crystal.ts +12 -0
  397. package/src/crystal3d/core/cellClip.ts +229 -0
  398. package/src/crystal3d/core/cellGeometry.ts +193 -0
  399. package/src/crystal3d/core/cellStack.ts +87 -0
  400. package/src/crystal3d/core/crystalView.ts +114 -0
  401. package/src/crystal3d/core/drawingSet.ts +71 -0
  402. package/src/crystal3d/core/elementDrawing.ts +147 -0
  403. package/src/crystal3d/core/elementExtent.ts +81 -0
  404. package/src/crystal3d/core/elementLabels.ts +130 -0
  405. package/src/crystal3d/core/elementShapes.ts +141 -0
  406. package/src/crystal3d/core/frame.ts +56 -0
  407. package/src/crystal3d/core/framing.ts +101 -0
  408. package/src/crystal3d/core/index.ts +132 -0
  409. package/src/crystal3d/core/labelText.ts +44 -0
  410. package/src/crystal3d/core/latticeBasis.ts +110 -0
  411. package/src/crystal3d/core/mat3.ts +163 -0
  412. package/src/crystal3d/core/operationMatrix.ts +255 -0
  413. package/src/crystal3d/core/orientation.ts +229 -0
  414. package/src/crystal3d/core/palette.ts +43 -0
  415. package/src/crystal3d/core/primitives.ts +183 -0
  416. package/src/crystal3d/core/structureText.ts +43 -0
  417. package/src/crystal3d/core/supercell.ts +40 -0
  418. package/src/crystal3d/core/types.ts +186 -0
  419. package/src/crystal3d/core/vec3.ts +127 -0
  420. package/src/crystal3d/ui/CrystalCanvas3D.tsx +384 -0
  421. package/src/crystal3d/ui/CrystalStructureView.tsx +148 -0
  422. package/src/crystal3d/ui/CrystalStructureViewer.tsx +39 -0
  423. package/src/crystal3d/ui/CrystalViewControls.tsx +100 -0
  424. package/src/crystal3d/ui/CrystalViewer3D.tsx +183 -0
  425. package/src/crystal3d/ui/crystalScene.ts +100 -0
  426. package/src/crystal3d/ui/crystalStructureViewerProps.ts +54 -0
  427. package/src/crystal3d/ui/index.ts +20 -0
  428. package/src/crystal3d/ui/useCrystalCaption.ts +38 -0
  429. package/src/crystal3d/viewer/animate.ts +113 -0
  430. package/src/crystal3d/viewer/camera.ts +139 -0
  431. package/src/crystal3d/viewer/index.ts +13 -0
  432. package/src/crystal3d/viewer/layerRegistry.ts +47 -0
  433. package/src/crystal3d/viewer/meshPrimitives.ts +102 -0
  434. package/src/crystal3d/viewer/plugin.ts +258 -0
  435. package/src/crystal3d/viewer/renderCell.ts +98 -0
  436. package/src/crystal3d/viewer/renderElements.ts +121 -0
  437. package/src/crystal3d/viewer/renderStructure.ts +144 -0
  438. package/src/crystal3d/viewer/sceneParts.ts +119 -0
  439. package/src/crystal3d/viewer/shapeLayer.ts +108 -0
  440. package/src/crystal3d/viewer/textLayer.ts +85 -0
  441. package/src/crystal3d/viewer/viewer.ts +207 -0
  442. package/src/crystal3d.ts +12 -0
  443. package/src/locales/de.json +19 -1
  444. package/src/locales/en.json +19 -1
  445. package/src/locales/es.json +19 -1
  446. package/src/locales/fr.json +19 -1
  447. package/src/locales/it.json +19 -1
  448. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +45 -71
  449. package/src/molstar/bonds/bondRule.ts +34 -0
  450. package/src/molstar/bonds/index.ts +9 -0
  451. package/src/molstar/ui/MolstarToolbar.tsx +103 -0
  452. package/src/molstar/ui/index.ts +14 -0
  453. package/src/molstar/ui/useMolstarTools.ts +98 -0
  454. package/styles/chrome.css +90 -0
@@ -0,0 +1,128 @@
1
+ import { crystalCellAtoms } from './cellAtoms.ts';
2
+ import { keptPairs, writtenTwice } from './cellBonds.ts';
3
+ import type { CrystalStructure } from './cif/types.ts';
4
+ import { bondGraph, walkComponents } from './components.ts';
5
+ import { covalentBondLimit } from './covalentRadii.ts';
6
+ import type { MoleculeContext } from './moleculeOf.ts';
7
+ import { buildMolecule } from './moleculeOf.ts';
8
+ import type {
9
+ CrystalMolecule,
10
+ CrystalMolecules,
11
+ CrystalMoleculesOptions,
12
+ CrystalNetwork,
13
+ } from './moleculeTypes.ts';
14
+ import { findPeriodicBonds } from './periodicBonds.ts';
15
+ import { isIdentity } from './symmetry/operation.ts';
16
+ import type { CrystalOperation } from './symmetry/types.ts';
17
+ import {
18
+ representative,
19
+ siteIndicesOf,
20
+ symmetryClasses,
21
+ } from './symmetryClasses.ts';
22
+
23
+ /**
24
+ * Two atoms closer than this, in ångström, are one atom written twice: no
25
+ * bond is that short.
26
+ */
27
+ export const SAME_ATOM_DISTANCE = 0.5;
28
+
29
+ /**
30
+ * The molecules of a crystal, each whole and once.
31
+ *
32
+ * The asymmetric unit is expanded into the cell, the cell is bonded across its
33
+ * faces by `bondLimit`, and every connected set of atoms is walked. Copies the
34
+ * space group makes of one molecule share the sites they are built from, so
35
+ * they are told apart from an independent molecule by that alone: Z′ = 2 gives
36
+ * two molecules, the four images of a molecule in P2₁/c give one, and a
37
+ * molecule sitting on a special position comes out whole, both halves of it.
38
+ *
39
+ * - **Networks** — a set of atoms bonded to its own translate: a salt, a
40
+ * mineral, a metal, a coordination polymer — are reported in `networks` and
41
+ * never returned as molecules.
42
+ * - **Disorder**: the atoms in no disorder group are kept, and the disorder
43
+ * groups by decreasing mean occupancy, each unless it overlaps one already
44
+ * kept — the major part of each disorder (see `chooseDisorder`). An atom of
45
+ * a negative group, as SHELX writes disorder about a special position, is
46
+ * not bonded to a symmetry copy of an atom in a disorder group, as SHELX
47
+ * itself does.
48
+ * - **Hydrogen** holds one bond, to its nearest neighbour.
49
+ * - **Atoms written twice** — two sites, or two images of one site, closer than
50
+ * {@link SAME_ATOM_DISTANCE} — are one atom: the higher occupancy is kept,
51
+ * the one written first on a tie.
52
+ * @param structure - What `readCif` returned.
53
+ * @param options - Options.
54
+ * @returns The independent molecules, in Cartesian coordinates, and the
55
+ * networks.
56
+ * @throws {Error} When the file names no space group and lists no operation, or its
57
+ * cell has angles no cell can have.
58
+ */
59
+ export function crystalMolecules(
60
+ structure: CrystalStructure,
61
+ options: CrystalMoleculesOptions = {},
62
+ ): CrystalMolecules {
63
+ const { bondLimit = covalentBondLimit, maxAtoms = 100_000 } = options;
64
+ const cell = crystalCellAtoms(structure, { maxAtoms });
65
+ if (cell.tooLarge) {
66
+ return {
67
+ molecules: [],
68
+ networks: [],
69
+ cellAtoms: cell.count,
70
+ tooLarge: true,
71
+ };
72
+ }
73
+ const { lattice, operations, atoms } = cell;
74
+ const { sites } = structure;
75
+ const pairs = findPeriodicBonds(atoms, lattice, bondLimit, {
76
+ samePlace: SAME_ATOM_DISTANCE,
77
+ });
78
+ const removed = writtenTwice(atoms, pairs.coincident);
79
+ const graph = bondGraph(
80
+ atoms.length,
81
+ pairs,
82
+ keptPairs(pairs, atoms, sites, removed),
83
+ );
84
+ const { components, shifts } = walkComponents(graph, removed);
85
+ const context: MoleculeContext = {
86
+ atoms,
87
+ sites,
88
+ graph,
89
+ shifts,
90
+ lattice,
91
+ identityIndex: identityIndexOf(operations),
92
+ localOf: new Int32Array(atoms.length).fill(-1),
93
+ };
94
+ const molecules: CrystalMolecule[] = [];
95
+ const networks: CrystalNetwork[] = [];
96
+ for (const members of symmetryClasses(components, atoms, sites.length)) {
97
+ let periodicity = 0;
98
+ let cellAtoms = 0;
99
+ for (const component of members) {
100
+ periodicity = Math.max(periodicity, component.periodicity);
101
+ cellAtoms += component.atoms.length;
102
+ }
103
+ if (periodicity > 0) {
104
+ networks.push({
105
+ siteIndices: siteIndicesOf(members, atoms),
106
+ cellAtoms,
107
+ periodicity: periodicity as 1 | 2 | 3,
108
+ });
109
+ } else {
110
+ const chosen = representative(members, atoms, context.identityIndex);
111
+ molecules.push(buildMolecule(chosen.atoms, members.length, context));
112
+ }
113
+ }
114
+ let cellAtoms = atoms.length;
115
+ for (let index = 0; index < removed.length; index++) {
116
+ cellAtoms -= removed[index] ?? 0;
117
+ }
118
+ return { molecules, networks, cellAtoms, tooLarge: false };
119
+ }
120
+
121
+ function identityIndexOf(
122
+ operations: ReadonlyArray<CrystalOperation<3>>,
123
+ ): number {
124
+ for (let index = 0; index < operations.length; index++) {
125
+ if (isIdentity(operations[index] as CrystalOperation<3>)) return index;
126
+ }
127
+ return -1;
128
+ }
@@ -0,0 +1,79 @@
1
+ import type { CrystalStructure } from './cif/types.ts';
2
+ import { resolveStructureSetting } from './resolve.ts';
3
+ import { spaceGroupOperations } from './spaceGroups/spaceGroupOperations.ts';
4
+ import { closure } from './symmetry/group.ts';
5
+ import { operationKey } from './symmetry/operation.ts';
6
+ import { parseOperation } from './symmetry/parseOperation.ts';
7
+ import type { CrystalOperation } from './symmetry/types.ts';
8
+
9
+ /**
10
+ * The full coset list a structure's asymmetric unit is expanded with.
11
+ *
12
+ * The file's own operations come first, in file order, so an atom's
13
+ * `operationIndex` points at the line of the file that made it. A file that
14
+ * lists only part of the group — one coset of a centred group, or a few
15
+ * generators — is completed: from the setting its symbol names when every
16
+ * listed operation belongs to it, else by composing the listed ones. A file
17
+ * that lists none, or one that cannot be read, is expanded with the setting its
18
+ * Hall symbol, Hermann–Mauguin symbol or number names.
19
+ * @param structure - What `readCif` returned.
20
+ * @returns The operations, the identity among them.
21
+ * @throws {Error} When no listed operation can be used and the file names no space
22
+ * group the catalogue knows.
23
+ */
24
+ export function structureOperations(
25
+ structure: CrystalStructure,
26
+ ): ReadonlyArray<CrystalOperation<3>> {
27
+ const resolved = resolveStructureSetting(structure);
28
+ const listed = readListed(structure.symopsXyz);
29
+ if (typeof listed === 'string' || listed.length === 0) {
30
+ if (resolved.setting !== null) {
31
+ return spaceGroupOperations(resolved.setting);
32
+ }
33
+ throw new Error(
34
+ typeof listed === 'string'
35
+ ? `This CIF names no space group this reader knows, and its operation list cannot be read: ${listed}.`
36
+ : 'This CIF names no space group this reader knows, and lists no symmetry operation.',
37
+ );
38
+ }
39
+ const keys = new Set<string>();
40
+ const operations: Array<CrystalOperation<3>> = [];
41
+ appendNew(operations, keys, listed);
42
+ if (resolved.setting !== null && resolved.agrees === true) {
43
+ appendNew(operations, keys, spaceGroupOperations(resolved.setting));
44
+ return operations;
45
+ }
46
+ try {
47
+ appendNew(operations, keys, closure(operations));
48
+ } catch {
49
+ // Operations that close on no group are left as the file wrote them.
50
+ }
51
+ return operations;
52
+ }
53
+
54
+ function readListed(
55
+ symopsXyz: readonly string[],
56
+ ): Array<CrystalOperation<3>> | string {
57
+ const operations: Array<CrystalOperation<3>> = [];
58
+ for (const xyz of symopsXyz) {
59
+ try {
60
+ operations.push(parseOperation(xyz, 3));
61
+ } catch (error) {
62
+ return error instanceof Error ? error.message : String(error);
63
+ }
64
+ }
65
+ return operations;
66
+ }
67
+
68
+ function appendNew(
69
+ operations: Array<CrystalOperation<3>>,
70
+ keys: Set<string>,
71
+ candidates: ReadonlyArray<CrystalOperation<3>>,
72
+ ) {
73
+ for (const operation of candidates) {
74
+ const key = operationKey(operation);
75
+ if (keys.has(key)) continue;
76
+ keys.add(key);
77
+ operations.push(operation);
78
+ }
79
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Whole molecules instead of atoms cut at the cell walls.
3
+ *
4
+ * The expanded cell holds every atom wrapped into [0, 1), so a molecule lying
5
+ * across a face is drawn in pieces at opposite ends of the box. Here the cell
6
+ * is read as the periodic graph it is: two atoms are bonded, possibly across a
7
+ * face, by the rule handed in — a viewer hands the one it draws bonds with, so
8
+ * what is completed here is exactly what it joins. Each molecule is then moved,
9
+ * whole, to the cell its centre falls in, and appears once per cell.
10
+ *
11
+ * A component that reaches its own translate is not a molecule but a network
12
+ * — rock salt, quartz, a metal — and has no whole to complete: its atoms stay
13
+ * where the cell put them.
14
+ */
15
+
16
+ import { bondGraph, walkComponents } from './components.ts';
17
+ import type { BondLimit, PackedAtom } from './periodicBonds.ts';
18
+ import { findPeriodicBonds } from './periodicBonds.ts';
19
+ import type { Lattice } from './symmetry/lattice.ts';
20
+
21
+ /** What {@link packMolecules} found. */
22
+ export interface PackingResult {
23
+ /** The atoms, each molecule whole and once per cell. */
24
+ readonly atoms: readonly PackedAtom[];
25
+ /**
26
+ * How many molecules one cell holds: sets of two atoms or more bonded to
27
+ * nothing outside themselves. A lone ion is not counted.
28
+ */
29
+ readonly molecules: number;
30
+ /** Whether some atoms belong to a network extending through the crystal. */
31
+ readonly extended: boolean;
32
+ }
33
+
34
+ /**
35
+ * The most atoms per cell the bonds are searched over, so a cell beyond it is
36
+ * drawn as it is rather than holding a page.
37
+ */
38
+ export const MAX_PACKED_ATOMS = 2000;
39
+
40
+ /** Slack on a centroid sitting on a cell face, so it lands in one cell only. */
41
+ const CENTRE_TOLERANCE = 1e-6;
42
+
43
+ /**
44
+ * Complete the molecules of one cell.
45
+ * @param atoms - Every atom of one cell, fractional, wrapped into [0, 1).
46
+ * @param lattice - The cell they sit in.
47
+ * @param bondLimit - When two atoms are bonded.
48
+ * @returns The atoms, molecules whole; the input unchanged when it holds more
49
+ * than {@link MAX_PACKED_ATOMS}.
50
+ */
51
+ export function packMolecules(
52
+ atoms: readonly PackedAtom[],
53
+ lattice: Lattice,
54
+ bondLimit: BondLimit,
55
+ ): PackingResult {
56
+ const count = atoms.length;
57
+ if (count === 0 || count > MAX_PACKED_ATOMS) {
58
+ return { atoms, molecules: 0, extended: false };
59
+ }
60
+ const graph = bondGraph(count, findPeriodicBonds(atoms, lattice, bondLimit));
61
+ const { components, shifts } = walkComponents(graph);
62
+ const packed: PackedAtom[] = [];
63
+ let molecules = 0;
64
+ let extended = false;
65
+ for (const component of components) {
66
+ if (component.periodicity > 0) {
67
+ extended = true;
68
+ for (const index of component.atoms) {
69
+ packed.push(atoms[index] as PackedAtom);
70
+ }
71
+ continue;
72
+ }
73
+ if (component.atoms.length > 1) molecules++;
74
+ pushMolecule(packed, atoms, component.atoms, shifts);
75
+ }
76
+ return { atoms: packed, molecules, extended };
77
+ }
78
+
79
+ /**
80
+ * Add one molecule, moved whole to the cell its centre falls in.
81
+ * @param packed - The atoms placed so far, appended to.
82
+ * @param atoms - The atoms of the cell.
83
+ * @param members - The atoms of the molecule.
84
+ * @param shifts - The cell each atom was reached in.
85
+ */
86
+ function pushMolecule(
87
+ packed: PackedAtom[],
88
+ atoms: readonly PackedAtom[],
89
+ members: readonly number[],
90
+ shifts: Int32Array,
91
+ ): void {
92
+ const centre = [0, 0, 0];
93
+ for (const index of members) {
94
+ const position = (atoms[index] as PackedAtom).position;
95
+ for (let axis = 0; axis < 3; axis++) {
96
+ centre[axis] =
97
+ (centre[axis] ?? 0) +
98
+ (position[axis] ?? 0) +
99
+ (shifts[index * 3 + axis] ?? 0);
100
+ }
101
+ }
102
+ const move: [number, number, number] = [0, 0, 0];
103
+ for (let axis = 0; axis < 3; axis++) {
104
+ const mean = (centre[axis] ?? 0) / members.length;
105
+ move[axis] = -Math.floor(mean + CENTRE_TOLERANCE);
106
+ }
107
+ for (const index of members) {
108
+ const atom = atoms[index] as PackedAtom;
109
+ const position: [number, number, number] = [0, 0, 0];
110
+ for (let axis = 0; axis < 3; axis++) {
111
+ const shift = shifts[index * 3 + axis] ?? 0;
112
+ position[axis] = (atom.position[axis] ?? 0) + shift + (move[axis] ?? 0);
113
+ }
114
+ packed.push({ element: atom.element, position });
115
+ }
116
+ }
@@ -0,0 +1,234 @@
1
+ /**
2
+ * The bonds of one cell, found across its faces.
3
+ *
4
+ * The atoms are binned on a grid of the cell itself, each bin at least one
5
+ * bond long across, so an atom is compared only with the atoms of its own bin
6
+ * and of the bins around it — wrapped across the faces with the cell they lie
7
+ * in — rather than with every atom of 27 cells. A cell a bond is longer than
8
+ * is searched over as many cells as the bond can reach.
9
+ */
10
+
11
+ import { createGrid } from './bondGrid.ts';
12
+ import type { Lattice } from './symmetry/lattice.ts';
13
+
14
+ /**
15
+ * The longest bond between two elements, in ångström; 0 for a pair never
16
+ * bonded.
17
+ */
18
+ export type BondLimit = (a: string, b: string) => number;
19
+
20
+ /** One atom of a cell, in fractional coordinates. */
21
+ export interface PackedAtom {
22
+ readonly element: string;
23
+ readonly position: readonly [number, number, number];
24
+ }
25
+
26
+ /** The bonded pairs of one cell, each listed once. */
27
+ export interface PeriodicPairs {
28
+ /** How many pairs. */
29
+ readonly count: number;
30
+ /** The first atom of each pair. */
31
+ readonly from: Int32Array;
32
+ /** The second atom of each pair; never lower than `from`. */
33
+ readonly to: Int32Array;
34
+ /** The cell `to` is bonded in, seen from `from`: three integers per pair. */
35
+ readonly shifts: Int32Array;
36
+ /** The length of each bond, Å. */
37
+ readonly lengths: Float64Array;
38
+ /**
39
+ * The pairs of atoms closer than `samePlace`, which are one atom written
40
+ * twice and are never bonded: `[i, j, i, j, …]`, each `i` below its `j`.
41
+ */
42
+ readonly coincident: Int32Array;
43
+ }
44
+
45
+ /** Options of {@link findPeriodicBonds}. */
46
+ export interface PeriodicBondOptions {
47
+ /**
48
+ * Two atoms closer than this, in ångström, are one atom written twice.
49
+ * @default 1e-4
50
+ */
51
+ readonly samePlace?: number;
52
+ }
53
+
54
+ /**
55
+ * Every bond of one cell, each from an atom of the cell to an atom of it or of
56
+ * a cell around it.
57
+ * @param atoms - The atoms of one cell, fractional, wrapped into [0, 1).
58
+ * @param lattice - The cell they sit in.
59
+ * @param bondLimit - When two atoms are bonded.
60
+ * @param options - Options.
61
+ * @returns The bonded pairs, and the atoms written twice.
62
+ */
63
+ export function findPeriodicBonds(
64
+ atoms: readonly PackedAtom[],
65
+ lattice: Lattice,
66
+ bondLimit: BondLimit,
67
+ options: PeriodicBondOptions = {},
68
+ ): PeriodicPairs {
69
+ const { samePlace = 1e-4 } = options;
70
+ const count = atoms.length;
71
+ const kinds = elementKinds(atoms);
72
+ const limits = pairLimits(kinds.symbols, bondLimit);
73
+ let reach = samePlace;
74
+ for (let index = 0; index < limits.length; index++) {
75
+ reach = Math.max(reach, limits[index] ?? 0);
76
+ }
77
+ const xyz = cartesianOf(atoms, lattice);
78
+ const grid = createGrid(atoms, lattice, reach);
79
+ const found = new PairBuffer();
80
+ const reachSquared = reach * reach;
81
+ const sameSquared = samePlace * samePlace;
82
+ const kindCount = kinds.symbols.length;
83
+ const { counts, reaches, start, members, cells } = grid;
84
+ const [na, nb, nc] = counts;
85
+ const [ka, kb, kc] = reaches;
86
+ const m = lattice.cartesian;
87
+
88
+ for (let i = 0; i < count; i++) {
89
+ const xi = xyz[i * 3] ?? 0;
90
+ const yi = xyz[i * 3 + 1] ?? 0;
91
+ const zi = xyz[i * 3 + 2] ?? 0;
92
+ const row = (kinds.indices[i] ?? 0) * kindCount;
93
+ for (let oa = -ka; oa <= ka; oa++) {
94
+ const ta = (cells[i * 3] ?? 0) + oa;
95
+ const sa = Math.floor(ta / na);
96
+ for (let ob = -kb; ob <= kb; ob++) {
97
+ const tb = (cells[i * 3 + 1] ?? 0) + ob;
98
+ const sb = Math.floor(tb / nb);
99
+ for (let oc = -kc; oc <= kc; oc++) {
100
+ const tc = (cells[i * 3 + 2] ?? 0) + oc;
101
+ const sc = Math.floor(tc / nc);
102
+ const positive =
103
+ sa > 0 || (sa === 0 && (sb > 0 || (sb === 0 && sc > 0)));
104
+ const bin =
105
+ ((ta - sa * na) * nb + (tb - sb * nb)) * nc + (tc - sc * nc);
106
+ const ox = shiftAxis(m, 0, sa, sb, sc) - xi;
107
+ const oy = shiftAxis(m, 1, sa, sb, sc) - yi;
108
+ const oz = shiftAxis(m, 2, sa, sb, sc) - zi;
109
+ const last = start[bin + 1] ?? 0;
110
+ for (let slot = start[bin] ?? 0; slot < last; slot++) {
111
+ const j = members[slot] ?? 0;
112
+ if (j < i || (j === i && !positive)) continue;
113
+ const dx = (xyz[j * 3] ?? 0) + ox;
114
+ const dy = (xyz[j * 3 + 1] ?? 0) + oy;
115
+ const dz = (xyz[j * 3 + 2] ?? 0) + oz;
116
+ const squared = dx * dx + dy * dy + dz * dz;
117
+ if (squared > reachSquared) continue;
118
+ if (squared < sameSquared) {
119
+ if (j !== i) found.coincide(i, j);
120
+ continue;
121
+ }
122
+ const limit = limits[row + (kinds.indices[j] ?? 0)] ?? 0;
123
+ if (squared > limit * limit) continue;
124
+ found.bond(i, j, sa, sb, sc, Math.sqrt(squared));
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ return found.result();
131
+ }
132
+
133
+ function shiftAxis(
134
+ m: number[][],
135
+ axis: number,
136
+ sa: number,
137
+ sb: number,
138
+ sc: number,
139
+ ): number {
140
+ const row = m[axis];
141
+ return (row?.[0] ?? 0) * sa + (row?.[1] ?? 0) * sb + (row?.[2] ?? 0) * sc;
142
+ }
143
+
144
+ function cartesianOf(atoms: readonly PackedAtom[], lattice: Lattice) {
145
+ const m = lattice.cartesian;
146
+ const xyz = new Float64Array(atoms.length * 3);
147
+ for (let index = 0; index < atoms.length; index++) {
148
+ const [x, y, z] = (atoms[index] as PackedAtom).position;
149
+ for (let axis = 0; axis < 3; axis++) {
150
+ const row = m[axis];
151
+ xyz[index * 3 + axis] =
152
+ (row?.[0] ?? 0) * x + (row?.[1] ?? 0) * y + (row?.[2] ?? 0) * z;
153
+ }
154
+ }
155
+ return xyz;
156
+ }
157
+
158
+ /**
159
+ * The elements present, and which of them each atom is.
160
+ * @param atoms - The atoms of the cell.
161
+ * @returns The index of each atom’s element, and the elements.
162
+ */
163
+ function elementKinds(atoms: readonly PackedAtom[]) {
164
+ const indices = new Int32Array(atoms.length);
165
+ const symbols: string[] = [];
166
+ const known = new Map<string, number>();
167
+ for (let index = 0; index < atoms.length; index++) {
168
+ const element = (atoms[index] as PackedAtom).element;
169
+ let kind = known.get(element);
170
+ if (kind === undefined) {
171
+ kind = symbols.length;
172
+ known.set(element, kind);
173
+ symbols.push(element);
174
+ }
175
+ indices[index] = kind;
176
+ }
177
+ return { indices, symbols };
178
+ }
179
+
180
+ /**
181
+ * The bond limit of every pair of the elements present, row-major.
182
+ * @param symbols - The elements present.
183
+ * @param bondLimit - When two atoms are bonded.
184
+ * @returns The limits, row-major over the elements present.
185
+ */
186
+ function pairLimits(symbols: readonly string[], bondLimit: BondLimit) {
187
+ const size = symbols.length;
188
+ const limits = new Float64Array(size * size);
189
+ for (let a = 0; a < size; a++) {
190
+ for (let b = 0; b < size; b++) {
191
+ const limit = bondLimit(symbols[a] ?? '', symbols[b] ?? '');
192
+ limits[a * size + b] = Math.max(limit, 0);
193
+ }
194
+ }
195
+ return limits;
196
+ }
197
+
198
+ /** The pairs as they are found, turned into typed arrays once at the end. */
199
+ class PairBuffer {
200
+ readonly #from: number[] = [];
201
+ readonly #to: number[] = [];
202
+ readonly #shifts: number[] = [];
203
+ readonly #lengths: number[] = [];
204
+ readonly #coincident: number[] = [];
205
+
206
+ bond(
207
+ i: number,
208
+ j: number,
209
+ sa: number,
210
+ sb: number,
211
+ sc: number,
212
+ length: number,
213
+ ) {
214
+ this.#from.push(i);
215
+ this.#to.push(j);
216
+ this.#shifts.push(sa, sb, sc);
217
+ this.#lengths.push(length);
218
+ }
219
+
220
+ coincide(i: number, j: number) {
221
+ this.#coincident.push(i, j);
222
+ }
223
+
224
+ result(): PeriodicPairs {
225
+ return {
226
+ count: this.#from.length,
227
+ from: Int32Array.from(this.#from),
228
+ to: Int32Array.from(this.#to),
229
+ shifts: Int32Array.from(this.#shifts),
230
+ lengths: Float64Array.from(this.#lengths),
231
+ coincident: Int32Array.from(this.#coincident),
232
+ };
233
+ }
234
+ }