mdapy 2.0.0b1__tar.gz → 2.1.0__tar.gz

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 (252) hide show
  1. mdapy-2.1.0/CITATION.cff +23 -0
  2. {mdapy-2.0.0b1 → mdapy-2.1.0}/PKG-INFO +17 -6
  3. {mdapy-2.0.0b1 → mdapy-2.1.0}/README.md +13 -4
  4. {mdapy-2.0.0b1 → mdapy-2.1.0}/pyproject.toml +3 -1
  5. mdapy-2.1.0/src/cpp/analysis/dislocations.cpp +484 -0
  6. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dislocations.h +6 -1
  7. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/distribution.cpp +10 -5
  8. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_mesh.cpp +5 -0
  9. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_mesh.h +4 -1
  10. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_structure.cpp +116 -19
  11. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_structure.h +4 -1
  12. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_tracer.cpp +19 -1
  13. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_tracer.h +3 -1
  14. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/geometry.cpp +17 -6
  15. mdapy-2.1.0/src/cpp/analysis/phonon_scattering.cpp +235 -0
  16. mdapy-2.1.0/src/cpp/analysis/phonon_scattering.h +75 -0
  17. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/rings.cpp +14 -2
  18. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/surface_mesh.cpp +124 -23
  19. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/voronoi.cpp +168 -14
  20. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/voronoi.h +11 -6
  21. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/analysis.cpp +127 -8
  22. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/calculators.cpp +15 -5
  23. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/identify.cpp +69 -31
  24. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/calculators/eam.cpp +7 -6
  25. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/calculators/eam.h +12 -2
  26. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/calculators/nep.cpp +5 -3
  27. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/core/voronoi_cell.h +66 -4
  28. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/grains.h +1 -1
  29. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/ptm.cpp +126 -52
  30. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/ptm.h +6 -2
  31. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/ptm_tools.cpp +2 -2
  32. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/structure.cpp +3 -1
  33. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/io/text.cpp +14 -0
  34. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/neighbor/frames.cpp +2 -2
  35. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/neighbor/kd_tree.h +23 -0
  36. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/visualization/render.cpp +16 -9
  37. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/visualization/render_d3d12.cpp +1 -1
  38. mdapy-2.1.0/src/cpp/visualization/render_d3d12.dxil +0 -0
  39. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/visualization/render_d3d12.hlsl +18 -16
  40. mdapy-2.1.0/src/cpp/visualization/render_d3d12_rt.dxil +0 -0
  41. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/visualization/render_gpu.h +1 -1
  42. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/visualization/render_metal.mm +17 -9
  43. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/visualization/render_vulkan.comp +17 -9
  44. mdapy-2.1.0/src/cpp/visualization/render_vulkan.spv +0 -0
  45. mdapy-2.1.0/src/cpp/visualization/render_vulkan_rt.spv +0 -0
  46. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/__init__.py +4 -2
  47. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/__init__.py +2 -0
  48. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_binning.py +5 -5
  49. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_bonds.py +7 -7
  50. mdapy-2.1.0/src/mdapy/analysis/_ca_files.py +460 -0
  51. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_dislocations.py +108 -8
  52. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_distribution.py +24 -23
  53. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_dynamics.py +4 -4
  54. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_polyhedra.py +1 -1
  55. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_surface_mesh.py +1 -3
  56. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/build/_alloy.py +34 -2
  57. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/build/_crystal.py +19 -7
  58. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/build/_defects.py +36 -9
  59. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/build/_dislocation.py +6 -3
  60. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/build/_dislocation_models.py +2 -1
  61. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/build/_graphene.py +6 -5
  62. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/build/_polycrystal.py +10 -4
  63. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/build/_sqs.py +2 -2
  64. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/calculators/_eam.py +212 -22
  65. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/calculators/testing.py +3 -3
  66. mdapy-2.1.0/src/mdapy/core/__init__.py +15 -0
  67. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/_conditions.py +22 -0
  68. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/box.py +68 -20
  69. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/system.py +15 -4
  70. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/threads.py +4 -1
  71. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/topology.py +4 -0
  72. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/elements.py +15 -6
  73. mdapy-2.1.0/src/mdapy/fitting/__init__.py +50 -0
  74. mdapy-2.1.0/src/mdapy/fitting/_eos.py +257 -0
  75. mdapy-2.1.0/src/mdapy/fitting/_least_squares.py +786 -0
  76. mdapy-2.1.0/src/mdapy/fitting/_spline.py +442 -0
  77. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/identify/_grains.py +10 -9
  78. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/identify/_ptm.py +37 -21
  79. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/interop/_ase.py +41 -1
  80. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/interop/_ase_calculator.py +3 -2
  81. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_cif.py +13 -0
  82. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_extxyz.py +46 -20
  83. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_files.py +9 -6
  84. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_lammps_data.py +9 -5
  85. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_lammps_dump.py +15 -1
  86. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_text.py +3 -0
  87. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_trajectory.py +16 -4
  88. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/lattice_dynamics/__init__.py +35 -2
  89. mdapy-2.1.0/src/mdapy/lattice_dynamics/_bond_stiffness.py +371 -0
  90. mdapy-2.1.0/src/mdapy/lattice_dynamics/_conductivity.py +391 -0
  91. mdapy-2.1.0/src/mdapy/lattice_dynamics/_elastic.py +488 -0
  92. mdapy-2.1.0/src/mdapy/lattice_dynamics/_force_constants.py +1056 -0
  93. mdapy-2.1.0/src/mdapy/lattice_dynamics/_green_kubo.py +272 -0
  94. mdapy-2.1.0/src/mdapy/lattice_dynamics/_md_elastic.py +363 -0
  95. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/lattice_dynamics/_phonons.py +427 -34
  96. mdapy-2.1.0/src/mdapy/lattice_dynamics/_quasi_harmonic.py +521 -0
  97. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/lattice_dynamics/_thermal_elastic.py +62 -15
  98. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/lattice_dynamics/_thermal_phonons.py +8 -8
  99. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/mlip/_selection.py +13 -13
  100. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/mlip/_soap.py +18 -18
  101. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/mlip/_training.py +23 -16
  102. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/neighbor/__init__.py +4 -2
  103. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/simulation/_dynamics.py +77 -27
  104. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/simulation/_free_energy.py +15 -15
  105. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/simulation/_melting.py +34 -21
  106. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/transform/__init__.py +3 -1
  107. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/transform/_bonds.py +10 -4
  108. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/transform/_combine.py +57 -6
  109. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/transform/_frames.py +1 -1
  110. mdapy-2.1.0/src/mdapy/transform/_orthogonal.py +208 -0
  111. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/transform/_periodic.py +37 -7
  112. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/visualization/_render.py +41 -21
  113. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/visualization/_scene.py +25 -8
  114. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/visualization/plot.py +381 -15
  115. mdapy-2.0.0b1/src/cpp/analysis/dislocations.cpp +0 -204
  116. mdapy-2.0.0b1/src/cpp/visualization/render_d3d12.dxil +0 -0
  117. mdapy-2.0.0b1/src/cpp/visualization/render_d3d12_rt.dxil +0 -0
  118. mdapy-2.0.0b1/src/cpp/visualization/render_vulkan.spv +0 -0
  119. mdapy-2.0.0b1/src/cpp/visualization/render_vulkan_rt.spv +0 -0
  120. mdapy-2.0.0b1/src/mdapy/core/__init__.py +0 -31
  121. mdapy-2.0.0b1/src/mdapy/lattice_dynamics/_elastic.py +0 -259
  122. mdapy-2.0.0b1/src/mdapy/lattice_dynamics/_md_elastic.py +0 -135
  123. mdapy-2.0.0b1/src/mdapy/lattice_dynamics/_quasi_harmonic.py +0 -340
  124. {mdapy-2.0.0b1 → mdapy-2.1.0}/.gitattributes +0 -0
  125. {mdapy-2.0.0b1 → mdapy-2.1.0}/.gitignore +0 -0
  126. {mdapy-2.0.0b1 → mdapy-2.1.0}/CMakeLists.txt +0 -0
  127. {mdapy-2.0.0b1 → mdapy-2.1.0}/LICENSE +0 -0
  128. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/distribution.h +0 -0
  129. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_clusters.cpp +0 -0
  130. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_clusters.h +0 -0
  131. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_mapping.cpp +0 -0
  132. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_mapping.h +0 -0
  133. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/dxa_math.h +0 -0
  134. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/elastic_strain.cpp +0 -0
  135. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/elastic_strain.h +0 -0
  136. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/geometry.h +0 -0
  137. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/isosurface.cpp +0 -0
  138. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/isosurface.h +0 -0
  139. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/rings.h +0 -0
  140. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/soap.cpp +0 -0
  141. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/soap.h +0 -0
  142. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/steinhardt.cpp +0 -0
  143. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/steinhardt.h +0 -0
  144. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/strain.cpp +0 -0
  145. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/strain.h +0 -0
  146. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/surface_mesh.h +0 -0
  147. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/tessellation.cpp +0 -0
  148. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/analysis/tessellation.h +0 -0
  149. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/build.cpp +0 -0
  150. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/control.h +0 -0
  151. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/core.cpp +0 -0
  152. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/frames.h +0 -0
  153. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/io.cpp +0 -0
  154. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/list_view.h +0 -0
  155. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/module.cpp +0 -0
  156. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/neighbor.cpp +0 -0
  157. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/testing.cpp +0 -0
  158. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/bindings/visualization.cpp +0 -0
  159. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/build/crystal.cpp +0 -0
  160. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/build/crystal.h +0 -0
  161. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/build/polycrystal.cpp +0 -0
  162. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/build/polycrystal.h +0 -0
  163. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/build/sqs.cpp +0 -0
  164. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/build/sqs.h +0 -0
  165. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/calculators/nep.h +0 -0
  166. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/core/buffer.h +0 -0
  167. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/core/hardware.cpp +0 -0
  168. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/core/hardware.h +0 -0
  169. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/core/index.h +0 -0
  170. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/core/parallel.cpp +0 -0
  171. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/core/parallel.h +0 -0
  172. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/core/wrap.h +0 -0
  173. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/cna.h +0 -0
  174. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/grains.cpp +0 -0
  175. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/planar_faults.cpp +0 -0
  176. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/planar_faults.h +0 -0
  177. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/ptm_data.cpp +0 -0
  178. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/ptm_data.h +0 -0
  179. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/ptm_tools.h +0 -0
  180. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/identify/structure.h +0 -0
  181. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/io/powers_of_five.h +0 -0
  182. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/io/text.h +0 -0
  183. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/neighbor/cell_list.cpp +0 -0
  184. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/neighbor/cell_list.h +0 -0
  185. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/neighbor/frame.h +0 -0
  186. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/neighbor/frames.h +0 -0
  187. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/neighbor/kd_tree.cpp +0 -0
  188. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/neighbor/list_view.h +0 -0
  189. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/visualization/render.h +0 -0
  190. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/cpp/visualization/render_vulkan.cpp +0 -0
  191. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_correlation.py +0 -0
  192. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_displacement.py +0 -0
  193. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_elastic_strain.py +0 -0
  194. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_entropy.py +0 -0
  195. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_isosurface.py +0 -0
  196. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_rings.py +0 -0
  197. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_species.py +0 -0
  198. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_statistics.py +0 -0
  199. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_steinhardt.py +0 -0
  200. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_strain.py +0 -0
  201. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_symmetry.py +0 -0
  202. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_temperature.py +0 -0
  203. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_voronoi.py +0 -0
  204. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/analysis/_wigner_seitz.py +0 -0
  205. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/build/__init__.py +0 -0
  206. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/build/_anisotropic.py +0 -0
  207. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/calculators/__init__.py +0 -0
  208. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/calculators/_base.py +0 -0
  209. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/calculators/_lammps.py +0 -0
  210. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/calculators/_nep.py +0 -0
  211. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/calculators/_vasp.py +0 -0
  212. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/calculators/_zhou.py +0 -0
  213. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/_atoms.py +0 -0
  214. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/_frames.py +0 -0
  215. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/indices.py +0 -0
  216. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/mesh.py +0 -0
  217. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/result.py +0 -0
  218. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/core/versions.py +0 -0
  219. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/errors.py +0 -0
  220. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/identify/__init__.py +0 -0
  221. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/identify/_planar_faults.py +0 -0
  222. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/identify/_structure.py +0 -0
  223. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/interop/__init__.py +0 -0
  224. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/interop/_freud.py +0 -0
  225. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/interop/_ovito.py +0 -0
  226. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/interop/_pymatgen.py +0 -0
  227. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/__init__.py +0 -0
  228. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_native.py +0 -0
  229. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_outcar.py +0 -0
  230. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_pdb.py +0 -0
  231. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_poscar.py +0 -0
  232. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/io/_registry.py +0 -0
  233. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/lattice_dynamics/_sheets.py +0 -0
  234. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/mlip/__init__.py +0 -0
  235. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/neighbor/_expand.py +0 -0
  236. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/neighbor/_neighbor_list.py +0 -0
  237. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/neighbor/_overlapping.py +0 -0
  238. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/simulation/__init__.py +0 -0
  239. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/simulation/_defect_energies.py +0 -0
  240. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/simulation/_fault_free_energy.py +0 -0
  241. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/simulation/_minimize.py +0 -0
  242. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/simulation/_phase_diagram.py +0 -0
  243. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/transform/_affine.py +0 -0
  244. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/transform/_drift.py +0 -0
  245. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/transform/_slice.py +0 -0
  246. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/units.py +0 -0
  247. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/visualization/__init__.py +0 -0
  248. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/visualization/_colormap_tables.py +0 -0
  249. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/visualization/_elements.py +0 -0
  250. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/visualization/_legend.py +0 -0
  251. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/visualization/_movie.py +0 -0
  252. {mdapy-2.0.0b1 → mdapy-2.1.0}/src/mdapy/visualization/_voxels.py +0 -0
@@ -0,0 +1,23 @@
1
+ cff-version: 1.2.0
2
+ message: "If MDAPY contributes to a publication, please cite the paper below."
3
+ title: MDAPY
4
+ type: software
5
+ authors:
6
+ - family-names: Wu
7
+ given-names: Yong-Chao
8
+ repository-code: "https://github.com/mushroomfire/mdapy"
9
+ url: "https://mushroomfire.github.io/mdapy/"
10
+ license: MPL-2.0
11
+ preferred-citation:
12
+ type: article
13
+ title: "mdapy: A flexible and efficient analysis software for molecular dynamics simulations"
14
+ authors:
15
+ - family-names: Wu
16
+ given-names: Yong-Chao
17
+ - family-names: Shao
18
+ given-names: Jian-Li
19
+ journal: Computer Physics Communications
20
+ volume: 290
21
+ start: 108764
22
+ year: 2023
23
+ doi: 10.1016/j.cpc.2023.108764
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdapy
3
- Version: 2.0.0b1
3
+ Version: 2.1.0
4
4
  Summary: Analysis and modelling of atomistic simulations
5
5
  Author-Email: Yongchao Wu <934313174@qq.com>
6
6
  License-Expression: MPL-2.0
7
7
  License-File: LICENSE
8
- Classifier: Development Status :: 4 - Beta
8
+ Classifier: Development Status :: 5 - Production/Stable
9
9
  Classifier: Intended Audience :: Science/Research
10
10
  Classifier: Topic :: Scientific/Engineering :: Physics
11
11
  Classifier: Programming Language :: C++
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
17
18
  Project-URL: Homepage, https://github.com/mushroomfire/mdapy
18
19
  Project-URL: Documentation, https://mushroomfire.github.io/mdapy/
19
20
  Project-URL: Issues, https://github.com/mushroomfire/mdapy/issues
@@ -44,6 +45,7 @@ Provides-Extra: docs
44
45
  Requires-Dist: mkdocs<2,>=1.6; extra == "docs"
45
46
  Requires-Dist: mkdocs-material>=9.5; extra == "docs"
46
47
  Requires-Dist: mkdocstrings[python]>=0.26; extra == "docs"
48
+ Requires-Dist: mike>=2.1; extra == "docs"
47
49
  Description-Content-Type: text/markdown
48
50
 
49
51
  <p align="center">
@@ -79,7 +81,9 @@ Description-Content-Type: text/markdown
79
81
  </p>
80
82
 
81
83
  > **MDAPY 2.0 is a complete rewrite and is not compatible with MDAPY 1.x.** It brings many
82
- > more features, and we recommend upgrading. The code of 1.x stays on the branch
84
+ > more features, and we recommend upgrading:
85
+ > [From MDAPY 1.x](https://mushroomfire.github.io/mdapy/getting-started/from-1x/) gives the
86
+ > 2.0 way of each common call. The code of 1.x stays on the branch
83
87
  > [`1.x`](https://github.com/mushroomfire/mdapy/tree/1.x).
84
88
 
85
89
  If you like MDAPY, please give it a ⭐ [star](https://github.com/mushroomfire/mdapy).
@@ -100,6 +104,10 @@ If you like MDAPY, please give it a ⭐ [star](https://github.com/mushroomfire/m
100
104
  `CommonNeighborAnalysis`. A `System` never changes in place, every analysis has the form
101
105
  `compute(system)` and returns NumPy arrays, and one unit system, Å, eV and ps, runs
102
106
  through everything.
107
+ - **Stable.** From 2.0.0 on, code that works keeps working: the API changes only with
108
+ 3.0, a replaced name warns long before it goes, and a result changes only to fix a bug,
109
+ named in the release notes. See
110
+ [Compatibility](https://mushroomfire.github.io/mdapy/about/compatibility/).
103
111
  - **Integrated.** One package and one `System`, from the first structure to the last
104
112
  picture. It converts systems to and from [ASE](https://wiki.fysik.dtu.dk/ase/),
105
113
  [OVITO](https://www.ovito.org), [pymatgen](https://pymatgen.org) and
@@ -175,11 +183,11 @@ More in the [documentation](https://mushroomfire.github.io/mdapy/), from the
175
183
  ## 📦 Install
176
184
 
177
185
  ```bash
178
- pip install --pre mdapy
186
+ pip install mdapy
179
187
  ```
180
188
 
181
- The first release of 2.0 is a preview, and `--pre` asks `pip` for it: without it, `pip`
182
- installs 1.x. MDAPY needs Python 3.11 or newer. [Installation](https://mushroomfire.github.io/mdapy/getting-started/installation/)
189
+ MDAPY needs Python 3.11 or newer. Code written for 1.x keeps working with
190
+ `pip install "mdapy<2"`, or moves to 2.0 [as this guide shows](https://mushroomfire.github.io/mdapy/getting-started/from-1x/). [Installation](https://mushroomfire.github.io/mdapy/getting-started/installation/)
183
191
  describes the other ways to install it, from a source archive or from git, what those need,
184
192
  and the optional packages.
185
193
 
@@ -204,6 +212,9 @@ If MDAPY contributes to a publication, please cite:
204
212
  > for molecular dynamics simulations*, Computer Physics Communications **290**, 108764
205
213
  > (2023). [doi:10.1016/j.cpc.2023.108764](https://doi.org/10.1016/j.cpc.2023.108764)
206
214
 
215
+ [Papers citing MDAPY](https://mushroomfire.github.io/mdapy/about/citations/) lists, by year,
216
+ the papers that cite it.
217
+
207
218
  ## 📄 License
208
219
 
209
220
  Mozilla Public License 2.0, see [LICENSE](https://github.com/mushroomfire/mdapy/blob/master/LICENSE):
@@ -31,7 +31,9 @@
31
31
  </p>
32
32
 
33
33
  > **MDAPY 2.0 is a complete rewrite and is not compatible with MDAPY 1.x.** It brings many
34
- > more features, and we recommend upgrading. The code of 1.x stays on the branch
34
+ > more features, and we recommend upgrading:
35
+ > [From MDAPY 1.x](https://mushroomfire.github.io/mdapy/getting-started/from-1x/) gives the
36
+ > 2.0 way of each common call. The code of 1.x stays on the branch
35
37
  > [`1.x`](https://github.com/mushroomfire/mdapy/tree/1.x).
36
38
 
37
39
  If you like MDAPY, please give it a ⭐ [star](https://github.com/mushroomfire/mdapy).
@@ -52,6 +54,10 @@ If you like MDAPY, please give it a ⭐ [star](https://github.com/mushroomfire/m
52
54
  `CommonNeighborAnalysis`. A `System` never changes in place, every analysis has the form
53
55
  `compute(system)` and returns NumPy arrays, and one unit system, Å, eV and ps, runs
54
56
  through everything.
57
+ - **Stable.** From 2.0.0 on, code that works keeps working: the API changes only with
58
+ 3.0, a replaced name warns long before it goes, and a result changes only to fix a bug,
59
+ named in the release notes. See
60
+ [Compatibility](https://mushroomfire.github.io/mdapy/about/compatibility/).
55
61
  - **Integrated.** One package and one `System`, from the first structure to the last
56
62
  picture. It converts systems to and from [ASE](https://wiki.fysik.dtu.dk/ase/),
57
63
  [OVITO](https://www.ovito.org), [pymatgen](https://pymatgen.org) and
@@ -127,11 +133,11 @@ More in the [documentation](https://mushroomfire.github.io/mdapy/), from the
127
133
  ## 📦 Install
128
134
 
129
135
  ```bash
130
- pip install --pre mdapy
136
+ pip install mdapy
131
137
  ```
132
138
 
133
- The first release of 2.0 is a preview, and `--pre` asks `pip` for it: without it, `pip`
134
- installs 1.x. MDAPY needs Python 3.11 or newer. [Installation](https://mushroomfire.github.io/mdapy/getting-started/installation/)
139
+ MDAPY needs Python 3.11 or newer. Code written for 1.x keeps working with
140
+ `pip install "mdapy<2"`, or moves to 2.0 [as this guide shows](https://mushroomfire.github.io/mdapy/getting-started/from-1x/). [Installation](https://mushroomfire.github.io/mdapy/getting-started/installation/)
135
141
  describes the other ways to install it, from a source archive or from git, what those need,
136
142
  and the optional packages.
137
143
 
@@ -156,6 +162,9 @@ If MDAPY contributes to a publication, please cite:
156
162
  > for molecular dynamics simulations*, Computer Physics Communications **290**, 108764
157
163
  > (2023). [doi:10.1016/j.cpc.2023.108764](https://doi.org/10.1016/j.cpc.2023.108764)
158
164
 
165
+ [Papers citing MDAPY](https://mushroomfire.github.io/mdapy/about/citations/) lists, by year,
166
+ the papers that cite it.
167
+
159
168
  ## 📄 License
160
169
 
161
170
  Mozilla Public License 2.0, see [LICENSE](https://github.com/mushroomfire/mdapy/blob/master/LICENSE):
@@ -13,7 +13,7 @@ license-files = ["LICENSE"]
13
13
  authors = [{ name = "Yongchao Wu", email = "934313174@qq.com" }]
14
14
  dependencies = ["numpy>=2.3.1", "polars>=2"]
15
15
  classifiers = [
16
- "Development Status :: 4 - Beta",
16
+ "Development Status :: 5 - Production/Stable",
17
17
  "Intended Audience :: Science/Research",
18
18
  "Topic :: Scientific/Engineering :: Physics",
19
19
  "Programming Language :: C++",
@@ -22,6 +22,7 @@ classifiers = [
22
22
  "Programming Language :: Python :: 3.12",
23
23
  "Programming Language :: Python :: 3.13",
24
24
  "Programming Language :: Python :: 3.14",
25
+ "Programming Language :: Python :: 3.15",
25
26
  ]
26
27
 
27
28
  [project.optional-dependencies]
@@ -44,6 +45,7 @@ docs = [
44
45
  "mkdocs>=1.6,<2",
45
46
  "mkdocs-material>=9.5",
46
47
  "mkdocstrings[python]>=0.26",
48
+ "mike>=2.1",
47
49
  ]
48
50
 
49
51
  [project.urls]
@@ -0,0 +1,484 @@
1
+ // Copyright (c) 2022-2026, Yongchao Wu
2
+ // This Source Code Form is subject to the terms of the Mozilla Public License,
3
+ // v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
+ // obtain one at https://mozilla.org/MPL/2.0/.
5
+
6
+ #include "analysis/dislocations.h"
7
+
8
+ #include <algorithm>
9
+ #include <cmath>
10
+ #include <cstdint>
11
+ #include <cstddef>
12
+ #include <stdexcept>
13
+ #include <utility>
14
+ #include <vector>
15
+
16
+ #include "analysis/dxa_mapping.h"
17
+ #include "analysis/dxa_mesh.h"
18
+ #include "analysis/tessellation.h"
19
+ #include "analysis/voronoi.h"
20
+ #include "neighbor/cell_list.h"
21
+
22
+ namespace mdapy::analysis {
23
+ namespace {
24
+
25
+ // Clusters of the crystal's structure smaller than this are slivers, such as
26
+ // the one layer of crystal inside an extrinsic stacking fault: their frame
27
+ // rests on a few atoms.
28
+ constexpr std::int64_t kSliver = 100;
29
+
30
+ // About a line, the atoms of its cluster closer than this (Å) to a point of
31
+ // it fit the lattice there; turned from the frame of the cluster by more
32
+ // than kTurned, with at least kFewest atoms, the lattice there gives the
33
+ // spatial Burgers vector instead of the cluster's mean orientation, as when
34
+ // one cluster holds two grains.
35
+ constexpr double kAbout = 7.0;
36
+ constexpr double kTurned = 3.0 * 3.14159265358979323846 / 180.0;
37
+ constexpr std::int64_t kFewest = 10;
38
+
39
+ // The rotation of the polar decomposition of m, by Newton's iteration.
40
+ dxa::Mat rotation_of(dxa::Mat r) {
41
+ for (int step = 0; step < 100; ++step) {
42
+ const auto inverse = dxa::inverse(r);
43
+ if (!inverse) {
44
+ break;
45
+ }
46
+ const dxa::Mat back = dxa::transpose(*inverse);
47
+ double change = 0.0;
48
+ for (std::size_t k = 0; k < 9; ++k) {
49
+ const double next = 0.5 * (r[k] + back[k]);
50
+ change = std::max(change, std::abs(next - r[k]));
51
+ r[k] = next;
52
+ }
53
+ if (change < 1e-15) {
54
+ break;
55
+ }
56
+ }
57
+ return r;
58
+ }
59
+
60
+ // The vector from atom a to atom b, the nearest image along periodic axes.
61
+ dxa::Vec bond(const dxa::ClusterInput& input, std::int64_t a, std::int64_t b) {
62
+ const double* x = input.positions;
63
+ double f[3];
64
+ for (int e = 0; e < 3; ++e) {
65
+ f[e] = 0.0;
66
+ for (int k = 0; k < 3; ++k) {
67
+ f[e] += (x[3 * b + k] - x[3 * a + k]) * input.inverse[3 * k + e];
68
+ }
69
+ if (input.pbc[e]) {
70
+ f[e] -= std::round(f[e]);
71
+ }
72
+ }
73
+ dxa::Vec d{};
74
+ for (int k = 0; k < 3; ++k) {
75
+ d[static_cast<std::size_t>(k)] =
76
+ f[0] * input.matrix[k] + f[1] * input.matrix[3 + k] + f[2] * input.matrix[6 + k];
77
+ }
78
+ return d;
79
+ }
80
+
81
+ // The spatial Burgers vector of each line (3 each): its vector turned by the
82
+ // orientation of its cluster, or, where the lattice about the line is turned
83
+ // from the cluster's frame, by that rotation times the stretch of the cluster.
84
+ std::vector<double> spatial_burgers(const dxa::Network& network, const dxa::Clusters& clusters,
85
+ const dxa::ClusterInput& input, const double* origin,
86
+ const bool* pbc) {
87
+ const std::int64_t n = input.n;
88
+ const auto& segments = network.segments;
89
+ // the points of the lines, put into the box, after the atoms
90
+ std::vector<double> places(input.positions, input.positions + 3 * n);
91
+ std::vector<std::int64_t> owner;
92
+ for (std::size_t s = 0; s < segments.size(); ++s) {
93
+ const std::vector<double>& points = segments[s].points;
94
+ for (std::size_t q = 0; q + 2 < points.size(); q += 3) {
95
+ double f[3];
96
+ for (int e = 0; e < 3; ++e) {
97
+ f[e] = 0.0;
98
+ for (int k = 0; k < 3; ++k) {
99
+ f[e] += (points[q + static_cast<std::size_t>(k)] - origin[k]) *
100
+ input.inverse[3 * k + e];
101
+ }
102
+ if (pbc[e]) {
103
+ f[e] -= std::floor(f[e]);
104
+ }
105
+ }
106
+ for (int k = 0; k < 3; ++k) {
107
+ places.push_back(origin[k] + f[0] * input.matrix[k] + f[1] * input.matrix[3 + k] +
108
+ f[2] * input.matrix[6 + k]);
109
+ }
110
+ owner.push_back(static_cast<std::int64_t>(s));
111
+ }
112
+ }
113
+ std::vector<std::pair<std::int64_t, std::int64_t>> near; // (line, atom)
114
+ if (!owner.empty() && n > 0) {
115
+ const auto total = n + static_cast<std::int64_t>(owner.size());
116
+ const neighbor::CellGrid grid(places.data(), total, input.matrix, origin, pbc, kAbout);
117
+ for (std::int64_t t = 0; t < total; ++t) {
118
+ const auto i = static_cast<std::int64_t>(grid.atom(t));
119
+ if (i < n) {
120
+ continue;
121
+ }
122
+ const std::int64_t s = owner[static_cast<std::size_t>(i - n)];
123
+ const std::int64_t c = segments[static_cast<std::size_t>(s)].cluster;
124
+ grid.visit(t, [&](index_t j, const std::int32_t*, double) {
125
+ if (j < n && c >= 0 && clusters.cluster[static_cast<std::size_t>(j)] == c) {
126
+ near.emplace_back(s, static_cast<std::int64_t>(j));
127
+ }
128
+ });
129
+ }
130
+ std::sort(near.begin(), near.end());
131
+ near.erase(std::unique(near.begin(), near.end()), near.end());
132
+ }
133
+ // the sums of the fits of the lattice about each line
134
+ std::vector<dxa::Mat> real(segments.size(), dxa::Mat{}), ideal(segments.size(), dxa::Mat{});
135
+ std::vector<std::int64_t> count(segments.size(), 0);
136
+ for (const auto& [s, a] : near) {
137
+ const dxa::Lattice* l = dxa::lattice(input.structure[a]);
138
+ if (l == nullptr) {
139
+ continue;
140
+ }
141
+ const dxa::Mat& turn = l->group[static_cast<std::size_t>(clusters.rotation[static_cast<std::size_t>(a)])];
142
+ dxa::Mat& r = real[static_cast<std::size_t>(s)];
143
+ dxa::Mat& v2 = ideal[static_cast<std::size_t>(s)];
144
+ for (int k = 0; k < l->neighbors; ++k) {
145
+ const auto j = static_cast<std::int64_t>(input.neighbors[16 * a + k]);
146
+ if (j < 0) {
147
+ continue;
148
+ }
149
+ const dxa::Vec v = dxa::turn(turn, l->vectors[static_cast<std::size_t>(k)]);
150
+ const dxa::Vec d = bond(input, a, j);
151
+ for (std::size_t p = 0; p < 3; ++p) {
152
+ for (std::size_t q = 0; q < 3; ++q) {
153
+ r[3 * p + q] += d[p] * v[q];
154
+ v2[3 * p + q] += v[p] * v[q];
155
+ }
156
+ }
157
+ }
158
+ ++count[static_cast<std::size_t>(s)];
159
+ }
160
+ std::vector<double> out;
161
+ out.reserve(3 * segments.size());
162
+ for (std::size_t s = 0; s < segments.size(); ++s) {
163
+ const dxa::Segment& segment = segments[s];
164
+ dxa::Mat orientation{};
165
+ if (segment.cluster >= 0) {
166
+ std::copy_n(clusters.orientation.begin() + 9 * segment.cluster, 9, orientation.begin());
167
+ }
168
+ dxa::Vec spatial = dxa::turn(orientation, segment.burgers);
169
+ const auto fitted = dxa::inverse(ideal[s]);
170
+ if (segment.cluster >= 0 && count[s] >= kFewest && fitted) {
171
+ const dxa::Mat here = rotation_of(dxa::multiply(real[s], *fitted));
172
+ const dxa::Mat mean = rotation_of(orientation);
173
+ const dxa::Mat between = dxa::multiply(here, dxa::transpose(mean));
174
+ const double cosine =
175
+ std::clamp(0.5 * (between[0] + between[4] + between[8] - 1.0), -1.0, 1.0);
176
+ if (std::acos(cosine) > kTurned) {
177
+ const dxa::Mat stretch = dxa::multiply(dxa::transpose(mean), orientation);
178
+ spatial = dxa::turn(dxa::multiply(here, stretch), segment.burgers);
179
+ }
180
+ }
181
+ out.insert(out.end(), spatial.begin(), spatial.end());
182
+ }
183
+ return out;
184
+ }
185
+
186
+ // A line traced in a sliver of the crystal gets its Burgers vector in the
187
+ // frame of the largest cluster of the crystal related to the sliver, through
188
+ // one cluster at most; the frame of a sliver is fitted to a few atoms only.
189
+ void out_of_slivers(dxa::Network& network, const dxa::Clusters& clusters,
190
+ const dxa::Mapping& mapping, int crystal) {
191
+ const auto count = static_cast<std::int64_t>(clusters.structure.size());
192
+ for (dxa::Segment& segment : network.segments) {
193
+ const std::int64_t c = segment.cluster;
194
+ if (c < 0 || clusters.structure[static_cast<std::size_t>(c)] != crystal ||
195
+ clusters.size[static_cast<std::size_t>(c)] >= kSliver) {
196
+ continue;
197
+ }
198
+ std::int64_t best = -1;
199
+ dxa::Mat into{};
200
+ for (std::int64_t k = 0; k < count; ++k) {
201
+ const auto size = clusters.size[static_cast<std::size_t>(k)];
202
+ if (k == c || clusters.structure[static_cast<std::size_t>(k)] != crystal ||
203
+ size <= clusters.size[static_cast<std::size_t>(c)] ||
204
+ (best >= 0 && size <= clusters.size[static_cast<std::size_t>(best)])) {
205
+ continue;
206
+ }
207
+ if (const auto m = mapping.transition(c, k)) {
208
+ best = k;
209
+ into = *m;
210
+ }
211
+ }
212
+ if (best >= 0) {
213
+ segment.burgers = dxa::turn(into, segment.burgers);
214
+ segment.cluster = best;
215
+ }
216
+ }
217
+ }
218
+
219
+ // The mesh of the triangles faces of the interface mesh and of caps, the
220
+ // corners of each triangle images of its vertices, the vertices those it
221
+ // uses.
222
+ SurfaceMesh triangles(const dxa::InterfaceMesh& mesh, const std::vector<std::int64_t>& faces,
223
+ const std::vector<dxa::Cap>& caps, const double* matrix,
224
+ const double* inverse, const double* origin, const bool* pbc) {
225
+ SurfaceMesh out;
226
+ std::vector<std::int64_t> index(static_cast<std::size_t>(mesh.vertices()), -1);
227
+ auto vertex = [&](std::int64_t v) {
228
+ auto& at = index[static_cast<std::size_t>(v)];
229
+ if (at < 0) {
230
+ at = static_cast<std::int64_t>(out.atoms.size());
231
+ out.atoms.push_back(mesh.atoms[static_cast<std::size_t>(v)]);
232
+ const double* p = mesh.positions.data() + 3 * v;
233
+ out.vertices.insert(out.vertices.end(), p, p + 3);
234
+ }
235
+ return at;
236
+ };
237
+ // the periodic image of a vertex at the corner at point
238
+ auto corner = [&](std::int64_t v, const dxa::Vec& point) {
239
+ out.faces.push_back(v);
240
+ for (int k = 0; k < 3; ++k) {
241
+ double f = 0.0;
242
+ for (int d = 0; d < 3; ++d) {
243
+ f += (point[static_cast<std::size_t>(d)] -
244
+ out.vertices[static_cast<std::size_t>(3 * v + d)]) *
245
+ inverse[3 * d + k];
246
+ }
247
+ out.shifts.push_back(static_cast<std::int8_t>(pbc[k] ? std::lround(f) : 0));
248
+ }
249
+ };
250
+ auto at = [&](std::int64_t v) {
251
+ const double* p = mesh.positions.data() + 3 * v;
252
+ return dxa::Vec{p[0], p[1], p[2]};
253
+ };
254
+ auto physical = [&](std::int64_t e) {
255
+ const double* p = mesh.physical.data() + 3 * e;
256
+ return dxa::Vec{p[0], p[1], p[2]};
257
+ };
258
+ for (const std::int64_t f : faces) {
259
+ dxa::Vec point = at(mesh.start[static_cast<std::size_t>(3 * f)]);
260
+ for (std::int64_t e = 3 * f; e < 3 * f + 3; ++e) {
261
+ corner(vertex(mesh.start[static_cast<std::size_t>(e)]), point);
262
+ point = dxa::add(point, physical(e));
263
+ }
264
+ }
265
+ for (const dxa::Cap& cap : caps) {
266
+ // the end of the line in the box
267
+ dxa::Vec apex = cap.apex;
268
+ for (int k = 0; k < 3; ++k) {
269
+ if (!pbc[k]) {
270
+ continue;
271
+ }
272
+ double f = 0.0;
273
+ for (int d = 0; d < 3; ++d) {
274
+ f += (apex[static_cast<std::size_t>(d)] - origin[d]) * inverse[3 * d + k];
275
+ }
276
+ for (int d = 0; d < 3; ++d) {
277
+ apex[static_cast<std::size_t>(d)] -= std::floor(f) * matrix[3 * k + d];
278
+ }
279
+ }
280
+ const auto tip = static_cast<std::int64_t>(out.atoms.size());
281
+ out.atoms.push_back(-1);
282
+ out.vertices.insert(out.vertices.end(), apex.begin(), apex.end());
283
+ for (const std::int64_t e : cap.edges) {
284
+ const dxa::Vec from = at(mesh.end(e));
285
+ corner(vertex(mesh.end(e)), from);
286
+ corner(vertex(mesh.start[static_cast<std::size_t>(e)]), dxa::minus(from, physical(e)));
287
+ // the image of the end nearest the edge
288
+ dxa::Vec near = dxa::minus(cap.apex, from);
289
+ for (int k = 0; k < 3; ++k) {
290
+ if (!pbc[k]) {
291
+ continue;
292
+ }
293
+ double f = 0.0;
294
+ for (int d = 0; d < 3; ++d) {
295
+ f += near[static_cast<std::size_t>(d)] * inverse[3 * d + k];
296
+ }
297
+ for (int d = 0; d < 3; ++d) {
298
+ near[static_cast<std::size_t>(d)] -= std::round(f) * matrix[3 * k + d];
299
+ }
300
+ }
301
+ corner(tip, dxa::add(from, near));
302
+ }
303
+ }
304
+ return out;
305
+ }
306
+
307
+ // The line whose core holds each atom, -1 for none. The core of a line is
308
+ // the bad crystal its circuits enclose: the tetrahedra that are not good and
309
+ // not empty space behind the triangles its circuits took for good, and those
310
+ // reached from them through such tetrahedra; where they meet those reached
311
+ // from the triangles of the other defects, each tetrahedron goes to the
312
+ // nearest in steps, a line before the other defects and the first line
313
+ // before the others. An atom at a corner of tetrahedra of several lines
314
+ // is of the first.
315
+ std::vector<std::int64_t> core_atoms(const dxa::InterfaceMesh& mesh, const Tetrahedra& tetrahedra,
316
+ const std::vector<std::uint8_t>& good, double alpha,
317
+ const std::vector<std::int64_t>& face_line, std::int64_t n) {
318
+ constexpr std::int64_t kFree = -1, kDefect = -2, kNot = -3;
319
+ const std::size_t count = tetrahedra.radii.size();
320
+ // of each tetrahedron: the line, the other defects, not reached yet, or
321
+ // not of the bad crystal
322
+ std::vector<std::int64_t> owner(count);
323
+ for (std::size_t t = 0; t < count; ++t) {
324
+ const double r = tetrahedra.radii[t];
325
+ owner[t] = !good[t] && r * r < alpha ? kFree : kNot;
326
+ }
327
+ auto better = [](std::int64_t a, std::int64_t b) { return a >= 0 && (b < 0 || a < b); };
328
+ std::vector<std::int32_t> depth(count, 0);
329
+ std::vector<std::int64_t> reached;
330
+ for (std::int64_t f = 0; f < mesh.faces(); ++f) {
331
+ const std::int64_t t = mesh.outside[static_cast<std::size_t>(f)];
332
+ if (t < 0 || owner[static_cast<std::size_t>(t)] == kNot) {
333
+ continue;
334
+ }
335
+ const std::int64_t line = face_line[static_cast<std::size_t>(f)];
336
+ const std::int64_t label = line >= 0 ? line : kDefect;
337
+ std::int64_t& of = owner[static_cast<std::size_t>(t)];
338
+ if (of == kFree) {
339
+ reached.push_back(t);
340
+ of = label;
341
+ } else if (better(label, of)) {
342
+ of = label;
343
+ }
344
+ }
345
+ for (std::size_t head = 0; head < reached.size(); ++head) {
346
+ const auto t = static_cast<std::size_t>(reached[head]);
347
+ for (int s = 0; s < 4; ++s) {
348
+ const std::int64_t u = tetrahedra.neighbors[4 * t + static_cast<std::size_t>(s)];
349
+ if (u < 0) {
350
+ continue;
351
+ }
352
+ std::int64_t& of = owner[static_cast<std::size_t>(u)];
353
+ if (of == kFree) {
354
+ of = owner[t];
355
+ depth[static_cast<std::size_t>(u)] = depth[t] + 1;
356
+ reached.push_back(u);
357
+ } else if (of != kNot && depth[static_cast<std::size_t>(u)] == depth[t] + 1 &&
358
+ better(owner[t], of)) {
359
+ of = owner[t];
360
+ }
361
+ }
362
+ }
363
+ std::vector<std::int64_t> core(static_cast<std::size_t>(n), -1);
364
+ for (const std::int64_t t : reached) {
365
+ const std::int64_t line = owner[static_cast<std::size_t>(t)];
366
+ if (line < 0) {
367
+ continue;
368
+ }
369
+ for (int k = 0; k < 4; ++k) {
370
+ std::int64_t& of = core[static_cast<std::size_t>(
371
+ tetrahedra.atoms[static_cast<std::size_t>(4 * t + k)])];
372
+ if (of < 0 || line < of) {
373
+ of = line;
374
+ }
375
+ }
376
+ }
377
+ return core;
378
+ }
379
+
380
+ } // namespace
381
+
382
+ Dislocations dislocation_analysis(const double* positions, const double* jittered, std::int64_t n,
383
+ const double* matrix, const double* inverse,
384
+ const double* origin, const bool* pbc,
385
+ const DislocationOptions& options, const Control& control) {
386
+ if (dxa::lattice(options.crystal) == nullptr) {
387
+ throw std::invalid_argument("no lattice for this structure");
388
+ }
389
+ constexpr int kStages = 5;
390
+ Dislocations out;
391
+ if (options.core) {
392
+ out.core.assign(static_cast<std::size_t>(n), -1);
393
+ }
394
+ out.structures = dxa::find_structures(positions, n, matrix, origin, pbc, options.crystal,
395
+ options.defects, stage(control, 0, kStages),
396
+ options.low_ca);
397
+ dxa::ClusterInput input;
398
+ input.n = n;
399
+ input.structure = out.structures.structure.data();
400
+ input.neighbors = out.structures.neighbors.data();
401
+ input.positions = positions;
402
+ input.matrix = matrix;
403
+ input.inverse = inverse;
404
+ input.pbc = pbc;
405
+ input.crystal = options.crystal;
406
+ out.clusters = dxa::build_clusters(input);
407
+ if (out.clusters.structure.empty()) {
408
+ return out;
409
+ }
410
+ // tetrahedra whose circumscribed sphere has a squared radius above five
411
+ // Å times the largest neighbor cutoff are empty space, as in OVITO (the
412
+ // positions are in Å); the walls of the open directions lie beyond the
413
+ // reach of such a sphere
414
+ const double alpha = 5 * dxa::neighbor_cutoff(input);
415
+ double walls[9], corner[3];
416
+ std::copy(matrix, matrix + 9, walls);
417
+ std::copy(origin, origin + 3, corner);
418
+ for (int axis = 0; axis < 3; ++axis) {
419
+ if (pbc[axis]) {
420
+ continue;
421
+ }
422
+ double spacing = 0.0; // between the faces of the box across the axis
423
+ for (int d = 0; d < 3; ++d) {
424
+ spacing += inverse[3 * d + axis] * inverse[3 * d + axis];
425
+ }
426
+ spacing = 1.0 / std::sqrt(spacing);
427
+ double low = 0.0, high = 0.0;
428
+ for (std::int64_t i = 0; i < n; ++i) {
429
+ double f = 0.0;
430
+ for (int d = 0; d < 3; ++d) {
431
+ f += (jittered[3 * i + d] - origin[d]) * inverse[3 * d + axis];
432
+ }
433
+ low = i == 0 ? f : std::min(low, f);
434
+ high = i == 0 ? f : std::max(high, f);
435
+ }
436
+ const double margin = (std::sqrt(alpha) + 1.0) / spacing;
437
+ low -= margin;
438
+ high += margin;
439
+ for (int d = 0; d < 3; ++d) {
440
+ corner[d] += low * matrix[3 * axis + d];
441
+ walls[3 * axis + d] = (high - low) * matrix[3 * axis + d];
442
+ }
443
+ }
444
+ const Tetrahedra tetrahedra =
445
+ delaunay(voronoi_vertices(jittered, n, walls, corner, pbc, stage(control, 1, kStages)),
446
+ stage(control, 2, kStages));
447
+ if (tetrahedra.repeated) {
448
+ throw std::invalid_argument("an atom meets its own periodic image");
449
+ }
450
+ const dxa::Mapping mapping(input, out.clusters, tetrahedra);
451
+ const auto count = static_cast<std::int64_t>(tetrahedra.radii.size());
452
+ std::vector<std::uint8_t> good(static_cast<std::size_t>(count));
453
+ parallel_for(
454
+ count, 0,
455
+ [&](std::int64_t begin, std::int64_t end) {
456
+ for (std::int64_t t = begin; t < end; ++t) {
457
+ good[static_cast<std::size_t>(t)] = mapping.good(t) ? 1 : 0;
458
+ }
459
+ },
460
+ stage(control, 3, kStages));
461
+ const dxa::InterfaceMesh mesh =
462
+ dxa::interface_mesh(input, mapping, tetrahedra, good, jittered, alpha);
463
+ out.network = dxa::trace_dislocations(mesh, input, out.clusters, options.max_circuit,
464
+ options.stretch, stage(control, 4, kStages));
465
+ if (options.core) {
466
+ out.core = core_atoms(mesh, tetrahedra, good, alpha, out.network.face_line, n);
467
+ }
468
+ out_of_slivers(out.network, out.clusters, mapping, options.crystal);
469
+ dxa::smooth_lines(out.network, options.separation, options.smoothing);
470
+ out.spatial = spatial_burgers(out.network, out.clusters, input, origin, pbc);
471
+ out.defects =
472
+ triangles(mesh, out.network.faces, out.network.caps, matrix, inverse, origin, pbc);
473
+ smooth_mesh(out.defects, matrix, options.mesh_smoothing);
474
+ if (options.interface) {
475
+ std::vector<std::int64_t> all(static_cast<std::size_t>(mesh.faces()));
476
+ for (std::int64_t f = 0; f < mesh.faces(); ++f) {
477
+ all[static_cast<std::size_t>(f)] = f;
478
+ }
479
+ out.interface = triangles(mesh, all, {}, matrix, inverse, origin, pbc);
480
+ }
481
+ return out;
482
+ }
483
+
484
+ } // namespace mdapy::analysis