@mat3ra/mode 2025.10.2-0 → 2025.11.5-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/package.json +32 -17
  2. package/src/js/default_methods.ts +36 -0
  3. package/src/js/default_models.ts +11 -0
  4. package/src/js/generated/MethodSchemaMixin.ts +26 -0
  5. package/src/js/generated/ModelSchemaMixin.ts +23 -0
  6. package/src/{index.js → js/index.ts} +5 -11
  7. package/src/js/method.ts +67 -0
  8. package/src/js/methodConversionHandler.ts +142 -0
  9. package/src/{methods/factory.js → js/methods/factory.ts} +3 -1
  10. package/src/js/methods/pseudopotential.ts +86 -0
  11. package/src/js/model.ts +168 -0
  12. package/src/js/modelConversionHandler.ts +102 -0
  13. package/src/js/models/dft.ts +110 -0
  14. package/src/{models/factory.js → js/models/factory.ts} +9 -4
  15. package/src/{tree.js → js/tree.ts} +26 -33
  16. package/src/js/types/index.ts +37 -0
  17. package/tsconfig.json +3 -0
  18. package/.babelrc +0 -17
  19. package/dist/data/method_list.js +0 -1132
  20. package/dist/data/model_list.js +0 -786
  21. package/dist/data/model_method_map.js +0 -82
  22. package/dist/default_methods.js +0 -39
  23. package/dist/default_models.js +0 -14
  24. package/dist/index.js +0 -62
  25. package/dist/method.js +0 -84
  26. package/dist/methods/factory.js +0 -24
  27. package/dist/methods/pseudopotential.js +0 -100
  28. package/dist/model.js +0 -123
  29. package/dist/models/dft.js +0 -102
  30. package/dist/models/factory.js +0 -36
  31. package/dist/tree.js +0 -165
  32. package/src/data/method_list.js +0 -2
  33. package/src/data/model_list.js +0 -2
  34. package/src/data/model_method_map.js +0 -2
  35. package/src/default_methods.js +0 -38
  36. package/src/default_models.js +0 -9
  37. package/src/method.js +0 -77
  38. package/src/methods/pseudopotential.js +0 -99
  39. package/src/model.js +0 -127
  40. package/src/models/dft.js +0 -115
package/src/model.js DELETED
@@ -1,127 +0,0 @@
1
- import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
- import lodash from "lodash";
3
-
4
- import { DFTModelConfig } from "./default_models";
5
- import { Method } from "./method";
6
- import { MethodFactory } from "./methods/factory";
7
- import { getTreeByApplicationNameAndVersion, MODEL_TREE, treeSlugToNamedObject } from "./tree";
8
-
9
- export class Model extends InMemoryEntity {
10
- constructor({ application, ...config }) {
11
- super(config);
12
- this._application = application;
13
- this._MethodFactory = MethodFactory;
14
- }
15
-
16
- get type() {
17
- return this.prop("type", this.defaultType);
18
- }
19
-
20
- get subtype() {
21
- return this.prop("subtype", this.defaultSubtype);
22
- }
23
-
24
- setSubtype(subtype) {
25
- this.setProp("subtype", subtype);
26
- this.setMethod(this._MethodFactory.create(this.defaultMethodConfig));
27
- }
28
-
29
- get allowedTypes() {
30
- return Object.keys(this.tree).map((modelSlug) => treeSlugToNamedObject(modelSlug));
31
- }
32
-
33
- get allowedSubtypes() {
34
- return Object.keys(this.treeBranchForType).map((slug) => treeSlugToNamedObject(slug));
35
- }
36
-
37
- get defaultType() {
38
- return this.allowedTypes[0]?.slug;
39
- }
40
-
41
- get defaultSubtype() {
42
- return this.allowedSubtypes[0]?.slug;
43
- }
44
-
45
- get tree() {
46
- return (this._application && this.treeByApplicationNameAndVersion) || MODEL_TREE;
47
- }
48
-
49
- get treeBranchForType() {
50
- return this.tree[this.type] || {};
51
- }
52
-
53
- get treeBranchForSubType() {
54
- return this.treeBranchForType[this.subtype] || {};
55
- }
56
-
57
- get treeByApplicationNameAndVersion() {
58
- const [name, version] = [this._application.name, this._application.version];
59
- return getTreeByApplicationNameAndVersion({ name, version });
60
- }
61
-
62
- get groupSlug() {
63
- return `${this._application.shortName}:${this.type}:${this.subtype}`;
64
- }
65
-
66
- get method() {
67
- if (!this._method) {
68
- const method = this.prop("method") || this.defaultMethodConfig;
69
- this._method = this._MethodFactory.create(method);
70
- }
71
- return this._method;
72
- }
73
-
74
- setMethod(method) {
75
- this._method = method;
76
- }
77
-
78
- // Consider moving the below to `Method`
79
- get methodsFromTree() {
80
- return this.treeBranchForSubType.methods || {};
81
- }
82
-
83
- get methodTypes() {
84
- return Object.keys(this.methodsFromTree).map((m) => treeSlugToNamedObject(m));
85
- }
86
-
87
- get methodSubtypes() {
88
- return this.methodsFromTree[this.method.type].map((m) => treeSlugToNamedObject(m)) || [];
89
- }
90
-
91
- get defaultMethodConfig() {
92
- const type = Object.keys(this.methodsFromTree)[0];
93
- const subtype = (this.methodsFromTree[type] || [])[0];
94
- return { type, subtype };
95
- }
96
-
97
- static get defaultConfig() {
98
- return {
99
- ...DFTModelConfig,
100
- method: Method.defaultConfig,
101
- };
102
- }
103
-
104
- static get allTypes() {
105
- return Object.keys(this.tree).map((modelSlug) => treeSlugToNamedObject(modelSlug));
106
- }
107
-
108
- toJSON() {
109
- return {
110
- ...super.toJSON(),
111
- type: this.type,
112
- subtype: this.subtype,
113
- // TODO: use schema-based cleaning instead
114
- method: this.method.toJSONWithCleanData(),
115
- };
116
- }
117
-
118
- // to be used with extra properties
119
- // eslint-disable-next-line class-methods-use-this
120
- _stringToSlugifiedObject(slug) {
121
- return lodash.isString(slug) ? { slug } : slug;
122
- }
123
-
124
- get isUnknown() {
125
- return this.type === "unknown";
126
- }
127
- }
package/src/models/dft.js DELETED
@@ -1,115 +0,0 @@
1
- import _ from "underscore";
2
-
3
- import { MethodFactory } from "../methods/factory";
4
- import { Model } from "../model";
5
- import { treeSlugToNamedObject } from "../tree";
6
-
7
- export class DFTModel extends Model {
8
- constructor(config) {
9
- super(config);
10
- this._MethodFactory = config.MethodFactory || MethodFactory;
11
- }
12
-
13
- /**
14
- * @summary Build slug string based on model information
15
- * @returns {string}
16
- */
17
- get groupSlug() {
18
- return [
19
- this._application.shortName,
20
- this.type,
21
- this.subtype,
22
- this.functional.slug,
23
- this.refiners.map((o) => o.slug).join("+"),
24
- this.modifiers.map((o) => o.slug).join("+"),
25
- ]
26
- .join(":")
27
- .replace("::", ":")
28
- .replace(/:$/, "");
29
- }
30
-
31
- get defaultFunctional() {
32
- return treeSlugToNamedObject(this.treeBranchForSubType.functionals[0]);
33
- }
34
-
35
- // eslint-disable-next-line class-methods-use-this
36
- get defaultRefiners() {
37
- return [];
38
- }
39
-
40
- // eslint-disable-next-line class-methods-use-this
41
- get defaultModifiers() {
42
- return [];
43
- }
44
-
45
- get functional() {
46
- return this.prop("functional", this.defaultFunctional);
47
- }
48
-
49
- get refiners() {
50
- return this.prop("refiners", this.defaultRefiners);
51
- }
52
-
53
- get modifiers() {
54
- return this.prop("modifiers", this.defaultModifiers);
55
- }
56
-
57
- setSubtype(subtype) {
58
- this.setProp("subtype", subtype);
59
- this.setFunctional(this.defaultFunctional);
60
- }
61
-
62
- setFunctional(functional) {
63
- this.setProp("functional", this._stringToSlugifiedObject(functional));
64
- this.setMethod(this._MethodFactory.create(this.defaultMethodConfig));
65
- }
66
-
67
- _setArrayProp(name, data) {
68
- // eslint-disable-next-line no-param-reassign, no-undef
69
- data = safeMakeArray(data).map((r) => this._stringToSlugifiedObject(r));
70
- this.setProp(name, data);
71
- this[`_${name}`] = data;
72
- }
73
-
74
- setRefiners(refiners) {
75
- this._setArrayProp("refiners", refiners);
76
- }
77
-
78
- setModifiers(modifiers) {
79
- this._setArrayProp("modifiers", modifiers);
80
- }
81
-
82
- toJSON() {
83
- const pickSlugFromObject = (o) => _.pick(o, "slug");
84
- return {
85
- ...super.toJSON(),
86
- functional: pickSlugFromObject(this.functional), // only store slug for `functional`
87
- refiners: this.refiners,
88
- modifiers: this.modifiers,
89
- };
90
- }
91
-
92
- /**
93
- * Get all functionals in the form of {name: ..., slug: ...} for further use in UI
94
- * @returns {Object.<string, string>[]} - List of functional objects
95
- */
96
- get allFunctionals() {
97
- return this.treeBranchForSubType.functionals.map((x) => treeSlugToNamedObject(x));
98
- }
99
-
100
- /**
101
- * Get all refiners in the form of {name: ..., slug: ...} for further use in UI
102
- * @returns {Object.<string, string>[]} - List of refiner objects
103
- */
104
- get allRefiners() {
105
- return this.treeBranchForSubType.refiners.map((x) => treeSlugToNamedObject(x));
106
- }
107
-
108
- /**
109
- * Get all modifiers in the form of {name: ..., slug: ...} for further use in UI
110
- * @returns {Object.<string, string>[]} - List of modifier objects
111
- */
112
- get allModifiers() {
113
- return this.treeBranchForSubType.modifiers.map((x) => treeSlugToNamedObject(x));
114
- }
115
- }