@mat3ra/mode 2025.11.5-0 → 2025.11.5-2

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.
@@ -0,0 +1,6 @@
1
+ import { BaseMethod, BaseModel, SlugifiedEntry } from "@mat3ra/esse/dist/js/types";
2
+ export declare const PseudopotentialMethodConfig: BaseMethod;
3
+ export declare const LocalOrbitalMethodConfig: BaseMethod;
4
+ export declare const UnknownMethodConfig: BaseMethod;
5
+ export declare function allowedTypes(model: Pick<BaseModel, "type" | "subtype">): SlugifiedEntry[];
6
+ export declare function allowedSubtypes(model: Pick<BaseModel, "type" | "subtype">, type: string): SlugifiedEntry[];
@@ -0,0 +1,36 @@
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.UnknownMethodConfig = exports.LocalOrbitalMethodConfig = exports.PseudopotentialMethodConfig = void 0;
7
+ exports.allowedTypes = allowedTypes;
8
+ exports.allowedSubtypes = allowedSubtypes;
9
+ const lodash_1 = __importDefault(require("lodash"));
10
+ const tree_1 = require("./tree");
11
+ exports.PseudopotentialMethodConfig = {
12
+ type: "pseudopotential",
13
+ subtype: "us",
14
+ };
15
+ exports.LocalOrbitalMethodConfig = {
16
+ type: "localorbital",
17
+ subtype: "pople",
18
+ };
19
+ exports.UnknownMethodConfig = {
20
+ type: "unknown",
21
+ subtype: "unknown",
22
+ };
23
+ const mapSlugToNamedObject = (slug) => {
24
+ return {
25
+ slug,
26
+ name: lodash_1.default.get(tree_1.MODEL_NAMES, slug, slug),
27
+ };
28
+ };
29
+ function allowedTypes(model) {
30
+ const branch = lodash_1.default.get(tree_1.MODEL_TREE, `${model.type}.${model.subtype}.methods`, {});
31
+ return lodash_1.default.keys(branch).map(mapSlugToNamedObject);
32
+ }
33
+ function allowedSubtypes(model, type) {
34
+ const branch = lodash_1.default.get(tree_1.MODEL_TREE, `${model.type}.${model.subtype}.methods.${type}`, []);
35
+ return branch.map(mapSlugToNamedObject);
36
+ }
@@ -0,0 +1,3 @@
1
+ import type { ModelConfig } from "./types";
2
+ export declare const DFTModelConfig: ModelConfig;
3
+ export declare const UnknownModelConfig: ModelConfig;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnknownModelConfig = exports.DFTModelConfig = void 0;
4
+ exports.DFTModelConfig = {
5
+ type: "dft",
6
+ subtype: "gga",
7
+ };
8
+ exports.UnknownModelConfig = {
9
+ type: "unknown",
10
+ subtype: "unknown",
11
+ };
@@ -0,0 +1,5 @@
1
+ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { BaseMethod } from "@mat3ra/esse/dist/js/types";
3
+ export type MethodSchemaMixin = BaseMethod;
4
+ export type MethodInMemoryEntity = InMemoryEntity & MethodSchemaMixin;
5
+ export declare function methodSchemaMixin(item: InMemoryEntity): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.methodSchemaMixin = methodSchemaMixin;
4
+ function methodSchemaMixin(item) {
5
+ // @ts-expect-error
6
+ const properties = {
7
+ get type() {
8
+ return this.requiredProp("type");
9
+ },
10
+ get subtype() {
11
+ return this.requiredProp("subtype");
12
+ },
13
+ get precision() {
14
+ return this.prop("precision");
15
+ },
16
+ get data() {
17
+ return this.prop("data");
18
+ },
19
+ };
20
+ Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
21
+ }
@@ -0,0 +1,5 @@
1
+ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { BaseModel } from "@mat3ra/esse/dist/js/types";
3
+ export type ModelSchemaMixin = BaseModel;
4
+ export type ModelInMemoryEntity = InMemoryEntity & ModelSchemaMixin;
5
+ export declare function modelSchemaMixin(item: InMemoryEntity): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelSchemaMixin = modelSchemaMixin;
4
+ function modelSchemaMixin(item) {
5
+ // @ts-expect-error
6
+ const properties = {
7
+ get type() {
8
+ return this.requiredProp("type");
9
+ },
10
+ get subtype() {
11
+ return this.requiredProp("subtype");
12
+ },
13
+ get method() {
14
+ return this.requiredProp("method");
15
+ },
16
+ };
17
+ Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
18
+ }
@@ -0,0 +1,12 @@
1
+ import * as default_methods from "./default_methods";
2
+ import * as default_models from "./default_models";
3
+ import { Method } from "./method";
4
+ import { MethodConversionHandler } from "./methodConversionHandler";
5
+ import { MethodFactory } from "./methods/factory";
6
+ import { PseudopotentialMethod } from "./methods/pseudopotential";
7
+ import { Model } from "./model";
8
+ import { ModelConversionHandler } from "./modelConversionHandler";
9
+ import { DFTModel } from "./models/dft";
10
+ import { ModelFactory } from "./models/factory";
11
+ import * as tree from "./tree";
12
+ export { Method, Model, MethodFactory, ModelFactory, PseudopotentialMethod, DFTModel, MethodConversionHandler, ModelConversionHandler, tree, default_models, default_methods, };
@@ -0,0 +1,58 @@
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.default_methods = exports.default_models = exports.tree = exports.ModelConversionHandler = exports.MethodConversionHandler = exports.DFTModel = exports.PseudopotentialMethod = exports.ModelFactory = exports.MethodFactory = exports.Model = exports.Method = void 0;
37
+ const default_methods = __importStar(require("./default_methods"));
38
+ exports.default_methods = default_methods;
39
+ const default_models = __importStar(require("./default_models"));
40
+ exports.default_models = default_models;
41
+ const method_1 = require("./method");
42
+ Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return method_1.Method; } });
43
+ const methodConversionHandler_1 = require("./methodConversionHandler");
44
+ Object.defineProperty(exports, "MethodConversionHandler", { enumerable: true, get: function () { return methodConversionHandler_1.MethodConversionHandler; } });
45
+ const factory_1 = require("./methods/factory");
46
+ Object.defineProperty(exports, "MethodFactory", { enumerable: true, get: function () { return factory_1.MethodFactory; } });
47
+ const pseudopotential_1 = require("./methods/pseudopotential");
48
+ Object.defineProperty(exports, "PseudopotentialMethod", { enumerable: true, get: function () { return pseudopotential_1.PseudopotentialMethod; } });
49
+ const model_1 = require("./model");
50
+ Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return model_1.Model; } });
51
+ const modelConversionHandler_1 = require("./modelConversionHandler");
52
+ Object.defineProperty(exports, "ModelConversionHandler", { enumerable: true, get: function () { return modelConversionHandler_1.ModelConversionHandler; } });
53
+ const dft_1 = require("./models/dft");
54
+ Object.defineProperty(exports, "DFTModel", { enumerable: true, get: function () { return dft_1.DFTModel; } });
55
+ const factory_2 = require("./models/factory");
56
+ Object.defineProperty(exports, "ModelFactory", { enumerable: true, get: function () { return factory_2.ModelFactory; } });
57
+ const tree = __importStar(require("./tree"));
58
+ exports.tree = tree;
@@ -0,0 +1,22 @@
1
+ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
3
+ import type { BaseMethod, SlugifiedEntry } from "@mat3ra/esse/dist/js/types";
4
+ import { type MethodSchemaMixin } from "./generated/MethodSchemaMixin";
5
+ type Base = typeof InMemoryEntity & Constructor<MethodSchemaMixin>;
6
+ interface MethodData extends Record<string, unknown> {
7
+ searchText?: string;
8
+ }
9
+ declare const Method_base: Base;
10
+ export declare class Method extends Method_base implements BaseMethod {
11
+ constructor(config: BaseMethod);
12
+ cloneWithoutData(): Method;
13
+ setSubtype(subtype: SlugifiedEntry): void;
14
+ static get defaultConfig(): BaseMethod;
15
+ get searchText(): string;
16
+ setSearchText(searchText: string): void;
17
+ setData(data?: MethodData): void;
18
+ get omitInHashCalculation(): boolean;
19
+ cleanData(fieldsToExclude?: string[]): MethodData;
20
+ toJSONWithCleanData(fieldsToExclude?: string[]): BaseMethod;
21
+ }
22
+ export {};
@@ -0,0 +1,54 @@
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.Method = void 0;
7
+ const entity_1 = require("@mat3ra/code/dist/js/entity");
8
+ const utils_1 = require("@mat3ra/code/dist/js/utils");
9
+ const lodash_1 = __importDefault(require("lodash"));
10
+ const default_methods_1 = require("./default_methods");
11
+ const MethodSchemaMixin_1 = require("./generated/MethodSchemaMixin");
12
+ class Method extends entity_1.InMemoryEntity {
13
+ constructor(config) {
14
+ const data = config.data || {};
15
+ super({ ...config, data });
16
+ }
17
+ cloneWithoutData() {
18
+ const clone = this.clone();
19
+ clone.setData({});
20
+ return clone;
21
+ }
22
+ setSubtype(subtype) {
23
+ this.setProp("subtype", subtype);
24
+ }
25
+ static get defaultConfig() {
26
+ return default_methods_1.PseudopotentialMethodConfig;
27
+ }
28
+ get searchText() {
29
+ return this.prop("data.searchText", "");
30
+ }
31
+ setSearchText(searchText) {
32
+ this.setData({ ...this.data, searchText });
33
+ }
34
+ setData(data = {}) {
35
+ this.setProp("data", data);
36
+ }
37
+ get omitInHashCalculation() {
38
+ const data = this.data;
39
+ return !(data === null || data === void 0 ? void 0 : data.searchText) && lodash_1.default.isEmpty(lodash_1.default.omit(data, "searchText"));
40
+ }
41
+ cleanData(fieldsToExclude = []) {
42
+ const filteredData = { ...this.data };
43
+ fieldsToExclude.forEach((field) => {
44
+ delete filteredData[field];
45
+ });
46
+ return filteredData;
47
+ }
48
+ toJSONWithCleanData(fieldsToExclude = []) {
49
+ const json = { ...this._json, data: this.cleanData(fieldsToExclude) };
50
+ return (0, utils_1.deepClone)(json);
51
+ }
52
+ }
53
+ exports.Method = Method;
54
+ (0, MethodSchemaMixin_1.methodSchemaMixin)(Method.prototype);
@@ -0,0 +1,14 @@
1
+ import { BaseMethod, CategorizedMethod, CategorizedUnitMethod, SlugifiedEntry } from "@mat3ra/esse/dist/js/types";
2
+ import type { SimplifiedCategorizedMethod } from "./types";
3
+ export declare function safelyGetSlug(slugObj: SlugifiedEntry | string): SlugifiedEntry["slug"];
4
+ export declare class MethodConversionHandler {
5
+ static convertToSimple(categorizedMethod: CategorizedMethod | undefined): BaseMethod;
6
+ static convertUnknownToSimple(): BaseMethod;
7
+ static convertPspUnitsToSimple(units: CategorizedUnitMethod[]): BaseMethod;
8
+ static convertAoUnitToSimple(): BaseMethod;
9
+ static convertRegressionUnitToSimple(unit: CategorizedUnitMethod): BaseMethod;
10
+ static convertToCategorized(simpleMethod: BaseMethod | undefined, allMethods?: CategorizedMethod[]): SimplifiedCategorizedMethod | undefined;
11
+ static convertPspToCategorized(simpleMethod: BaseMethod, allMethods?: CategorizedMethod[]): SimplifiedCategorizedMethod | undefined;
12
+ static convertAoToCategorized(simpleMethod: BaseMethod): SimplifiedCategorizedMethod;
13
+ static convertRegressionToCategorized(simpleMethod: BaseMethod): SimplifiedCategorizedMethod;
14
+ }
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MethodConversionHandler = void 0;
4
+ exports.safelyGetSlug = safelyGetSlug;
5
+ const default_methods_1 = require("./default_methods");
6
+ function safelyGetSlug(slugObj) {
7
+ return typeof slugObj === "string" ? slugObj : slugObj.slug;
8
+ }
9
+ class MethodConversionHandler {
10
+ static convertToSimple(categorizedMethod) {
11
+ if (!categorizedMethod)
12
+ return this.convertUnknownToSimple();
13
+ const pspUnits = categorizedMethod.units.filter((unit) => { var _a; return ((_a = unit.categories) === null || _a === void 0 ? void 0 : _a.type) === "psp"; });
14
+ const aoUnit = categorizedMethod.units.find((unit) => { var _a; return ((_a = unit.categories) === null || _a === void 0 ? void 0 : _a.type) === "ao"; });
15
+ const regressionUnit = categorizedMethod.units.find((unit) => {
16
+ return unit.name && unit.name.includes("regression");
17
+ });
18
+ if (pspUnits.length)
19
+ return this.convertPspUnitsToSimple(pspUnits);
20
+ if (aoUnit)
21
+ return this.convertAoUnitToSimple();
22
+ if (regressionUnit)
23
+ return this.convertRegressionUnitToSimple(regressionUnit);
24
+ return this.convertUnknownToSimple();
25
+ }
26
+ static convertUnknownToSimple() {
27
+ return default_methods_1.UnknownMethodConfig;
28
+ }
29
+ static convertPspUnitsToSimple(units) {
30
+ var _a;
31
+ const [firstUnit, ...otherUnits] = units;
32
+ if (!firstUnit || !((_a = firstUnit.categories) === null || _a === void 0 ? void 0 : _a.subtype))
33
+ return this.convertUnknownToSimple();
34
+ const subtype = otherUnits.length ? "any" : safelyGetSlug(firstUnit.categories.subtype);
35
+ return {
36
+ type: "pseudopotential",
37
+ subtype,
38
+ };
39
+ }
40
+ static convertAoUnitToSimple() {
41
+ return default_methods_1.LocalOrbitalMethodConfig;
42
+ }
43
+ static convertRegressionUnitToSimple(unit) {
44
+ var _a, _b;
45
+ const type = ((_a = unit.categories) === null || _a === void 0 ? void 0 : _a.type) || "linear";
46
+ const subtype = ((_b = unit.categories) === null || _b === void 0 ? void 0 : _b.subtype) || "least_squares";
47
+ return {
48
+ type: safelyGetSlug(type),
49
+ subtype: safelyGetSlug(subtype),
50
+ precision: unit.precision,
51
+ };
52
+ }
53
+ static convertToCategorized(simpleMethod, allMethods = []) {
54
+ switch (simpleMethod === null || simpleMethod === void 0 ? void 0 : simpleMethod.type) {
55
+ case "pseudopotential":
56
+ return this.convertPspToCategorized(simpleMethod, allMethods);
57
+ case "localorbital":
58
+ return this.convertAoToCategorized(simpleMethod);
59
+ case "linear":
60
+ case "kernel_ridge":
61
+ return this.convertRegressionToCategorized(simpleMethod);
62
+ default:
63
+ return undefined;
64
+ }
65
+ }
66
+ static convertPspToCategorized(simpleMethod, allMethods = []) {
67
+ const subtype = safelyGetSlug(simpleMethod.subtype);
68
+ // the "any" subtype is equivalent to the method representing all planewave-pseudopotential
69
+ // methods. All other subtypes are equivalent to using a specific PW-PSP method.
70
+ const allPath = "/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";
71
+ const path = subtype === "any"
72
+ ? allPath
73
+ : `/qm/wf/none/smearing/gaussian::/linalg/diag/none/davidson/none::/qm/wf/none/psp/${subtype}::/qm/wf/none/pw/none`;
74
+ return allMethods.find((categorized) => categorized.path === path);
75
+ }
76
+ static convertAoToCategorized(simpleMethod) {
77
+ const subtype = safelyGetSlug(simpleMethod.subtype);
78
+ return {
79
+ units: [
80
+ {
81
+ parameters: {
82
+ basisSlug: "6-31G",
83
+ },
84
+ categories: {
85
+ tier1: "qm",
86
+ tier2: "wf",
87
+ type: "ao",
88
+ subtype,
89
+ },
90
+ tags: ["atomic orbital"],
91
+ name: "Wave function: LCAO - Pople basis set (6-31G)",
92
+ path: "/qm/wf/none/ao/pople?basisSlug=6-31G",
93
+ },
94
+ ],
95
+ name: "Wave function: LCAO - Pople basis set (6-31G)",
96
+ path: "/qm/wf/none/ao/pople?basisSlug=6-31G",
97
+ };
98
+ }
99
+ static convertRegressionToCategorized(simpleMethod) {
100
+ const type = safelyGetSlug(simpleMethod.type);
101
+ const subtype = safelyGetSlug(simpleMethod.subtype);
102
+ const precision = simpleMethod.precision;
103
+ const path = `/none/none/none/${type}/${subtype}`;
104
+ const nameMap = {
105
+ kernel_ridge: "Kernel ridge",
106
+ linear: "Linear",
107
+ least_squares: "least squares",
108
+ ridge: "ridge",
109
+ };
110
+ const name = `${nameMap[type] || type} ${nameMap[subtype] || subtype} regression`;
111
+ return {
112
+ units: [
113
+ {
114
+ categories: {
115
+ type,
116
+ subtype,
117
+ },
118
+ name,
119
+ path,
120
+ precision,
121
+ },
122
+ ],
123
+ name,
124
+ path,
125
+ };
126
+ }
127
+ }
128
+ exports.MethodConversionHandler = MethodConversionHandler;
@@ -0,0 +1,8 @@
1
+ import { BaseMethod } from "@mat3ra/esse/dist/js/types";
2
+ import { Method } from "../method";
3
+ import { PseudopotentialMethod } from "./pseudopotential";
4
+ export declare class MethodFactory {
5
+ static Method: typeof Method;
6
+ static PseudopotentialMethod: typeof PseudopotentialMethod;
7
+ static create(config: BaseMethod): Method;
8
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MethodFactory = void 0;
4
+ const method_1 = require("../method");
5
+ const pseudopotential_1 = require("./pseudopotential");
6
+ class MethodFactory {
7
+ static create(config) {
8
+ switch (config.type) {
9
+ case "pseudopotential":
10
+ return new this.PseudopotentialMethod(config);
11
+ default:
12
+ return new this.Method(config);
13
+ }
14
+ }
15
+ }
16
+ exports.MethodFactory = MethodFactory;
17
+ MethodFactory.Method = method_1.Method;
18
+ MethodFactory.PseudopotentialMethod = pseudopotential_1.PseudopotentialMethod;
@@ -0,0 +1,21 @@
1
+ import { BaseMethod } from "@mat3ra/esse/dist/js/types";
2
+ import { Method } from "../method";
3
+ import type { PseudopotentialCtor, PseudopotentialLike } from "../types";
4
+ export declare class PseudopotentialMethod extends Method {
5
+ PseudopotentialCls: PseudopotentialCtor | null;
6
+ constructor(config: BaseMethod);
7
+ get pseudo(): Record<string, unknown>[];
8
+ get allPseudo(): Record<string, unknown>[];
9
+ get pseudopotentials(): PseudopotentialLike[];
10
+ get allPseudopotentials(): PseudopotentialLike[];
11
+ static extractExchangeCorrelationFromSubworkflow(subworkflow: any): {
12
+ approximation: string;
13
+ functional: string;
14
+ };
15
+ hasPseudopotentialFor(element: string): boolean;
16
+ setPseudopotentialPerElement(pseudo: PseudopotentialLike | undefined): void;
17
+ addToAllPseudos(pseudos: PseudopotentialLike | PseudopotentialLike[]): void;
18
+ setPseudopotentials(pseudopotentials: PseudopotentialLike[]): void;
19
+ setAllPseudopotentials(pseudopotentials: PseudopotentialLike[]): void;
20
+ toJSONWithCleanData(exclude?: string[]): BaseMethod;
21
+ }
@@ -0,0 +1,75 @@
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.PseudopotentialMethod = void 0;
7
+ const utils_1 = require("@mat3ra/code/dist/js/utils");
8
+ const underscore_1 = __importDefault(require("underscore"));
9
+ const method_1 = require("../method");
10
+ class PseudopotentialMethod extends method_1.Method {
11
+ constructor(config) {
12
+ super(config);
13
+ this.PseudopotentialCls = null;
14
+ }
15
+ get pseudo() {
16
+ return this.prop("data.pseudo", []);
17
+ }
18
+ get allPseudo() {
19
+ return this.prop("data.allPseudo", []);
20
+ }
21
+ get pseudopotentials() {
22
+ if (!this.PseudopotentialCls)
23
+ return [];
24
+ return this.pseudo.map((config) => new this.PseudopotentialCls(config));
25
+ }
26
+ get allPseudopotentials() {
27
+ if (!this.PseudopotentialCls)
28
+ return [];
29
+ return this.allPseudo.map((config) => new this.PseudopotentialCls(config));
30
+ }
31
+ static extractExchangeCorrelationFromSubworkflow(subworkflow) {
32
+ const { model } = subworkflow;
33
+ const approximation = model.subtype;
34
+ const functionalValue = model.functional;
35
+ const functional = functionalValue && (functionalValue.slug || functionalValue);
36
+ return {
37
+ approximation,
38
+ functional: functional || "",
39
+ };
40
+ }
41
+ hasPseudopotentialFor(element) {
42
+ return Boolean(this.pseudopotentials.find((pseudo) => pseudo.element === element));
43
+ }
44
+ setPseudopotentialPerElement(pseudo) {
45
+ if (!pseudo) {
46
+ this.setPseudopotentials([]);
47
+ return;
48
+ }
49
+ const filtered = this.pseudopotentials.filter((item) => item.element !== pseudo.element);
50
+ filtered.push(pseudo);
51
+ this.setPseudopotentials(filtered);
52
+ }
53
+ addToAllPseudos(pseudos) {
54
+ const list = (0, utils_1.safeMakeArray)(pseudos);
55
+ const all = this.allPseudopotentials;
56
+ all.push(...list);
57
+ this.setAllPseudopotentials(all);
58
+ }
59
+ setPseudopotentials(pseudopotentials) {
60
+ this.setData({
61
+ ...this.data,
62
+ pseudo: underscore_1.default.sortBy(pseudopotentials, "element").map((item) => item.toJSON()),
63
+ });
64
+ }
65
+ setAllPseudopotentials(pseudopotentials) {
66
+ this.setData({
67
+ ...this.data,
68
+ allPseudo: underscore_1.default.sortBy(pseudopotentials, "element").map((item) => item.toJSON()),
69
+ });
70
+ }
71
+ toJSONWithCleanData(exclude = []) {
72
+ return super.toJSONWithCleanData(exclude.concat(["allPseudo"]));
73
+ }
74
+ }
75
+ exports.PseudopotentialMethod = PseudopotentialMethod;
@@ -0,0 +1,38 @@
1
+ import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
3
+ import type { ApplicationSchemaBase, BaseMethod, BaseModel, SlugifiedEntry, SlugifiedEntryOrSlug } from "@mat3ra/esse/dist/js/types";
4
+ import { type ModelSchemaMixin } from "./generated/ModelSchemaMixin";
5
+ import { Method } from "./method";
6
+ import { MethodFactory } from "./methods/factory";
7
+ import type { ModelConfig, MethodTreeBranch, ModelTree } from "./types";
8
+ type Base = typeof InMemoryEntity & Constructor<ModelSchemaMixin>;
9
+ declare const Model_base: Base;
10
+ export declare class Model extends Model_base implements BaseModel {
11
+ protected _application?: ApplicationSchemaBase;
12
+ protected _MethodFactory: typeof MethodFactory;
13
+ protected _method?: Method;
14
+ constructor(config: ModelConfig);
15
+ setSubtype(subtype: SlugifiedEntryOrSlug): void;
16
+ get allowedTypes(): SlugifiedEntry[];
17
+ get allowedSubtypes(): SlugifiedEntry[];
18
+ get defaultType(): string;
19
+ get defaultSubtype(): string;
20
+ get tree(): ModelTree;
21
+ get treeBranchForType(): Record<string, MethodTreeBranch>;
22
+ get treeBranchForSubType(): MethodTreeBranch;
23
+ get treeByApplicationNameAndVersion(): ModelTree | undefined;
24
+ get groupSlug(): string;
25
+ get Method(): Method;
26
+ setMethod(method: Method): void;
27
+ get methodsFromTree(): Record<string, string[]>;
28
+ get methodTypes(): SlugifiedEntry[];
29
+ get methodSubtypes(): SlugifiedEntry[];
30
+ get defaultMethodConfig(): BaseMethod;
31
+ static get defaultConfig(): ModelConfig;
32
+ static get allTypes(): SlugifiedEntry[];
33
+ toJSON(): Record<string, unknown>;
34
+ protected _stringToSlugifiedObject(slug: SlugifiedEntryOrSlug): SlugifiedEntry;
35
+ get isUnknown(): boolean;
36
+ protected get subtypeSlug(): string;
37
+ }
38
+ export {};
@@ -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;
@@ -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>>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,29 +1,27 @@
1
1
  {
2
2
  "name": "@mat3ra/mode",
3
- "version": "2025.11.5-0",
3
+ "version": "2025.11.5-2",
4
4
  "description": "MOdel and method DEfinitions",
5
5
  "scripts": {
6
6
  "test": "nyc --reporter=text mocha --extension ts --recursive --bail --require ts-node/register/transpile-only \"tests/**/*.test.ts\"",
7
7
  "pretest": "npm run transpile",
8
8
  "lint": "eslint src tests && prettier --write src tests",
9
9
  "lint:fix": "eslint --fix --cache src tests && prettier --write src tests",
10
- "transpile": "npm run transpile:js && npm run transpile:ts",
11
- "transpile:js": "babel --out-dir dist src",
12
- "transpile:ts": "tsc --project tsconfig.json",
10
+ "transpile": "tsc --project tsconfig.json",
13
11
  "prettier": "prettier --check src tests",
14
12
  "prepare": "husky install || exit 0",
15
- "prepublishOnly": "rm -rf dist; npm run transpile",
13
+ "prepublishOnly": "rm -rf dist && npm run transpile",
16
14
  "generate-mixins": "ts-node scripts/generate-mixins.ts"
17
15
  },
18
16
  "repository": {
19
17
  "type": "git",
20
18
  "url": "https://github.com/Exabyte-io/mode.git"
21
19
  },
22
- "main": "dist/index.js",
20
+ "main": "dist/js/index.js",
23
21
  "types": "dist/js/index.d.ts",
24
22
  "files": [
25
23
  "/dist",
26
- "/src",
24
+ "/src/js",
27
25
  "tsconfig.json"
28
26
  ],
29
27
  "author": "Exabyte Inc.",
package/src/js/model.ts CHANGED
@@ -144,7 +144,7 @@ export class Model extends (InMemoryEntity as Base) implements BaseModel {
144
144
  ...json,
145
145
  type: this.type,
146
146
  subtype: this.subtype,
147
- method: (this.method as any).toJSONWithCleanData(),
147
+ method: this.Method.toJSONWithCleanData(),
148
148
  };
149
149
  }
150
150
 
package/tsconfig.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "extends": "@mat3ra/tsconfig/tsconfig-js-py-dev.json"
2
+ "extends": "@mat3ra/tsconfig/tsconfig-js-py-transpile.json"
3
3
  }