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
2 changes: 1 addition & 1 deletion .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-checkout' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-checkout' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; }
git lfs post-checkout "$@"
2 changes: 1 addition & 1 deletion .husky/post-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; }
git lfs post-commit "$@"
2 changes: 1 addition & 1 deletion .husky/post-merge
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-merge' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-merge' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; }
git lfs post-merge "$@"
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; }
git lfs pre-push "$@"
9 changes: 9 additions & 0 deletions dist/js/basis/basis.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ export declare class Basis extends InMemoryEntity implements BasisSchema {
get hashString(): string;
get atomicLabelsArray(): string[];
get elementsWithLabelsArray(): string[];
/**
* Strips any label associated with atomic symbol
* Possible labels:
* (1) Fe1, Fe11
* (2) Fe-a, Fe-b, Fe-1, Fe-1a
* (3) Fe_a, Fe_b, Fe_1, Fe_1a
* As of Mar 2025, only single digit numerical labels are allowed
*/
static stripLabelToGetElementSymbol: (elementWithLabel: string) => string;
/**
* Returns an array of strings with chemical elements and their atomic positions.
* E.g., ``` ['Si 0 0 0', 'Li 0.5 0.5 0.5']```
Expand Down
33 changes: 24 additions & 9 deletions dist/js/basis/basis.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,9 @@ class Basis extends entity_1.InMemoryEntity {
const clsInstance = this.clone();
clsInstance.toStandardRepresentation();
const standardRep = clsInstance.elementsAndCoordinatesAndLabelsArray.map((entry) => {
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));
return `${element}${atomicLabel} ${toleratedCoordinate.join()}`;
const [element, coordinate, atomicLabel] = entry;
const toleratedCoordinates = coordinate.map((x) => math_1.default.round(x, constants_1.HASH_TOLERANCE));
return `${element}${atomicLabel} ${toleratedCoordinates.join()}`;
});
return `${standardRep.sort().join(";")};`;
}
Expand Down Expand Up @@ -336,10 +334,8 @@ class Basis extends entity_1.InMemoryEntity {
* E.g., ``` ['Si 0 0 0', 'Li 0.5 0.5 0.5']```
*/
get atomicPositions() {
return this.elementsAndCoordinatesAndLabelsArray.map((entry, idx) => {
const element = entry[0];
const coordinate = entry[1];
const atomicLabel = this.atomicLabelsArray[idx];
return this.elementsAndCoordinatesAndLabelsArray.map((entry) => {
const [element, coordinate, atomicLabel] = entry;
return `${element}${atomicLabel} ${coordinate}`;
});
}
Expand Down Expand Up @@ -478,3 +474,22 @@ class Basis extends entity_1.InMemoryEntity {
}
exports.Basis = Basis;
Basis.defaultConfig = DEFAULT_BASIS_CONFIG;
/**
* Strips any label associated with atomic symbol
* Possible labels:
* (1) Fe1, Fe11
* (2) Fe-a, Fe-b, Fe-1, Fe-1a
* (3) Fe_a, Fe_b, Fe_1, Fe_1a
* As of Mar 2025, only single digit numerical labels are allowed
*/
Basis.stripLabelToGetElementSymbol = (elementWithLabel) => {
// Strip anything after `-` or `_`
let elementSymbol = elementWithLabel.split(/[- _]/)[0];
// Exclude digit labels at the end of the symbol if present
elementSymbol = elementSymbol.replace(/\d+$/, "");
// Return symbol in title case
elementSymbol =
elementSymbol.charAt(0).toUpperCase() + elementSymbol.slice(1).toLowerCase();
// We can improve by validating element symbol matches one from the periodic table
return elementSymbol;
};
50 changes: 37 additions & 13 deletions dist/js/lattice/lattice_bravais.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LatticeBravais = void 0;
const constants_1 = __importDefault(require("../constants"));
Expand All @@ -16,14 +18,24 @@ class LatticeBravais {
* Create a Bravais lattice.
*/
constructor(config) {
const { a = 1, // default lattice is cubic with unity in edge sizes
b = a, c = a, alpha = 90, beta = alpha, gamma = alpha,
// if we do not know what lattice type this is => set to TRI
type = "TRI", units = {
length: "angstrom",
angle: "degree",
}, } = config;
const k = constants_1.default.units.bohr === units.length ? constants_1.default.coefficients.BOHR_TO_ANGSTROM : 1;
const {
a = 1, // default lattice is cubic with unity in edge sizes
b = a,
c = a,
alpha = 90,
beta = alpha,
gamma = alpha,
// if we do not know what lattice type this is => set to TRI
type = "TRI",
units = {
length: "angstrom",
angle: "degree",
},
} = config;
const k =
constants_1.default.units.bohr === units.length
? constants_1.default.coefficients.BOHR_TO_ANGSTROM
: 1;
this.a = a * k;
this.b = b * k;
this.c = c * k;
Expand All @@ -39,7 +51,15 @@ class LatticeBravais {
/**
* Create a Bravais lattice from vectors.
*/
static fromVectors({ a, b, c, alat = 1, units = "angstrom", type = "TRI", skipRounding = false, }) {
static fromVectors({
a,
b,
c,
alat = 1,
units = "angstrom",
type = "TRI",
skipRounding = false,
}) {
const roundValue = skipRounding ? (x) => x : this._roundValue;
const config = {
a: roundValue(math_1.default.vlen(a) * alat),
Expand Down Expand Up @@ -77,7 +97,11 @@ class LatticeBravais {
get editables() {
var _a;
const object = {};
const editablesList = (_a = types_1.LATTICE_TYPE_CONFIGS.find((entry) => entry.code === this.type)) === null || _a === void 0 ? void 0 : _a.editables;
const editablesList =
(_a = types_1.LATTICE_TYPE_CONFIGS.find((entry) => entry.code === this.type)) ===
null || _a === void 0
? void 0
: _a.editables;
// ["a", "gamma"] => {a: true, gamma: true}
if (editablesList) {
editablesList.forEach((element) => {
Expand Down
Loading
Loading