@mat3ra/mode 2025.11.10-0 → 2025.11.22-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,9 +33,11 @@ class DFTModel extends model_1.Model {
33
33
  const [slug] = this.treeBranchForSubType.functionals || [];
34
34
  return (0, tree_1.treeSlugToNamedObject)(slug);
35
35
  }
36
+ // eslint-disable-next-line class-methods-use-this
36
37
  get defaultRefiners() {
37
38
  return [];
38
39
  }
40
+ // eslint-disable-next-line class-methods-use-this
39
41
  get defaultModifiers() {
40
42
  return [];
41
43
  }
@@ -69,11 +71,17 @@ class DFTModel extends model_1.Model {
69
71
  }
70
72
  toJSON() {
71
73
  const pickSlugFromObject = (item) => underscore_1.default.pick(item, "slug");
74
+ const baseJson = super.toJSON();
75
+ const keysToExclude = ["type", "subtype", "functional", "refiners", "modifiers", "method"];
76
+ const restJson = Object.fromEntries(Object.entries(baseJson).filter(([key]) => !keysToExclude.includes(key)));
72
77
  return {
73
- ...super.toJSON(),
78
+ type: this.type,
79
+ subtype: this.subtype,
80
+ method: this.Method.toJSONWithCleanData(),
74
81
  functional: pickSlugFromObject(this.functional),
75
82
  refiners: this.refiners,
76
83
  modifiers: this.modifiers,
84
+ ...restJson,
77
85
  };
78
86
  }
79
87
  get allFunctionals() {
package/dist/js/tree.d.ts CHANGED
@@ -1,5 +1,67 @@
1
1
  import { ApplicationSchemaBase, SlugifiedEntry } from "@mat3ra/esse/dist/js/types";
2
2
  import type { ModelTree } from "./types";
3
+ export declare const MODEL_TREE: {
4
+ dft: {
5
+ gga: {
6
+ refiners: string[];
7
+ modifiers: string[];
8
+ methods: {
9
+ pseudopotential: string[];
10
+ localorbital: string[];
11
+ unknown: string[];
12
+ };
13
+ functionals: string[];
14
+ };
15
+ lda: {
16
+ refiners: string[];
17
+ modifiers: string[];
18
+ methods: {
19
+ pseudopotential: string[];
20
+ localorbital: string[];
21
+ unknown: string[];
22
+ };
23
+ functionals: string[];
24
+ };
25
+ hybrid: {
26
+ methods: {
27
+ pseudopotential: string[];
28
+ localorbital: string[];
29
+ unknown: string[];
30
+ };
31
+ functionals: string[];
32
+ };
33
+ other: {
34
+ methods: {
35
+ pseudopotential: string[];
36
+ localorbital: string[];
37
+ unknown: string[];
38
+ };
39
+ functionals: string[];
40
+ };
41
+ };
42
+ ml: {
43
+ re: {
44
+ methods: {
45
+ linear: string[];
46
+ kernel_ridge: string[];
47
+ };
48
+ };
49
+ };
50
+ unknown: {
51
+ unknown: {
52
+ methods: {
53
+ unknown: string[];
54
+ };
55
+ };
56
+ };
57
+ }, MODEL_NAMES: {
58
+ dft: string;
59
+ lda: string;
60
+ gga: string;
61
+ hybrid: string;
62
+ ml: string;
63
+ re: string;
64
+ };
3
65
  export declare const METHODS: {
4
66
  readonly pseudopotential: "pseudopotential";
5
67
  readonly localorbital: "localorbital";
@@ -8,8 +70,6 @@ export declare const METHODS: {
8
70
  export declare const getPseudopotentialTypesFromTree: () => string[];
9
71
  export declare const getDFTFunctionalsFromTree: () => string[];
10
72
  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
73
  export declare const treeSlugToNamedObject: (modelSlug: string) => SlugifiedEntry;
14
74
  export declare const getTreeByApplicationNameAndVersion: ({ name, }: Pick<ApplicationSchemaBase, "name" | "version">) => ModelTree;
15
75
  export declare const getDefaultModelTypeForApplication: (application: ApplicationSchemaBase) => string;
package/dist/js/tree.js CHANGED
@@ -3,83 +3,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
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");
6
+ exports.getDefaultModelTypeForApplication = exports.getTreeByApplicationNameAndVersion = exports.treeSlugToNamedObject = exports.getDFTFunctionalsByApproximation = exports.getDFTFunctionalsFromTree = exports.getPseudopotentialTypesFromTree = exports.METHODS = exports.MODEL_NAMES = exports.MODEL_TREE = void 0;
7
+ const modelsTreeConfigByApplication_json_1 = __importDefault(require("@mat3ra/standata/dist/js/runtime_data/models/modelsTreeConfigByApplication.json"));
8
+ const modelTree_json_1 = __importDefault(require("@mat3ra/standata/dist/js/runtime_data/models/modelTree.json"));
8
9
  const lodash_1 = __importDefault(require("lodash"));
9
- const underscore_1 = __importDefault(require("underscore"));
10
- // TODO: migrate to use manifest instead
10
+ exports.MODEL_TREE = modelTree_json_1.default.MODEL_TREE, exports.MODEL_NAMES = modelTree_json_1.default.MODEL_NAMES;
11
11
  exports.METHODS = {
12
12
  pseudopotential: "pseudopotential",
13
13
  localorbital: "localorbital",
14
14
  unknown: "unknown",
15
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"],
16
+ const getPseudopotentialTypesFromTree = () => {
17
+ var _a;
18
+ const dftTree = exports.MODEL_TREE.dft;
19
+ const firstBranch = Object.values(dftTree)[0];
20
+ return ((_a = firstBranch === null || firstBranch === void 0 ? void 0 : firstBranch.methods) === null || _a === void 0 ? void 0 : _a.pseudopotential) || [];
21
21
  };
22
- const getPseudopotentialTypesFromTree = () => methods[exports.METHODS.pseudopotential];
23
22
  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
- },
23
+ const getDFTFunctionalsFromTree = () => {
24
+ return Object.keys(exports.MODEL_TREE.dft);
48
25
  };
49
- const getDFTFunctionalsFromTree = () => Object.keys(DFTModelTree);
50
26
  exports.getDFTFunctionalsFromTree = getDFTFunctionalsFromTree;
51
27
  const getDFTFunctionalsByApproximation = (approximation) => {
52
- const branch = DFTModelTree[approximation];
53
- return branch && branch.functionals;
28
+ const dftTree = exports.MODEL_TREE.dft;
29
+ const branch = dftTree[approximation];
30
+ return branch === null || branch === void 0 ? void 0 : branch.functionals;
54
31
  };
55
32
  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
33
  const treeSlugToNamedObject = (modelSlug) => {
84
34
  return {
85
35
  slug: modelSlug,
@@ -87,52 +37,10 @@ const treeSlugToNamedObject = (modelSlug) => {
87
37
  };
88
38
  };
89
39
  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
40
  const getTreeByApplicationNameAndVersion = ({ name, }) => {
133
41
  // 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);
42
+ // @ts-ignore
43
+ return modelsTreeConfigByApplication_json_1.default[name] || {};
136
44
  };
137
45
  exports.getTreeByApplicationNameAndVersion = getTreeByApplicationNameAndVersion;
138
46
  const getDefaultModelTypeForApplication = (application) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/mode",
3
- "version": "2025.11.10-0",
3
+ "version": "2025.11.22-0",
4
4
  "description": "MOdel and method DEfinitions",
5
5
  "scripts": {
6
6
  "test": "nyc --reporter=text mocha --recursive --bail",
@@ -54,7 +54,7 @@
54
54
  "devDependencies": {
55
55
  "@exabyte-io/eslint-config": "2025.5.13-0",
56
56
  "@mat3ra/esse": "2025.10.8-0",
57
- "@mat3ra/standata": "2025.10.2-0",
57
+ "@mat3ra/standata": "2025.11.12-0",
58
58
  "@mat3ra/code": "2025.10.8-0",
59
59
  "@mat3ra/tsconfig": "2024.6.3-0",
60
60
  "@types/chai": "^4.3.11",
@@ -33,10 +33,12 @@ export class DFTModel extends Model {
33
33
  return treeSlugToNamedObject(slug);
34
34
  }
35
35
 
36
+ // eslint-disable-next-line class-methods-use-this
36
37
  get defaultRefiners(): SlugifiedEntry[] {
37
38
  return [];
38
39
  }
39
40
 
41
+ // eslint-disable-next-line class-methods-use-this
40
42
  get defaultModifiers(): SlugifiedEntry[] {
41
43
  return [];
42
44
  }
@@ -82,11 +84,19 @@ export class DFTModel extends Model {
82
84
 
83
85
  toJSON(): Record<string, unknown> {
84
86
  const pickSlugFromObject = (item: SlugifiedEntry) => _.pick(item, "slug");
87
+ const baseJson = super.toJSON();
88
+ const keysToExclude = ["type", "subtype", "functional", "refiners", "modifiers", "method"];
89
+ const restJson = Object.fromEntries(
90
+ Object.entries(baseJson).filter(([key]) => !keysToExclude.includes(key)),
91
+ );
85
92
  return {
86
- ...super.toJSON(),
93
+ type: this.type,
94
+ subtype: this.subtype,
95
+ method: this.Method.toJSONWithCleanData(),
87
96
  functional: pickSlugFromObject(this.functional),
88
97
  refiners: this.refiners,
89
98
  modifiers: this.modifiers,
99
+ ...restJson,
90
100
  };
91
101
  }
92
102
 
package/src/js/tree.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { deepClone } from "@mat3ra/code/dist/js/utils";
2
1
  import { ApplicationSchemaBase, SlugifiedEntry } from "@mat3ra/esse/dist/js/types";
2
+ import MODELS_TREE_CONFIG_BY_APPLICATION from "@mat3ra/standata/dist/js/runtime_data/models/modelsTreeConfigByApplication.json";
3
+ import MODEL_TREE_DATA from "@mat3ra/standata/dist/js/runtime_data/models/modelTree.json";
3
4
  import lodash from "lodash";
4
- import _ from "underscore";
5
5
 
6
6
  import type { ModelTree } from "./types";
7
7
 
8
- // TODO: migrate to use manifest instead
8
+ export const { MODEL_TREE, MODEL_NAMES } = MODEL_TREE_DATA;
9
9
 
10
10
  export const METHODS = {
11
11
  pseudopotential: "pseudopotential",
@@ -13,78 +13,20 @@ export const METHODS = {
13
13
  unknown: "unknown",
14
14
  } as const;
15
15
 
16
- const methods: Record<string, string[]> = {
17
- [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
- [METHODS.localorbital]: ["pople"],
20
- [METHODS.unknown]: ["unknown"],
16
+ export const getPseudopotentialTypesFromTree = (): string[] => {
17
+ const dftTree = MODEL_TREE.dft as Record<string, any>;
18
+ const firstBranch = Object.values(dftTree)[0];
19
+ return firstBranch?.methods?.pseudopotential || [];
21
20
  };
22
21
 
23
- export const getPseudopotentialTypesFromTree = (): string[] => methods[METHODS.pseudopotential];
24
-
25
- // DFT-specific
26
-
27
- const DFTModelRefiners = ["hse", "g0w0"];
28
- const DFTModelModifiers = ["soc", "magn"];
29
-
30
- const DFTModelTree = {
31
- gga: {
32
- refiners: DFTModelRefiners,
33
- modifiers: DFTModelModifiers,
34
- methods,
35
- functionals: ["pbe", "pbesol", "pw91", "other"],
36
- },
37
- lda: {
38
- refiners: DFTModelRefiners,
39
- modifiers: DFTModelModifiers,
40
- methods,
41
- functionals: ["pz", "pw", "vwn", "other"],
42
- },
43
- hybrid: {
44
- methods,
45
- functionals: ["b3lyp", "hse06"],
46
- },
47
- other: {
48
- methods,
49
- functionals: ["other"],
50
- },
22
+ export const getDFTFunctionalsFromTree = (): string[] => {
23
+ return Object.keys(MODEL_TREE.dft);
51
24
  };
52
25
 
53
- export const getDFTFunctionalsFromTree = (): string[] => Object.keys(DFTModelTree);
54
-
55
26
  export const getDFTFunctionalsByApproximation = (approximation: string): string[] | undefined => {
56
- const branch = DFTModelTree[approximation as keyof typeof DFTModelTree];
57
- return branch && branch.functionals;
58
- };
59
-
60
- // GENERAL
61
-
62
- export const MODEL_TREE: ModelTree = {
63
- dft: DFTModelTree,
64
- ml: {
65
- re: {
66
- methods: {
67
- linear: ["least_squares", "ridge"],
68
- kernel_ridge: ["least_squares"],
69
- },
70
- },
71
- },
72
- unknown: {
73
- unknown: {
74
- methods: {
75
- unknown: ["unknown"],
76
- },
77
- },
78
- },
79
- };
80
-
81
- export const MODEL_NAMES: Record<string, string> = {
82
- dft: "density functional theory",
83
- lda: "local density approximation",
84
- gga: "generalized gradient approximation",
85
- hybrid: "hybrid functional",
86
- ml: "machine learning",
87
- re: "regression",
27
+ const dftTree = MODEL_TREE.dft as Record<string, any>;
28
+ const branch = dftTree[approximation];
29
+ return branch?.functionals;
88
30
  };
89
31
 
90
32
  export const treeSlugToNamedObject = (modelSlug: string): SlugifiedEntry => {
@@ -94,73 +36,12 @@ export const treeSlugToNamedObject = (modelSlug: string): SlugifiedEntry => {
94
36
  };
95
37
  };
96
38
 
97
- // TODO: find a better way to handle application-specific model-method combination
98
- // must be a subset of the MODEL_TREE above
99
- // demonstrate how tree can be modified
100
- // VASP_MODELS_TREE.gga.functionals = _.omit(VASP_MODELS_TREE.gga.functionals);
101
-
102
- type DftOnlyTree = { dft: typeof DFTModelTree };
103
-
104
- const VASP_MODELS_TREE = deepClone(_.pick(MODEL_TREE, "dft")) as DftOnlyTree;
105
- const ESPRESSO_MODELS_TREE = deepClone(_.pick(MODEL_TREE, "dft")) as DftOnlyTree;
106
- const NWCHEM_MODELS_TREE = deepClone(_.pick(MODEL_TREE, "dft")) as DftOnlyTree;
107
-
108
- (["gga", "lda"] as const).forEach((approximation) => {
109
- // pick "paw" for vasp
110
- VASP_MODELS_TREE.dft[approximation].methods.pseudopotential = VASP_MODELS_TREE.dft[
111
- approximation
112
- ].methods.pseudopotential.splice(0, 1);
113
-
114
- // assert "us" is the first option
115
- ESPRESSO_MODELS_TREE.dft[approximation].methods.pseudopotential =
116
- ESPRESSO_MODELS_TREE.dft[approximation].methods.pseudopotential.reverse();
117
- });
118
-
119
- const UNKNOWN_MODELS_TREE = _.pick(MODEL_TREE, "unknown") as ModelTree;
120
- // const ML_MODELS_TREE = _.pick(MODEL_TREE, "ml");
121
-
122
- const MODELS_TREE_CONFIGS_BY_APPLICATION_NAME_VERSION: Array<{
123
- name: string;
124
- tree: ModelTree;
125
- }> = [
126
- {
127
- name: "vasp",
128
- tree: VASP_MODELS_TREE,
129
- },
130
- {
131
- name: "espresso",
132
- tree: ESPRESSO_MODELS_TREE,
133
- },
134
- {
135
- name: "python",
136
- tree: UNKNOWN_MODELS_TREE,
137
- },
138
- {
139
- name: "shell",
140
- tree: UNKNOWN_MODELS_TREE,
141
- },
142
- {
143
- name: "jupyterLab",
144
- tree: UNKNOWN_MODELS_TREE,
145
- },
146
- {
147
- name: "nwchem",
148
- tree: NWCHEM_MODELS_TREE,
149
- },
150
- {
151
- name: "deepmd",
152
- tree: UNKNOWN_MODELS_TREE,
153
- },
154
- ];
155
-
156
39
  export const getTreeByApplicationNameAndVersion = ({
157
40
  name,
158
41
  }: Pick<ApplicationSchemaBase, "name" | "version">): ModelTree => {
159
42
  // TODO: add logic to filter by version when necessary
160
- const cfgs = MODELS_TREE_CONFIGS_BY_APPLICATION_NAME_VERSION.filter(
161
- (cfg) => cfg.name === name,
162
- ).map((cfg) => cfg.tree);
163
- return Object.assign({}, ...cfgs);
43
+ // @ts-ignore
44
+ return MODELS_TREE_CONFIG_BY_APPLICATION[name] || {};
164
45
  };
165
46
 
166
47
  export const getDefaultModelTypeForApplication = (application: ApplicationSchemaBase): string => {