Skip to content

Commit

Permalink
Merge pull request #15 from Exabyte-io/feat/SOF-6970-2
Browse files Browse the repository at this point in the history
feat/SOF-6970-2
  • Loading branch information
timurbazhirov authored Sep 14, 2023
2 parents 90ffae8 + 13d9454 commit 54eea75
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 30 deletions.
11 changes: 11 additions & 0 deletions src/include/meta_properties/pseudopotential.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export class Pseudopotential extends Property {
filteredPseudos = this.filterByAppName(filteredPseudos, fValue);
} else if (fKey === "elements" && fValue) {
filteredPseudos = this.filterByElements(filteredPseudos, fValue);
} else if (fKey === "type" && fValue) {
filteredPseudos = this.filterByType(filteredPseudos, fValue);
}
});
return filteredPseudos;
Expand Down Expand Up @@ -161,4 +163,13 @@ export class Pseudopotential extends Property {
return 0;
});
}

/**
* @param {Pseudopotential[]} pseudos - Pseudopotentials to filter
* @param {string} pseudoType - Pseudopotential type (e.g. "us", "nc", ...)
* @returns {Pseudopotential[]}
*/
static filterByType(pseudos, pseudoType) {
return pseudos.filter((pseudo) => pseudo.type.includes(pseudoType));
}
}
47 changes: 22 additions & 25 deletions src/include/non-scalar/dielectric_tensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,18 @@ export class DielectricTensorProperty extends Property {
getAllChartConfigs() {
const complementaryPairs = this.getComplementaryPairs();

return complementaryPairs.flatMap((pair) => {
return complementaryPairs.map((pair) => {
const xDataArray = pair[0].frequencies;
const components_first = this.rowMajorToColumnMajor(pair[0].components);
const components_second = this.rowMajorToColumnMajor(pair[1].components);
return components_first.map((epsilon, index) => {
return {
subtitle: `${this.subtitle} - ${"xyz"[index]}`,
xAxisTitle: this.xAxisTitle,
yAxisTitle: this.yAxisTitle,
yAxisType: "linear",
xDataArray,
yDataSeries: [epsilon, components_second[index]],
legend: pair.map((p) => p.part),
};
});
const spinChannel = pair[0].spin ? ` - spin(${pair[0].spin})` : "";
return {
subtitle: `${this.subtitle}${spinChannel}`,
xAxisTitle: this.xAxisTitle,
yAxisTitle: this.yAxisTitle,
yAxisType: "linear",
xDataArray,
yDataSeries: pair.flatMap((p) => this.rowMajorToColumnMajor(p.components)),
legend: pair.flatMap((p) => [..."xyz"].map((char) => `eps_${char} (${p.part})`)),
};
});
}
}
Expand Down Expand Up @@ -136,17 +133,17 @@ export class DielectricTensorConfig extends TwoDimensionalHighChartConfigMixin {
get overrideConfig() {
return {
...super.overrideConfig,
// colors: [
// "#7cb5ec",
// "#90ed7d",
// "#f7a35c",
// "#8085e9",
// "#f15c80",
// "#e4d354",
// "#2b908f",
// "#f45b5b",
// "#91e8e1",
// ],
colors: [
"#7cb5ec",
"#90ed7d",
"#f7a35c",
"#8085e9",
"#f15c80",
"#e4d354",
"#2b908f",
"#f45b5b",
"#91e8e1",
],
credits: {
enabled: false,
},
Expand Down
21 changes: 16 additions & 5 deletions tests/pseudopotential.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ describe("Pseudopotentials", () => {
elements: ["Pb"],
};

it("are sorted by default pattern: '/gbrv/'", () => {
it("can be sorted by default pattern: '/gbrv/'", () => {
const sortedPseudos = Pseudopotential.sortPseudosByPattern(pseudos);
expect(sortedPseudos[0].source).to.equal("gbrv");
});
it("are sorted by default path for VASP version 5.2", () => {
it("can be sorted by default path for VASP version 5.2", () => {
const sortedPseudos = Pseudopotential.sortByPathVASP(pseudos);
expect(sortedPseudos[0].source).to.equal("vasp");
});
it("are filtered by exchangeCorrelation and searchText at once", () => {
it("can be filtered by exchangeCorrelation and searchText at once", () => {
const { functional: func, approximation: appr } = filterObj.exchangeCorrelation;
const filtered = Pseudopotential.applyPseudoFilters(pseudos, filterObj);
// may need to be adjusted when new pseudos array is modified!
Expand All @@ -138,14 +138,14 @@ describe("Pseudopotentials", () => {
expect(filtered[0].exchangeCorrelation).to.have.property("approximation", appr);
expect(filtered[0].source).to.be.equal(filterObj.searchText);
});
it("are filtered by appName and elements at once", () => {
it("can be filtered by appName and elements at once", () => {
const filtered = Pseudopotential.applyPseudoFilters(pseudos, filterObj2);
// may need to be adjusted when new pseudos array is modified!
expect(filtered).to.have.lengthOf(1);
expect(filtered[0].apps[0]).to.be.equal(filterObj2.appName);
expect(filtered[0].element).to.be.equal(filterObj2.elements[0]);
});
it("are filtered by compatible functionals", () => {
it("can be filtered by compatible functionals", () => {
const exchangeCorrelation = { approximation: "hybrid", functional: "hse06" };
const sortedPseudos = Pseudopotential.filterRawDataByExchangeCorrelation(
pseudos,
Expand All @@ -154,4 +154,15 @@ describe("Pseudopotentials", () => {
expect(sortedPseudos).to.have.length(3); // there are 3 PBE pseudos above
expect(sortedPseudos.map((p) => p.exchangeCorrelation.functional)).to.include("pbe");
});
it("can be filtered by pseudopotential type", () => {
const filtered = Pseudopotential.filterByType(pseudos, "paw");
const filteredWithObject = Pseudopotential.applyPseudoFilters(pseudos, { type: "paw" });
// may need to be adjusted when new pseudos array is modified!
expect(filtered).to.have.lengthOf(1);
expect(filtered[0].type).to.be.equal("paw");
expect(filtered[0].path).to.be.equal(
"/export/share/pseudo/si/gga/pbe/vasp/5.2/paw/default/POTCAR",
);
expect(filteredWithObject).to.have.deep.members(filtered);
});
});

0 comments on commit 54eea75

Please sign in to comment.