@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.
Files changed (74) hide show
  1. package/dist/js/default_methods.d.ts +6 -0
  2. package/dist/js/default_methods.js +36 -0
  3. package/dist/js/default_models.d.ts +3 -0
  4. package/dist/js/default_models.js +11 -0
  5. package/dist/js/generated/MethodSchemaMixin.d.ts +5 -0
  6. package/dist/js/generated/MethodSchemaMixin.js +21 -0
  7. package/dist/js/generated/ModelSchemaMixin.d.ts +5 -0
  8. package/dist/js/generated/ModelSchemaMixin.js +18 -0
  9. package/dist/js/index.d.ts +12 -0
  10. package/dist/js/index.js +58 -0
  11. package/dist/js/method.d.ts +22 -0
  12. package/dist/js/method.js +54 -0
  13. package/dist/js/methodConversionHandler.d.ts +14 -0
  14. package/dist/js/methodConversionHandler.js +128 -0
  15. package/dist/js/methods/factory.d.ts +8 -0
  16. package/dist/js/methods/factory.js +18 -0
  17. package/dist/js/methods/pseudopotential.d.ts +21 -0
  18. package/dist/js/methods/pseudopotential.js +75 -0
  19. package/dist/js/model.d.ts +38 -0
  20. package/dist/js/model.js +138 -0
  21. package/dist/js/modelConversionHandler.d.ts +12 -0
  22. package/dist/js/modelConversionHandler.js +127 -0
  23. package/dist/js/models/dft.d.ts +25 -0
  24. package/dist/js/models/dft.js +89 -0
  25. package/dist/js/models/factory.d.ts +9 -0
  26. package/dist/js/models/factory.js +30 -0
  27. package/dist/js/tree.d.ts +15 -0
  28. package/dist/js/tree.js +141 -0
  29. package/dist/js/types/index.d.ts +20 -0
  30. package/dist/js/types/index.js +2 -0
  31. package/package.json +32 -19
  32. package/src/js/default_methods.ts +36 -0
  33. package/src/js/default_models.ts +11 -0
  34. package/src/js/generated/MethodSchemaMixin.ts +26 -0
  35. package/src/js/generated/ModelSchemaMixin.ts +23 -0
  36. package/src/{index.js → js/index.ts} +1 -1
  37. package/src/js/method.ts +67 -0
  38. package/src/js/methodConversionHandler.ts +142 -0
  39. package/src/{methods/factory.js → js/methods/factory.ts} +3 -1
  40. package/src/js/methods/pseudopotential.ts +86 -0
  41. package/src/js/model.ts +168 -0
  42. package/src/js/modelConversionHandler.ts +102 -0
  43. package/src/js/models/dft.ts +110 -0
  44. package/src/{models/factory.js → js/models/factory.ts} +9 -4
  45. package/src/{tree.js → js/tree.ts} +26 -20
  46. package/src/js/types/index.ts +37 -0
  47. package/tsconfig.json +3 -0
  48. package/.babelrc +0 -17
  49. package/dist/data/method_list.js +0 -1132
  50. package/dist/data/model_list.js +0 -786
  51. package/dist/data/model_method_map.js +0 -82
  52. package/dist/default_methods.js +0 -39
  53. package/dist/default_models.js +0 -14
  54. package/dist/index.js +0 -69
  55. package/dist/method.js +0 -84
  56. package/dist/methodConversionHandler.js +0 -128
  57. package/dist/methods/factory.js +0 -24
  58. package/dist/methods/pseudopotential.js +0 -100
  59. package/dist/model.js +0 -123
  60. package/dist/modelConversionHandler.js +0 -102
  61. package/dist/models/dft.js +0 -102
  62. package/dist/models/factory.js +0 -36
  63. package/dist/tree.js +0 -147
  64. package/src/data/method_list.js +0 -2
  65. package/src/data/model_list.js +0 -2
  66. package/src/data/model_method_map.js +0 -2
  67. package/src/default_methods.js +0 -38
  68. package/src/default_models.js +0 -9
  69. package/src/method.js +0 -77
  70. package/src/methodConversionHandler.js +0 -125
  71. package/src/methods/pseudopotential.js +0 -99
  72. package/src/model.js +0 -127
  73. package/src/modelConversionHandler.js +0 -91
  74. package/src/models/dft.js +0 -115
@@ -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 {};