Skip to content

Commit

Permalink
Merge pull request #133 from Exabyte-io/chore/SOF-7209
Browse files Browse the repository at this point in the history
SOF-7209: new TS config + fix math module
  • Loading branch information
k0stik authored Jun 4, 2024
2 parents fe0e9ad + 81de5f3 commit 61f29e8
Show file tree
Hide file tree
Showing 13 changed files with 609 additions and 235 deletions.
5 changes: 3 additions & 2 deletions dist/js/cell/cell.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CodeMath from "@mat3ra/code/dist/js/math";
import { Coordinate } from "../basis/types";
import { Vector, VectorsAsArray } from "../lattice/types";
type Point = Coordinate | math.Matrix | math.MathType;
type Point = Coordinate | CodeMath.Matrix | CodeMath.MathType;
export declare class Cell {
tolerance: number;
vector1: Vector;
Expand All @@ -21,7 +22,7 @@ export declare class Cell {
/**
* Convert a point (in crystal coordinates) to cartesian.
*/
convertPointToCartesian(point: Point): import("mathjs").MathType;
convertPointToCartesian(point: Point): CodeMath.MathType;
/**
* Convert a point (in cartesian coordinates) to crystal (fractional).
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/js/lattice/lattice.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export declare class Lattice extends LatticeBravais implements LatticeSchema {
beta: number;
gamma: number;
units: {
length?: "bohr" | "angstrom" | undefined;
length?: "angstrom" | "bohr" | undefined;
angle?: "degree" | "radian" | undefined;
};
type: "CUB" | "BCC" | "FCC" | "TET" | "MCL" | "ORC" | "ORCC" | "ORCF" | "ORCI" | "HEX" | "BCT" | "TRI" | "MCLC" | "RHL";
Expand Down
11 changes: 3 additions & 8 deletions dist/js/material.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity";
import { AnyObject } from "@mat3ra/code/dist/js/entity/in_memory";
import { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
import { ConsistencyCheck, DerivedPropertiesSchema, FileSourceSchema, MaterialSchema } from "@mat3ra/esse/dist/js/types";
import { ConstrainedBasis } from "./basis/constrained_basis";
import { Constraint } from "./constraints/constraints";
Expand Down Expand Up @@ -483,9 +483,7 @@ export declare const Material: {
setProps(json?: AnyObject | undefined): any;
toJSON(exclude?: string[] | undefined): AnyObject;
toJSONSafe(exclude?: string[] | undefined): AnyObject;
toJSONQuick(exclude?: string[] | undefined): AnyObject; /**
* Returns a copy of the material with conventional cell constructed instead of primitive.
*/
toJSONQuick(exclude?: string[] | undefined): AnyObject;
clone(extraContext?: object | undefined): any;
validate(): void;
clean(config: AnyObject): AnyObject;
Expand All @@ -511,10 +509,7 @@ export declare const Material: {
toJSONQuick(exclude?: string[] | undefined): AnyObject;
clone(extraContext?: object | undefined): any;
validate(): void;
clean(config: AnyObject): AnyObject; /**
* @summary a series of checks for the material's basis and returns an array of results in ConsistencyChecks format.
* @returns Array of checks results
*/
clean(config: AnyObject): AnyObject;
isValid(): boolean;
id: string;
readonly cls: string;
Expand Down
4 changes: 2 additions & 2 deletions dist/js/math.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ declare const _default: {
uninitialized: any;
version: string;
expression: import("mathjs").MathNode;
json: mathjs.MathJsJson;
json: import("mathjs").MathJsJson;
config: (options: any) => void;
lsolve(L: import("mathjs").Matrix | import("mathjs").MathArray, b: import("mathjs").Matrix | import("mathjs").MathArray): import("mathjs").Matrix | import("mathjs").MathArray;
lup(A?: import("mathjs").Matrix | import("mathjs").MathArray | undefined): import("mathjs").MathArray;
Expand Down Expand Up @@ -184,7 +184,7 @@ declare const _default: {
re(x: number | import("mathjs").Matrix | import("mathjs").BigNumber | import("mathjs").Complex | import("mathjs").MathArray): number | import("mathjs").Matrix | import("mathjs").BigNumber | import("mathjs").MathArray;
bignumber(x?: string | number | boolean | import("mathjs").Matrix | import("mathjs").MathArray | undefined): import("mathjs").BigNumber;
boolean(x: string | number | boolean | import("mathjs").Matrix | import("mathjs").MathArray): boolean | import("mathjs").Matrix | import("mathjs").MathArray;
chain(value?: any): any;
chain(value?: any): import("mathjs").MathJsChain;
complex(arg?: string | import("mathjs").Complex | import("mathjs").MathArray | import("mathjs").PolarCoordinates | undefined): import("mathjs").Complex;
complex(re: number, im: number): import("mathjs").Complex;
fraction(numerator: string | number | import("mathjs").Matrix | import("mathjs").MathArray, denominator?: string | number | import("mathjs").Matrix | import("mathjs").MathArray | undefined): import("mathjs").Matrix | import("mathjs").Fraction | import("mathjs").MathArray;
Expand Down
9 changes: 3 additions & 6 deletions dist/js/tools/material.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const mathjs_1 = __importDefault(require("mathjs"));
const math_1 = require("@mat3ra/code/dist/js/math");
const constants_1 = require("../constants");
const lattice_1 = require("../lattice/lattice");
/**
Expand Down Expand Up @@ -40,8 +37,8 @@ function getBasisConfigTranslatedToCenter(material) {
material.toCartesian();
const updatedBasis = material.Basis;
const centerOfCoordinates = updatedBasis.centerOfCoordinatesPoint;
const centerOfLattice = mathjs_1.default.multiply(0.5, material.Lattice.vectorArrays.reduce((a, b) => mathjs_1.default.add(a, b)));
const translationVector = mathjs_1.default.subtract(centerOfLattice, centerOfCoordinates);
const centerOfLattice = math_1.math.multiply(0.5, material.Lattice.vectorArrays.reduce((a, b) => math_1.math.add(a, b)));
const translationVector = math_1.math.subtract(centerOfLattice, centerOfCoordinates);
updatedBasis.translateByVector(translationVector);
material.setBasis(updatedBasis.toJSON());
if (originalUnits !== constants_1.ATOMIC_COORD_UNITS.cartesian)
Expand Down
2 changes: 1 addition & 1 deletion dist/js/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { AnyObject } from "@mat3ra/code/dist/js/entity/in_memory";
import { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
import { MaterialSchema } from "@mat3ra/esse/dist/js/types";
export type MaterialJSON = MaterialSchema & AnyObject;
Loading

0 comments on commit 61f29e8

Please sign in to comment.