@mat3ra/mode 2025.10.2-0 → 2025.11.5-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/package.json +32 -17
- package/src/js/default_methods.ts +36 -0
- package/src/js/default_models.ts +11 -0
- package/src/js/generated/MethodSchemaMixin.ts +26 -0
- package/src/js/generated/ModelSchemaMixin.ts +23 -0
- package/src/{index.js → js/index.ts} +5 -11
- package/src/js/method.ts +67 -0
- package/src/js/methodConversionHandler.ts +142 -0
- package/src/{methods/factory.js → js/methods/factory.ts} +3 -1
- package/src/js/methods/pseudopotential.ts +86 -0
- package/src/js/model.ts +168 -0
- package/src/js/modelConversionHandler.ts +102 -0
- package/src/js/models/dft.ts +110 -0
- package/src/{models/factory.js → js/models/factory.ts} +9 -4
- package/src/{tree.js → js/tree.ts} +26 -33
- package/src/js/types/index.ts +37 -0
- package/tsconfig.json +3 -0
- package/.babelrc +0 -17
- package/dist/data/method_list.js +0 -1132
- package/dist/data/model_list.js +0 -786
- package/dist/data/model_method_map.js +0 -82
- package/dist/default_methods.js +0 -39
- package/dist/default_models.js +0 -14
- package/dist/index.js +0 -62
- package/dist/method.js +0 -84
- package/dist/methods/factory.js +0 -24
- package/dist/methods/pseudopotential.js +0 -100
- package/dist/model.js +0 -123
- package/dist/models/dft.js +0 -102
- package/dist/models/factory.js +0 -36
- package/dist/tree.js +0 -165
- package/src/data/method_list.js +0 -2
- package/src/data/model_list.js +0 -2
- package/src/data/model_method_map.js +0 -2
- package/src/default_methods.js +0 -38
- package/src/default_models.js +0 -9
- package/src/method.js +0 -77
- package/src/methods/pseudopotential.js +0 -99
- package/src/model.js +0 -127
- package/src/models/dft.js +0 -115
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
module.exports = {
|
|
5
|
-
"pb": {
|
|
6
|
-
"qm": {
|
|
7
|
-
"abin": {
|
|
8
|
-
"gw": [{
|
|
9
|
-
"path": "/qm/wf/none/pw/none"
|
|
10
|
-
}, {
|
|
11
|
-
"regex": "\\/qm\\/wf\\/none\\/psp\\/.*"
|
|
12
|
-
}, {
|
|
13
|
-
"regex": "\\/qm\\/wf\\/none\\/smearing\\/.*"
|
|
14
|
-
}, {
|
|
15
|
-
"regex": "\\/qm\\/wf\\/none\\/tetrahedron\\/.*"
|
|
16
|
-
}, {
|
|
17
|
-
"path": "/opt/diff/ordern/cg/none"
|
|
18
|
-
}, {
|
|
19
|
-
"path": "/linalg/diag/none/davidson/none"
|
|
20
|
-
}]
|
|
21
|
-
},
|
|
22
|
-
"dft": {
|
|
23
|
-
"ksdft": {
|
|
24
|
-
"lda": [{
|
|
25
|
-
"path": "/qm/wf/none/pw/none"
|
|
26
|
-
}, {
|
|
27
|
-
"regex": "\\/qm\\/wf\\/none\\/psp\\/.*"
|
|
28
|
-
}, {
|
|
29
|
-
"regex": "\\/qm\\/wf\\/none\\/smearing\\/.*"
|
|
30
|
-
}, {
|
|
31
|
-
"regex": "\\/qm\\/wf\\/none\\/tetrahedron\\/.*"
|
|
32
|
-
}, {
|
|
33
|
-
"path": "/opt/diff/ordern/cg/none"
|
|
34
|
-
}, {
|
|
35
|
-
"path": "/linalg/diag/none/davidson/none"
|
|
36
|
-
}],
|
|
37
|
-
"gga": [{
|
|
38
|
-
"path": "/qm/wf/none/pw/none"
|
|
39
|
-
}, {
|
|
40
|
-
"regex": "\\/qm\\/wf\\/none\\/psp\\/.*"
|
|
41
|
-
}, {
|
|
42
|
-
"regex": "\\/qm\\/wf\\/none\\/smearing\\/.*"
|
|
43
|
-
}, {
|
|
44
|
-
"regex": "\\/qm\\/wf\\/none\\/tetrahedron\\/.*"
|
|
45
|
-
}, {
|
|
46
|
-
"path": "/opt/diff/ordern/cg/none"
|
|
47
|
-
}, {
|
|
48
|
-
"path": "/linalg/diag/none/davidson/none"
|
|
49
|
-
}],
|
|
50
|
-
"hybrid": [{
|
|
51
|
-
"path": "/qm/wf/none/pw/none"
|
|
52
|
-
}, {
|
|
53
|
-
"regex": "\\/qm\\/wf\\/none\\/psp\\/.*"
|
|
54
|
-
}, {
|
|
55
|
-
"regex": "\\/qm\\/wf\\/none\\/smearing\\/.*"
|
|
56
|
-
}, {
|
|
57
|
-
"regex": "\\/qm\\/wf\\/none\\/tetrahedron\\/.*"
|
|
58
|
-
}, {
|
|
59
|
-
"path": "/opt/diff/ordern/cg/none"
|
|
60
|
-
}, {
|
|
61
|
-
"path": "/linalg/diag/none/davidson/none"
|
|
62
|
-
}, {
|
|
63
|
-
"regex": "\\/qm\\/wf\\/none\\/ao\\/pople.*"
|
|
64
|
-
}]
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
"st": {
|
|
70
|
-
"det": {
|
|
71
|
-
"ml": {
|
|
72
|
-
"re": [{
|
|
73
|
-
"path": "/none/none/none/linear/least_squares"
|
|
74
|
-
}, {
|
|
75
|
-
"path": "/none/none/none/linear/ridge"
|
|
76
|
-
}, {
|
|
77
|
-
"path": "/none/none/none/kernel_ridge/least_squares"
|
|
78
|
-
}]
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
package/dist/default_methods.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.UnknownMethodConfig = exports.PseudopotentialMethodConfig = exports.LocalOrbitalMethodConfig = void 0;
|
|
7
|
-
exports.allowedSubtypes = allowedSubtypes;
|
|
8
|
-
exports.allowedTypes = allowedTypes;
|
|
9
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
-
var _tree = require("./tree");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
const PseudopotentialMethodConfig = exports.PseudopotentialMethodConfig = {
|
|
13
|
-
type: "pseudopotential",
|
|
14
|
-
subtype: "us"
|
|
15
|
-
};
|
|
16
|
-
const LocalOrbitalMethodConfig = exports.LocalOrbitalMethodConfig = {
|
|
17
|
-
type: "localorbital",
|
|
18
|
-
subtype: "pople"
|
|
19
|
-
};
|
|
20
|
-
const UnknownMethodConfig = exports.UnknownMethodConfig = {
|
|
21
|
-
type: "unknown",
|
|
22
|
-
subtype: "unknown"
|
|
23
|
-
};
|
|
24
|
-
function allowedTypes(model) {
|
|
25
|
-
return _lodash.default.keys(_lodash.default.get(_tree.MODEL_TREE, `${model.type}.${model.subtype}.methods`, [])).map(x => {
|
|
26
|
-
return {
|
|
27
|
-
slug: x,
|
|
28
|
-
name: _lodash.default.get(_tree.MODEL_NAMES, x, x)
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
function allowedSubtypes(model, type) {
|
|
33
|
-
return _lodash.default.get(_tree.MODEL_TREE, `${model.type}.${model.subtype}.methods.${type}`, []).map(x => {
|
|
34
|
-
return {
|
|
35
|
-
slug: x,
|
|
36
|
-
name: _lodash.default.get(_tree.MODEL_NAMES, x, x)
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}
|
package/dist/default_models.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.UnknownModelConfig = exports.DFTModelConfig = void 0;
|
|
7
|
-
const DFTModelConfig = exports.DFTModelConfig = {
|
|
8
|
-
type: "dft",
|
|
9
|
-
subtype: "gga"
|
|
10
|
-
};
|
|
11
|
-
const UnknownModelConfig = exports.UnknownModelConfig = {
|
|
12
|
-
type: "unknown",
|
|
13
|
-
subtype: "unknown"
|
|
14
|
-
};
|
package/dist/index.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "DFTModel", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _dft.DFTModel;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "Method", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _method.Method;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "MethodFactory", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _factory.MethodFactory;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "Model", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _model.Model;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "ModelFactory", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _factory2.ModelFactory;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "PseudopotentialMethod", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _pseudopotential.PseudopotentialMethod;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
exports.tree = exports.default_models = exports.default_methods = exports.categorizedModelList = exports.categorizedMethodList = void 0;
|
|
43
|
-
var _standata = require("@mat3ra/standata");
|
|
44
|
-
var default_methods = _interopRequireWildcard(require("./default_methods"));
|
|
45
|
-
exports.default_methods = default_methods;
|
|
46
|
-
var default_models = _interopRequireWildcard(require("./default_models"));
|
|
47
|
-
exports.default_models = default_models;
|
|
48
|
-
var _method = require("./method");
|
|
49
|
-
var _factory = require("./methods/factory");
|
|
50
|
-
var _pseudopotential = require("./methods/pseudopotential");
|
|
51
|
-
var _model = require("./model");
|
|
52
|
-
var _dft = require("./models/dft");
|
|
53
|
-
var _factory2 = require("./models/factory");
|
|
54
|
-
var tree = _interopRequireWildcard(require("./tree"));
|
|
55
|
-
exports.tree = tree;
|
|
56
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
57
|
-
// TODO : can replace these with subpackages in exports in package.json
|
|
58
|
-
|
|
59
|
-
const methodStandata = new _standata.MethodStandata();
|
|
60
|
-
const modelStandata = new _standata.ModelStandata();
|
|
61
|
-
const categorizedMethodList = exports.categorizedMethodList = methodStandata.getAll();
|
|
62
|
-
const categorizedModelList = exports.categorizedModelList = modelStandata.getAll();
|
package/dist/method.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Method = void 0;
|
|
7
|
-
var _entity = require("@mat3ra/code/dist/js/entity");
|
|
8
|
-
var _utils = require("@mat3ra/code/dist/js/utils");
|
|
9
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
-
var _default_methods = require("./default_methods");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
class Method extends _entity.InMemoryEntity {
|
|
13
|
-
constructor(config) {
|
|
14
|
-
const data = config.data || {};
|
|
15
|
-
super({
|
|
16
|
-
...config,
|
|
17
|
-
data
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
cloneWithoutData() {
|
|
21
|
-
const clone = this.clone();
|
|
22
|
-
clone.setData({});
|
|
23
|
-
return clone;
|
|
24
|
-
}
|
|
25
|
-
get type() {
|
|
26
|
-
return this.prop("type");
|
|
27
|
-
}
|
|
28
|
-
get subtype() {
|
|
29
|
-
return this.prop("subtype");
|
|
30
|
-
}
|
|
31
|
-
setSubtype(subtype) {
|
|
32
|
-
// TODO: add proper handling of method data subscriptions on type/subtype change
|
|
33
|
-
this.setProp("subtype", subtype);
|
|
34
|
-
}
|
|
35
|
-
static get defaultConfig() {
|
|
36
|
-
return _default_methods.PseudopotentialMethodConfig;
|
|
37
|
-
}
|
|
38
|
-
get precision() {
|
|
39
|
-
return this.prop("precision");
|
|
40
|
-
}
|
|
41
|
-
get data() {
|
|
42
|
-
return this.prop("data");
|
|
43
|
-
}
|
|
44
|
-
get searchText() {
|
|
45
|
-
return this.prop("data.searchText", "");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// used to narrow down the list of methodData items available for selection
|
|
49
|
-
// utilizing "data" field as a "blackbox" container for searchText
|
|
50
|
-
setSearchText(searchText) {
|
|
51
|
-
this.setData({
|
|
52
|
-
...this.prop("data"),
|
|
53
|
-
searchText
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
setData(data = {}) {
|
|
57
|
-
this.setProp("data", data);
|
|
58
|
-
}
|
|
59
|
-
get omitInHashCalculation() {
|
|
60
|
-
const data = this.prop("data");
|
|
61
|
-
return !data.searchText && _lodash.default.isEmpty(_lodash.default.omit(data, "searchText"));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// data without client-only fields
|
|
65
|
-
cleanData(fieldsToExclude = []) {
|
|
66
|
-
const filteredData = {
|
|
67
|
-
...this.prop("data")
|
|
68
|
-
};
|
|
69
|
-
fieldsToExclude.forEach(f => {
|
|
70
|
-
delete filteredData[f];
|
|
71
|
-
});
|
|
72
|
-
return filteredData;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// override in child class if needed
|
|
76
|
-
toJSONWithCleanData(fieldsToExclude = []) {
|
|
77
|
-
const json = {
|
|
78
|
-
...this._json,
|
|
79
|
-
data: this.cleanData(fieldsToExclude)
|
|
80
|
-
};
|
|
81
|
-
return (0, _utils.deepClone)(json);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.Method = Method;
|
package/dist/methods/factory.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MethodFactory = void 0;
|
|
7
|
-
var _method = require("../method");
|
|
8
|
-
var _pseudopotential = require("./pseudopotential");
|
|
9
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
11
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
|
-
class MethodFactory {
|
|
13
|
-
static create(config) {
|
|
14
|
-
switch (config.type) {
|
|
15
|
-
case "pseudopotential":
|
|
16
|
-
return new this.PseudopotentialMethod(config);
|
|
17
|
-
default:
|
|
18
|
-
return new this.Method(config);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.MethodFactory = MethodFactory;
|
|
23
|
-
_defineProperty(MethodFactory, "Method", _method.Method);
|
|
24
|
-
_defineProperty(MethodFactory, "PseudopotentialMethod", _pseudopotential.PseudopotentialMethod);
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PseudopotentialMethod = void 0;
|
|
7
|
-
var _utils = require("@mat3ra/code/dist/js/utils");
|
|
8
|
-
var _underscore = _interopRequireDefault(require("underscore"));
|
|
9
|
-
var _method = require("../method");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
class PseudopotentialMethod extends _method.Method {
|
|
12
|
-
constructor(config) {
|
|
13
|
-
super(config);
|
|
14
|
-
this.PseudopotentialCls = null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// "Unique" or "selected" pseudopotentials - one per element
|
|
18
|
-
get pseudo() {
|
|
19
|
-
return this.prop("data.pseudo", []);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// "All" or "non-unique" pseudopotentials available for a choice
|
|
23
|
-
get allPseudo() {
|
|
24
|
-
return this.prop("data.allPseudo", []);
|
|
25
|
-
}
|
|
26
|
-
get pseudopotentials() {
|
|
27
|
-
return this.pseudo.map(x => new this.PseudopotentialCls(x));
|
|
28
|
-
}
|
|
29
|
-
get allPseudopotentials() {
|
|
30
|
-
return this.allPseudo.map(x => new this.PseudopotentialCls(x));
|
|
31
|
-
}
|
|
32
|
-
static extractExchangeCorrelationFromSubworkflow(subworkflow) {
|
|
33
|
-
const {
|
|
34
|
-
model
|
|
35
|
-
} = subworkflow;
|
|
36
|
-
const approximation = model.subtype;
|
|
37
|
-
const functional = model.functional ? model.functional.slug || model.functional : "";
|
|
38
|
-
return {
|
|
39
|
-
approximation,
|
|
40
|
-
functional
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
hasPseudopotentialFor(element) {
|
|
44
|
-
return Boolean(this.pseudopotentials.find(x => x.element === element));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @summary Sets one pseudopotential per element. Subsequent applications will override previous.
|
|
49
|
-
* @param pseudo {Pseudopotential}
|
|
50
|
-
*/
|
|
51
|
-
setPseudopotentialPerElement(pseudo) {
|
|
52
|
-
if (!pseudo) {
|
|
53
|
-
this.setPseudopotentials([]);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const arr = this.pseudopotentials.filter(x => x.element !== pseudo.element);
|
|
57
|
-
arr.push(pseudo);
|
|
58
|
-
this.setPseudopotentials(arr);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// add new pseudopotentials to the list of all pseudopotentials
|
|
62
|
-
addToAllPseudos(pseudos) {
|
|
63
|
-
// eslint-disable-next-line no-param-reassign
|
|
64
|
-
pseudos = (0, _utils.safeMakeArray)(pseudos);
|
|
65
|
-
const allPseudos = this.allPseudopotentials;
|
|
66
|
-
allPseudos.push(...pseudos);
|
|
67
|
-
this.setAllPseudopotentials(allPseudos);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @param pseudopotentials {Pseudopotential[]}
|
|
72
|
-
*/
|
|
73
|
-
setPseudopotentials(pseudopotentials) {
|
|
74
|
-
// sort by alphabetical order to ensure elements order consistency in VASP POSCAR/POTCAR
|
|
75
|
-
this.setData({
|
|
76
|
-
...this.data,
|
|
77
|
-
pseudo: _underscore.default.sortBy(pseudopotentials, "element").map(x => x.toJSON())
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @param pseudopotentials {Pseudopotential[]}
|
|
83
|
-
*/
|
|
84
|
-
setAllPseudopotentials(pseudopotentials) {
|
|
85
|
-
// sort by alphabetical order to ensure elements order consistency in VASP POSCAR/POTCAR
|
|
86
|
-
this.setData({
|
|
87
|
-
...this.data,
|
|
88
|
-
allPseudo: _underscore.default.sortBy(pseudopotentials, "element").map(x => x.toJSON())
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// override default `toJSONWithCleanData` method to avoid saving `allPseudo` inside the workflow
|
|
93
|
-
// TODO: revise after implementing Pseudopotential Sets
|
|
94
|
-
toJSONWithCleanData(exclude = []) {
|
|
95
|
-
return super.toJSONWithCleanData(exclude.concat(["allPseudo"
|
|
96
|
-
// 'pseudo' - not cleaning the field to save it in `Job.workflow`
|
|
97
|
-
]));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.PseudopotentialMethod = PseudopotentialMethod;
|
package/dist/model.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Model = void 0;
|
|
7
|
-
var _entity = require("@mat3ra/code/dist/js/entity");
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
-
var _default_models = require("./default_models");
|
|
10
|
-
var _method = require("./method");
|
|
11
|
-
var _factory = require("./methods/factory");
|
|
12
|
-
var _tree = require("./tree");
|
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
class Model extends _entity.InMemoryEntity {
|
|
15
|
-
constructor({
|
|
16
|
-
application,
|
|
17
|
-
...config
|
|
18
|
-
}) {
|
|
19
|
-
super(config);
|
|
20
|
-
this._application = application;
|
|
21
|
-
this._MethodFactory = _factory.MethodFactory;
|
|
22
|
-
}
|
|
23
|
-
get type() {
|
|
24
|
-
return this.prop("type", this.defaultType);
|
|
25
|
-
}
|
|
26
|
-
get subtype() {
|
|
27
|
-
return this.prop("subtype", this.defaultSubtype);
|
|
28
|
-
}
|
|
29
|
-
setSubtype(subtype) {
|
|
30
|
-
this.setProp("subtype", subtype);
|
|
31
|
-
this.setMethod(this._MethodFactory.create(this.defaultMethodConfig));
|
|
32
|
-
}
|
|
33
|
-
get allowedTypes() {
|
|
34
|
-
return Object.keys(this.tree).map(modelSlug => (0, _tree.treeSlugToNamedObject)(modelSlug));
|
|
35
|
-
}
|
|
36
|
-
get allowedSubtypes() {
|
|
37
|
-
return Object.keys(this.treeBranchForType).map(slug => (0, _tree.treeSlugToNamedObject)(slug));
|
|
38
|
-
}
|
|
39
|
-
get defaultType() {
|
|
40
|
-
return this.allowedTypes[0]?.slug;
|
|
41
|
-
}
|
|
42
|
-
get defaultSubtype() {
|
|
43
|
-
return this.allowedSubtypes[0]?.slug;
|
|
44
|
-
}
|
|
45
|
-
get tree() {
|
|
46
|
-
return this._application && this.treeByApplicationNameAndVersion || _tree.MODEL_TREE;
|
|
47
|
-
}
|
|
48
|
-
get treeBranchForType() {
|
|
49
|
-
return this.tree[this.type] || {};
|
|
50
|
-
}
|
|
51
|
-
get treeBranchForSubType() {
|
|
52
|
-
return this.treeBranchForType[this.subtype] || {};
|
|
53
|
-
}
|
|
54
|
-
get treeByApplicationNameAndVersion() {
|
|
55
|
-
const [name, version] = [this._application.name, this._application.version];
|
|
56
|
-
return (0, _tree.getTreeByApplicationNameAndVersion)({
|
|
57
|
-
name,
|
|
58
|
-
version
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
get groupSlug() {
|
|
62
|
-
return `${this._application.shortName}:${this.type}:${this.subtype}`;
|
|
63
|
-
}
|
|
64
|
-
get method() {
|
|
65
|
-
if (!this._method) {
|
|
66
|
-
const method = this.prop("method") || this.defaultMethodConfig;
|
|
67
|
-
this._method = this._MethodFactory.create(method);
|
|
68
|
-
}
|
|
69
|
-
return this._method;
|
|
70
|
-
}
|
|
71
|
-
setMethod(method) {
|
|
72
|
-
this._method = method;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Consider moving the below to `Method`
|
|
76
|
-
get methodsFromTree() {
|
|
77
|
-
return this.treeBranchForSubType.methods || {};
|
|
78
|
-
}
|
|
79
|
-
get methodTypes() {
|
|
80
|
-
return Object.keys(this.methodsFromTree).map(m => (0, _tree.treeSlugToNamedObject)(m));
|
|
81
|
-
}
|
|
82
|
-
get methodSubtypes() {
|
|
83
|
-
return this.methodsFromTree[this.method.type].map(m => (0, _tree.treeSlugToNamedObject)(m)) || [];
|
|
84
|
-
}
|
|
85
|
-
get defaultMethodConfig() {
|
|
86
|
-
const type = Object.keys(this.methodsFromTree)[0];
|
|
87
|
-
const subtype = (this.methodsFromTree[type] || [])[0];
|
|
88
|
-
return {
|
|
89
|
-
type,
|
|
90
|
-
subtype
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
static get defaultConfig() {
|
|
94
|
-
return {
|
|
95
|
-
..._default_models.DFTModelConfig,
|
|
96
|
-
method: _method.Method.defaultConfig
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
static get allTypes() {
|
|
100
|
-
return Object.keys(this.tree).map(modelSlug => (0, _tree.treeSlugToNamedObject)(modelSlug));
|
|
101
|
-
}
|
|
102
|
-
toJSON() {
|
|
103
|
-
return {
|
|
104
|
-
...super.toJSON(),
|
|
105
|
-
type: this.type,
|
|
106
|
-
subtype: this.subtype,
|
|
107
|
-
// TODO: use schema-based cleaning instead
|
|
108
|
-
method: this.method.toJSONWithCleanData()
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// to be used with extra properties
|
|
113
|
-
// eslint-disable-next-line class-methods-use-this
|
|
114
|
-
_stringToSlugifiedObject(slug) {
|
|
115
|
-
return _lodash.default.isString(slug) ? {
|
|
116
|
-
slug
|
|
117
|
-
} : slug;
|
|
118
|
-
}
|
|
119
|
-
get isUnknown() {
|
|
120
|
-
return this.type === "unknown";
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.Model = Model;
|
package/dist/models/dft.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DFTModel = void 0;
|
|
7
|
-
var _underscore = _interopRequireDefault(require("underscore"));
|
|
8
|
-
var _factory = require("../methods/factory");
|
|
9
|
-
var _model = require("../model");
|
|
10
|
-
var _tree = require("../tree");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
class DFTModel extends _model.Model {
|
|
13
|
-
constructor(config) {
|
|
14
|
-
super(config);
|
|
15
|
-
this._MethodFactory = config.MethodFactory || _factory.MethodFactory;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @summary Build slug string based on model information
|
|
20
|
-
* @returns {string}
|
|
21
|
-
*/
|
|
22
|
-
get groupSlug() {
|
|
23
|
-
return [this._application.shortName, this.type, this.subtype, this.functional.slug, this.refiners.map(o => o.slug).join("+"), this.modifiers.map(o => o.slug).join("+")].join(":").replace("::", ":").replace(/:$/, "");
|
|
24
|
-
}
|
|
25
|
-
get defaultFunctional() {
|
|
26
|
-
return (0, _tree.treeSlugToNamedObject)(this.treeBranchForSubType.functionals[0]);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// eslint-disable-next-line class-methods-use-this
|
|
30
|
-
get defaultRefiners() {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// eslint-disable-next-line class-methods-use-this
|
|
35
|
-
get defaultModifiers() {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
get functional() {
|
|
39
|
-
return this.prop("functional", this.defaultFunctional);
|
|
40
|
-
}
|
|
41
|
-
get refiners() {
|
|
42
|
-
return this.prop("refiners", this.defaultRefiners);
|
|
43
|
-
}
|
|
44
|
-
get modifiers() {
|
|
45
|
-
return this.prop("modifiers", this.defaultModifiers);
|
|
46
|
-
}
|
|
47
|
-
setSubtype(subtype) {
|
|
48
|
-
this.setProp("subtype", subtype);
|
|
49
|
-
this.setFunctional(this.defaultFunctional);
|
|
50
|
-
}
|
|
51
|
-
setFunctional(functional) {
|
|
52
|
-
this.setProp("functional", this._stringToSlugifiedObject(functional));
|
|
53
|
-
this.setMethod(this._MethodFactory.create(this.defaultMethodConfig));
|
|
54
|
-
}
|
|
55
|
-
_setArrayProp(name, data) {
|
|
56
|
-
// eslint-disable-next-line no-param-reassign, no-undef
|
|
57
|
-
data = safeMakeArray(data).map(r => this._stringToSlugifiedObject(r));
|
|
58
|
-
this.setProp(name, data);
|
|
59
|
-
this[`_${name}`] = data;
|
|
60
|
-
}
|
|
61
|
-
setRefiners(refiners) {
|
|
62
|
-
this._setArrayProp("refiners", refiners);
|
|
63
|
-
}
|
|
64
|
-
setModifiers(modifiers) {
|
|
65
|
-
this._setArrayProp("modifiers", modifiers);
|
|
66
|
-
}
|
|
67
|
-
toJSON() {
|
|
68
|
-
const pickSlugFromObject = o => _underscore.default.pick(o, "slug");
|
|
69
|
-
return {
|
|
70
|
-
...super.toJSON(),
|
|
71
|
-
functional: pickSlugFromObject(this.functional),
|
|
72
|
-
// only store slug for `functional`
|
|
73
|
-
refiners: this.refiners,
|
|
74
|
-
modifiers: this.modifiers
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Get all functionals in the form of {name: ..., slug: ...} for further use in UI
|
|
80
|
-
* @returns {Object.<string, string>[]} - List of functional objects
|
|
81
|
-
*/
|
|
82
|
-
get allFunctionals() {
|
|
83
|
-
return this.treeBranchForSubType.functionals.map(x => (0, _tree.treeSlugToNamedObject)(x));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Get all refiners in the form of {name: ..., slug: ...} for further use in UI
|
|
88
|
-
* @returns {Object.<string, string>[]} - List of refiner objects
|
|
89
|
-
*/
|
|
90
|
-
get allRefiners() {
|
|
91
|
-
return this.treeBranchForSubType.refiners.map(x => (0, _tree.treeSlugToNamedObject)(x));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get all modifiers in the form of {name: ..., slug: ...} for further use in UI
|
|
96
|
-
* @returns {Object.<string, string>[]} - List of modifier objects
|
|
97
|
-
*/
|
|
98
|
-
get allModifiers() {
|
|
99
|
-
return this.treeBranchForSubType.modifiers.map(x => (0, _tree.treeSlugToNamedObject)(x));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.DFTModel = DFTModel;
|
package/dist/models/factory.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ModelFactory = void 0;
|
|
7
|
-
var _model = require("../model");
|
|
8
|
-
var _tree = require("../tree");
|
|
9
|
-
var _dft = require("./dft");
|
|
10
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
11
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
12
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
-
class ModelFactory {
|
|
14
|
-
static create(config) {
|
|
15
|
-
switch (config.type) {
|
|
16
|
-
case "dft":
|
|
17
|
-
return new this.DFTModel(config);
|
|
18
|
-
default:
|
|
19
|
-
return new this.Model(config);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
static createFromApplication(config) {
|
|
23
|
-
const {
|
|
24
|
-
application
|
|
25
|
-
} = config;
|
|
26
|
-
const type = application && (0, _tree.getDefaultModelTypeForApplication)(application);
|
|
27
|
-
if (!type) throw new Error(`ModelFactory.createFromApplication: cannot determine model type: ${type}`);
|
|
28
|
-
return this.create({
|
|
29
|
-
...config,
|
|
30
|
-
type
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.ModelFactory = ModelFactory;
|
|
35
|
-
_defineProperty(ModelFactory, "DFTModel", _dft.DFTModel);
|
|
36
|
-
_defineProperty(ModelFactory, "Model", _model.Model);
|