@mat3ra/made 2025.6.25-0 → 2025.7.15-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.
@@ -37,6 +37,6 @@ export declare class ConstrainedBasis extends Basis {
37
37
  * Returns an array with atomic positions (with constraints) per atom stored as strings.
38
38
  * E.g., ``` ['Si 0 0 0 0 1 0', 'Li 0.5 0.5 0.5 1 0 1']```
39
39
  */
40
- getAtomicPositionsWithConstraintsAsStrings(coordinatePrintFormat: string, precision?: number): string[];
40
+ getAtomicPositionsWithConstraintsAsStrings(coordinatePrintFormat?: string, precision?: number): string[];
41
41
  removeAllAtoms(): void;
42
42
  }
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ReciprocalLattice = void 0;
7
7
  const constants_1 = require("@mat3ra/code/dist/js/constants");
8
- const array_almost_equal_1 = __importDefault(require("array-almost-equal"));
9
8
  const lodash_1 = __importDefault(require("lodash"));
10
9
  const math_1 = __importDefault(require("../../math"));
11
10
  const lattice_1 = require("../lattice");
@@ -75,7 +74,7 @@ class ReciprocalLattice extends lattice_1.Lattice {
75
74
  const symmPoints = this.symmetryPoints;
76
75
  dataPoints.forEach((point, index) => {
77
76
  const symmPoint = symmPoints.find((x) => {
78
- return (0, array_almost_equal_1.default)(x.coordinates, point, 1e-4);
77
+ return math_1.default.vEqualWithTolerance(x.coordinates, point, 1e-4);
79
78
  });
80
79
  if (symmPoint) {
81
80
  kpointPath.push({
package/dist/js/made.d.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { Basis } from "./basis/basis";
2
2
  import { Cell } from "./cell/cell";
3
+ import { ATOMIC_COORD_UNITS, coefficients, tolerance, units } from "./constants";
3
4
  import { AtomicConstraints } from "./constraints/constraints";
4
- import { Lattice } from "./lattice/lattice";
5
+ import { Lattice, nonPeriodicLatticeScalingFactor } from "./lattice/lattice";
6
+ import { DEFAULT_LATTICE_UNITS, LATTICE_TYPE_CONFIGS } from "./lattice/lattice_types";
5
7
  import { ReciprocalLattice } from "./lattice/reciprocal/lattice_reciprocal";
6
- import { Material } from "./material";
8
+ import { UnitCell } from "./lattice/unit_cell";
9
+ import { defaultMaterialConfig, Material } from "./material";
10
+ import parsers from "./parsers/parsers";
11
+ import tools from "./tools/index";
7
12
  export declare const Made: {
8
13
  coefficients: {
9
14
  EV_TO_RY: number;
@@ -489,6 +494,7 @@ export declare const Made: {
489
494
  defaultMaterialConfig: import("@mat3ra/esse/dist/js/types").MaterialSchema;
490
495
  Lattice: typeof Lattice;
491
496
  Cell: typeof Cell;
497
+ UnitCell: typeof UnitCell;
492
498
  nonPeriodicLatticeScalingFactor: number;
493
499
  ReciprocalLattice: typeof ReciprocalLattice;
494
500
  Basis: typeof Basis;
@@ -503,7 +509,7 @@ export declare const Made: {
503
509
  };
504
510
  poscar: {
505
511
  isPoscar: (text: string) => boolean;
506
- toPoscar: (materialOrConfig: import("./types").MaterialJSON, omitConstraints?: boolean) => string;
512
+ toPoscar: (materialOrConfig: import("@mat3ra/esse/dist/js/types").MaterialSchema, omitConstraints?: boolean) => string;
507
513
  fromPoscar: (fileContent: string) => object;
508
514
  atomicConstraintsCharFromBool: (bool: boolean) => string;
509
515
  atomsCount: typeof import("./parsers/poscar").atomsCount;
@@ -524,7 +530,7 @@ export declare const Made: {
524
530
  generateConfig: (material: Material, millerIndices: import("@mat3ra/esse/dist/js/types").Coordinate3DSchema, numberOfLayers?: number, vx?: number, vy?: number) => import("./tools/surface").SlabConfigSchema;
525
531
  };
526
532
  supercell: {
527
- generateConfig: (material: import("./types").MaterialInterface, supercellMatrix: import("@mat3ra/esse/dist/js/types").Matrix3X3Schema) => {
533
+ generateConfig: (material: Material, supercellMatrix: import("@mat3ra/esse/dist/js/types").Matrix3X3Schema) => {
528
534
  name: string;
529
535
  basis: import("@mat3ra/esse/dist/js/types").BasisSchema;
530
536
  lattice: import("@mat3ra/esse/dist/js/types").LatticeSchema;
@@ -551,3 +557,5 @@ export declare const Made: {
551
557
  };
552
558
  };
553
559
  };
560
+ export { coefficients, tolerance, units, ATOMIC_COORD_UNITS, Material, defaultMaterialConfig, Lattice, Cell, UnitCell, nonPeriodicLatticeScalingFactor, ReciprocalLattice, Basis, AtomicConstraints, parsers, tools, LATTICE_TYPE_CONFIGS, DEFAULT_LATTICE_UNITS, };
561
+ export type { MaterialInMemoryEntity } from "./materialMixin";
package/dist/js/made.js CHANGED
@@ -3,18 +3,36 @@ 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.Made = void 0;
6
+ exports.DEFAULT_LATTICE_UNITS = exports.LATTICE_TYPE_CONFIGS = exports.tools = exports.parsers = exports.AtomicConstraints = exports.Basis = exports.ReciprocalLattice = exports.nonPeriodicLatticeScalingFactor = exports.UnitCell = exports.Cell = exports.Lattice = exports.defaultMaterialConfig = exports.Material = exports.ATOMIC_COORD_UNITS = exports.units = exports.tolerance = exports.coefficients = exports.Made = void 0;
7
7
  const basis_1 = require("./basis/basis");
8
+ Object.defineProperty(exports, "Basis", { enumerable: true, get: function () { return basis_1.Basis; } });
8
9
  const cell_1 = require("./cell/cell");
10
+ Object.defineProperty(exports, "Cell", { enumerable: true, get: function () { return cell_1.Cell; } });
9
11
  const constants_1 = require("./constants");
12
+ Object.defineProperty(exports, "ATOMIC_COORD_UNITS", { enumerable: true, get: function () { return constants_1.ATOMIC_COORD_UNITS; } });
13
+ Object.defineProperty(exports, "coefficients", { enumerable: true, get: function () { return constants_1.coefficients; } });
14
+ Object.defineProperty(exports, "tolerance", { enumerable: true, get: function () { return constants_1.tolerance; } });
15
+ Object.defineProperty(exports, "units", { enumerable: true, get: function () { return constants_1.units; } });
10
16
  const constraints_1 = require("./constraints/constraints");
17
+ Object.defineProperty(exports, "AtomicConstraints", { enumerable: true, get: function () { return constraints_1.AtomicConstraints; } });
11
18
  const lattice_1 = require("./lattice/lattice");
19
+ Object.defineProperty(exports, "Lattice", { enumerable: true, get: function () { return lattice_1.Lattice; } });
20
+ Object.defineProperty(exports, "nonPeriodicLatticeScalingFactor", { enumerable: true, get: function () { return lattice_1.nonPeriodicLatticeScalingFactor; } });
12
21
  const lattice_types_1 = require("./lattice/lattice_types");
22
+ Object.defineProperty(exports, "DEFAULT_LATTICE_UNITS", { enumerable: true, get: function () { return lattice_types_1.DEFAULT_LATTICE_UNITS; } });
23
+ Object.defineProperty(exports, "LATTICE_TYPE_CONFIGS", { enumerable: true, get: function () { return lattice_types_1.LATTICE_TYPE_CONFIGS; } });
13
24
  const lattice_reciprocal_1 = require("./lattice/reciprocal/lattice_reciprocal");
25
+ Object.defineProperty(exports, "ReciprocalLattice", { enumerable: true, get: function () { return lattice_reciprocal_1.ReciprocalLattice; } });
26
+ const unit_cell_1 = require("./lattice/unit_cell");
27
+ Object.defineProperty(exports, "UnitCell", { enumerable: true, get: function () { return unit_cell_1.UnitCell; } });
14
28
  const material_1 = require("./material");
29
+ Object.defineProperty(exports, "defaultMaterialConfig", { enumerable: true, get: function () { return material_1.defaultMaterialConfig; } });
30
+ Object.defineProperty(exports, "Material", { enumerable: true, get: function () { return material_1.Material; } });
15
31
  const math_1 = __importDefault(require("./math"));
16
32
  const parsers_1 = __importDefault(require("./parsers/parsers"));
33
+ exports.parsers = parsers_1.default;
17
34
  const index_1 = __importDefault(require("./tools/index"));
35
+ exports.tools = index_1.default;
18
36
  exports.Made = {
19
37
  coefficients: constants_1.coefficients,
20
38
  tolerance: constants_1.tolerance,
@@ -25,6 +43,7 @@ exports.Made = {
25
43
  defaultMaterialConfig: material_1.defaultMaterialConfig,
26
44
  Lattice: lattice_1.Lattice,
27
45
  Cell: cell_1.Cell,
46
+ UnitCell: unit_cell_1.UnitCell,
28
47
  nonPeriodicLatticeScalingFactor: lattice_1.nonPeriodicLatticeScalingFactor,
29
48
  ReciprocalLattice: lattice_reciprocal_1.ReciprocalLattice,
30
49
  Basis: basis_1.Basis,
@@ -1,15 +1,13 @@
1
- import type { MaterialSchema } from "@mat3ra/esse/dist/js/types";
1
+ import { HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
+ import type { ConsistencyCheck, MaterialSchema } from "@mat3ra/esse/dist/js/types";
2
3
  import { type MaterialMixinConstructor, defaultMaterialConfig } from "./materialMixin";
3
4
  export { defaultMaterialConfig };
4
- declare const BaseInMemoryEntity: typeof import("@mat3ra/code/dist/js/entity").InMemoryEntity & import("@mat3ra/code/dist/js/entity/mixins/DefaultableMixin").DefaultableInMemoryEntityConstructor & {
5
- createDefault<T extends import("@mat3ra/code/dist/js/utils/types").Constructor<import("@mat3ra/code/dist/js/entity").InMemoryEntity> & {
6
- defaultConfig?: object | null | undefined;
7
- }>(this: T): InstanceType<T> & {
8
- isDefault: boolean;
9
- };
10
- } & import("@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin").NamedInMemoryEntityConstructor & import("@mat3ra/code/dist/js/entity/mixins/HasMetadataMixin").HasMetadataInMemoryEntityConstructor & import("@mat3ra/code/dist/js/entity/mixins/HasConsistencyChecksMixin").HasConsistencyChecksInMemoryEntityConstructor;
5
+ declare const BaseInMemoryEntity: typeof HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity;
11
6
  type BaseMaterial = MaterialMixinConstructor & typeof BaseInMemoryEntity;
7
+ type MaterialSchemaWithConsistencyChecksAsString = Omit<MaterialSchema, "consistencyChecks"> & {
8
+ consistencyChecks?: ConsistencyCheck[];
9
+ };
12
10
  declare const Material_base: BaseMaterial;
13
- export declare class Material extends Material_base {
11
+ export declare class Material extends Material_base implements MaterialSchemaWithConsistencyChecksAsString {
14
12
  constructor(config: MaterialSchema);
15
13
  }
@@ -7,18 +7,17 @@ import type { BasisConfig } from "./basis/basis";
7
7
  import { type ConstrainedBasisConfig, ConstrainedBasis } from "./basis/constrained_basis";
8
8
  import { Constraint } from "./constraints/constraints";
9
9
  import { Lattice } from "./lattice/lattice";
10
- import { MaterialJSON } from "./types";
11
10
  export declare const defaultMaterialConfig: MaterialSchema;
12
11
  export interface MaterialSchemaJSON extends MaterialSchema, AnyObject {
13
12
  }
14
- type MaterialMixinProps = ReturnType<typeof materialMixin>;
13
+ export type MaterialMixinProps = ReturnType<typeof materialMixin>;
15
14
  type MaterialMixinStaticProps = ReturnType<typeof materialMixinStaticProps>;
16
- export type MaterialMixin = MaterialMixinProps;
15
+ export type MaterialInMemoryEntity = InMemoryEntity & MaterialMixinProps;
17
16
  export type MaterialMixinConstructor = Constructor<MaterialMixinProps> & MaterialMixinStaticProps;
18
17
  export type OptionallyConstrainedBasisConfig = BasisConfig & Partial<Pick<ConstrainedBasisConfig, "constraints">>;
19
18
  type Base = InMemoryEntity & NamedInMemoryEntity;
20
19
  export declare function materialMixin<T extends Base = Base>(item: T): {
21
- toJSON(): MaterialJSON;
20
+ toJSON(): MaterialSchema;
22
21
  name: string;
23
22
  src: FileSourceSchema | undefined;
24
23
  updateFormula(): void;
@@ -291,9 +291,9 @@ function materialMixin(item) {
291
291
  return material;
292
292
  const conventionalSupercellMatrix = conventional_cell_1.PRIMITIVE_TO_CONVENTIONAL_CELL_MULTIPLIERS[this.Lattice.type];
293
293
  const conventionalLatticeType = conventional_cell_1.PRIMITIVE_TO_CONVENTIONAL_CELL_LATTICE_TYPES[this.Lattice.type];
294
- const config = supercell_1.default.generateConfig(material, conventionalSupercellMatrix);
294
+ const config = supercell_1.default.generateConfig(this, conventionalSupercellMatrix);
295
295
  config.lattice.type = conventionalLatticeType;
296
- config.name = `${material.name} - conventional cell`;
296
+ config.name = `${this.name} - conventional cell`;
297
297
  return new this.constructor(config);
298
298
  },
299
299
  /**
@@ -2,13 +2,13 @@ declare const _default: {
2
2
  xyz: {
3
3
  validate: typeof import("./xyz").validate;
4
4
  fromMaterial: (materialOrConfig: import("@mat3ra/esse/dist/js/types").MaterialSchema, fractional?: boolean) => string;
5
- toBasisConfig: (txt: string, units?: string, cell?: import("../cell/cell").Cell) => import("../basis/constrained_basis").ConstrainedBasisConfig;
5
+ toBasisConfig: (txt: string, units?: string, cell?: import("../made").Cell) => import("../basis/constrained_basis").ConstrainedBasisConfig;
6
6
  fromBasis: (basisClsInstance: import("../basis/constrained_basis").ConstrainedBasis, coordinatePrintFormat: string) => string;
7
7
  CombinatorialBasis: typeof import("./xyz_combinatorial_basis").CombinatorialBasis;
8
8
  };
9
9
  poscar: {
10
10
  isPoscar: (text: string) => boolean;
11
- toPoscar: (materialOrConfig: import("../types").MaterialJSON, omitConstraints?: boolean) => string;
11
+ toPoscar: (materialOrConfig: import("@mat3ra/esse/dist/js/types").MaterialSchema, omitConstraints?: boolean) => string;
12
12
  fromPoscar: (fileContent: string) => object;
13
13
  atomicConstraintsCharFromBool: (bool: boolean) => string;
14
14
  atomsCount: typeof import("./poscar").atomsCount;
@@ -1,10 +1,10 @@
1
- import { MaterialJSON } from "../types";
1
+ import { MaterialSchema } from "@mat3ra/esse/dist/js/types";
2
2
  /**
3
3
  * Obtain a textual representation of a material in POSCAR format.
4
4
  * @param materialOrConfig - material class instance or config object.
5
5
  * @param omitConstraints - whether to discard constraints passed with material.
6
6
  */
7
- declare function toPoscar(materialOrConfig: MaterialJSON, omitConstraints?: boolean): string;
7
+ declare function toPoscar(materialOrConfig: MaterialSchema, omitConstraints?: boolean): string;
8
8
  /**
9
9
  * @summary calculates the number of atoms in a poscar file based on the summation of the numbers in line 7 of the file.
10
10
  * Poscar file formatting: https://www.vasp.at/wiki/index.php/POSCAR
@@ -3,12 +3,12 @@ declare const _default: {
3
3
  generateConfig: (material: import("../material").Material, millerIndices: import("@mat3ra/esse/dist/js/types").Coordinate3DSchema, numberOfLayers?: number, vx?: number, vy?: number) => import("./surface").SlabConfigSchema;
4
4
  };
5
5
  supercell: {
6
- generateConfig: (material: import("../types").MaterialInterface, supercellMatrix: import("@mat3ra/esse/dist/js/types").Matrix3X3Schema) => {
6
+ generateConfig: (material: import("../material").Material, supercellMatrix: import("@mat3ra/esse/dist/js/types").Matrix3X3Schema) => {
7
7
  name: string;
8
8
  basis: import("@mat3ra/esse/dist/js/types").BasisSchema;
9
9
  lattice: import("@mat3ra/esse/dist/js/types").LatticeSchema;
10
10
  };
11
- generateNewBasisWithinSupercell: (basis: import("../basis/basis").Basis | import("../basis/constrained_basis").ConstrainedBasis, cell: import("../cell/cell").Cell, supercell: import("../cell/cell").Cell, supercellMatrix: import("@mat3ra/esse/dist/js/types").Matrix3X3Schema) => import("../basis/basis").Basis;
11
+ generateNewBasisWithinSupercell: (basis: import("../made").Basis | import("../basis/constrained_basis").ConstrainedBasis, cell: import("../made").Cell, supercell: import("../made").Cell, supercellMatrix: import("@mat3ra/esse/dist/js/types").Matrix3X3Schema) => import("../made").Basis;
12
12
  };
13
13
  material: {
14
14
  scaleOneLatticeVector: (material: import("../material").Material, key?: "a" | "b" | "c", factor?: number) => void;
@@ -16,8 +16,8 @@ declare const _default: {
16
16
  translateAtomsToCenter: (material: import("../material").Material) => void;
17
17
  };
18
18
  basis: {
19
- repeat: (basis: import("../basis/basis").Basis, repetitions: number[]) => import("../basis/basis").Basis;
20
- interpolate: (initialBasis: import("../basis/basis").Basis, finalBasis: import("../basis/basis").Basis, numberOfSteps?: number) => import("../basis/basis").Basis[];
19
+ repeat: (basis: import("../made").Basis, repetitions: number[]) => import("../made").Basis;
20
+ interpolate: (initialBasis: import("../made").Basis, finalBasis: import("../made").Basis, numberOfSteps?: number) => import("../made").Basis[];
21
21
  };
22
22
  };
23
23
  export default _default;
@@ -2,7 +2,7 @@ import { Matrix3X3Schema } from "@mat3ra/esse/dist/js/types";
2
2
  import { Basis } from "../basis/basis";
3
3
  import { ConstrainedBasis } from "../basis/constrained_basis";
4
4
  import { Cell } from "../cell/cell";
5
- import { MaterialInterface } from "../types";
5
+ import type { Material } from "../material";
6
6
  /**
7
7
  * @summary Generates new basis for a supercell. For each site from basis generates shifts that are within supercell.
8
8
  */
@@ -12,7 +12,7 @@ declare function generateNewBasisWithinSupercell(basis: Basis | ConstrainedBasis
12
12
  * @param material
13
13
  * @param supercellMatrix {Number[][]}
14
14
  */
15
- declare function generateConfig(material: MaterialInterface, supercellMatrix: Matrix3X3Schema): {
15
+ declare function generateConfig(material: Material, supercellMatrix: Matrix3X3Schema): {
16
16
  name: string;
17
17
  basis: import("@mat3ra/esse/dist/js/types").BasisSchema;
18
18
  lattice: import("@mat3ra/esse/dist/js/types").LatticeSchema;
@@ -1,15 +1 @@
1
- import { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
2
- import { MaterialSchema } from "@mat3ra/esse/dist/js/types";
3
- import { Basis } from "./basis/basis";
4
- import { ConstrainedBasis } from "./basis/constrained_basis";
5
- import { Lattice } from "./lattice/lattice";
6
- export type MaterialJSON = MaterialSchema & AnyObject;
7
- export interface MaterialInterface {
8
- name: string;
9
- Basis: Basis | ConstrainedBasis;
10
- Lattice: Lattice;
11
- }
12
- /**
13
- * @deprecated Import from './types' directory instead
14
- */
15
- export * from './types/material';
1
+ export type { MaterialInMemoryEntity } from "./materialMixin";
package/dist/js/types.js CHANGED
@@ -1,20 +1,2 @@
1
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- /**
18
- * @deprecated Import from './types' directory instead
19
- */
20
- __exportStar(require("./types/material"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/made",
3
- "version": "2025.6.25-0",
3
+ "version": "2025.7.15-0",
4
4
  "description": "MAterials DEsign library",
5
5
  "scripts": {
6
6
  "lint": "eslint --cache src/js tests/js && prettier --write src/js tests/js",
@@ -33,7 +33,7 @@
33
33
  "@babel/register": "^7.22.15",
34
34
  "@babel/runtime-corejs3": "^7.16.8",
35
35
  "@exabyte-io/eslint-config": "2025.5.13-0",
36
- "@mat3ra/code": "git+https://github.com/Exabyte-io/code.git#3e19f4c9407b61ff04dbd927c62156c7e2dbf999",
36
+ "@mat3ra/code": "2025.7.15-0",
37
37
  "@mat3ra/esse": "2025.5.16-0",
38
38
  "@mat3ra/tsconfig": "2024.6.3-0",
39
39
  "@mat3ra/utils": "2025.4.14-0",
@@ -88,7 +88,7 @@ export class ConstrainedBasis extends Basis {
88
88
  * E.g., ``` ['Si 0 0 0 0 1 0', 'Li 0.5 0.5 0.5 1 0 1']```
89
89
  */
90
90
  getAtomicPositionsWithConstraintsAsStrings(
91
- coordinatePrintFormat: string,
91
+ coordinatePrintFormat?: string,
92
92
  precision?: number,
93
93
  ): string[] {
94
94
  const omitConstraints = this._constraints.areUnconstrained;
@@ -1,6 +1,5 @@
1
1
  import { ATOMIC_COORD_UNITS, units as UNITS } from "@mat3ra/code/dist/js/constants";
2
2
  import { Vector3DSchema } from "@mat3ra/esse/dist/js/types";
3
- import almostEqual from "array-almost-equal";
4
3
  import lodash from "lodash";
5
4
 
6
5
  import math from "../../math";
@@ -108,7 +107,7 @@ export class ReciprocalLattice extends Lattice {
108
107
 
109
108
  dataPoints.forEach((point: KPointCoordinates, index: number) => {
110
109
  const symmPoint: SymmetryPoint | undefined = symmPoints.find((x) => {
111
- return almostEqual(x.coordinates, point, 1e-4);
110
+ return math.vEqualWithTolerance(x.coordinates, point, 1e-4);
112
111
  });
113
112
  if (symmPoint) {
114
113
  kpointPath.push({
package/src/js/made.ts CHANGED
@@ -5,6 +5,7 @@ import { AtomicConstraints } from "./constraints/constraints";
5
5
  import { Lattice, nonPeriodicLatticeScalingFactor } from "./lattice/lattice";
6
6
  import { DEFAULT_LATTICE_UNITS, LATTICE_TYPE_CONFIGS } from "./lattice/lattice_types";
7
7
  import { ReciprocalLattice } from "./lattice/reciprocal/lattice_reciprocal";
8
+ import { UnitCell } from "./lattice/unit_cell";
8
9
  import { defaultMaterialConfig, Material } from "./material";
9
10
  import MadeMath from "./math";
10
11
  import parsers from "./parsers/parsers";
@@ -21,6 +22,7 @@ export const Made = {
21
22
  defaultMaterialConfig,
22
23
  Lattice,
23
24
  Cell,
25
+ UnitCell,
24
26
  nonPeriodicLatticeScalingFactor,
25
27
  ReciprocalLattice,
26
28
  Basis,
@@ -31,3 +33,25 @@ export const Made = {
31
33
  LATTICE_TYPE_CONFIGS,
32
34
  DEFAULT_LATTICE_UNITS,
33
35
  };
36
+
37
+ export {
38
+ coefficients,
39
+ tolerance,
40
+ units,
41
+ ATOMIC_COORD_UNITS,
42
+ Material,
43
+ defaultMaterialConfig,
44
+ Lattice,
45
+ Cell,
46
+ UnitCell,
47
+ nonPeriodicLatticeScalingFactor,
48
+ ReciprocalLattice,
49
+ Basis,
50
+ AtomicConstraints,
51
+ parsers,
52
+ tools,
53
+ LATTICE_TYPE_CONFIGS,
54
+ DEFAULT_LATTICE_UNITS,
55
+ };
56
+
57
+ export type { MaterialInMemoryEntity } from "./materialMixin";
@@ -1,5 +1,5 @@
1
1
  import { HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity";
2
- import type { MaterialSchema } from "@mat3ra/esse/dist/js/types";
2
+ import type { ConsistencyCheck, MaterialSchema } from "@mat3ra/esse/dist/js/types";
3
3
 
4
4
  import {
5
5
  type MaterialMixinConstructor,
@@ -11,9 +11,18 @@ import {
11
11
  export { defaultMaterialConfig };
12
12
 
13
13
  const BaseInMemoryEntity = HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity;
14
+
14
15
  type BaseMaterial = MaterialMixinConstructor & typeof BaseInMemoryEntity;
15
16
 
16
- export class Material extends (BaseInMemoryEntity as BaseMaterial) {
17
+ // TODO: remove in-line type creation
18
+ type MaterialSchemaWithConsistencyChecksAsString = Omit<MaterialSchema, "consistencyChecks"> & {
19
+ consistencyChecks?: ConsistencyCheck[];
20
+ };
21
+
22
+ export class Material
23
+ extends (BaseInMemoryEntity as BaseMaterial)
24
+ implements MaterialSchemaWithConsistencyChecksAsString
25
+ {
17
26
  constructor(config: MaterialSchema) {
18
27
  super(config);
19
28
  materialMixin(this);
@@ -24,7 +24,6 @@ import { Constraint } from "./constraints/constraints";
24
24
  import { Lattice } from "./lattice/lattice";
25
25
  import parsers from "./parsers/parsers";
26
26
  import supercellTools from "./tools/supercell";
27
- import { MaterialJSON } from "./types";
28
27
 
29
28
  export const defaultMaterialConfig: MaterialSchema = {
30
29
  name: "Silicon FCC",
@@ -69,10 +68,11 @@ export const defaultMaterialConfig: MaterialSchema = {
69
68
 
70
69
  export interface MaterialSchemaJSON extends MaterialSchema, AnyObject {}
71
70
 
72
- type MaterialMixinProps = ReturnType<typeof materialMixin>;
71
+ export type MaterialMixinProps = ReturnType<typeof materialMixin>;
73
72
  type MaterialMixinStaticProps = ReturnType<typeof materialMixinStaticProps>;
74
73
 
75
- export type MaterialMixin = MaterialMixinProps;
74
+ export type MaterialInMemoryEntity = InMemoryEntity & MaterialMixinProps;
75
+
76
76
  export type MaterialMixinConstructor = Constructor<MaterialMixinProps> & MaterialMixinStaticProps;
77
77
 
78
78
  export type OptionallyConstrainedBasisConfig = BasisConfig &
@@ -84,7 +84,7 @@ export function materialMixin<T extends Base = Base>(item: T) {
84
84
  const originalToJSON = item.toJSON.bind(item);
85
85
 
86
86
  const properties = {
87
- toJSON(): MaterialJSON {
87
+ toJSON(): MaterialSchema {
88
88
  return {
89
89
  ...originalToJSON(),
90
90
  lattice: this.Lattice.toJSON(),
@@ -348,19 +348,20 @@ export function materialMixin<T extends Base = Base>(item: T) {
348
348
  * Returns a copy of the material with conventional cell constructed instead of primitive.
349
349
  */
350
350
  getACopyWithConventionalCell(): T {
351
- const material = item.clone() as T & typeof properties;
351
+ const material = item.clone();
352
352
 
353
353
  // if conventional and primitive cells are the same => return a copy.
354
- if (isConventionalCellSameAsPrimitiveForLatticeType(this.Lattice.type)) return material;
354
+ if (isConventionalCellSameAsPrimitiveForLatticeType(this.Lattice.type))
355
+ return material as T & typeof properties;
355
356
 
356
357
  const conventionalSupercellMatrix =
357
358
  PRIMITIVE_TO_CONVENTIONAL_CELL_MULTIPLIERS[this.Lattice.type];
358
359
  const conventionalLatticeType =
359
360
  PRIMITIVE_TO_CONVENTIONAL_CELL_LATTICE_TYPES[this.Lattice.type];
360
- const config = supercellTools.generateConfig(material, conventionalSupercellMatrix);
361
+ const config = supercellTools.generateConfig(this as any, conventionalSupercellMatrix);
361
362
 
362
363
  config.lattice.type = conventionalLatticeType;
363
- config.name = `${material.name} - conventional cell`;
364
+ config.name = `${this.name} - conventional cell`;
364
365
 
365
366
  return new (this.constructor as any)(config);
366
367
  },
@@ -1,4 +1,9 @@
1
- import { BasisSchema, Coordinate3DSchema, Vector3DSchema } from "@mat3ra/esse/dist/js/types";
1
+ import {
2
+ BasisSchema,
3
+ Coordinate3DSchema,
4
+ MaterialSchema,
5
+ Vector3DSchema,
6
+ } from "@mat3ra/esse/dist/js/types";
2
7
  import s from "underscore.string";
3
8
 
4
9
  import { ConstrainedBasis } from "../basis/constrained_basis";
@@ -9,7 +14,6 @@ import { ATOMIC_COORD_UNITS } from "../constants";
9
14
  import { AtomicConstraintValue } from "../constraints/constraints";
10
15
  import { Lattice } from "../lattice/lattice";
11
16
  import math from "../math";
12
- import { MaterialJSON } from "../types";
13
17
 
14
18
  const _print = (x: number, printFormat = "%14.9f") => s.sprintf(printFormat, math.precise(x));
15
19
  const _latticeVectorsToString = (vectors: Vector3DSchema[]) =>
@@ -21,7 +25,7 @@ const atomicConstraintsCharFromBool = (bool: boolean): string => (bool ? "T" : "
21
25
  * @param materialOrConfig - material class instance or config object.
22
26
  * @param omitConstraints - whether to discard constraints passed with material.
23
27
  */
24
- function toPoscar(materialOrConfig: MaterialJSON, omitConstraints = false): string {
28
+ function toPoscar(materialOrConfig: MaterialSchema, omitConstraints = false): string {
25
29
  const lattice = new Lattice(materialOrConfig.lattice);
26
30
  const vectorsAsString = _latticeVectorsToString(lattice.vectorArrays);
27
31
  // @ts-ignore
@@ -4,8 +4,8 @@ import { Basis } from "../basis/basis";
4
4
  import { ConstrainedBasis } from "../basis/constrained_basis";
5
5
  import { Cell } from "../cell/cell";
6
6
  import { Lattice } from "../lattice/lattice";
7
+ import type { Material } from "../material";
7
8
  import math from "../math";
8
- import { MaterialInterface } from "../types";
9
9
  import cellTools from "./cell";
10
10
 
11
11
  const ADD = math.add;
@@ -55,7 +55,7 @@ function generateNewBasisWithinSupercell(
55
55
  * @param material
56
56
  * @param supercellMatrix {Number[][]}
57
57
  */
58
- function generateConfig(material: MaterialInterface, supercellMatrix: Matrix3X3Schema) {
58
+ function generateConfig(material: Material, supercellMatrix: Matrix3X3Schema) {
59
59
  const det = math.det(supercellMatrix);
60
60
  if (det === 0) {
61
61
  throw new Error("Scaling matrix is degenerate.");
@@ -1,19 +0,0 @@
1
- /**
2
- * Declaration file for the array-almost-equal package
3
- * Used for comparing arrays of numbers with a specified tolerance
4
- */
5
-
6
- declare module "array-almost-equal" {
7
- /**
8
- * Compares two arrays of numbers and returns true if all elements are
9
- * equal within the specified tolerance
10
- *
11
- * @param a - First array to compare
12
- * @param b - Second array to compare
13
- * @param tolerance - The maximum allowed difference between array elements (default: 1e-6)
14
- * @returns boolean - True if arrays are almost equal, false otherwise
15
- */
16
- function almostEqual(a: number[], b: number[], tolerance?: number): boolean;
17
-
18
- export default almostEqual;
19
- }
@@ -1 +0,0 @@
1
- export * from "./material";
@@ -1,21 +0,0 @@
1
- import { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
2
- import { MaterialSchema } from "@mat3ra/esse/dist/js/types";
3
-
4
- import { Basis } from "../basis/basis";
5
- import { ConstrainedBasis } from "../basis/constrained_basis";
6
- import { Cell } from "../cell/cell";
7
-
8
- export type MaterialJSON = MaterialSchema & AnyObject;
9
-
10
- /**
11
- * Interface defining the minimum required properties for a Material
12
- * when used by other components like the supercell tools.
13
- * This helps break circular dependencies.
14
- */
15
- export interface MaterialInterface {
16
- name: string;
17
- Basis: Basis | ConstrainedBasis;
18
- Lattice: {
19
- vectors: Cell;
20
- };
21
- }
package/src/js/types.ts DELETED
@@ -1,20 +0,0 @@
1
- import { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
2
- import { MaterialSchema } from "@mat3ra/esse/dist/js/types";
3
-
4
- import { Basis } from "./basis/basis";
5
- import { ConstrainedBasis } from "./basis/constrained_basis";
6
- import { Lattice } from "./lattice/lattice";
7
-
8
- export type MaterialJSON = MaterialSchema & AnyObject;
9
-
10
- export interface MaterialInterface {
11
- name: string;
12
- Basis: Basis | ConstrainedBasis;
13
- Lattice: Lattice;
14
- }
15
-
16
- /**
17
- * @deprecated Import from './types' directory instead
18
- */
19
-
20
- export * from './types/material';