@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.
- package/.babelrc +17 -0
- package/LICENSE.md +15 -0
- package/README.md +164 -0
- package/assets/subworkflows/deepmd/deepmd.yml +31 -0
- package/assets/subworkflows/deepmd/espresso_cp_md.yml +16 -0
- package/assets/subworkflows/espresso/average_electrostatic_potential_find_minima.yml +27 -0
- package/assets/subworkflows/espresso/average_electrostatic_potential_via_band_structure.yml +67 -0
- package/assets/subworkflows/espresso/band_gap.yml +21 -0
- package/assets/subworkflows/espresso/band_gap_hse_dos.yml +30 -0
- package/assets/subworkflows/espresso/band_structure.yml +26 -0
- package/assets/subworkflows/espresso/band_structure_dos.yml +34 -0
- package/assets/subworkflows/espresso/band_structure_hse.yml +30 -0
- package/assets/subworkflows/espresso/band_structure_magn.yml +31 -0
- package/assets/subworkflows/espresso/band_structure_soc.yml +30 -0
- package/assets/subworkflows/espresso/dielectric_tensor.yml +35 -0
- package/assets/subworkflows/espresso/dos.yml +24 -0
- package/assets/subworkflows/espresso/electronic_density_mesh.yml +19 -0
- package/assets/subworkflows/espresso/esm.yml +14 -0
- package/assets/subworkflows/espresso/esm_relax.yml +14 -0
- package/assets/subworkflows/espresso/espresso_extract_kpoints.yml +16 -0
- package/assets/subworkflows/espresso/espresso_xml_get_qpt_irr.yml +12 -0
- package/assets/subworkflows/espresso/fixed_cell_relaxation.yml +16 -0
- package/assets/subworkflows/espresso/gw_band_structure_band_gap_full_frequency.yml +22 -0
- package/assets/subworkflows/espresso/gw_band_structure_band_gap_plasmon_pole.yml +22 -0
- package/assets/subworkflows/espresso/hubbard_u_hp.yml +21 -0
- package/assets/subworkflows/espresso/kpoint_convergence.yml +86 -0
- package/assets/subworkflows/espresso/neb.yml +16 -0
- package/assets/subworkflows/espresso/ph_init_qpoints.yml +14 -0
- package/assets/subworkflows/espresso/ph_single_irr_qpt.yml +14 -0
- package/assets/subworkflows/espresso/phonon_dispersions.yml +29 -0
- package/assets/subworkflows/espresso/phonon_dos.yml +29 -0
- package/assets/subworkflows/espresso/phonon_dos_dispersion.yml +34 -0
- package/assets/subworkflows/espresso/phonon_reduce.yml +29 -0
- package/assets/subworkflows/espresso/post_processor.yml +14 -0
- package/assets/subworkflows/espresso/pre_processor.yml +14 -0
- package/assets/subworkflows/espresso/pw_scf.yml +16 -0
- package/assets/subworkflows/espresso/recalculate_bands.yml +19 -0
- package/assets/subworkflows/espresso/surface_energy.yml +16 -0
- package/assets/subworkflows/espresso/total_energy.yml +16 -0
- package/assets/subworkflows/espresso/valence_band_offset_calc_from_previous_esp_vbm.yml +35 -0
- package/assets/subworkflows/espresso/variable_cell_relaxation.yml +18 -0
- package/assets/subworkflows/espresso/zero_point_energy.yml +19 -0
- package/assets/subworkflows/jupyterLab/jupyter_notebook.yml +17 -0
- package/assets/subworkflows/nwchem/total_energy.yml +16 -0
- package/assets/subworkflows/python/ml/classification_tail.yml +56 -0
- package/assets/subworkflows/python/ml/clustering_tail.yml +62 -0
- package/assets/subworkflows/python/ml/regression_tail.yml +56 -0
- package/assets/subworkflows/python/ml/train_head.yml +61 -0
- package/assets/subworkflows/python/python_script.yml +14 -0
- package/assets/subworkflows/shell/batch_espresso_pwscf.yml +14 -0
- package/assets/subworkflows/shell/hello_world.yml +14 -0
- package/assets/subworkflows/vasp/band_gap.yml +21 -0
- package/assets/subworkflows/vasp/band_structure.yml +21 -0
- package/assets/subworkflows/vasp/band_structure_dos.yml +23 -0
- package/assets/subworkflows/vasp/dos.yml +18 -0
- package/assets/subworkflows/vasp/fixed_cell_relaxation.yml +16 -0
- package/assets/subworkflows/vasp/initial_final_total_energies.yml +25 -0
- package/assets/subworkflows/vasp/kpoint_convergence.yml +89 -0
- package/assets/subworkflows/vasp/neb_subworkflow.yml +16 -0
- package/assets/subworkflows/vasp/prepare_images.yml +16 -0
- package/assets/subworkflows/vasp/recalculate_bands.yml +16 -0
- package/assets/subworkflows/vasp/surface_energy.yml +18 -0
- package/assets/subworkflows/vasp/total_energy.yml +16 -0
- package/assets/subworkflows/vasp/variable_cell_relaxation.yml +18 -0
- package/assets/subworkflows/vasp/zero_point_energy.yml +16 -0
- package/assets/workflows/deepmd/deepmd_md.yml +6 -0
- package/assets/workflows/espresso/band_gap.yml +4 -0
- package/assets/workflows/espresso/band_gap_dos_hse.yml +4 -0
- package/assets/workflows/espresso/band_structure.yml +4 -0
- package/assets/workflows/espresso/band_structure_dos.yml +4 -0
- package/assets/workflows/espresso/band_structure_hse.yml +14 -0
- package/assets/workflows/espresso/band_structure_magn.yml +7 -0
- package/assets/workflows/espresso/band_structure_soc.yml +7 -0
- package/assets/workflows/espresso/dielectric_tensor.yml +4 -0
- package/assets/workflows/espresso/dos.yml +4 -0
- package/assets/workflows/espresso/electronic_density_mesh.yml +4 -0
- package/assets/workflows/espresso/esm.yml +4 -0
- package/assets/workflows/espresso/esm_relax.yml +4 -0
- package/assets/workflows/espresso/fixed_cell_relaxation.yml +4 -0
- package/assets/workflows/espresso/gw_band_structure_band_gap_full_frequency.yml +4 -0
- package/assets/workflows/espresso/gw_band_structure_band_gap_plasmon_pole.yml +4 -0
- package/assets/workflows/espresso/hubbard_u_hp.yml +7 -0
- package/assets/workflows/espresso/kpoint_convergence.yml +4 -0
- package/assets/workflows/espresso/neb.yml +4 -0
- package/assets/workflows/espresso/phonon_dispersions.yml +4 -0
- package/assets/workflows/espresso/phonon_dos.yml +4 -0
- package/assets/workflows/espresso/phonon_dos_dispersion.yml +4 -0
- package/assets/workflows/espresso/phonon_map.yml +28 -0
- package/assets/workflows/espresso/recalculate_bands.yml +4 -0
- package/assets/workflows/espresso/surface_energy.yml +4 -0
- package/assets/workflows/espresso/total_energy.yml +4 -0
- package/assets/workflows/espresso/valence_band_offset.yml +171 -0
- package/assets/workflows/espresso/variable_cell_relaxation.yml +4 -0
- package/assets/workflows/espresso/zero_point_energy.yml +4 -0
- package/assets/workflows/jupyterLab/jupyter_notebook.yml +4 -0
- package/assets/workflows/nwchem/total_energy.yml +4 -0
- package/assets/workflows/python/ml/classification_workflow.yml +9 -0
- package/assets/workflows/python/ml/clustering_workflow.yml +9 -0
- package/assets/workflows/python/ml/regression_workflow.yml +9 -0
- package/assets/workflows/python/python_script.yml +4 -0
- package/assets/workflows/shell/batch_espresso_pwscf.yml +4 -0
- package/assets/workflows/shell/hello_world.yml +4 -0
- package/assets/workflows/vasp/band_gap.yml +4 -0
- package/assets/workflows/vasp/band_structure.yml +4 -0
- package/assets/workflows/vasp/band_structure_dos.yml +4 -0
- package/assets/workflows/vasp/dos.yml +4 -0
- package/assets/workflows/vasp/fixed_cell_relaxation.yml +4 -0
- package/assets/workflows/vasp/kpoint_convergence.yml +4 -0
- package/assets/workflows/vasp/neb.yml +8 -0
- package/assets/workflows/vasp/recalculate_bands.yml +4 -0
- package/assets/workflows/vasp/surface_energy.yml +4 -0
- package/assets/workflows/vasp/total_energy.yml +4 -0
- package/assets/workflows/vasp/variable_cell_relaxation.yml +4 -0
- package/assets/workflows/vasp/zero_point_energy.yml +4 -0
- package/build_workflows.js +65 -0
- package/dist/context/context.js +49 -0
- package/dist/context/mixins/ApplicationContextMixin.js +19 -0
- package/dist/context/mixins/JobContextMixin.js +39 -0
- package/dist/context/mixins/MaterialContextMixin.js +40 -0
- package/dist/context/mixins/MaterialsContextMixin.js +19 -0
- package/dist/context/mixins/MaterialsSetContextMixin.js +25 -0
- package/dist/context/mixins/MethodDataContextMixin.js +48 -0
- package/dist/context/mixins/WorkflowContextMixin.js +28 -0
- package/dist/context/providers/BoundaryConditionsFormDataProvider.js +86 -0
- package/dist/context/providers/CollinearMagnetizationContextProvider.js +113 -0
- package/dist/context/providers/HubbardContextProviderLegacy.js +81 -0
- package/dist/context/providers/HubbardJContextProvider.js +74 -0
- package/dist/context/providers/HubbardUContextProvider.js +77 -0
- package/dist/context/providers/HubbardVContextProvider.js +104 -0
- package/dist/context/providers/IonDynamicsContextProvider.js +62 -0
- package/dist/context/providers/MLSettingsContextProvider.js +52 -0
- package/dist/context/providers/MLTrainTestSplitContextProvider.js +48 -0
- package/dist/context/providers/NEBFormDataProvider.js +38 -0
- package/dist/context/providers/NonCollinearMagnetizationContextProvider.js +253 -0
- package/dist/context/providers/PlanewaveCutoffsContextProvider.js +67 -0
- package/dist/context/providers/PointsGridFormDataProvider.js +272 -0
- package/dist/context/providers/PointsPathFormDataProvider.js +155 -0
- package/dist/context/providers/by_application/ExecutableContextProvider.js +17 -0
- package/dist/context/providers/by_application/espresso/QENEBContextProvider.js +60 -0
- package/dist/context/providers/by_application/espresso/QEPWXContextProvider.js +149 -0
- package/dist/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.js +84 -0
- package/dist/context/providers/by_application/vasp/VASPContextProvider.js +64 -0
- package/dist/context/providers/by_application/vasp/VASPNEBContextProvider.js +56 -0
- package/dist/context/providers/settings.js +37 -0
- package/dist/context/providers.js +199 -0
- package/dist/enums.js +65 -0
- package/dist/index.js +64 -0
- package/dist/patch.js +19 -0
- package/dist/subworkflows/convergence/factory.js +35 -0
- package/dist/subworkflows/convergence/non_uniform_kgrid.js +31 -0
- package/dist/subworkflows/convergence/parameter.js +70 -0
- package/dist/subworkflows/convergence/uniform_kgrid.js +26 -0
- package/dist/subworkflows/convergence.js +189 -0
- package/dist/subworkflows/create.js +285 -0
- package/dist/subworkflows/dynamic/espresso/getQpointIrrep.js +34 -0
- package/dist/subworkflows/dynamic/index.js +19 -0
- package/dist/subworkflows/dynamic/surfaceEnergy.js +67 -0
- package/dist/subworkflows/index.js +19 -0
- package/dist/subworkflows/subworkflow.js +279 -0
- package/dist/units/assertion.js +37 -0
- package/dist/units/assignment.js +42 -0
- package/dist/units/base.js +91 -0
- package/dist/units/builders/AssertionUnitConfigBuilder.js +34 -0
- package/dist/units/builders/AssignmentUnitConfigBuilder.js +41 -0
- package/dist/units/builders/ExecutionUnitConfigBuilder.js +67 -0
- package/dist/units/builders/IOUnitConfigBuilder.js +54 -0
- package/dist/units/builders/UnitConfigBuilder.js +79 -0
- package/dist/units/builders/index.js +18 -0
- package/dist/units/condition.js +52 -0
- package/dist/units/execution.js +222 -0
- package/dist/units/factory.js +53 -0
- package/dist/units/index.js +82 -0
- package/dist/units/io.js +148 -0
- package/dist/units/map.js +38 -0
- package/dist/units/processing.js +41 -0
- package/dist/units/reduce.js +24 -0
- package/dist/units/subworkflow.js +23 -0
- package/dist/utils.js +92 -0
- package/dist/workflows/create.js +312 -0
- package/dist/workflows/default.js +41 -0
- package/dist/workflows/index.js +108 -0
- package/dist/workflows/relaxation.js +37 -0
- package/dist/workflows/workflow.js +303 -0
- package/package.json +94 -0
- package/src/context/context.js +47 -0
- package/src/context/mixins/ApplicationContextMixin.js +19 -0
- package/src/context/mixins/JobContextMixin.js +36 -0
- package/src/context/mixins/MaterialContextMixin.js +41 -0
- package/src/context/mixins/MaterialsContextMixin.js +18 -0
- package/src/context/mixins/MaterialsSetContextMixin.js +24 -0
- package/src/context/mixins/MethodDataContextMixin.js +48 -0
- package/src/context/mixins/WorkflowContextMixin.js +25 -0
- package/src/context/providers/BoundaryConditionsFormDataProvider.js +80 -0
- package/src/context/providers/CollinearMagnetizationContextProvider.js +117 -0
- package/src/context/providers/HubbardContextProviderLegacy.js +75 -0
- package/src/context/providers/HubbardJContextProvider.js +73 -0
- package/src/context/providers/HubbardUContextProvider.js +100 -0
- package/src/context/providers/HubbardVContextProvider.js +111 -0
- package/src/context/providers/IonDynamicsContextProvider.js +56 -0
- package/src/context/providers/MLSettingsContextProvider.js +48 -0
- package/src/context/providers/MLTrainTestSplitContextProvider.js +45 -0
- package/src/context/providers/NEBFormDataProvider.js +32 -0
- package/src/context/providers/NonCollinearMagnetizationContextProvider.js +269 -0
- package/src/context/providers/PlanewaveCutoffsContextProvider.js +68 -0
- package/src/context/providers/PointsGridFormDataProvider.js +285 -0
- package/src/context/providers/PointsPathFormDataProvider.js +165 -0
- package/src/context/providers/by_application/ExecutableContextProvider.js +10 -0
- package/src/context/providers/by_application/espresso/QENEBContextProvider.js +56 -0
- package/src/context/providers/by_application/espresso/QEPWXContextProvider.js +166 -0
- package/src/context/providers/by_application/nwchem/NWChemTotalEnergyContextProvider.js +86 -0
- package/src/context/providers/by_application/vasp/VASPContextProvider.js +56 -0
- package/src/context/providers/by_application/vasp/VASPNEBContextProvider.js +46 -0
- package/src/context/providers/settings.js +38 -0
- package/src/context/providers.js +140 -0
- package/src/enums.js +65 -0
- package/src/index.js +17 -0
- package/src/patch.js +12 -0
- package/src/subworkflows/convergence/factory.js +14 -0
- package/src/subworkflows/convergence/non_uniform_kgrid.js +28 -0
- package/src/subworkflows/convergence/parameter.js +58 -0
- package/src/subworkflows/convergence/uniform_kgrid.js +22 -0
- package/src/subworkflows/convergence.js +196 -0
- package/src/subworkflows/create.js +201 -0
- package/src/subworkflows/dynamic/espresso/getQpointIrrep.js +35 -0
- package/src/subworkflows/dynamic/index.js +8 -0
- package/src/subworkflows/dynamic/surfaceEnergy.js +124 -0
- package/src/subworkflows/index.js +2 -0
- package/src/subworkflows/subworkflow.js +329 -0
- package/src/units/assertion.js +29 -0
- package/src/units/assignment.js +34 -0
- package/src/units/base.js +97 -0
- package/src/units/builders/AssertionUnitConfigBuilder.js +28 -0
- package/src/units/builders/AssignmentUnitConfigBuilder.js +36 -0
- package/src/units/builders/ExecutionUnitConfigBuilder.js +59 -0
- package/src/units/builders/IOUnitConfigBuilder.js +53 -0
- package/src/units/builders/UnitConfigBuilder.js +86 -0
- package/src/units/builders/index.js +15 -0
- package/src/units/condition.js +47 -0
- package/src/units/execution.js +263 -0
- package/src/units/factory.js +53 -0
- package/src/units/index.js +25 -0
- package/src/units/io.js +163 -0
- package/src/units/map.js +33 -0
- package/src/units/processing.js +39 -0
- package/src/units/reduce.js +17 -0
- package/src/units/subworkflow.js +15 -0
- package/src/utils.js +73 -0
- package/src/workflows/create.js +222 -0
- package/src/workflows/default.js +39 -0
- package/src/workflows/index.js +99 -0
- package/src/workflows/relaxation.js +41 -0
- package/src/workflows/workflow.js +351 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ConvergenceParameter = void 0;
|
|
7
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
/* eslint-disable class-methods-use-this */
|
|
10
|
+
|
|
11
|
+
class ConvergenceParameter {
|
|
12
|
+
constructor({
|
|
13
|
+
name,
|
|
14
|
+
initialValue,
|
|
15
|
+
increment
|
|
16
|
+
}) {
|
|
17
|
+
this.name = name;
|
|
18
|
+
this._initialValue = initialValue;
|
|
19
|
+
this._increment = increment;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Getter for initial value as string.
|
|
24
|
+
* Note: this will be used in assignment unit.
|
|
25
|
+
* @return {string}
|
|
26
|
+
*/
|
|
27
|
+
get initialValue() {
|
|
28
|
+
if (!_lodash.default.isString(this._initialValue)) {
|
|
29
|
+
return JSON.stringify(this._initialValue);
|
|
30
|
+
}
|
|
31
|
+
return this._initialValue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @summary Defines how to increment the parameter.
|
|
36
|
+
* @return {string} - increment operation used in assignment unit
|
|
37
|
+
*/
|
|
38
|
+
get increment() {
|
|
39
|
+
return ""; // overwrite in derived class
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Defines content for updating the unit context
|
|
44
|
+
* @return {Object}
|
|
45
|
+
*/
|
|
46
|
+
get unitContext() {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Defines value once convergence is reached (for 'exit' unit).
|
|
52
|
+
* Note: This is used in assignment unit and most often the variable will be assigned to itself.
|
|
53
|
+
* @return {string}
|
|
54
|
+
*/
|
|
55
|
+
get finalValue() {
|
|
56
|
+
return `${this.name}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Create list of variables to fetch from a unit.
|
|
61
|
+
* Note: this is used for the `input` field for an assignment unit.
|
|
62
|
+
* @param {string} flowchartId - flowchartId of unit containing context variables
|
|
63
|
+
* @return {Object|{scope, name}}
|
|
64
|
+
*/
|
|
65
|
+
// eslint-disable-next-line class-methods-use-this, no-unused-vars
|
|
66
|
+
useVariablesFromUnitContext(flowchartId) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.ConvergenceParameter = ConvergenceParameter;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UniformKGridConvergence = void 0;
|
|
7
|
+
var _parameter = require("./parameter");
|
|
8
|
+
class UniformKGridConvergence extends _parameter.ConvergenceParameter {
|
|
9
|
+
get increment() {
|
|
10
|
+
return `${this.name} + ${this._increment}`;
|
|
11
|
+
}
|
|
12
|
+
get unitContext() {
|
|
13
|
+
return {
|
|
14
|
+
kgrid: {
|
|
15
|
+
dimensions: [`{{${this.name}}}`, `{{${this.name}}}`, `{{${this.name}}}`],
|
|
16
|
+
shifts: [0, 0, 0]
|
|
17
|
+
},
|
|
18
|
+
isKgridEdited: true,
|
|
19
|
+
isUsingJinjaVariables: true
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
get finalValue() {
|
|
23
|
+
return `${this.name} + 0`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.UniformKGridConvergence = UniformKGridConvergence;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ConvergenceMixin = void 0;
|
|
7
|
+
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
8
|
+
var _enums = require("../enums");
|
|
9
|
+
var _factory = require("./convergence/factory");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const ConvergenceMixin = superclass => class extends superclass {
|
|
12
|
+
get convergenceParam() {
|
|
13
|
+
return this.findUnitWithTag("hasConvergenceParam")?.operand || undefined;
|
|
14
|
+
}
|
|
15
|
+
get convergenceResult() {
|
|
16
|
+
return this.findUnitWithTag("hasConvergenceResult")?.operand || undefined;
|
|
17
|
+
}
|
|
18
|
+
convergenceSeries(scopeTrack) {
|
|
19
|
+
if (!this.hasConvergence || !scopeTrack?.length) return [];
|
|
20
|
+
let lastResult;
|
|
21
|
+
const series = scopeTrack.map((scopeItem, i) => ({
|
|
22
|
+
x: i,
|
|
23
|
+
param: scopeItem.scope?.global[this.convergenceParam],
|
|
24
|
+
y: scopeItem.scope?.global[this.convergenceResult]
|
|
25
|
+
})).filter(({
|
|
26
|
+
y
|
|
27
|
+
}) => {
|
|
28
|
+
const isNewResult = y !== undefined && y !== lastResult;
|
|
29
|
+
lastResult = y;
|
|
30
|
+
return isNewResult;
|
|
31
|
+
});
|
|
32
|
+
return series.map((item, i) => {
|
|
33
|
+
return {
|
|
34
|
+
x: i + 1,
|
|
35
|
+
param: item.param,
|
|
36
|
+
y: item.y
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
addConvergence({
|
|
41
|
+
parameter,
|
|
42
|
+
parameterInitial,
|
|
43
|
+
parameterIncrement,
|
|
44
|
+
result,
|
|
45
|
+
resultInitial,
|
|
46
|
+
condition,
|
|
47
|
+
operator,
|
|
48
|
+
tolerance,
|
|
49
|
+
maxOccurrences
|
|
50
|
+
}) {
|
|
51
|
+
// RF: added TODO comments for future improvements
|
|
52
|
+
|
|
53
|
+
const {
|
|
54
|
+
units
|
|
55
|
+
} = this;
|
|
56
|
+
// Find unit to converge: should contain passed result in its results list
|
|
57
|
+
// TODO: make user to select unit for convergence explicitly
|
|
58
|
+
const unitForConvergence = units.find(x => x.resultNames.find(name => name === result));
|
|
59
|
+
if (!unitForConvergence) {
|
|
60
|
+
// eslint-disable-next-line no-undef
|
|
61
|
+
sAlert.error(`Subworkflow does not contain unit with '${result}' as extracted property.`);
|
|
62
|
+
throw new Error("There is no result to converge");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// initialize parameter
|
|
66
|
+
const param = (0, _factory.createConvergenceParameter)({
|
|
67
|
+
name: parameter,
|
|
68
|
+
initialValue: parameterInitial,
|
|
69
|
+
increment: parameterIncrement
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Replace kgrid to be ready for convergence
|
|
73
|
+
// TODO: kgrid should be abstracted and selected by user
|
|
74
|
+
const providers = unitForConvergence.importantSettingsProviders;
|
|
75
|
+
const gridProvider = providers.find(p => p.name === "kgrid" || p.name === "qgrid");
|
|
76
|
+
let mergedContext = param.unitContext;
|
|
77
|
+
if (gridProvider) {
|
|
78
|
+
mergedContext = (0, _merge.default)(gridProvider.yieldData(), param.unitContext);
|
|
79
|
+
gridProvider.setData(mergedContext);
|
|
80
|
+
gridProvider.setIsEdited(true);
|
|
81
|
+
}
|
|
82
|
+
unitForConvergence.updateContext(mergedContext);
|
|
83
|
+
const prevResult = "prev_result";
|
|
84
|
+
const iteration = "iteration";
|
|
85
|
+
|
|
86
|
+
// Assignment with result's initial value
|
|
87
|
+
const prevResultInit = this._UnitFactory.create({
|
|
88
|
+
name: "init result",
|
|
89
|
+
type: _enums.UNIT_TYPES.assignment,
|
|
90
|
+
head: true,
|
|
91
|
+
operand: prevResult,
|
|
92
|
+
value: resultInitial
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Assignment with initial value of convergence parameter
|
|
96
|
+
const paramInit = this._UnitFactory.create({
|
|
97
|
+
name: "init parameter",
|
|
98
|
+
type: _enums.UNIT_TYPES.assignment,
|
|
99
|
+
operand: param.name,
|
|
100
|
+
value: param.initialValue,
|
|
101
|
+
tags: [_enums.UNIT_TAGS.hasConvergenceParam]
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Assignment with initial value of iteration counter
|
|
105
|
+
const iterInit = this._UnitFactory.create({
|
|
106
|
+
name: "init counter",
|
|
107
|
+
type: _enums.UNIT_TYPES.assignment,
|
|
108
|
+
operand: iteration,
|
|
109
|
+
value: 1
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Assignment for storing iteration result: extracts 'result' from convergence unit scope
|
|
113
|
+
const storePrevResult = this._UnitFactory.create({
|
|
114
|
+
name: "store result",
|
|
115
|
+
type: _enums.UNIT_TYPES.assignment,
|
|
116
|
+
input: [{
|
|
117
|
+
scope: unitForConvergence.flowchartId,
|
|
118
|
+
name: result
|
|
119
|
+
}],
|
|
120
|
+
operand: prevResult,
|
|
121
|
+
value: result
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Assignment for convergence param increase
|
|
125
|
+
const nextStep = this._UnitFactory.create({
|
|
126
|
+
name: "update parameter",
|
|
127
|
+
type: _enums.UNIT_TYPES.assignment,
|
|
128
|
+
input: param.useVariablesFromUnitContext(unitForConvergence.flowchartId),
|
|
129
|
+
operand: param.name,
|
|
130
|
+
value: param.increment,
|
|
131
|
+
next: unitForConvergence.flowchartId
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Final step of convergence
|
|
135
|
+
const exit = this._UnitFactory.create({
|
|
136
|
+
type: _enums.UNIT_TYPES.assignment,
|
|
137
|
+
name: "exit",
|
|
138
|
+
input: [],
|
|
139
|
+
operand: param.name,
|
|
140
|
+
value: param.finalValue
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Final step of convergence
|
|
144
|
+
const storeResult = this._UnitFactory.create({
|
|
145
|
+
name: "update result",
|
|
146
|
+
type: _enums.UNIT_TYPES.assignment,
|
|
147
|
+
input: [{
|
|
148
|
+
scope: unitForConvergence.flowchartId,
|
|
149
|
+
name: result
|
|
150
|
+
}],
|
|
151
|
+
operand: result,
|
|
152
|
+
value: result,
|
|
153
|
+
tags: [_enums.UNIT_TAGS.hasConvergenceResult]
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Assign next iteration value
|
|
157
|
+
const nextIter = this._UnitFactory.create({
|
|
158
|
+
name: "update counter",
|
|
159
|
+
type: _enums.UNIT_TYPES.assignment,
|
|
160
|
+
input: [],
|
|
161
|
+
operand: iteration,
|
|
162
|
+
value: `${iteration} + 1`
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Convergence condition unit
|
|
166
|
+
const conditionUnit = this._UnitFactory.create({
|
|
167
|
+
name: "check convergence",
|
|
168
|
+
type: _enums.UNIT_TYPES.condition,
|
|
169
|
+
statement: `${condition} ${operator} ${tolerance}`,
|
|
170
|
+
then: exit.flowchartId,
|
|
171
|
+
else: storePrevResult.flowchartId,
|
|
172
|
+
maxOccurrences,
|
|
173
|
+
next: storePrevResult.flowchartId
|
|
174
|
+
});
|
|
175
|
+
this.addUnit(paramInit, 0);
|
|
176
|
+
this.addUnit(prevResultInit, 1);
|
|
177
|
+
this.addUnit(iterInit, 2);
|
|
178
|
+
this.addUnit(storeResult);
|
|
179
|
+
this.addUnit(conditionUnit);
|
|
180
|
+
this.addUnit(storePrevResult);
|
|
181
|
+
this.addUnit(nextIter);
|
|
182
|
+
this.addUnit(nextStep);
|
|
183
|
+
this.addUnit(exit);
|
|
184
|
+
|
|
185
|
+
// `addUnit` adjusts the `next` field, hence the below.
|
|
186
|
+
nextStep.next = unitForConvergence.flowchartId;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
exports.ConvergenceMixin = ConvergenceMixin;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createSubworkflow = createSubworkflow;
|
|
7
|
+
exports.createSubworkflowByName = createSubworkflowByName;
|
|
8
|
+
exports.createUnit = createUnit;
|
|
9
|
+
var _ApplicationRegistry = _interopRequireDefault(require("@exabyte-io/ade.js/dist/js/ApplicationRegistry"));
|
|
10
|
+
var _mode = require("@exabyte-io/mode.js");
|
|
11
|
+
var _standata = require("@mat3ra/standata");
|
|
12
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
+
var _units = require("../units");
|
|
14
|
+
var _builders = require("../units/builders");
|
|
15
|
+
var _utils = require("../utils");
|
|
16
|
+
var _dynamic = require("./dynamic");
|
|
17
|
+
var _subworkflow = require("./subworkflow");
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
// NOTE: DFTModel => DFTModelConfig, configs should have the same name as the model/method class + "Config" at the end
|
|
20
|
+
function _getConfigFromModelOrMethodName(name, kind) {
|
|
21
|
+
const configs = kind === "Model" ? _mode.default_models : _mode.default_methods;
|
|
22
|
+
if (!configs[`${name}Config`]) {
|
|
23
|
+
// eslint-disable-next-line no-param-reassign
|
|
24
|
+
name = `Unknown${kind}`;
|
|
25
|
+
}
|
|
26
|
+
return configs[`${name}Config`];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @summary Create model from subworkflow data
|
|
31
|
+
* @param config {Object} model config
|
|
32
|
+
* @param modelFactoryCls {any} model factory to use
|
|
33
|
+
* @returns {DFTModel|Model}
|
|
34
|
+
*/
|
|
35
|
+
function createModel({
|
|
36
|
+
config,
|
|
37
|
+
modelFactoryCls
|
|
38
|
+
}) {
|
|
39
|
+
const {
|
|
40
|
+
name,
|
|
41
|
+
config: modelConfig = {}
|
|
42
|
+
} = config;
|
|
43
|
+
const defaultConfig = _getConfigFromModelOrMethodName(name, "Model");
|
|
44
|
+
return modelFactoryCls.create({
|
|
45
|
+
...defaultConfig,
|
|
46
|
+
...modelConfig
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @summary Create method from subworkflow data
|
|
52
|
+
* @param config {Object} method configuration
|
|
53
|
+
* @param methodFactoryCls {any}
|
|
54
|
+
* @returns {{method, setSearchText}}
|
|
55
|
+
*/
|
|
56
|
+
function createMethod({
|
|
57
|
+
config,
|
|
58
|
+
methodFactoryCls
|
|
59
|
+
}) {
|
|
60
|
+
const {
|
|
61
|
+
name,
|
|
62
|
+
setSearchText = null,
|
|
63
|
+
config: methodConfig = {}
|
|
64
|
+
} = config;
|
|
65
|
+
const defaultConfig = _getConfigFromModelOrMethodName(name, "Method");
|
|
66
|
+
const method = methodFactoryCls.create({
|
|
67
|
+
...defaultConfig,
|
|
68
|
+
...methodConfig
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
method,
|
|
72
|
+
setSearchText
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @summary Create top-level objects used in subworkflow initialization
|
|
78
|
+
* @param subworkflowData {Object} subworkflow data
|
|
79
|
+
* @param AppRegistry
|
|
80
|
+
* @param modelFactoryCls {any} model factory class
|
|
81
|
+
* @param methodFactoryCls {any} method factory class
|
|
82
|
+
* @returns {{application: *, method: *, model: (DFTModel|Model), setSearchText: String|null}}
|
|
83
|
+
*/
|
|
84
|
+
function createTopLevel({
|
|
85
|
+
subworkflowData,
|
|
86
|
+
modelFactoryCls,
|
|
87
|
+
methodFactoryCls,
|
|
88
|
+
AppRegistry
|
|
89
|
+
}) {
|
|
90
|
+
const {
|
|
91
|
+
application: appConfig,
|
|
92
|
+
model: modelConfig,
|
|
93
|
+
method: methodConfig
|
|
94
|
+
} = subworkflowData;
|
|
95
|
+
const application = AppRegistry.createApplication(appConfig);
|
|
96
|
+
const model = createModel({
|
|
97
|
+
config: modelConfig,
|
|
98
|
+
modelFactoryCls
|
|
99
|
+
});
|
|
100
|
+
const {
|
|
101
|
+
method,
|
|
102
|
+
setSearchText
|
|
103
|
+
} = createMethod({
|
|
104
|
+
config: methodConfig,
|
|
105
|
+
methodFactoryCls
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
application,
|
|
109
|
+
model,
|
|
110
|
+
method,
|
|
111
|
+
setSearchText
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @summary Create workflow unit from JSON configuration
|
|
117
|
+
* Supports applying functions to the builder prior to building via "functions"
|
|
118
|
+
* Supports applying attributes to the builder after building via "attributes"
|
|
119
|
+
* @param config {Object} unit config
|
|
120
|
+
* @param application {*} application
|
|
121
|
+
* @param unitBuilders {Object} workflow unit builders
|
|
122
|
+
* @param unitFactoryCls {*} workflow unit class factory
|
|
123
|
+
* @returns {*|{head: boolean, preProcessors: [], postProcessors: [], name: *, flowchartId: *, type: *, results: [], monitors: []}}
|
|
124
|
+
*/
|
|
125
|
+
function createUnit({
|
|
126
|
+
config,
|
|
127
|
+
application,
|
|
128
|
+
unitBuilders,
|
|
129
|
+
unitFactoryCls
|
|
130
|
+
}) {
|
|
131
|
+
const {
|
|
132
|
+
type,
|
|
133
|
+
config: unitConfig
|
|
134
|
+
} = config;
|
|
135
|
+
if (type === "executionBuilder") {
|
|
136
|
+
const {
|
|
137
|
+
name,
|
|
138
|
+
execName,
|
|
139
|
+
flavorName,
|
|
140
|
+
flowchartId
|
|
141
|
+
} = unitConfig;
|
|
142
|
+
const builder = new unitBuilders.ExecutionUnitConfigBuilder(name, application, execName, flavorName, flowchartId);
|
|
143
|
+
|
|
144
|
+
// config should contain "functions" and "attributes"
|
|
145
|
+
const cfg = (0, _utils.applyConfig)({
|
|
146
|
+
obj: builder,
|
|
147
|
+
config,
|
|
148
|
+
callBuild: true
|
|
149
|
+
});
|
|
150
|
+
return unitFactoryCls.create(cfg);
|
|
151
|
+
}
|
|
152
|
+
return unitFactoryCls.create({
|
|
153
|
+
type,
|
|
154
|
+
...unitConfig
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @summary Dynamically create subworkflow units
|
|
160
|
+
* @param dynamicSubworkflow {String} name of unit creation function
|
|
161
|
+
* @param units {Array} configured units to provide to dynamic unit creation
|
|
162
|
+
* @param unitBuilders {Object} unit configuration builders
|
|
163
|
+
* @param unitFactoryCls {*} unit factory class
|
|
164
|
+
* @param application {*} application (optional)
|
|
165
|
+
* @returns {*}
|
|
166
|
+
*/
|
|
167
|
+
function createDynamicUnits({
|
|
168
|
+
dynamicSubworkflow,
|
|
169
|
+
units,
|
|
170
|
+
unitBuilders,
|
|
171
|
+
unitFactoryCls,
|
|
172
|
+
application = null
|
|
173
|
+
}) {
|
|
174
|
+
const {
|
|
175
|
+
name,
|
|
176
|
+
subfolder
|
|
177
|
+
} = dynamicSubworkflow;
|
|
178
|
+
const func = subfolder && _lodash.default.get(_dynamic.dynamicSubworkflowsByApp, `${subfolder}.${name}`, () => {});
|
|
179
|
+
switch (name) {
|
|
180
|
+
case "surfaceEnergy":
|
|
181
|
+
// eslint-disable-next-line no-case-declarations
|
|
182
|
+
const [scfUnit] = units;
|
|
183
|
+
return (0, _dynamic.getSurfaceEnergySubworkflowUnits)({
|
|
184
|
+
scfUnit,
|
|
185
|
+
unitBuilders
|
|
186
|
+
});
|
|
187
|
+
case "getQpointIrrep":
|
|
188
|
+
return func({
|
|
189
|
+
unitBuilders,
|
|
190
|
+
unitFactoryCls,
|
|
191
|
+
application
|
|
192
|
+
});
|
|
193
|
+
default:
|
|
194
|
+
throw new Error(`dynamicSubworkflow=${name} not recognized`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function createSubworkflow({
|
|
198
|
+
subworkflowData,
|
|
199
|
+
AppRegistry = _ApplicationRegistry.default,
|
|
200
|
+
modelFactoryCls = _mode.ModelFactory,
|
|
201
|
+
methodFactoryCls = _mode.MethodFactory,
|
|
202
|
+
subworkflowCls = _subworkflow.Subworkflow,
|
|
203
|
+
unitFactoryCls = _units.UnitFactory,
|
|
204
|
+
unitBuilders = _builders.builders
|
|
205
|
+
}) {
|
|
206
|
+
const {
|
|
207
|
+
application,
|
|
208
|
+
model,
|
|
209
|
+
method,
|
|
210
|
+
setSearchText
|
|
211
|
+
} = createTopLevel({
|
|
212
|
+
subworkflowData,
|
|
213
|
+
AppRegistry,
|
|
214
|
+
modelFactoryCls,
|
|
215
|
+
methodFactoryCls
|
|
216
|
+
});
|
|
217
|
+
let units = [];
|
|
218
|
+
const {
|
|
219
|
+
name,
|
|
220
|
+
units: unitConfigs,
|
|
221
|
+
config = {},
|
|
222
|
+
dynamicSubworkflow = null
|
|
223
|
+
} = subworkflowData;
|
|
224
|
+
unitConfigs.forEach(_config => {
|
|
225
|
+
units.push(createUnit({
|
|
226
|
+
config: _config,
|
|
227
|
+
application,
|
|
228
|
+
unitBuilders,
|
|
229
|
+
unitFactoryCls
|
|
230
|
+
}));
|
|
231
|
+
});
|
|
232
|
+
if (dynamicSubworkflow) {
|
|
233
|
+
units = createDynamicUnits({
|
|
234
|
+
dynamicSubworkflow,
|
|
235
|
+
units,
|
|
236
|
+
unitBuilders,
|
|
237
|
+
unitFactoryCls,
|
|
238
|
+
application
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const {
|
|
242
|
+
functions = {},
|
|
243
|
+
attributes = {},
|
|
244
|
+
...cfg
|
|
245
|
+
} = config;
|
|
246
|
+
let subworkflow = subworkflowCls.fromArguments(application, model, method, name, units, cfg);
|
|
247
|
+
subworkflow = (0, _utils.applyConfig)({
|
|
248
|
+
obj: subworkflow,
|
|
249
|
+
config: {
|
|
250
|
+
functions,
|
|
251
|
+
attributes
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
if (setSearchText) subworkflow.model.method.setSearchText(setSearchText);
|
|
255
|
+
return subworkflow;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @summary Convenience wrapper around createSubworkflow to create by app name and swf name
|
|
260
|
+
* @param appName {String} application name
|
|
261
|
+
* @param swfName {String} subworkflow name (snake_case.yml)
|
|
262
|
+
* @param workflowSubworkflowMapByApplication {Object} object containing all workflow/subworkflow map by application
|
|
263
|
+
* @param swArgs {Object} classes for instantiation
|
|
264
|
+
* @returns {*} subworkflow object
|
|
265
|
+
*/
|
|
266
|
+
function createSubworkflowByName({
|
|
267
|
+
appName,
|
|
268
|
+
swfName,
|
|
269
|
+
workflowSubworkflowMapByApplication = _standata.workflowSubforkflowMapByApplication,
|
|
270
|
+
...swArgs
|
|
271
|
+
}) {
|
|
272
|
+
const {
|
|
273
|
+
subworkflows
|
|
274
|
+
} = workflowSubworkflowMapByApplication;
|
|
275
|
+
const {
|
|
276
|
+
[appName]: allSubworkflowData
|
|
277
|
+
} = subworkflows;
|
|
278
|
+
const {
|
|
279
|
+
[swfName]: subworkflowData
|
|
280
|
+
} = allSubworkflowData;
|
|
281
|
+
return createSubworkflow({
|
|
282
|
+
subworkflowData,
|
|
283
|
+
...swArgs
|
|
284
|
+
});
|
|
285
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getQpointIrrep = getQpointIrrep;
|
|
7
|
+
var _enums = require("../../../enums");
|
|
8
|
+
/**
|
|
9
|
+
* @summary Get QptIrr units used in phonon map calculations
|
|
10
|
+
* @param unitBuilders {Object} unit builders
|
|
11
|
+
* @param unitFactoryCls {*} unit factory class
|
|
12
|
+
* @param application {*} application instance
|
|
13
|
+
* @returns {[{head: boolean, preProcessors: [], postProcessors: [], name: *, flowchartId: *, type: *, results: [], monitors: []},*]}
|
|
14
|
+
*/
|
|
15
|
+
function getQpointIrrep({
|
|
16
|
+
unitBuilders,
|
|
17
|
+
unitFactoryCls,
|
|
18
|
+
application
|
|
19
|
+
}) {
|
|
20
|
+
const {
|
|
21
|
+
ExecutionUnitConfigBuilder
|
|
22
|
+
} = unitBuilders;
|
|
23
|
+
const pythonUnit = new ExecutionUnitConfigBuilder("python", application, "python", "espresso_xml_get_qpt_irr").build();
|
|
24
|
+
const assignmentUnit = unitFactoryCls.create({
|
|
25
|
+
type: _enums.UNIT_TYPES.assignment,
|
|
26
|
+
input: [{
|
|
27
|
+
scope: pythonUnit.flowchartId,
|
|
28
|
+
name: "STDOUT"
|
|
29
|
+
}],
|
|
30
|
+
operand: "Q_POINTS",
|
|
31
|
+
value: "json.loads(STDOUT)"
|
|
32
|
+
});
|
|
33
|
+
return [pythonUnit, assignmentUnit];
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dynamicSubworkflowsByApp = void 0;
|
|
7
|
+
Object.defineProperty(exports, "getSurfaceEnergySubworkflowUnits", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _surfaceEnergy.getSurfaceEnergySubworkflowUnits;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _getQpointIrrep = require("./espresso/getQpointIrrep");
|
|
14
|
+
var _surfaceEnergy = require("./surfaceEnergy");
|
|
15
|
+
const dynamicSubworkflowsByApp = exports.dynamicSubworkflowsByApp = {
|
|
16
|
+
espresso: {
|
|
17
|
+
getQpointIrrep: _getQpointIrrep.getQpointIrrep
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSurfaceEnergySubworkflowUnits = getSurfaceEnergySubworkflowUnits;
|
|
7
|
+
var _utils = require("@mat3ra/utils");
|
|
8
|
+
function getIOUnitEndpointOptions(query, projection = "{}") {
|
|
9
|
+
return {
|
|
10
|
+
params: {
|
|
11
|
+
query,
|
|
12
|
+
projection
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function getAssignmentUnitInput(unit, name) {
|
|
17
|
+
return [{
|
|
18
|
+
name,
|
|
19
|
+
scope: unit.flowchartId
|
|
20
|
+
}];
|
|
21
|
+
}
|
|
22
|
+
function getSurfaceEnergySubworkflowUnits({
|
|
23
|
+
scfUnit,
|
|
24
|
+
unitBuilders
|
|
25
|
+
}) {
|
|
26
|
+
const {
|
|
27
|
+
IOUnitConfigBuilder,
|
|
28
|
+
AssignmentUnitConfigBuilder,
|
|
29
|
+
AssertionUnitConfigBuilder
|
|
30
|
+
} = unitBuilders;
|
|
31
|
+
let input, endpointOptions;
|
|
32
|
+
endpointOptions = getIOUnitEndpointOptions("{'_id': MATERIAL_ID}");
|
|
33
|
+
const getSlabUnit = new IOUnitConfigBuilder("io-slab", "materials", endpointOptions).build();
|
|
34
|
+
input = getAssignmentUnitInput(getSlabUnit, "DATA");
|
|
35
|
+
const setSlabUnit = new AssignmentUnitConfigBuilder("slab", "SLAB", "DATA[0]", input).build();
|
|
36
|
+
endpointOptions = getIOUnitEndpointOptions("{'_id': SLAB.metadata.bulkId}");
|
|
37
|
+
const getBulkUnit = new IOUnitConfigBuilder("io-bulk", "materials", endpointOptions).build();
|
|
38
|
+
const BULKValue = "DATA[0] if DATA else None";
|
|
39
|
+
input = getAssignmentUnitInput(getBulkUnit, "DATA");
|
|
40
|
+
const setBulkUnit = new AssignmentUnitConfigBuilder("bulk", "BULK", BULKValue, input).build();
|
|
41
|
+
const assertBulkUnit = new AssertionUnitConfigBuilder("assert-bulk", "BULK != None", "Bulk material does not exist!").build();
|
|
42
|
+
const query = _utils.Utils.str.removeNewLinesAndExtraSpaces(`{
|
|
43
|
+
'exabyteId': BULK.exabyteId,
|
|
44
|
+
'data.name': 'total_energy',
|
|
45
|
+
'group': {'$regex': ''.join((SUBWORKFLOW.application.shortName, ':'))}
|
|
46
|
+
}`);
|
|
47
|
+
// Do not confuse `sort` with `$sort`. `sort` is used in meteor collections and `$sort` is used in Mongo queries.
|
|
48
|
+
const projection = "{'sort': {'precision.value': -1}, 'limit': 1}";
|
|
49
|
+
endpointOptions = getIOUnitEndpointOptions(query, projection);
|
|
50
|
+
const getEBulkUnit = new IOUnitConfigBuilder("io-e-bulk", "refined-properties", endpointOptions).build();
|
|
51
|
+
input = getAssignmentUnitInput(getEBulkUnit, "DATA");
|
|
52
|
+
const EBULKValue = "DATA[0].data.value if DATA else None";
|
|
53
|
+
const setEBulkUnit = new AssignmentUnitConfigBuilder("e-bulk", "E_BULK", EBULKValue, input).build();
|
|
54
|
+
const assertEBulkUnit = new AssertionUnitConfigBuilder("assert-e-bulk", "E_BULK != None", "E_BULK does not exist!").build();
|
|
55
|
+
const AValue = "np.linalg.norm(np.cross(SLAB.lattice.vectors.a, SLAB.lattice.vectors.b))";
|
|
56
|
+
const setSurfaceUnit = new AssignmentUnitConfigBuilder("surface", "A", AValue).build();
|
|
57
|
+
const setNBulkUnit = new AssignmentUnitConfigBuilder("n-bulk", "N_BULK", "len(BULK.basis.elements)").build();
|
|
58
|
+
const setNSlabUnit = new AssignmentUnitConfigBuilder("n-slab", "N_SLAB", "len(SLAB.basis.elements)").build();
|
|
59
|
+
input = getAssignmentUnitInput(scfUnit, "total_energy");
|
|
60
|
+
const setESlabUnit = new AssignmentUnitConfigBuilder("e-slab", "E_SLAB", "total_energy", input).build();
|
|
61
|
+
const results = [{
|
|
62
|
+
name: "surface_energy"
|
|
63
|
+
}];
|
|
64
|
+
const SEValue = "1 / (2 * A) * (E_SLAB - E_BULK * (N_SLAB/N_BULK))";
|
|
65
|
+
const surfaceEnergyUnit = new AssignmentUnitConfigBuilder("surface-energy", "SURFACE_ENERGY", SEValue, [], results).build();
|
|
66
|
+
return [getSlabUnit, setSlabUnit, getBulkUnit, setBulkUnit, assertBulkUnit, getEBulkUnit, setEBulkUnit, assertEBulkUnit, setSurfaceUnit, setNBulkUnit, setNSlabUnit, scfUnit, setESlabUnit, surfaceEnergyUnit];
|
|
67
|
+
}
|