@mat3ra/wode 2025.10.1-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 (252) hide show
  1. package/.babelrc +17 -0
  2. package/LICENSE.md +15 -0
  3. package/README.md +164 -0
  4. package/assets/subworkflows/deepmd/deepmd.yml +31 -0
  5. package/assets/subworkflows/deepmd/espresso_cp_md.yml +16 -0
  6. package/assets/subworkflows/espresso/average_electrostatic_potential_find_minima.yml +27 -0
  7. package/assets/subworkflows/espresso/average_electrostatic_potential_via_band_structure.yml +67 -0
  8. package/assets/subworkflows/espresso/band_gap.yml +21 -0
  9. package/assets/subworkflows/espresso/band_gap_hse_dos.yml +30 -0
  10. package/assets/subworkflows/espresso/band_structure.yml +26 -0
  11. package/assets/subworkflows/espresso/band_structure_dos.yml +34 -0
  12. package/assets/subworkflows/espresso/band_structure_hse.yml +30 -0
  13. package/assets/subworkflows/espresso/band_structure_magn.yml +31 -0
  14. package/assets/subworkflows/espresso/band_structure_soc.yml +30 -0
  15. package/assets/subworkflows/espresso/dielectric_tensor.yml +35 -0
  16. package/assets/subworkflows/espresso/dos.yml +24 -0
  17. package/assets/subworkflows/espresso/electronic_density_mesh.yml +19 -0
  18. package/assets/subworkflows/espresso/esm.yml +14 -0
  19. package/assets/subworkflows/espresso/esm_relax.yml +14 -0
  20. package/assets/subworkflows/espresso/espresso_extract_kpoints.yml +16 -0
  21. package/assets/subworkflows/espresso/espresso_xml_get_qpt_irr.yml +12 -0
  22. package/assets/subworkflows/espresso/fixed_cell_relaxation.yml +16 -0
  23. package/assets/subworkflows/espresso/gw_band_structure_band_gap_full_frequency.yml +22 -0
  24. package/assets/subworkflows/espresso/gw_band_structure_band_gap_plasmon_pole.yml +22 -0
  25. package/assets/subworkflows/espresso/hubbard_u_hp.yml +21 -0
  26. package/assets/subworkflows/espresso/kpoint_convergence.yml +86 -0
  27. package/assets/subworkflows/espresso/neb.yml +16 -0
  28. package/assets/subworkflows/espresso/ph_init_qpoints.yml +14 -0
  29. package/assets/subworkflows/espresso/ph_single_irr_qpt.yml +14 -0
  30. package/assets/subworkflows/espresso/phonon_dispersions.yml +29 -0
  31. package/assets/subworkflows/espresso/phonon_dos.yml +29 -0
  32. package/assets/subworkflows/espresso/phonon_dos_dispersion.yml +34 -0
  33. package/assets/subworkflows/espresso/phonon_reduce.yml +29 -0
  34. package/assets/subworkflows/espresso/post_processor.yml +14 -0
  35. package/assets/subworkflows/espresso/pre_processor.yml +14 -0
  36. package/assets/subworkflows/espresso/pw_scf.yml +16 -0
  37. package/assets/subworkflows/espresso/recalculate_bands.yml +19 -0
  38. package/assets/subworkflows/espresso/surface_energy.yml +16 -0
  39. package/assets/subworkflows/espresso/total_energy.yml +16 -0
  40. package/assets/subworkflows/espresso/valence_band_offset_calc_from_previous_esp_vbm.yml +35 -0
  41. package/assets/subworkflows/espresso/variable_cell_relaxation.yml +18 -0
  42. package/assets/subworkflows/espresso/zero_point_energy.yml +19 -0
  43. package/assets/subworkflows/jupyterLab/jupyter_notebook.yml +17 -0
  44. package/assets/subworkflows/nwchem/total_energy.yml +16 -0
  45. package/assets/subworkflows/python/ml/classification_tail.yml +56 -0
  46. package/assets/subworkflows/python/ml/clustering_tail.yml +62 -0
  47. package/assets/subworkflows/python/ml/regression_tail.yml +56 -0
  48. package/assets/subworkflows/python/ml/train_head.yml +61 -0
  49. package/assets/subworkflows/python/python_script.yml +14 -0
  50. package/assets/subworkflows/shell/batch_espresso_pwscf.yml +14 -0
  51. package/assets/subworkflows/shell/hello_world.yml +14 -0
  52. package/assets/subworkflows/vasp/band_gap.yml +21 -0
  53. package/assets/subworkflows/vasp/band_structure.yml +21 -0
  54. package/assets/subworkflows/vasp/band_structure_dos.yml +23 -0
  55. package/assets/subworkflows/vasp/dos.yml +18 -0
  56. package/assets/subworkflows/vasp/fixed_cell_relaxation.yml +16 -0
  57. package/assets/subworkflows/vasp/initial_final_total_energies.yml +25 -0
  58. package/assets/subworkflows/vasp/kpoint_convergence.yml +89 -0
  59. package/assets/subworkflows/vasp/neb_subworkflow.yml +16 -0
  60. package/assets/subworkflows/vasp/prepare_images.yml +16 -0
  61. package/assets/subworkflows/vasp/recalculate_bands.yml +16 -0
  62. package/assets/subworkflows/vasp/surface_energy.yml +18 -0
  63. package/assets/subworkflows/vasp/total_energy.yml +16 -0
  64. package/assets/subworkflows/vasp/variable_cell_relaxation.yml +18 -0
  65. package/assets/subworkflows/vasp/zero_point_energy.yml +16 -0
  66. package/assets/workflows/deepmd/deepmd_md.yml +6 -0
  67. package/assets/workflows/espresso/band_gap.yml +4 -0
  68. package/assets/workflows/espresso/band_gap_dos_hse.yml +4 -0
  69. package/assets/workflows/espresso/band_structure.yml +4 -0
  70. package/assets/workflows/espresso/band_structure_dos.yml +4 -0
  71. package/assets/workflows/espresso/band_structure_hse.yml +14 -0
  72. package/assets/workflows/espresso/band_structure_magn.yml +7 -0
  73. package/assets/workflows/espresso/band_structure_soc.yml +7 -0
  74. package/assets/workflows/espresso/dielectric_tensor.yml +4 -0
  75. package/assets/workflows/espresso/dos.yml +4 -0
  76. package/assets/workflows/espresso/electronic_density_mesh.yml +4 -0
  77. package/assets/workflows/espresso/esm.yml +4 -0
  78. package/assets/workflows/espresso/esm_relax.yml +4 -0
  79. package/assets/workflows/espresso/fixed_cell_relaxation.yml +4 -0
  80. package/assets/workflows/espresso/gw_band_structure_band_gap_full_frequency.yml +4 -0
  81. package/assets/workflows/espresso/gw_band_structure_band_gap_plasmon_pole.yml +4 -0
  82. package/assets/workflows/espresso/hubbard_u_hp.yml +7 -0
  83. package/assets/workflows/espresso/kpoint_convergence.yml +4 -0
  84. package/assets/workflows/espresso/neb.yml +4 -0
  85. package/assets/workflows/espresso/phonon_dispersions.yml +4 -0
  86. package/assets/workflows/espresso/phonon_dos.yml +4 -0
  87. package/assets/workflows/espresso/phonon_dos_dispersion.yml +4 -0
  88. package/assets/workflows/espresso/phonon_map.yml +28 -0
  89. package/assets/workflows/espresso/recalculate_bands.yml +4 -0
  90. package/assets/workflows/espresso/surface_energy.yml +4 -0
  91. package/assets/workflows/espresso/total_energy.yml +4 -0
  92. package/assets/workflows/espresso/valence_band_offset.yml +171 -0
  93. package/assets/workflows/espresso/variable_cell_relaxation.yml +4 -0
  94. package/assets/workflows/espresso/zero_point_energy.yml +4 -0
  95. package/assets/workflows/jupyterLab/jupyter_notebook.yml +4 -0
  96. package/assets/workflows/nwchem/total_energy.yml +4 -0
  97. package/assets/workflows/python/ml/classification_workflow.yml +9 -0
  98. package/assets/workflows/python/ml/clustering_workflow.yml +9 -0
  99. package/assets/workflows/python/ml/regression_workflow.yml +9 -0
  100. package/assets/workflows/python/python_script.yml +4 -0
  101. package/assets/workflows/shell/batch_espresso_pwscf.yml +4 -0
  102. package/assets/workflows/shell/hello_world.yml +4 -0
  103. package/assets/workflows/vasp/band_gap.yml +4 -0
  104. package/assets/workflows/vasp/band_structure.yml +4 -0
  105. package/assets/workflows/vasp/band_structure_dos.yml +4 -0
  106. package/assets/workflows/vasp/dos.yml +4 -0
  107. package/assets/workflows/vasp/fixed_cell_relaxation.yml +4 -0
  108. package/assets/workflows/vasp/kpoint_convergence.yml +4 -0
  109. package/assets/workflows/vasp/neb.yml +8 -0
  110. package/assets/workflows/vasp/recalculate_bands.yml +4 -0
  111. package/assets/workflows/vasp/surface_energy.yml +4 -0
  112. package/assets/workflows/vasp/total_energy.yml +4 -0
  113. package/assets/workflows/vasp/variable_cell_relaxation.yml +4 -0
  114. package/assets/workflows/vasp/zero_point_energy.yml +4 -0
  115. package/build_workflows.js +65 -0
  116. package/dist/context/context.js +49 -0
  117. package/dist/context/mixins/ApplicationContextMixin.js +19 -0
  118. package/dist/context/mixins/JobContextMixin.js +39 -0
  119. package/dist/context/mixins/MaterialContextMixin.js +40 -0
  120. package/dist/context/mixins/MaterialsContextMixin.js +19 -0
  121. package/dist/context/mixins/MaterialsSetContextMixin.js +25 -0
  122. package/dist/context/mixins/MethodDataContextMixin.js +48 -0
  123. package/dist/context/mixins/WorkflowContextMixin.js +28 -0
  124. package/dist/context/providers/BoundaryConditionsFormDataProvider.js +86 -0
  125. package/dist/context/providers/CollinearMagnetizationContextProvider.js +113 -0
  126. package/dist/context/providers/HubbardContextProviderLegacy.js +81 -0
  127. package/dist/context/providers/HubbardJContextProvider.js +74 -0
  128. package/dist/context/providers/HubbardUContextProvider.js +77 -0
  129. package/dist/context/providers/HubbardVContextProvider.js +104 -0
  130. package/dist/context/providers/IonDynamicsContextProvider.js +62 -0
  131. package/dist/context/providers/MLSettingsContextProvider.js +52 -0
  132. package/dist/context/providers/MLTrainTestSplitContextProvider.js +48 -0
  133. package/dist/context/providers/NEBFormDataProvider.js +38 -0
  134. package/dist/context/providers/NonCollinearMagnetizationContextProvider.js +253 -0
  135. package/dist/context/providers/PlanewaveCutoffsContextProvider.js +67 -0
  136. package/dist/context/providers/PointsGridFormDataProvider.js +272 -0
  137. package/dist/context/providers/PointsPathFormDataProvider.js +155 -0
  138. package/dist/context/providers/by_application/ExecutableContextProvider.js +17 -0
  139. package/dist/context/providers/by_application/espresso/QENEBContextProvider.js +60 -0
  140. package/dist/context/providers/by_application/espresso/QEPWXContextProvider.js +149 -0
  141. package/dist/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.js +84 -0
  142. package/dist/context/providers/by_application/vasp/VASPContextProvider.js +64 -0
  143. package/dist/context/providers/by_application/vasp/VASPNEBContextProvider.js +56 -0
  144. package/dist/context/providers/settings.js +37 -0
  145. package/dist/context/providers.js +199 -0
  146. package/dist/enums.js +65 -0
  147. package/dist/index.js +64 -0
  148. package/dist/patch.js +19 -0
  149. package/dist/subworkflows/convergence/factory.js +35 -0
  150. package/dist/subworkflows/convergence/non_uniform_kgrid.js +31 -0
  151. package/dist/subworkflows/convergence/parameter.js +70 -0
  152. package/dist/subworkflows/convergence/uniform_kgrid.js +26 -0
  153. package/dist/subworkflows/convergence.js +189 -0
  154. package/dist/subworkflows/create.js +285 -0
  155. package/dist/subworkflows/dynamic/espresso/getQpointIrrep.js +34 -0
  156. package/dist/subworkflows/dynamic/index.js +19 -0
  157. package/dist/subworkflows/dynamic/surfaceEnergy.js +67 -0
  158. package/dist/subworkflows/index.js +19 -0
  159. package/dist/subworkflows/subworkflow.js +279 -0
  160. package/dist/units/assertion.js +37 -0
  161. package/dist/units/assignment.js +42 -0
  162. package/dist/units/base.js +91 -0
  163. package/dist/units/builders/AssertionUnitConfigBuilder.js +34 -0
  164. package/dist/units/builders/AssignmentUnitConfigBuilder.js +41 -0
  165. package/dist/units/builders/ExecutionUnitConfigBuilder.js +67 -0
  166. package/dist/units/builders/IOUnitConfigBuilder.js +54 -0
  167. package/dist/units/builders/UnitConfigBuilder.js +79 -0
  168. package/dist/units/builders/index.js +18 -0
  169. package/dist/units/condition.js +52 -0
  170. package/dist/units/execution.js +222 -0
  171. package/dist/units/factory.js +53 -0
  172. package/dist/units/index.js +82 -0
  173. package/dist/units/io.js +148 -0
  174. package/dist/units/map.js +38 -0
  175. package/dist/units/processing.js +41 -0
  176. package/dist/units/reduce.js +24 -0
  177. package/dist/units/subworkflow.js +23 -0
  178. package/dist/utils.js +92 -0
  179. package/dist/workflows/create.js +312 -0
  180. package/dist/workflows/default.js +41 -0
  181. package/dist/workflows/index.js +108 -0
  182. package/dist/workflows/relaxation.js +37 -0
  183. package/dist/workflows/workflow.js +303 -0
  184. package/package.json +94 -0
  185. package/src/context/context.js +47 -0
  186. package/src/context/mixins/ApplicationContextMixin.js +19 -0
  187. package/src/context/mixins/JobContextMixin.js +36 -0
  188. package/src/context/mixins/MaterialContextMixin.js +41 -0
  189. package/src/context/mixins/MaterialsContextMixin.js +18 -0
  190. package/src/context/mixins/MaterialsSetContextMixin.js +24 -0
  191. package/src/context/mixins/MethodDataContextMixin.js +48 -0
  192. package/src/context/mixins/WorkflowContextMixin.js +25 -0
  193. package/src/context/providers/BoundaryConditionsFormDataProvider.js +80 -0
  194. package/src/context/providers/CollinearMagnetizationContextProvider.js +117 -0
  195. package/src/context/providers/HubbardContextProviderLegacy.js +75 -0
  196. package/src/context/providers/HubbardJContextProvider.js +73 -0
  197. package/src/context/providers/HubbardUContextProvider.js +100 -0
  198. package/src/context/providers/HubbardVContextProvider.js +111 -0
  199. package/src/context/providers/IonDynamicsContextProvider.js +56 -0
  200. package/src/context/providers/MLSettingsContextProvider.js +48 -0
  201. package/src/context/providers/MLTrainTestSplitContextProvider.js +45 -0
  202. package/src/context/providers/NEBFormDataProvider.js +32 -0
  203. package/src/context/providers/NonCollinearMagnetizationContextProvider.js +269 -0
  204. package/src/context/providers/PlanewaveCutoffsContextProvider.js +68 -0
  205. package/src/context/providers/PointsGridFormDataProvider.js +285 -0
  206. package/src/context/providers/PointsPathFormDataProvider.js +165 -0
  207. package/src/context/providers/by_application/ExecutableContextProvider.js +10 -0
  208. package/src/context/providers/by_application/espresso/QENEBContextProvider.js +56 -0
  209. package/src/context/providers/by_application/espresso/QEPWXContextProvider.js +166 -0
  210. package/src/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.js +86 -0
  211. package/src/context/providers/by_application/vasp/VASPContextProvider.js +56 -0
  212. package/src/context/providers/by_application/vasp/VASPNEBContextProvider.js +46 -0
  213. package/src/context/providers/settings.js +38 -0
  214. package/src/context/providers.js +140 -0
  215. package/src/enums.js +65 -0
  216. package/src/index.js +17 -0
  217. package/src/patch.js +12 -0
  218. package/src/subworkflows/convergence/factory.js +14 -0
  219. package/src/subworkflows/convergence/non_uniform_kgrid.js +28 -0
  220. package/src/subworkflows/convergence/parameter.js +58 -0
  221. package/src/subworkflows/convergence/uniform_kgrid.js +22 -0
  222. package/src/subworkflows/convergence.js +196 -0
  223. package/src/subworkflows/create.js +201 -0
  224. package/src/subworkflows/dynamic/espresso/getQpointIrrep.js +35 -0
  225. package/src/subworkflows/dynamic/index.js +8 -0
  226. package/src/subworkflows/dynamic/surfaceEnergy.js +124 -0
  227. package/src/subworkflows/index.js +2 -0
  228. package/src/subworkflows/subworkflow.js +329 -0
  229. package/src/units/assertion.js +29 -0
  230. package/src/units/assignment.js +34 -0
  231. package/src/units/base.js +97 -0
  232. package/src/units/builders/AssertionUnitConfigBuilder.js +28 -0
  233. package/src/units/builders/AssignmentUnitConfigBuilder.js +36 -0
  234. package/src/units/builders/ExecutionUnitConfigBuilder.js +59 -0
  235. package/src/units/builders/IOUnitConfigBuilder.js +53 -0
  236. package/src/units/builders/UnitConfigBuilder.js +86 -0
  237. package/src/units/builders/index.js +15 -0
  238. package/src/units/condition.js +47 -0
  239. package/src/units/execution.js +263 -0
  240. package/src/units/factory.js +53 -0
  241. package/src/units/index.js +25 -0
  242. package/src/units/io.js +163 -0
  243. package/src/units/map.js +33 -0
  244. package/src/units/processing.js +39 -0
  245. package/src/units/reduce.js +17 -0
  246. package/src/units/subworkflow.js +15 -0
  247. package/src/utils.js +73 -0
  248. package/src/workflows/create.js +222 -0
  249. package/src/workflows/default.js +39 -0
  250. package/src/workflows/index.js +99 -0
  251. package/src/workflows/relaxation.js +41 -0
  252. package/src/workflows/workflow.js +351 -0
@@ -0,0 +1,140 @@
1
+ import context from "./context";
2
+
3
+ const {
4
+ BoundaryConditionsFormDataProvider,
5
+ MLSettingsContextProvider,
6
+ MLTrainTestSplitContextProvider,
7
+ NEBFormDataProvider,
8
+ PlanewaveCutoffsContextProvider,
9
+ PointsGridFormDataProvider,
10
+ PointsPathFormDataProvider,
11
+ ExplicitPointsPathFormDataProvider,
12
+ ExplicitPointsPath2PIBAFormDataProvider,
13
+ HubbardJContextProvider,
14
+ HubbardUContextProvider,
15
+ HubbardVContextProvider,
16
+ HubbardContextProviderLegacy,
17
+ IonDynamicsContextProvider,
18
+ CollinearMagnetizationContextProvider,
19
+ NonCollinearMagnetizationContextProvider,
20
+ VASPContextProvider,
21
+ VASPNEBContextProvider,
22
+ QEPWXContextProvider,
23
+ QENEBContextProvider,
24
+ NWChemTotalEnergyContextProvider,
25
+ } = context;
26
+
27
+ const CONTEXT_DOMAINS = {
28
+ important: "important", // used to generate `ImportantSettings` form
29
+ };
30
+
31
+ const _makeImportant = (config) => Object.assign(config, { domain: CONTEXT_DOMAINS.important });
32
+
33
+ /** ********************************
34
+ * Method-based context providers *
35
+ ********************************* */
36
+
37
+ export const wodeProviders = {
38
+ // NOTE: subworkflow-level data manager. Will override the unit-level data with the same name via subworkflow context.
39
+ PlanewaveCutoffDataManager: {
40
+ providerCls: PlanewaveCutoffsContextProvider,
41
+ config: _makeImportant({ name: "cutoffs", entityName: "subworkflow" }),
42
+ },
43
+ KGridFormDataManager: {
44
+ providerCls: PointsGridFormDataProvider,
45
+ config: _makeImportant({ name: "kgrid" }),
46
+ },
47
+ QGridFormDataManager: {
48
+ providerCls: PointsGridFormDataProvider,
49
+ config: _makeImportant({ name: "qgrid", divisor: 5 }), // Using less points for Qgrid by default
50
+ },
51
+ IGridFormDataManager: {
52
+ providerCls: PointsGridFormDataProvider,
53
+ config: _makeImportant({ name: "igrid", divisor: 0.2 }), // Using more points for interpolated grid by default
54
+ },
55
+ QPathFormDataManager: {
56
+ providerCls: PointsPathFormDataProvider,
57
+ config: _makeImportant({ name: "qpath" }),
58
+ },
59
+ IPathFormDataManager: {
60
+ providerCls: PointsPathFormDataProvider,
61
+ config: _makeImportant({ name: "ipath" }),
62
+ },
63
+ KPathFormDataManager: {
64
+ providerCls: PointsPathFormDataProvider,
65
+ config: _makeImportant({ name: "kpath" }),
66
+ },
67
+ ExplicitKPathFormDataManager: {
68
+ providerCls: ExplicitPointsPathFormDataProvider,
69
+ config: _makeImportant({ name: "explicitKPath" }),
70
+ },
71
+ ExplicitKPath2PIBAFormDataManager: {
72
+ providerCls: ExplicitPointsPath2PIBAFormDataProvider,
73
+ config: _makeImportant({ name: "explicitKPath2PIBA" }),
74
+ },
75
+ HubbardJContextManager: {
76
+ providerCls: HubbardJContextProvider,
77
+ config: _makeImportant({ name: "hubbard_j" }),
78
+ },
79
+ HubbardUContextManager: {
80
+ providerCls: HubbardUContextProvider,
81
+ config: _makeImportant({ name: "hubbard_u" }),
82
+ },
83
+ HubbardVContextManager: {
84
+ providerCls: HubbardVContextProvider,
85
+ config: _makeImportant({ name: "hubbard_v" }),
86
+ },
87
+ HubbardContextManagerLegacy: {
88
+ providerCls: HubbardContextProviderLegacy,
89
+ config: _makeImportant({ name: "hubbard_legacy" }),
90
+ },
91
+ // NEBFormDataManager context is stored under the same key (`input`) as InputDataManager contexts.
92
+ NEBFormDataManager: {
93
+ providerCls: NEBFormDataProvider,
94
+ config: _makeImportant({ name: "neb" }),
95
+ },
96
+ BoundaryConditionsFormDataManager: {
97
+ providerCls: BoundaryConditionsFormDataProvider,
98
+ config: _makeImportant({ name: "boundaryConditions" }),
99
+ },
100
+ MLSettingsDataManager: {
101
+ providerCls: MLSettingsContextProvider,
102
+ config: _makeImportant({ name: "mlSettings" }),
103
+ },
104
+ MLTrainTestSplitDataManager: {
105
+ providerCls: MLTrainTestSplitContextProvider,
106
+ config: _makeImportant({ name: "mlTrainTestSplit" }),
107
+ },
108
+ IonDynamicsContextProvider: {
109
+ providerCls: IonDynamicsContextProvider,
110
+ config: _makeImportant({ name: "dynamics" }),
111
+ },
112
+ CollinearMagnetizationDataManager: {
113
+ providerCls: CollinearMagnetizationContextProvider,
114
+ config: _makeImportant({ name: "collinearMagnetization" }),
115
+ },
116
+ NonCollinearMagnetizationDataManager: {
117
+ providerCls: NonCollinearMagnetizationContextProvider,
118
+ config: _makeImportant({ name: "nonCollinearMagnetization" }),
119
+ },
120
+ QEPWXInputDataManager: {
121
+ providerCls: QEPWXContextProvider,
122
+ config: { name: "input" },
123
+ },
124
+ QENEBInputDataManager: {
125
+ providerCls: QENEBContextProvider,
126
+ config: { name: "input" },
127
+ },
128
+ VASPInputDataManager: {
129
+ providerCls: VASPContextProvider,
130
+ config: { name: "input" },
131
+ },
132
+ VASPNEBInputDataManager: {
133
+ providerCls: VASPNEBContextProvider,
134
+ config: { name: "input" },
135
+ },
136
+ NWChemInputDataManager: {
137
+ providerCls: NWChemTotalEnergyContextProvider,
138
+ config: { name: "input" },
139
+ },
140
+ };
package/src/enums.js ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * THIS ENUMS ARE SHARED WITH TESTS.
3
+ * DO NOT IMPORT ANYTHINGS IN THIS MODULE.
4
+ */
5
+
6
+ export const IO_ID_COLUMN = "exabyteId";
7
+
8
+ export const UNIT_TYPES = {
9
+ // not currently used
10
+ convergence: "convergence",
11
+ exit: "exit",
12
+ // actively used
13
+ execution: "execution",
14
+ map: "map",
15
+ reduce: "reduce",
16
+ assignment: "assignment",
17
+ condition: "condition",
18
+ subworkflow: "subworkflow",
19
+ processing: "processing",
20
+ io: "io",
21
+ assertion: "assertion",
22
+ };
23
+
24
+ export const UNIT_STATUSES = {
25
+ idle: "idle",
26
+ active: "active",
27
+ finished: "finished",
28
+ error: "error",
29
+ warning: "warning",
30
+ };
31
+
32
+ export const UNIT_TAGS = {
33
+ hasConvergenceParam: "hasConvergenceParam",
34
+ hasConvergenceResult: "hasConvergenceResult",
35
+ };
36
+
37
+ export const WORKFLOW_STATUSES = {
38
+ "up-to-date": "up-to-date",
39
+ outdated: "outdated",
40
+ };
41
+
42
+ export const TAB_NAVIGATION_CONFIG = {
43
+ overview: {
44
+ itemName: "Overview",
45
+ className: "",
46
+ href: "sw-overview",
47
+ },
48
+ importantSettings: {
49
+ itemName: "Important settings",
50
+ className: "",
51
+ href: "sw-important-settings",
52
+ },
53
+ detailedView: {
54
+ itemName: "Detailed view",
55
+ className: "",
56
+ href: "sw-detailed-view",
57
+ },
58
+ compute: {
59
+ itemName: "Compute",
60
+ className: "",
61
+ href: "sw-compute",
62
+ },
63
+ };
64
+
65
+ export const UNIT_NAME_INVALID_CHARS = "/";
package/src/index.js ADDED
@@ -0,0 +1,17 @@
1
+ import { UNIT_STATUSES, UNIT_TYPES } from "./enums";
2
+ import { createSubworkflowByName, Subworkflow } from "./subworkflows";
3
+ import { builders } from "./units/builders";
4
+ import { UnitFactory } from "./units/factory";
5
+ import { createWorkflowConfigs, createWorkflows, Workflow } from "./workflows";
6
+
7
+ export {
8
+ Subworkflow,
9
+ Workflow,
10
+ createWorkflows,
11
+ createWorkflowConfigs,
12
+ createSubworkflowByName,
13
+ UnitFactory,
14
+ builders,
15
+ UNIT_TYPES,
16
+ UNIT_STATUSES,
17
+ };
package/src/patch.js ADDED
@@ -0,0 +1,12 @@
1
+ import { Template } from "@exabyte-io/ade.js";
2
+
3
+ import { wodeProviders } from "./context/providers";
4
+
5
+ // We patch the static providerRegistry here so that
6
+ // Template has all context providers available
7
+ // to it when creating workflows. It is then re-exported
8
+ // from WoDe for use downstream.
9
+
10
+ Template.setContextProvidersConfig(wodeProviders);
11
+
12
+ export { Template };
@@ -0,0 +1,14 @@
1
+ import { NonUniformKGridConvergence } from "./non_uniform_kgrid";
2
+ import { ConvergenceParameter } from "./parameter";
3
+ import { UniformKGridConvergence } from "./uniform_kgrid";
4
+
5
+ export function createConvergenceParameter({ name, initialValue, increment }) {
6
+ switch (name) {
7
+ case "N_k":
8
+ return new UniformKGridConvergence({ name, initialValue, increment });
9
+ case "N_k_nonuniform":
10
+ return new NonUniformKGridConvergence({ name, initialValue, increment });
11
+ default:
12
+ return new ConvergenceParameter({ name, initialValue, increment });
13
+ }
14
+ }
@@ -0,0 +1,28 @@
1
+ import { ConvergenceParameter } from "./parameter";
2
+
3
+ export class NonUniformKGridConvergence extends ConvergenceParameter {
4
+ get increment() {
5
+ return `[${this.initialValue}[i] + math.floor(iteration * ${this._increment} * float(context['kgrid']['reciprocalVectorRatios'][i])) for i in range(3)]`;
6
+ }
7
+
8
+ get unitContext() {
9
+ return {
10
+ kgrid: {
11
+ dimensions: [`{{${this.name}[0]}}`, `{{${this.name}[1]}}`, `{{${this.name}[2]}}`],
12
+ shifts: [0, 0, 0],
13
+ },
14
+ isKgridEdited: true,
15
+ isUsingJinjaVariables: true,
16
+ };
17
+ }
18
+
19
+ // eslint-disable-next-line class-methods-use-this
20
+ useVariablesFromUnitContext(flowchartId) {
21
+ return [
22
+ {
23
+ scope: flowchartId,
24
+ name: "context",
25
+ },
26
+ ];
27
+ }
28
+ }
@@ -0,0 +1,58 @@
1
+ /* eslint-disable class-methods-use-this */
2
+ import lodash from "lodash";
3
+
4
+ export class ConvergenceParameter {
5
+ constructor({ name, initialValue, increment }) {
6
+ this.name = name;
7
+ this._initialValue = initialValue;
8
+ this._increment = increment;
9
+ }
10
+
11
+ /**
12
+ * Getter for initial value as string.
13
+ * Note: this will be used in assignment unit.
14
+ * @return {string}
15
+ */
16
+ get initialValue() {
17
+ if (!lodash.isString(this._initialValue)) {
18
+ return JSON.stringify(this._initialValue);
19
+ }
20
+ return this._initialValue;
21
+ }
22
+
23
+ /**
24
+ * @summary Defines how to increment the parameter.
25
+ * @return {string} - increment operation used in assignment unit
26
+ */
27
+ get increment() {
28
+ return ""; // overwrite in derived class
29
+ }
30
+
31
+ /**
32
+ * Defines content for updating the unit context
33
+ * @return {Object}
34
+ */
35
+ get unitContext() {
36
+ return {};
37
+ }
38
+
39
+ /**
40
+ * Defines value once convergence is reached (for 'exit' unit).
41
+ * Note: This is used in assignment unit and most often the variable will be assigned to itself.
42
+ * @return {string}
43
+ */
44
+ get finalValue() {
45
+ return `${this.name}`;
46
+ }
47
+
48
+ /**
49
+ * Create list of variables to fetch from a unit.
50
+ * Note: this is used for the `input` field for an assignment unit.
51
+ * @param {string} flowchartId - flowchartId of unit containing context variables
52
+ * @return {Object|{scope, name}}
53
+ */
54
+ // eslint-disable-next-line class-methods-use-this, no-unused-vars
55
+ useVariablesFromUnitContext(flowchartId) {
56
+ return [];
57
+ }
58
+ }
@@ -0,0 +1,22 @@
1
+ import { ConvergenceParameter } from "./parameter";
2
+
3
+ export class UniformKGridConvergence extends ConvergenceParameter {
4
+ get increment() {
5
+ return `${this.name} + ${this._increment}`;
6
+ }
7
+
8
+ get unitContext() {
9
+ return {
10
+ kgrid: {
11
+ dimensions: [`{{${this.name}}}`, `{{${this.name}}}`, `{{${this.name}}}`],
12
+ shifts: [0, 0, 0],
13
+ },
14
+ isKgridEdited: true,
15
+ isUsingJinjaVariables: true,
16
+ };
17
+ }
18
+
19
+ get finalValue() {
20
+ return `${this.name} + 0`;
21
+ }
22
+ }
@@ -0,0 +1,196 @@
1
+ import merge from "lodash/merge";
2
+
3
+ import { UNIT_TAGS, UNIT_TYPES } from "../enums";
4
+ import { createConvergenceParameter } from "./convergence/factory";
5
+
6
+ export const ConvergenceMixin = (superclass) =>
7
+ class extends superclass {
8
+ get convergenceParam() {
9
+ return this.findUnitWithTag("hasConvergenceParam")?.operand || undefined;
10
+ }
11
+
12
+ get convergenceResult() {
13
+ return this.findUnitWithTag("hasConvergenceResult")?.operand || undefined;
14
+ }
15
+
16
+ convergenceSeries(scopeTrack) {
17
+ if (!this.hasConvergence || !scopeTrack?.length) return [];
18
+ let lastResult;
19
+ const series = scopeTrack
20
+ .map((scopeItem, i) => ({
21
+ x: i,
22
+ param: scopeItem.scope?.global[this.convergenceParam],
23
+ y: scopeItem.scope?.global[this.convergenceResult],
24
+ }))
25
+ .filter(({ y }) => {
26
+ const isNewResult = y !== undefined && y !== lastResult;
27
+ lastResult = y;
28
+ return isNewResult;
29
+ });
30
+ return series.map((item, i) => {
31
+ return {
32
+ x: i + 1,
33
+ param: item.param,
34
+ y: item.y,
35
+ };
36
+ });
37
+ }
38
+
39
+ addConvergence({
40
+ parameter,
41
+ parameterInitial,
42
+ parameterIncrement,
43
+ result,
44
+ resultInitial,
45
+ condition,
46
+ operator,
47
+ tolerance,
48
+ maxOccurrences,
49
+ }) {
50
+ // RF: added TODO comments for future improvements
51
+
52
+ const { units } = this;
53
+ // Find unit to converge: should contain passed result in its results list
54
+ // TODO: make user to select unit for convergence explicitly
55
+ const unitForConvergence = units.find((x) =>
56
+ x.resultNames.find((name) => name === result),
57
+ );
58
+
59
+ if (!unitForConvergence) {
60
+ // eslint-disable-next-line no-undef
61
+ sAlert.error(
62
+ `Subworkflow does not contain unit with '${result}' as extracted property.`,
63
+ );
64
+ throw new Error("There is no result to converge");
65
+ }
66
+
67
+ // initialize parameter
68
+ const param = createConvergenceParameter({
69
+ name: parameter,
70
+ initialValue: parameterInitial,
71
+ increment: parameterIncrement,
72
+ });
73
+
74
+ // Replace kgrid to be ready for convergence
75
+ // TODO: kgrid should be abstracted and selected by user
76
+ const providers = unitForConvergence.importantSettingsProviders;
77
+ const gridProvider = providers.find((p) => p.name === "kgrid" || p.name === "qgrid");
78
+ let mergedContext = param.unitContext;
79
+ if (gridProvider) {
80
+ mergedContext = merge(gridProvider.yieldData(), param.unitContext);
81
+ gridProvider.setData(mergedContext);
82
+ gridProvider.setIsEdited(true);
83
+ }
84
+ unitForConvergence.updateContext(mergedContext);
85
+
86
+ const prevResult = "prev_result";
87
+ const iteration = "iteration";
88
+
89
+ // Assignment with result's initial value
90
+ const prevResultInit = this._UnitFactory.create({
91
+ name: "init result",
92
+ type: UNIT_TYPES.assignment,
93
+ head: true,
94
+ operand: prevResult,
95
+ value: resultInitial,
96
+ });
97
+
98
+ // Assignment with initial value of convergence parameter
99
+ const paramInit = this._UnitFactory.create({
100
+ name: "init parameter",
101
+ type: UNIT_TYPES.assignment,
102
+ operand: param.name,
103
+ value: param.initialValue,
104
+ tags: [UNIT_TAGS.hasConvergenceParam],
105
+ });
106
+
107
+ // Assignment with initial value of iteration counter
108
+ const iterInit = this._UnitFactory.create({
109
+ name: "init counter",
110
+ type: UNIT_TYPES.assignment,
111
+ operand: iteration,
112
+ value: 1,
113
+ });
114
+
115
+ // Assignment for storing iteration result: extracts 'result' from convergence unit scope
116
+ const storePrevResult = this._UnitFactory.create({
117
+ name: "store result",
118
+ type: UNIT_TYPES.assignment,
119
+ input: [
120
+ {
121
+ scope: unitForConvergence.flowchartId,
122
+ name: result,
123
+ },
124
+ ],
125
+ operand: prevResult,
126
+ value: result,
127
+ });
128
+
129
+ // Assignment for convergence param increase
130
+ const nextStep = this._UnitFactory.create({
131
+ name: "update parameter",
132
+ type: UNIT_TYPES.assignment,
133
+ input: param.useVariablesFromUnitContext(unitForConvergence.flowchartId),
134
+ operand: param.name,
135
+ value: param.increment,
136
+ next: unitForConvergence.flowchartId,
137
+ });
138
+
139
+ // Final step of convergence
140
+ const exit = this._UnitFactory.create({
141
+ type: UNIT_TYPES.assignment,
142
+ name: "exit",
143
+ input: [],
144
+ operand: param.name,
145
+ value: param.finalValue,
146
+ });
147
+
148
+ // Final step of convergence
149
+ const storeResult = this._UnitFactory.create({
150
+ name: "update result",
151
+ type: UNIT_TYPES.assignment,
152
+ input: [
153
+ {
154
+ scope: unitForConvergence.flowchartId,
155
+ name: result,
156
+ },
157
+ ],
158
+ operand: result,
159
+ value: result,
160
+ tags: [UNIT_TAGS.hasConvergenceResult],
161
+ });
162
+
163
+ // Assign next iteration value
164
+ const nextIter = this._UnitFactory.create({
165
+ name: "update counter",
166
+ type: UNIT_TYPES.assignment,
167
+ input: [],
168
+ operand: iteration,
169
+ value: `${iteration} + 1`,
170
+ });
171
+
172
+ // Convergence condition unit
173
+ const conditionUnit = this._UnitFactory.create({
174
+ name: "check convergence",
175
+ type: UNIT_TYPES.condition,
176
+ statement: `${condition} ${operator} ${tolerance}`,
177
+ then: exit.flowchartId,
178
+ else: storePrevResult.flowchartId,
179
+ maxOccurrences,
180
+ next: storePrevResult.flowchartId,
181
+ });
182
+
183
+ this.addUnit(paramInit, 0);
184
+ this.addUnit(prevResultInit, 1);
185
+ this.addUnit(iterInit, 2);
186
+ this.addUnit(storeResult);
187
+ this.addUnit(conditionUnit);
188
+ this.addUnit(storePrevResult);
189
+ this.addUnit(nextIter);
190
+ this.addUnit(nextStep);
191
+ this.addUnit(exit);
192
+
193
+ // `addUnit` adjusts the `next` field, hence the below.
194
+ nextStep.next = unitForConvergence.flowchartId;
195
+ }
196
+ };