@mat3ra/mode 2025.11.3-0 → 2025.11.5-1
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/dist/js/default_methods.d.ts +6 -0
- package/dist/js/default_methods.js +36 -0
- package/dist/js/default_models.d.ts +3 -0
- package/dist/js/default_models.js +11 -0
- package/dist/js/generated/MethodSchemaMixin.d.ts +5 -0
- package/dist/js/generated/MethodSchemaMixin.js +21 -0
- package/dist/js/generated/ModelSchemaMixin.d.ts +5 -0
- package/dist/js/generated/ModelSchemaMixin.js +18 -0
- package/dist/js/index.d.ts +12 -0
- package/dist/js/index.js +58 -0
- package/dist/js/method.d.ts +22 -0
- package/dist/js/method.js +54 -0
- package/dist/js/methodConversionHandler.d.ts +14 -0
- package/dist/js/methodConversionHandler.js +128 -0
- package/dist/js/methods/factory.d.ts +8 -0
- package/dist/js/methods/factory.js +18 -0
- package/dist/js/methods/pseudopotential.d.ts +21 -0
- package/dist/js/methods/pseudopotential.js +75 -0
- package/dist/js/model.d.ts +38 -0
- package/dist/js/model.js +138 -0
- package/dist/js/modelConversionHandler.d.ts +12 -0
- package/dist/js/modelConversionHandler.js +127 -0
- package/dist/js/models/dft.d.ts +25 -0
- package/dist/js/models/dft.js +89 -0
- package/dist/js/models/factory.d.ts +9 -0
- package/dist/js/models/factory.js +30 -0
- package/dist/js/tree.d.ts +15 -0
- package/dist/js/tree.js +141 -0
- package/dist/js/types/index.d.ts +20 -0
- package/dist/js/types/index.js +2 -0
- package/package.json +32 -19
- 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
package/dist/js/model.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Model = void 0;
|
|
7
|
+
const entity_1 = require("@mat3ra/code/dist/js/entity");
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const default_models_1 = require("./default_models");
|
|
10
|
+
const ModelSchemaMixin_1 = require("./generated/ModelSchemaMixin");
|
|
11
|
+
const method_1 = require("./method");
|
|
12
|
+
const factory_1 = require("./methods/factory");
|
|
13
|
+
const tree_1 = require("./tree");
|
|
14
|
+
const EMPTY_BRANCH = { methods: {} };
|
|
15
|
+
class Model extends entity_1.InMemoryEntity {
|
|
16
|
+
constructor(config) {
|
|
17
|
+
const { application, ...entityConfig } = config;
|
|
18
|
+
super(entityConfig);
|
|
19
|
+
this._application = application;
|
|
20
|
+
this._MethodFactory = factory_1.MethodFactory;
|
|
21
|
+
}
|
|
22
|
+
// get type(): string {
|
|
23
|
+
// return this.prop<string>("type", this.defaultType);
|
|
24
|
+
// }
|
|
25
|
+
// get subtype(): StringOrNamedSlug {
|
|
26
|
+
// return this.prop<StringOrNamedSlug>("subtype", this.defaultSubtype);
|
|
27
|
+
// }
|
|
28
|
+
setSubtype(subtype) {
|
|
29
|
+
this.setProp("subtype", subtype);
|
|
30
|
+
this.setMethod(this._MethodFactory.create(this.defaultMethodConfig));
|
|
31
|
+
}
|
|
32
|
+
get allowedTypes() {
|
|
33
|
+
return Object.keys(this.tree).map((modelSlug) => (0, tree_1.treeSlugToNamedObject)(modelSlug));
|
|
34
|
+
}
|
|
35
|
+
get allowedSubtypes() {
|
|
36
|
+
return Object.keys(this.treeBranchForType).map((slug) => (0, tree_1.treeSlugToNamedObject)(slug));
|
|
37
|
+
}
|
|
38
|
+
get defaultType() {
|
|
39
|
+
var _a;
|
|
40
|
+
return ((_a = this.allowedTypes[0]) === null || _a === void 0 ? void 0 : _a.slug) || "";
|
|
41
|
+
}
|
|
42
|
+
get defaultSubtype() {
|
|
43
|
+
var _a;
|
|
44
|
+
return ((_a = this.allowedSubtypes[0]) === null || _a === void 0 ? void 0 : _a.slug) || "";
|
|
45
|
+
}
|
|
46
|
+
get tree() {
|
|
47
|
+
if (this._application) {
|
|
48
|
+
const treeByApplication = this.treeByApplicationNameAndVersion;
|
|
49
|
+
if (treeByApplication)
|
|
50
|
+
return treeByApplication;
|
|
51
|
+
}
|
|
52
|
+
return tree_1.MODEL_TREE;
|
|
53
|
+
}
|
|
54
|
+
get treeBranchForType() {
|
|
55
|
+
return this.tree[this.type] || {};
|
|
56
|
+
}
|
|
57
|
+
get treeBranchForSubType() {
|
|
58
|
+
return this.treeBranchForType[this.subtypeSlug] || EMPTY_BRANCH;
|
|
59
|
+
}
|
|
60
|
+
get treeByApplicationNameAndVersion() {
|
|
61
|
+
if (!this._application)
|
|
62
|
+
return undefined;
|
|
63
|
+
const { name, version } = this._application;
|
|
64
|
+
return (0, tree_1.getTreeByApplicationNameAndVersion)({ name, version });
|
|
65
|
+
}
|
|
66
|
+
get groupSlug() {
|
|
67
|
+
const subtype = this.subtypeSlug;
|
|
68
|
+
if (!this._application)
|
|
69
|
+
return `${this.type}:${subtype}`;
|
|
70
|
+
return `${this._application.shortName}:${this.type}:${subtype}`;
|
|
71
|
+
}
|
|
72
|
+
get Method() {
|
|
73
|
+
if (!this._method) {
|
|
74
|
+
const methodOrConfig = this.method;
|
|
75
|
+
const config = methodOrConfig || this.defaultMethodConfig;
|
|
76
|
+
this._method = this._MethodFactory.create(config);
|
|
77
|
+
}
|
|
78
|
+
return this._method;
|
|
79
|
+
}
|
|
80
|
+
setMethod(method) {
|
|
81
|
+
this._method = method;
|
|
82
|
+
}
|
|
83
|
+
get methodsFromTree() {
|
|
84
|
+
return this.treeBranchForSubType.methods || {};
|
|
85
|
+
}
|
|
86
|
+
get methodTypes() {
|
|
87
|
+
return Object.keys(this.methodsFromTree).map((type) => (0, tree_1.treeSlugToNamedObject)(type));
|
|
88
|
+
}
|
|
89
|
+
get methodSubtypes() {
|
|
90
|
+
const { type } = this.method;
|
|
91
|
+
const subtypes = this.methodsFromTree[type] || [];
|
|
92
|
+
return subtypes.map((slug) => (0, tree_1.treeSlugToNamedObject)(slug));
|
|
93
|
+
}
|
|
94
|
+
get defaultMethodConfig() {
|
|
95
|
+
var _a;
|
|
96
|
+
const methodTypes = Object.keys(this.methodsFromTree);
|
|
97
|
+
const type = methodTypes[0];
|
|
98
|
+
if (!type)
|
|
99
|
+
return method_1.Method.defaultConfig;
|
|
100
|
+
const subtype = (_a = this.methodsFromTree[type]) === null || _a === void 0 ? void 0 : _a[0];
|
|
101
|
+
if (!subtype)
|
|
102
|
+
return method_1.Method.defaultConfig;
|
|
103
|
+
return { type, subtype };
|
|
104
|
+
}
|
|
105
|
+
static get defaultConfig() {
|
|
106
|
+
return {
|
|
107
|
+
...default_models_1.DFTModelConfig,
|
|
108
|
+
method: method_1.Method.defaultConfig,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
static get allTypes() {
|
|
112
|
+
return Object.keys(tree_1.MODEL_TREE).map((modelSlug) => (0, tree_1.treeSlugToNamedObject)(modelSlug));
|
|
113
|
+
}
|
|
114
|
+
toJSON() {
|
|
115
|
+
const json = super.toJSON();
|
|
116
|
+
return {
|
|
117
|
+
...json,
|
|
118
|
+
type: this.type,
|
|
119
|
+
subtype: this.subtype,
|
|
120
|
+
method: this.method.toJSONWithCleanData(),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
_stringToSlugifiedObject(slug) {
|
|
124
|
+
if (lodash_1.default.isString(slug)) {
|
|
125
|
+
return { slug };
|
|
126
|
+
}
|
|
127
|
+
return slug;
|
|
128
|
+
}
|
|
129
|
+
get isUnknown() {
|
|
130
|
+
return this.type === "unknown";
|
|
131
|
+
}
|
|
132
|
+
get subtypeSlug() {
|
|
133
|
+
const subtype = this.subtype;
|
|
134
|
+
return typeof subtype === "string" ? subtype : subtype.slug;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.Model = Model;
|
|
138
|
+
(0, ModelSchemaMixin_1.modelSchemaMixin)(Model.prototype);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CategorizedModel, SlugifiedEntryOrSlug } from "@mat3ra/esse/dist/js/types";
|
|
2
|
+
import type { ModelConfig, SimplifiedCategorizedModel } from "./types";
|
|
3
|
+
export declare function safelyGetSlug(slugObj: SlugifiedEntryOrSlug): string;
|
|
4
|
+
export declare class ModelConversionHandler {
|
|
5
|
+
static convertToSimple(categorizedModel: CategorizedModel | undefined): ModelConfig;
|
|
6
|
+
static convertDftToSimple(categorizedModel: CategorizedModel): ModelConfig;
|
|
7
|
+
static convertMlToSimple(): ModelConfig;
|
|
8
|
+
static convertUnknownToSimple(): ModelConfig;
|
|
9
|
+
static convertToCategorized(simpleModel: ModelConfig | undefined, allModels?: CategorizedModel[]): SimplifiedCategorizedModel | undefined;
|
|
10
|
+
static convertDftToCategorized(simpleModel: ModelConfig, allModels?: CategorizedModel[]): SimplifiedCategorizedModel | undefined;
|
|
11
|
+
static convertMlToCategorized(simpleModel: ModelConfig): SimplifiedCategorizedModel;
|
|
12
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ModelConversionHandler = void 0;
|
|
37
|
+
exports.safelyGetSlug = safelyGetSlug;
|
|
38
|
+
const tree = __importStar(require("./tree"));
|
|
39
|
+
function safelyGetSlug(slugObj) {
|
|
40
|
+
return typeof slugObj === "string" ? slugObj : slugObj.slug;
|
|
41
|
+
}
|
|
42
|
+
class ModelConversionHandler {
|
|
43
|
+
static convertToSimple(categorizedModel) {
|
|
44
|
+
if (!categorizedModel)
|
|
45
|
+
return this.convertUnknownToSimple();
|
|
46
|
+
switch (categorizedModel.categories.tier3) {
|
|
47
|
+
case "dft":
|
|
48
|
+
return this.convertDftToSimple(categorizedModel);
|
|
49
|
+
case "ml":
|
|
50
|
+
return this.convertMlToSimple();
|
|
51
|
+
default:
|
|
52
|
+
return this.convertUnknownToSimple();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
static convertDftToSimple(categorizedModel) {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
if (!((_a = categorizedModel.categories) === null || _a === void 0 ? void 0 : _a.subtype))
|
|
58
|
+
return this.convertUnknownToSimple();
|
|
59
|
+
const subtypeCategory = categorizedModel.categories.subtype;
|
|
60
|
+
const subtype = safelyGetSlug(subtypeCategory);
|
|
61
|
+
const functionalParam = (_b = categorizedModel.parameters) === null || _b === void 0 ? void 0 : _b.functional;
|
|
62
|
+
const functionalSlug = functionalParam
|
|
63
|
+
? safelyGetSlug(functionalParam)
|
|
64
|
+
: "";
|
|
65
|
+
return {
|
|
66
|
+
type: "dft",
|
|
67
|
+
subtype,
|
|
68
|
+
functional: tree.treeSlugToNamedObject(functionalSlug),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
static convertMlToSimple() {
|
|
72
|
+
return {
|
|
73
|
+
type: "ml",
|
|
74
|
+
subtype: "re",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static convertUnknownToSimple() {
|
|
78
|
+
return {
|
|
79
|
+
type: "unknown",
|
|
80
|
+
subtype: "unknown",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
static convertToCategorized(simpleModel, allModels = []) {
|
|
84
|
+
switch (simpleModel === null || simpleModel === void 0 ? void 0 : simpleModel.type) {
|
|
85
|
+
case "dft":
|
|
86
|
+
return this.convertDftToCategorized(simpleModel, allModels);
|
|
87
|
+
case "ml":
|
|
88
|
+
return this.convertMlToCategorized(simpleModel);
|
|
89
|
+
case "unknown":
|
|
90
|
+
return undefined;
|
|
91
|
+
default:
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
static convertDftToCategorized(simpleModel, allModels = []) {
|
|
96
|
+
const { subtype, functional: functionalStringOrObject } = simpleModel;
|
|
97
|
+
const defaultFunctionals = {
|
|
98
|
+
lda: "pz",
|
|
99
|
+
gga: "pbe",
|
|
100
|
+
hybrid: "b3lyp",
|
|
101
|
+
};
|
|
102
|
+
let functional;
|
|
103
|
+
if (!functionalStringOrObject) {
|
|
104
|
+
functional = defaultFunctionals[subtype];
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
functional = safelyGetSlug(functionalStringOrObject);
|
|
108
|
+
}
|
|
109
|
+
const path = `/pb/qm/dft/ksdft/${subtype}?functional=${functional}`;
|
|
110
|
+
return allModels.find((categorized) => categorized.path === path);
|
|
111
|
+
}
|
|
112
|
+
static convertMlToCategorized(simpleModel) {
|
|
113
|
+
const subtype = safelyGetSlug(simpleModel.subtype);
|
|
114
|
+
return {
|
|
115
|
+
name: "Regression",
|
|
116
|
+
path: "/st/det/ml/re/none",
|
|
117
|
+
categories: {
|
|
118
|
+
tier1: "st",
|
|
119
|
+
tier2: "det",
|
|
120
|
+
tier3: "ml",
|
|
121
|
+
type: subtype,
|
|
122
|
+
},
|
|
123
|
+
parameters: {},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.ModelConversionHandler = ModelConversionHandler;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SlugifiedEntry, SlugifiedEntryOrSlug } from "@mat3ra/esse/dist/js/types";
|
|
2
|
+
import { MethodFactory } from "../methods/factory";
|
|
3
|
+
import { Model } from "../model";
|
|
4
|
+
import type { ModelConfig } from "../types";
|
|
5
|
+
export declare class DFTModel extends Model {
|
|
6
|
+
constructor(config: ModelConfig & {
|
|
7
|
+
MethodFactory?: typeof MethodFactory;
|
|
8
|
+
});
|
|
9
|
+
get groupSlug(): string;
|
|
10
|
+
get defaultFunctional(): SlugifiedEntry;
|
|
11
|
+
get defaultRefiners(): SlugifiedEntry[];
|
|
12
|
+
get defaultModifiers(): SlugifiedEntry[];
|
|
13
|
+
get functional(): SlugifiedEntry;
|
|
14
|
+
get refiners(): SlugifiedEntry[];
|
|
15
|
+
get modifiers(): SlugifiedEntry[];
|
|
16
|
+
setSubtype(subtype: SlugifiedEntryOrSlug): void;
|
|
17
|
+
setFunctional(functional: SlugifiedEntryOrSlug): void;
|
|
18
|
+
private _setArrayProp;
|
|
19
|
+
setRefiners(refiners: SlugifiedEntryOrSlug | SlugifiedEntryOrSlug[]): void;
|
|
20
|
+
setModifiers(modifiers: SlugifiedEntryOrSlug | SlugifiedEntryOrSlug[]): void;
|
|
21
|
+
toJSON(): Record<string, unknown>;
|
|
22
|
+
get allFunctionals(): SlugifiedEntry[];
|
|
23
|
+
get allRefiners(): SlugifiedEntry[];
|
|
24
|
+
get allModifiers(): SlugifiedEntry[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DFTModel = void 0;
|
|
7
|
+
const utils_1 = require("@mat3ra/code/dist/js/utils");
|
|
8
|
+
const underscore_1 = __importDefault(require("underscore"));
|
|
9
|
+
const factory_1 = require("../methods/factory");
|
|
10
|
+
const model_1 = require("../model");
|
|
11
|
+
const tree_1 = require("../tree");
|
|
12
|
+
class DFTModel extends model_1.Model {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super(config);
|
|
15
|
+
this._MethodFactory = config.MethodFactory || factory_1.MethodFactory;
|
|
16
|
+
}
|
|
17
|
+
get groupSlug() {
|
|
18
|
+
var _a;
|
|
19
|
+
const functionalSlug = this.functional.slug;
|
|
20
|
+
const refinersSlug = this.refiners.map((o) => o.slug).join("+");
|
|
21
|
+
const modifiersSlug = this.modifiers.map((o) => o.slug).join("+");
|
|
22
|
+
const slugs = [
|
|
23
|
+
(_a = this._application) === null || _a === void 0 ? void 0 : _a.shortName,
|
|
24
|
+
this.type,
|
|
25
|
+
this.subtype,
|
|
26
|
+
functionalSlug,
|
|
27
|
+
refinersSlug,
|
|
28
|
+
modifiersSlug,
|
|
29
|
+
].filter(Boolean);
|
|
30
|
+
return slugs.join(":");
|
|
31
|
+
}
|
|
32
|
+
get defaultFunctional() {
|
|
33
|
+
const [slug] = this.treeBranchForSubType.functionals || [];
|
|
34
|
+
return (0, tree_1.treeSlugToNamedObject)(slug);
|
|
35
|
+
}
|
|
36
|
+
get defaultRefiners() {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
get defaultModifiers() {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
get functional() {
|
|
43
|
+
return this.prop("functional", this.defaultFunctional);
|
|
44
|
+
}
|
|
45
|
+
get refiners() {
|
|
46
|
+
return this.prop("refiners", this.defaultRefiners);
|
|
47
|
+
}
|
|
48
|
+
get modifiers() {
|
|
49
|
+
return this.prop("modifiers", this.defaultModifiers);
|
|
50
|
+
}
|
|
51
|
+
setSubtype(subtype) {
|
|
52
|
+
this.setProp("subtype", subtype);
|
|
53
|
+
this.setFunctional(this.defaultFunctional);
|
|
54
|
+
}
|
|
55
|
+
setFunctional(functional) {
|
|
56
|
+
this.setProp("functional", this._stringToSlugifiedObject(functional));
|
|
57
|
+
this.setMethod(this._MethodFactory.create(this.defaultMethodConfig));
|
|
58
|
+
}
|
|
59
|
+
_setArrayProp(name, data) {
|
|
60
|
+
const normalized = (0, utils_1.safeMakeArray)(data).map((item) => this._stringToSlugifiedObject(item));
|
|
61
|
+
this.setProp(name, normalized);
|
|
62
|
+
this[`_${name}`] = normalized;
|
|
63
|
+
}
|
|
64
|
+
setRefiners(refiners) {
|
|
65
|
+
this._setArrayProp("refiners", refiners);
|
|
66
|
+
}
|
|
67
|
+
setModifiers(modifiers) {
|
|
68
|
+
this._setArrayProp("modifiers", modifiers);
|
|
69
|
+
}
|
|
70
|
+
toJSON() {
|
|
71
|
+
const pickSlugFromObject = (item) => underscore_1.default.pick(item, "slug");
|
|
72
|
+
return {
|
|
73
|
+
...super.toJSON(),
|
|
74
|
+
functional: pickSlugFromObject(this.functional),
|
|
75
|
+
refiners: this.refiners,
|
|
76
|
+
modifiers: this.modifiers,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
get allFunctionals() {
|
|
80
|
+
return (this.treeBranchForSubType.functionals || []).map((slug) => (0, tree_1.treeSlugToNamedObject)(slug));
|
|
81
|
+
}
|
|
82
|
+
get allRefiners() {
|
|
83
|
+
return (this.treeBranchForSubType.refiners || []).map((slug) => (0, tree_1.treeSlugToNamedObject)(slug));
|
|
84
|
+
}
|
|
85
|
+
get allModifiers() {
|
|
86
|
+
return (this.treeBranchForSubType.modifiers || []).map((slug) => (0, tree_1.treeSlugToNamedObject)(slug));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.DFTModel = DFTModel;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Model } from "../model";
|
|
2
|
+
import type { ModelConfig } from "../types";
|
|
3
|
+
import { DFTModel } from "./dft";
|
|
4
|
+
export declare class ModelFactory {
|
|
5
|
+
static DFTModel: typeof DFTModel;
|
|
6
|
+
static Model: typeof Model;
|
|
7
|
+
static create(config: ModelConfig): Model;
|
|
8
|
+
static createFromApplication(config: ModelConfig): Model;
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModelFactory = void 0;
|
|
4
|
+
const model_1 = require("../model");
|
|
5
|
+
const tree_1 = require("../tree");
|
|
6
|
+
const dft_1 = require("./dft");
|
|
7
|
+
class ModelFactory {
|
|
8
|
+
static create(config) {
|
|
9
|
+
switch (config.type) {
|
|
10
|
+
case "dft":
|
|
11
|
+
return new this.DFTModel(config);
|
|
12
|
+
default:
|
|
13
|
+
return new this.Model(config);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
static createFromApplication(config) {
|
|
17
|
+
const { application } = config;
|
|
18
|
+
if (!application) {
|
|
19
|
+
throw new Error("ModelFactory.createFromApplication: application is required");
|
|
20
|
+
}
|
|
21
|
+
const type = (0, tree_1.getDefaultModelTypeForApplication)(application);
|
|
22
|
+
if (!type) {
|
|
23
|
+
throw new Error(`ModelFactory.createFromApplication: cannot determine model type: ${type}`);
|
|
24
|
+
}
|
|
25
|
+
return this.create({ ...config, type });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ModelFactory = ModelFactory;
|
|
29
|
+
ModelFactory.DFTModel = dft_1.DFTModel;
|
|
30
|
+
ModelFactory.Model = model_1.Model;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApplicationSchemaBase, SlugifiedEntry } from "@mat3ra/esse/dist/js/types";
|
|
2
|
+
import type { ModelTree } from "./types";
|
|
3
|
+
export declare const METHODS: {
|
|
4
|
+
readonly pseudopotential: "pseudopotential";
|
|
5
|
+
readonly localorbital: "localorbital";
|
|
6
|
+
readonly unknown: "unknown";
|
|
7
|
+
};
|
|
8
|
+
export declare const getPseudopotentialTypesFromTree: () => string[];
|
|
9
|
+
export declare const getDFTFunctionalsFromTree: () => string[];
|
|
10
|
+
export declare const getDFTFunctionalsByApproximation: (approximation: string) => string[] | undefined;
|
|
11
|
+
export declare const MODEL_TREE: ModelTree;
|
|
12
|
+
export declare const MODEL_NAMES: Record<string, string>;
|
|
13
|
+
export declare const treeSlugToNamedObject: (modelSlug: string) => SlugifiedEntry;
|
|
14
|
+
export declare const getTreeByApplicationNameAndVersion: ({ name, }: Pick<ApplicationSchemaBase, "name" | "version">) => ModelTree;
|
|
15
|
+
export declare const getDefaultModelTypeForApplication: (application: ApplicationSchemaBase) => string;
|
package/dist/js/tree.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getDefaultModelTypeForApplication = exports.getTreeByApplicationNameAndVersion = exports.treeSlugToNamedObject = exports.MODEL_NAMES = exports.MODEL_TREE = exports.getDFTFunctionalsByApproximation = exports.getDFTFunctionalsFromTree = exports.getPseudopotentialTypesFromTree = exports.METHODS = void 0;
|
|
7
|
+
const utils_1 = require("@mat3ra/code/dist/js/utils");
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const underscore_1 = __importDefault(require("underscore"));
|
|
10
|
+
// TODO: migrate to use manifest instead
|
|
11
|
+
exports.METHODS = {
|
|
12
|
+
pseudopotential: "pseudopotential",
|
|
13
|
+
localorbital: "localorbital",
|
|
14
|
+
unknown: "unknown",
|
|
15
|
+
};
|
|
16
|
+
const methods = {
|
|
17
|
+
[exports.METHODS.pseudopotential]: ["paw", "nc", "nc-fr", "us"],
|
|
18
|
+
// TODO: Add additional basis set options, once user choice of specific (i.e 3-21G vs cc-pVDZ) is implemented.
|
|
19
|
+
[exports.METHODS.localorbital]: ["pople"],
|
|
20
|
+
[exports.METHODS.unknown]: ["unknown"],
|
|
21
|
+
};
|
|
22
|
+
const getPseudopotentialTypesFromTree = () => methods[exports.METHODS.pseudopotential];
|
|
23
|
+
exports.getPseudopotentialTypesFromTree = getPseudopotentialTypesFromTree;
|
|
24
|
+
// DFT-specific
|
|
25
|
+
const DFTModelRefiners = ["hse", "g0w0"];
|
|
26
|
+
const DFTModelModifiers = ["soc", "magn"];
|
|
27
|
+
const DFTModelTree = {
|
|
28
|
+
gga: {
|
|
29
|
+
refiners: DFTModelRefiners,
|
|
30
|
+
modifiers: DFTModelModifiers,
|
|
31
|
+
methods,
|
|
32
|
+
functionals: ["pbe", "pbesol", "pw91", "other"],
|
|
33
|
+
},
|
|
34
|
+
lda: {
|
|
35
|
+
refiners: DFTModelRefiners,
|
|
36
|
+
modifiers: DFTModelModifiers,
|
|
37
|
+
methods,
|
|
38
|
+
functionals: ["pz", "pw", "vwn", "other"],
|
|
39
|
+
},
|
|
40
|
+
hybrid: {
|
|
41
|
+
methods,
|
|
42
|
+
functionals: ["b3lyp", "hse06"],
|
|
43
|
+
},
|
|
44
|
+
other: {
|
|
45
|
+
methods,
|
|
46
|
+
functionals: ["other"],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const getDFTFunctionalsFromTree = () => Object.keys(DFTModelTree);
|
|
50
|
+
exports.getDFTFunctionalsFromTree = getDFTFunctionalsFromTree;
|
|
51
|
+
const getDFTFunctionalsByApproximation = (approximation) => {
|
|
52
|
+
const branch = DFTModelTree[approximation];
|
|
53
|
+
return branch && branch.functionals;
|
|
54
|
+
};
|
|
55
|
+
exports.getDFTFunctionalsByApproximation = getDFTFunctionalsByApproximation;
|
|
56
|
+
// GENERAL
|
|
57
|
+
exports.MODEL_TREE = {
|
|
58
|
+
dft: DFTModelTree,
|
|
59
|
+
ml: {
|
|
60
|
+
re: {
|
|
61
|
+
methods: {
|
|
62
|
+
linear: ["least_squares", "ridge"],
|
|
63
|
+
kernel_ridge: ["least_squares"],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
unknown: {
|
|
68
|
+
unknown: {
|
|
69
|
+
methods: {
|
|
70
|
+
unknown: ["unknown"],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
exports.MODEL_NAMES = {
|
|
76
|
+
dft: "density functional theory",
|
|
77
|
+
lda: "local density approximation",
|
|
78
|
+
gga: "generalized gradient approximation",
|
|
79
|
+
hybrid: "hybrid functional",
|
|
80
|
+
ml: "machine learning",
|
|
81
|
+
re: "regression",
|
|
82
|
+
};
|
|
83
|
+
const treeSlugToNamedObject = (modelSlug) => {
|
|
84
|
+
return {
|
|
85
|
+
slug: modelSlug,
|
|
86
|
+
name: lodash_1.default.get(exports.MODEL_NAMES, modelSlug, modelSlug),
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
exports.treeSlugToNamedObject = treeSlugToNamedObject;
|
|
90
|
+
const VASP_MODELS_TREE = (0, utils_1.deepClone)(underscore_1.default.pick(exports.MODEL_TREE, "dft"));
|
|
91
|
+
const ESPRESSO_MODELS_TREE = (0, utils_1.deepClone)(underscore_1.default.pick(exports.MODEL_TREE, "dft"));
|
|
92
|
+
const NWCHEM_MODELS_TREE = (0, utils_1.deepClone)(underscore_1.default.pick(exports.MODEL_TREE, "dft"));
|
|
93
|
+
["gga", "lda"].forEach((approximation) => {
|
|
94
|
+
// pick "paw" for vasp
|
|
95
|
+
VASP_MODELS_TREE.dft[approximation].methods.pseudopotential = VASP_MODELS_TREE.dft[approximation].methods.pseudopotential.splice(0, 1);
|
|
96
|
+
// assert "us" is the first option
|
|
97
|
+
ESPRESSO_MODELS_TREE.dft[approximation].methods.pseudopotential =
|
|
98
|
+
ESPRESSO_MODELS_TREE.dft[approximation].methods.pseudopotential.reverse();
|
|
99
|
+
});
|
|
100
|
+
const UNKNOWN_MODELS_TREE = underscore_1.default.pick(exports.MODEL_TREE, "unknown");
|
|
101
|
+
// const ML_MODELS_TREE = _.pick(MODEL_TREE, "ml");
|
|
102
|
+
const MODELS_TREE_CONFIGS_BY_APPLICATION_NAME_VERSION = [
|
|
103
|
+
{
|
|
104
|
+
name: "vasp",
|
|
105
|
+
tree: VASP_MODELS_TREE,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "espresso",
|
|
109
|
+
tree: ESPRESSO_MODELS_TREE,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "python",
|
|
113
|
+
tree: UNKNOWN_MODELS_TREE,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "shell",
|
|
117
|
+
tree: UNKNOWN_MODELS_TREE,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "jupyterLab",
|
|
121
|
+
tree: UNKNOWN_MODELS_TREE,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "nwchem",
|
|
125
|
+
tree: NWCHEM_MODELS_TREE,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "deepmd",
|
|
129
|
+
tree: UNKNOWN_MODELS_TREE,
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
const getTreeByApplicationNameAndVersion = ({ name, }) => {
|
|
133
|
+
// TODO: add logic to filter by version when necessary
|
|
134
|
+
const cfgs = MODELS_TREE_CONFIGS_BY_APPLICATION_NAME_VERSION.filter((cfg) => cfg.name === name).map((cfg) => cfg.tree);
|
|
135
|
+
return Object.assign({}, ...cfgs);
|
|
136
|
+
};
|
|
137
|
+
exports.getTreeByApplicationNameAndVersion = getTreeByApplicationNameAndVersion;
|
|
138
|
+
const getDefaultModelTypeForApplication = (application) => {
|
|
139
|
+
return Object.keys((0, exports.getTreeByApplicationNameAndVersion)(application))[0];
|
|
140
|
+
};
|
|
141
|
+
exports.getDefaultModelTypeForApplication = getDefaultModelTypeForApplication;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ApplicationSchemaBase, BaseModel, CategorizedMethod, CategorizedModel, CategorizedUnitMethod } from "@mat3ra/esse/dist/js/types";
|
|
2
|
+
export type ModelConfig = Pick<BaseModel, "type" | "subtype"> & Partial<Omit<BaseModel, "type" | "subtype">> & {
|
|
3
|
+
application?: ApplicationSchemaBase;
|
|
4
|
+
};
|
|
5
|
+
export type SimplifiedCategorizedModel = Pick<CategorizedModel, "name" | "path" | "categories" | "parameters">;
|
|
6
|
+
export type SimplifiedCategorizedMethod = Pick<CategorizedMethod, "name" | "path"> & {
|
|
7
|
+
units: CategorizedUnitMethod[];
|
|
8
|
+
};
|
|
9
|
+
export interface PseudopotentialLike {
|
|
10
|
+
element?: string;
|
|
11
|
+
toJSON(): Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export type PseudopotentialCtor = new (config: Record<string, unknown>) => PseudopotentialLike;
|
|
14
|
+
export interface MethodTreeBranch {
|
|
15
|
+
methods: Record<string, string[]>;
|
|
16
|
+
functionals?: string[];
|
|
17
|
+
refiners?: string[];
|
|
18
|
+
modifiers?: string[];
|
|
19
|
+
}
|
|
20
|
+
export type ModelTree = Record<string, Record<string, MethodTreeBranch>>;
|