Skip to content

Commit

Permalink
update: remove keys from CChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Oct 23, 2023
1 parent fd6887b commit 717c1aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"node": ">=0.12"
},
"devDependencies": {
"@exabyte-io/code.js": "https://github.com/Exabyte-io/code.js#2c6290b74be5f4001ec72950f2c67d0880ebbe57",
"@exabyte-io/code.js": "https://github.com/Exabyte-io/code.js#3eb3e812265cb75bac2c06a007cb76e684c1d0f9",
"@exabyte-io/eslint-config": "^2022.11.17-0",
"chai": "^4.3.4",
"chai-almost": "^1.0.1",
Expand Down
12 changes: 7 additions & 5 deletions src/basis/basis.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,17 +446,17 @@ export class Basis {
*/
getOverlappingAtoms() {
// to simplify calculations, convert to cartesian coordinates
const _basis = this;
_basis.toCartesian();
const { coordinates, elements } = _basis;
this.toCartesian();
const { coordinates, elements } = this;
const overlaps = [];

coordinates.forEach((entry1) => {
coordinates.forEach((entry2) => {
if (entry1.id === entry2.id) return; // Don't compare an atom with itself
if (entry1.id === entry2.id) return;
const el1 = elements.find((el) => el.id === entry1.id).value;
const el2 = elements.find((el) => el.id === entry2.id).value;
const overlapCoefficient = 0.75; // temporary value for overlap approximation, where atoms most certainly can't be located
// temporary value for overlap approximation, where atoms most certainly can't be located
const overlapCoefficient = 0.75;
const tolerance =
overlapCoefficient *
(getElementAtomicRadius(el1) + getElementAtomicRadius(el2)); // in angstroms
Expand All @@ -473,6 +473,8 @@ export class Basis {
});
});

this.toCrystal();

return overlaps;
}

Expand Down
17 changes: 7 additions & 10 deletions src/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,41 +322,38 @@ export class Material extends HasConsistencyChecksHasMetadataNamedDefaultableInM

/**
* @summary a series of checks for the material and returns an array of results in ConsistencyChecks format.
* @returns {{keys: *[], messages: *[]}} - Array of checks results
* @returns {*[]}} - Array of checks results
*/
getConsistencyChecks() {
const basisChecks = this.getBasisConsistencyChecks();

// any other Material checks can be added here

return {
keys: Array.from(basisChecks.keys),
messages: basisChecks.messages,
checks: basisChecks,
};
}

/**
* @summary a series of checks for the material's basis and returns an array of results in ConsistencyChecks format.
* @returns {{keys: Set<any>, messages: *[]}}
* @returns {*[]} - Array of checks results
*/
getBasisConsistencyChecks() {
const keys = new Set();
const messages = [];
const checks = [];

const basis = this.Basis;
const overlappingAtomsGroups = basis.getOverlappingAtoms();

overlappingAtomsGroups.forEach(({ id1, id2, element1, element2 }) => {
const key = `basis.coordinates.${id1}`;
keys.add(key);
messages.push({
checks.push({
key,
checkName: "atomsOverlap",
name: "atomsOverlap",
severity: "warning",
message: `Atom ${element1} is too close to ${element2} at position ${id2 + 1}`,
});
});

return { keys, messages };
return checks;
}
}

0 comments on commit 717c1aa

Please sign in to comment.