@mat3ra/mode 2025.11.3-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} +1 -1
- 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 -20
- 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 -69
- package/dist/method.js +0 -84
- package/dist/methodConversionHandler.js +0 -128
- package/dist/methods/factory.js +0 -24
- package/dist/methods/pseudopotential.js +0 -100
- package/dist/model.js +0 -123
- package/dist/modelConversionHandler.js +0 -102
- package/dist/models/dft.js +0 -102
- package/dist/models/factory.js +0 -36
- package/dist/tree.js +0 -147
- 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/methodConversionHandler.js +0 -125
- package/src/methods/pseudopotential.js +0 -99
- package/src/model.js +0 -127
- package/src/modelConversionHandler.js +0 -91
- 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,69 +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, "MethodConversionHandler", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _methodConversionHandler.MethodConversionHandler;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "MethodFactory", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _factory.MethodFactory;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "Model", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _model.Model;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "ModelConversionHandler", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _modelConversionHandler.ModelConversionHandler;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, "ModelFactory", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _factory2.ModelFactory;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(exports, "PseudopotentialMethod", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return _pseudopotential.PseudopotentialMethod;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
exports.tree = exports.default_models = exports.default_methods = void 0;
|
|
55
|
-
var default_methods = _interopRequireWildcard(require("./default_methods"));
|
|
56
|
-
exports.default_methods = default_methods;
|
|
57
|
-
var default_models = _interopRequireWildcard(require("./default_models"));
|
|
58
|
-
exports.default_models = default_models;
|
|
59
|
-
var _method = require("./method");
|
|
60
|
-
var _methodConversionHandler = require("./methodConversionHandler");
|
|
61
|
-
var _factory = require("./methods/factory");
|
|
62
|
-
var _pseudopotential = require("./methods/pseudopotential");
|
|
63
|
-
var _model = require("./model");
|
|
64
|
-
var _modelConversionHandler = require("./modelConversionHandler");
|
|
65
|
-
var _dft = require("./models/dft");
|
|
66
|
-
var _factory2 = require("./models/factory");
|
|
67
|
-
var tree = _interopRequireWildcard(require("./tree"));
|
|
68
|
-
exports.tree = tree;
|
|
69
|
-
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); }
|
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;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MethodConversionHandler = void 0;
|
|
7
|
-
exports.safelyGetSlug = safelyGetSlug;
|
|
8
|
-
var _default_methods = require("./default_methods");
|
|
9
|
-
function safelyGetSlug(slugObj) {
|
|
10
|
-
return typeof slugObj === "string" ? slugObj : slugObj.slug;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The method interface converts between the legacy method data structure (type, subtype)
|
|
15
|
-
* and the categorized method data structure (units with tier1, tier2, ...).
|
|
16
|
-
*/
|
|
17
|
-
class MethodConversionHandler {
|
|
18
|
-
static convertToSimple(cm) {
|
|
19
|
-
if (!cm) return this.convertUnknownToSimple();
|
|
20
|
-
const pspUnits = cm.units.filter(u => u.categories.type === "psp");
|
|
21
|
-
const aoUnit = cm.units.find(u => u.categories.type === "ao");
|
|
22
|
-
const reUnit = cm.units.find(u => u.name && u.name.includes("regression"));
|
|
23
|
-
if (pspUnits.length) return this.convertPspUnitsToSimple(pspUnits);
|
|
24
|
-
if (aoUnit) return this.convertAoUnitToSimple();
|
|
25
|
-
if (reUnit) return this.convertRegressionUnitToSimple(reUnit);
|
|
26
|
-
return this.convertRegressionUnitToSimple(reUnit);
|
|
27
|
-
}
|
|
28
|
-
static convertUnknownToSimple() {
|
|
29
|
-
return _default_methods.UnknownMethodConfig;
|
|
30
|
-
}
|
|
31
|
-
static convertPspUnitsToSimple(cm) {
|
|
32
|
-
const [firstPspUnit, ...otherUnits] = cm;
|
|
33
|
-
if (!firstPspUnit || !firstPspUnit.categories?.subtype) return this.convertUnknownToSimple();
|
|
34
|
-
const subtype = otherUnits?.length ? "any" : firstPspUnit.categories.subtype;
|
|
35
|
-
return {
|
|
36
|
-
type: "pseudopotential",
|
|
37
|
-
subtype
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
static convertAoUnitToSimple() {
|
|
41
|
-
return _default_methods.LocalOrbitalMethodConfig;
|
|
42
|
-
}
|
|
43
|
-
static convertRegressionUnitToSimple(cm) {
|
|
44
|
-
const type = cm.categories.type || "linear";
|
|
45
|
-
const subtype = cm.categories.subtype || "least_squares";
|
|
46
|
-
return {
|
|
47
|
-
type: safelyGetSlug(type),
|
|
48
|
-
subtype: safelyGetSlug(subtype),
|
|
49
|
-
data: cm.data,
|
|
50
|
-
precision: cm.precision
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
static convertToCategorized(sm, allMethods = []) {
|
|
54
|
-
switch (sm?.type) {
|
|
55
|
-
case "pseudopotential":
|
|
56
|
-
return this.convertPspToCategorized(sm, allMethods);
|
|
57
|
-
case "localorbital":
|
|
58
|
-
return this.convertAoToCategorized(sm);
|
|
59
|
-
case "linear":
|
|
60
|
-
return this.convertRegressionToCategorized(sm);
|
|
61
|
-
case "kernel_ridge":
|
|
62
|
-
return this.convertRegressionToCategorized(sm);
|
|
63
|
-
default:
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
static convertPspToCategorized(sm, allMethods = []) {
|
|
68
|
-
const subtype = safelyGetSlug(sm.subtype);
|
|
69
|
-
// the "any" subtype is equivalent to the method representing all planewave-pseudopotential
|
|
70
|
-
// methods. All other subtypes are equivalent to using a specific PW-PSP method.
|
|
71
|
-
const path = subtype === "any" ? "/qm/wf/none/psp/us::/qm/wf/none/psp/nc::/qm/wf/none/psp/nc-fr::/qm/wf/none/psp/paw::/qm/wf/none/pw/none" : `/qm/wf/none/smearing/gaussian::/linalg/diag/none/davidson/none::/qm/wf/none/psp/${subtype}::/qm/wf/none/pw/none`;
|
|
72
|
-
return allMethods.find(catMethod => {
|
|
73
|
-
return catMethod.path === path;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
static convertAoToCategorized(sm) {
|
|
77
|
-
const subtype = safelyGetSlug(sm.subtype);
|
|
78
|
-
return {
|
|
79
|
-
units: [{
|
|
80
|
-
parameters: {
|
|
81
|
-
basisSlug: "6-31G"
|
|
82
|
-
},
|
|
83
|
-
categories: {
|
|
84
|
-
tier1: "qm",
|
|
85
|
-
tier2: "wf",
|
|
86
|
-
type: "ao",
|
|
87
|
-
subtype
|
|
88
|
-
},
|
|
89
|
-
tags: ["atomic orbital"],
|
|
90
|
-
name: "Wave function: LCAO - Pople basis set (6-31G)",
|
|
91
|
-
path: "/qm/wf/none/ao/pople?basisSlug=6-31G"
|
|
92
|
-
}],
|
|
93
|
-
name: "Wave function: LCAO - Pople basis set (6-31G)",
|
|
94
|
-
path: "/qm/wf/none/ao/pople?basisSlug=6-31G"
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
static convertRegressionToCategorized(sm) {
|
|
98
|
-
const type = safelyGetSlug(sm.type);
|
|
99
|
-
const subtype = safelyGetSlug(sm.subtype);
|
|
100
|
-
const {
|
|
101
|
-
precision,
|
|
102
|
-
data
|
|
103
|
-
} = sm;
|
|
104
|
-
const path = `/none/none/none/${type}/${subtype}`;
|
|
105
|
-
const nameMap = {
|
|
106
|
-
kernel_ridge: "Kernel ridge",
|
|
107
|
-
linear: "Linear",
|
|
108
|
-
least_squares: "least squares",
|
|
109
|
-
ridge: "ridge"
|
|
110
|
-
};
|
|
111
|
-
const name = `${nameMap[type]} ${nameMap[subtype]} regression`;
|
|
112
|
-
return {
|
|
113
|
-
units: [{
|
|
114
|
-
categories: {
|
|
115
|
-
type,
|
|
116
|
-
subtype
|
|
117
|
-
},
|
|
118
|
-
name,
|
|
119
|
-
path,
|
|
120
|
-
precision,
|
|
121
|
-
data
|
|
122
|
-
}],
|
|
123
|
-
name,
|
|
124
|
-
path
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
exports.MethodConversionHandler = MethodConversionHandler;
|
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;
|