Skip to content

Commit

Permalink
Merge pull request #13 from Exabyte-io/epic/SOF-6009
Browse files Browse the repository at this point in the history
Epic/SOF-6009
  • Loading branch information
azech-hqs authored Sep 1, 2023
2 parents c9b8562 + b41576d commit d23a7fe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/include/meta_properties/pseudopotential.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import _ from "underscore";
import { Property } from "../../property";

export class Pseudopotential extends Property {
static compatibleExchangeCorrelation = {
hse06: ["pbe", "hse06"],
};

get path() {
return this.prop("path");
}
Expand Down Expand Up @@ -68,11 +72,17 @@ export class Pseudopotential extends Property {
* @param {String} exchangeCorrelation.functional
*/
static filterRawDataByExchangeCorrelation(rawData, exchangeCorrelation) {
return rawData.filter((el) =>
Object.keys(exchangeCorrelation).reduce(
(mem, key) => mem && el.exchangeCorrelation[key] === exchangeCorrelation[key],
),
const { functional } = exchangeCorrelation;
const isCompatibleWithOther = Object.keys(this.compatibleExchangeCorrelation).includes(
functional,
);
return rawData.filter((item) => {
return isCompatibleWithOther
? this.compatibleExchangeCorrelation[functional].includes(
item.exchangeCorrelation?.functional,
)
: functional === item.exchangeCorrelation?.functional;
});
}

// filter unique (assuming that path is always unique)
Expand Down
9 changes: 9 additions & 0 deletions tests/pseudopotential.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,13 @@ describe("Pseudopotentials", () => {
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", () => {
const exchangeCorrelation = { approximation: "hybrid", functional: "hse06" };
const sortedPseudos = Pseudopotential.filterRawDataByExchangeCorrelation(
pseudos,
exchangeCorrelation,
);
expect(sortedPseudos).to.have.length(3); // there are 3 PBE pseudos above
expect(sortedPseudos.map((p) => p.exchangeCorrelation.functional)).to.include("pbe");
});
});

0 comments on commit d23a7fe

Please sign in to comment.