Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions dist/js/abstract/array_with_ids.d.ts

This file was deleted.

88 changes: 0 additions & 88 deletions dist/js/abstract/array_with_ids.js

This file was deleted.

25 changes: 0 additions & 25 deletions dist/js/abstract/scalar_with_id.d.ts

This file was deleted.

44 changes: 0 additions & 44 deletions dist/js/abstract/scalar_with_id.js

This file was deleted.

17 changes: 7 additions & 10 deletions dist/js/basis/basis.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Basis = void 0;
// @ts-ignore
const periodic_table_js_1 = require("@exabyte-io/periodic-table.js");
const entity_1 = require("@mat3ra/code/dist/js/entity");
const math_1 = require("@mat3ra/code/dist/js/math");
const lodash_1 = require("lodash");
const cell_1 = require("../cell/cell");
const constants_1 = require("../constants");
const lattice_1 = require("../lattice/lattice");
const math_1 = __importDefault(require("../math"));
const coordinates_1 = require("./coordinates");
const elements_1 = require("./elements");
const labels_1 = require("./labels");
Expand Down Expand Up @@ -166,7 +163,7 @@ class Basis extends entity_1.InMemoryEntity {
}
toStandardRepresentation() {
this.toCrystal();
this._coordinates.mapArrayInPlace((point) => point.map((x) => math_1.default.mod(x)));
this._coordinates.mapArrayInPlace((point) => point.map((x) => math_1.math.mod(x)));
}
/** A representation where all coordinates are within 0 and 1 in crystal units */
get standardRepresentation() {
Expand Down Expand Up @@ -240,7 +237,7 @@ class Basis extends entity_1.InMemoryEntity {
get formula() {
const counts = this.uniqueElementCountsSortedByElectronegativity;
const countsValues = (0, lodash_1.values)(counts);
const gcd = countsValues.length > 1 ? math_1.default.gcd(...countsValues) : countsValues[0];
const gcd = countsValues.length > 1 ? math_1.math.gcd(...countsValues) : countsValues[0];
return (0, lodash_1.toPairs)(counts)
.map(([element, count]) => element + (count / gcd === 1 ? "" : count / gcd))
.reduce((acc, part) => acc + part, "");
Expand Down Expand Up @@ -293,7 +290,7 @@ class Basis extends entity_1.InMemoryEntity {
const element = entry[0];
const coordinate = entry[1];
const atomicLabel = entry[2];
const toleratedCoordinate = coordinate.map((x) => math_1.default.round(x, constants_1.HASH_TOLERANCE));
const toleratedCoordinate = coordinate.map((x) => math_1.math.round(x, constants_1.HASH_TOLERANCE));
return `${element}${atomicLabel} ${toleratedCoordinate.join()}`;
});
return `${standardRep.sort().join(";")};`;
Expand Down Expand Up @@ -364,7 +361,7 @@ class Basis extends entity_1.InMemoryEntity {
hasEquivalentCellTo(anotherBasisClsInstance) {
return !this.cell.vectorArrays
.map((vector, idx) => {
return math_1.default.vEqualWithTolerance(vector, anotherBasisClsInstance.cell.vectorArrays[idx]);
return math_1.math.vEqualWithTolerance(vector, anotherBasisClsInstance.cell.vectorArrays[idx]);
})
.some((x) => !x);
}
Expand Down Expand Up @@ -401,7 +398,7 @@ class Basis extends entity_1.InMemoryEntity {
const tolerance = overlapCoefficient *
((0, periodic_table_js_1.getElementAtomicRadius)(el1) + (0, periodic_table_js_1.getElementAtomicRadius)(el2)); // in angstroms
// @ts-ignore
const distance = math_1.default.vDist(entry1.value, entry2.value);
const distance = math_1.math.vDist(entry1.value, entry2.value);
if (distance < tolerance) {
overlaps.push({
id1: i,
Expand Down Expand Up @@ -437,7 +434,7 @@ class Basis extends entity_1.InMemoryEntity {
if (this._elements.values.length >= 2) {
for (let i = 0; i < this._elements.values.length; i++) {
for (let j = i + 1; j < this._elements.values.length; j++) {
const distance = math_1.default.vDist(this._coordinates.getElementValueByIndex(i), this._coordinates.getElementValueByIndex(j));
const distance = math_1.math.vDist(this._coordinates.getElementValueByIndex(i), this._coordinates.getElementValueByIndex(j));
if (distance && distance > maxDistance) {
maxDistance = distance;
}
Expand Down
7 changes: 2 additions & 5 deletions dist/js/basis/coordinates.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Coordinates = exports.Coordinate = void 0;
const code_1 = require("@mat3ra/code");
const math_1 = require("@mat3ra/code/dist/js/math");
const underscore_string_1 = require("underscore.string");
const math_1 = __importDefault(require("../math"));
class Coordinate extends code_1.RoundedValueWithId {
constructor({ value, id }) {
super(id, value);
Expand Down Expand Up @@ -61,7 +58,7 @@ class Coordinates extends code_1.RoundedArrayWithIds {
});
}
getCenterPoint() {
const transposed = math_1.default.transpose(this.values);
const transposed = math_1.math.transpose(this.values);
const center = [0, 0, 0];
for (let i = 0; i < 3; i++) {
const axisCoords = transposed[i];
Expand Down
1 change: 0 additions & 1 deletion dist/js/basis/types.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions dist/js/basis/types.js

This file was deleted.

37 changes: 17 additions & 20 deletions dist/js/cell/primitive_cell.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPrimitiveLatticeVectorsFromConfig = void 0;
const math_1 = __importDefault(require("../math"));
const math_1 = require("@mat3ra/code/dist/js/math");
/**
* Routines for calculating primitive cell vectors from conventional cell Bravais parameters.
* Following Setyawan, W., & Curtarolo, S. (2010). doi:10.1016/j.commatsci.2010.05.010
Expand Down Expand Up @@ -75,39 +72,39 @@ const PRIMITIVE_CELLS = {
},
HEX: ({ a, c }) => {
return [
[a / 2, (-a * math_1.default.sqrt(3)) / 2, 0],
[a / 2, (a * math_1.default.sqrt(3)) / 2, 0],
[a / 2, (-a * math_1.math.sqrt(3)) / 2, 0],
[a / 2, (a * math_1.math.sqrt(3)) / 2, 0],
[0, 0, c],
];
},
RHL: ({ a, alpha }) => {
const cosAlpha = math_1.default.cos((alpha / 180) * math_1.default.PI);
const cosHalfAlpha = math_1.default.sqrt((1 / 2) * (1 + cosAlpha));
const sinHalfAlpha = math_1.default.sqrt((1 / 2) * (1 - cosAlpha));
const cosAlpha = math_1.math.cos((alpha / 180) * math_1.math.PI);
const cosHalfAlpha = math_1.math.sqrt((1 / 2) * (1 + cosAlpha));
const sinHalfAlpha = math_1.math.sqrt((1 / 2) * (1 - cosAlpha));
return [
[a * cosHalfAlpha, -a * sinHalfAlpha, 0.0],
[a * cosHalfAlpha, a * sinHalfAlpha, 0.0],
[
(a * cosAlpha) / cosHalfAlpha,
0.0,
a * math_1.default.sqrt(1 - (cosAlpha * cosAlpha) / (cosHalfAlpha * cosHalfAlpha)),
a * math_1.math.sqrt(1 - (cosAlpha * cosAlpha) / (cosHalfAlpha * cosHalfAlpha)),
],
];
},
MCL: ({ a, b, c, alpha }) => {
const cosAlpha = math_1.default.cos((alpha / 180) * math_1.default.PI);
const cosAlpha = math_1.math.cos((alpha / 180) * math_1.math.PI);
return [
[a, 0, 0],
[0, b, 0],
[0, c * cosAlpha, c * math_1.default.sqrt(1 - cosAlpha * cosAlpha)],
[0, c * cosAlpha, c * math_1.math.sqrt(1 - cosAlpha * cosAlpha)],
];
},
MCLC: ({ a, b, c, alpha }) => {
const cosAlpha = math_1.default.cos((alpha / 180) * math_1.default.PI);
const cosAlpha = math_1.math.cos((alpha / 180) * math_1.math.PI);
return [
[a / 2, b / 2, 0],
[-a / 2, b / 2, 0],
[0, c * cosAlpha, c * math_1.default.sqrt(1 - cosAlpha * cosAlpha)],
[0, c * cosAlpha, c * math_1.math.sqrt(1 - cosAlpha * cosAlpha)],
];
},
// Algorithm from http://pymatgen.org/_modules/pymatgen/core/lattice.html (from_params)
Expand All @@ -116,19 +113,19 @@ const PRIMITIVE_CELLS = {
// eslint-disable-next-line no-param-reassign
[alpha, beta, gamma] = [alpha, beta, gamma].map(
// @ts-ignore
(x) => math_1.default.unit(x, "degree").to("rad").value);
const [cosAlpha, cosBeta, cosGamma] = [alpha, beta, gamma].map((x) => math_1.default.cos(x));
const [sinAlpha, sinBeta] = [alpha, beta].map((x) => math_1.default.sin(x));
(x) => math_1.math.unit(x, "degree").to("rad").value);
const [cosAlpha, cosBeta, cosGamma] = [alpha, beta, gamma].map((x) => math_1.math.cos(x));
const [sinAlpha, sinBeta] = [alpha, beta].map((x) => math_1.math.sin(x));
let acosArg = (cosAlpha * cosBeta - cosGamma) / (sinAlpha * sinBeta);
if (acosArg < -1) {
acosArg = -1;
}
else if (acosArg > 1) {
acosArg = 1;
}
const gammaStar = math_1.default.acos(acosArg);
const cosGammaStar = math_1.default.cos(gammaStar);
const sinGammaStar = math_1.default.sin(gammaStar);
const gammaStar = math_1.math.acos(acosArg);
const cosGammaStar = math_1.math.cos(gammaStar);
const sinGammaStar = math_1.math.sin(gammaStar);
return [
[a * sinBeta, 0.0, a * cosBeta],
[-b * sinAlpha * cosGammaStar, b * sinAlpha * sinGammaStar, b * cosAlpha],
Expand Down
Loading
Loading