diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 1b99fd4..68a3e9e 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -30,6 +30,13 @@ jobs: uses: ./actions/yaml/lint with: python-version: ${{ matrix.python-version }} + targets: ./applications ./materials ./properties ./workflows + + - name: Run JSON linter + uses: ./actions/json/lint + with: + python-version: 3.10.X + targets: ./applications ./materials ./properties ./workflows - name: Run ruff linter uses: ./actions/py/lint diff --git a/materials/Graphene.json b/materials/Graphene.json new file mode 100644 index 0000000..3166f8b --- /dev/null +++ b/materials/Graphene.json @@ -0,0 +1,92 @@ +{ + "lattice": { + "a": 2.467291, + "b": 2.467291, + "c": 20, + "alpha": 90, + "beta": 90, + "gamma": 120, + "units": { + "length": "angstrom", + "angle": "degree" + }, + "type": "HEX", + "vectors": { + "a": [ + 2.467291, + 0, + 0 + ], + "b": [ + -1.233645, + 2.136737, + 0 + ], + "c": [ + 0, + 0, + 20 + ], + "alat": 1, + "units": "angstrom" + } + }, + "basis": { + "elements": [ + { + "id": 0, + "value": "C" + }, + { + "id": 1, + "value": "C" + } + ], + "coordinates": [ + { + "id": 0, + "value": [ + 0, + 0, + 0 + ] + }, + { + "id": 1, + "value": [ + 0.333333, + 0.666667, + 0 + ] + } + ], + "units": "crystal", + "cell": [ + [ + 2.467291, + 0, + 0 + ], + [ + -1.2336454999999995, + 2.136736684528712, + 0 + ], + [ + 0, + 0, + 20 + ] + ], + "constraints": [] + }, + "name": "Graphene", + "isNonPeriodic": false, + "external": { + "id": "mp-1040425", + "source": "materials project", + "doi": "10.17188/1405723", + "url": "https://next-gen.materialsproject.org/materials/mp-1040425/", + "origin": true + } +} diff --git a/materials/Na4Cl4.json b/materials/Na4Cl4.json index af5373d..2eaaac4 100644 --- a/materials/Na4Cl4.json +++ b/materials/Na4Cl4.json @@ -105,12 +105,12 @@ [ 1, 0, - 6.123233995736766e-17 + 0 ], [ - 1.6081226496766366e-16, + 0, 1, - 6.123233995736766e-17 + 0 ], [ 0, @@ -120,9 +120,9 @@ ] }, "lattice": { - "a": 5.691694, - "b": 5.691694, - "c": 5.691694, + "a": 5.58813, + "b": 5.58813, + "c": 5.58813, "alpha": 90, "beta": 90, "gamma": 90, @@ -133,22 +133,31 @@ "type": "CUB", "vectors": { "a": [ - 5.691694, + 5.58813, 0, 0 ], "b": [ 0, - 5.691694, + 5.58813, 0 ], "c": [ 0, 0, - 5.691694 + 5.58813 ], "alat": 1, "units": "angstrom" } + }, + "name": "Na4Cl4", + "isNonPeriodic": false, + "external": { + "id": "mp-22862", + "source": "materials project", + "doi": "10.17188/1199028", + "url": "https://next-gen.materialsproject.org/materials/mp-22862/", + "origin": true } } diff --git a/materials/Si.json b/materials/Si.json index 57a08a5..d8d41b2 100644 --- a/materials/Si.json +++ b/materials/Si.json @@ -30,16 +30,25 @@ ] }, "lattice": { - "a": 5, - "b": 5, - "c": 5, - "alpha": 90, - "beta": 90, - "gamma": 90, + "a": 3.867, + "b": 3.867, + "c": 3.867, + "alpha": 60, + "beta": 60, + "gamma": 60, "type": "TRI", "units": { "length": "angstrom", "angle": "degree" } + }, + "name": "Si", + "isNonPeriodic": false, + "external": { + "id": "mp-149", + "source": "materials project", + "doi": "10.17188/1190959", + "url": "https://next-gen.materialsproject.org/materials/mp-149/", + "origin": true } } diff --git a/materials/WS2.json b/materials/WS2.json new file mode 100644 index 0000000..262af68 --- /dev/null +++ b/materials/WS2.json @@ -0,0 +1,104 @@ +{ + "lattice": { + "a": 3.184222, + "b": 3.184222, + "c": 12.97828, + "alpha": 90, + "beta": 90, + "gamma": 120, + "units": { + "length": "angstrom", + "angle": "degree" + }, + "type": "HEX", + "vectors": { + "a": [ + 1.5921114461115318, + -2.7576179159771317, + 0.0 + ], + "b": [ + 1.5921114461115318, + 2.7576179159771317, + 0.0 + ], + "c": [ + 0.0, + 0.0, + 12.97828236 + ], + "alat": 1, + "units": "angstrom" + } + }, + "basis": { + "elements": [ + { + "id": 0, + "value": "W" + }, + { + "id": 1, + "value": "S" + }, + { + "id": 2, + "value": "S" + } + ], + "coordinates": [ + { + "id": 0, + "value": [ + 0.333333, + 0.666667, + 0.120195 + ] + }, + { + "id": 1, + "value": [ + 0, + 0, + 0 + ] + }, + { + "id": 2, + "value": [ + 0.0, + 0.0, + 0.24039 + ] + } + ], + "units": "crystal", + "cell": [ + [ + 1.5921114461115318, + -2.7576179159771317, + 0.0 + ], + [ + 1.5921114461115318, + 2.7576179159771317, + 0.0 + ], + [ + 0, + 0, + 12.97828236 + ] + ], + "constraints": [] + }, + "name": "WS2", + "isNonPeriodic": false, + "external": { + "id": "mp-224", + "source": "materials project", + "doi": "10.17188/1197614", + "url": "https://next-gen.materialsproject.org/materials/mp-224/", + "origin": true + } +} diff --git a/materials/categories.yml b/materials/categories.yml index 868e567..906faf4 100644 --- a/materials/categories.yml +++ b/materials/categories.yml @@ -43,6 +43,18 @@ categories: - carbide entities: + - filename: Graphene.json + categories: + - 2D + - surface + - semi-metal + - non-magnetic + - filename: h-BN.json + categories: + - 2D + - surface + - insulator + - non-magnetic - filename: Na4Cl4.json categories: - 3D @@ -54,3 +66,9 @@ entities: - 3D - bulk - semiconductor + - filename: WS2.json + categories: + - 2D + - surface + - semiconductor + - non-magnetic diff --git a/materials/h-BN.json b/materials/h-BN.json new file mode 100644 index 0000000..1ce4300 --- /dev/null +++ b/materials/h-BN.json @@ -0,0 +1,92 @@ +{ + "lattice": { + "a": 2.50899515, + "b": 2.50899515, + "c": 7.71, + "alpha": 90, + "beta": 90, + "gamma": 120, + "units": { + "length": "angstrom", + "angle": "degree" + }, + "type": "HEX", + "vectors": { + "a": [ + 2.467291, + 0, + 0 + ], + "b": [ + -1.233645, + 2.136737, + 0 + ], + "c": [ + 0, + 0, + 7.71 + ], + "alat": 1, + "units": "angstrom" + } + }, + "basis": { + "elements": [ + { + "id": 0, + "value": "B" + }, + { + "id": 1, + "value": "N" + } + ], + "coordinates": [ + { + "id": 0, + "value": [ + 0, + 0, + 0 + ] + }, + { + "id": 1, + "value": [ + 0.333333, + 0.666667, + 0 + ] + } + ], + "units": "crystal", + "cell": [ + [ + 2.467291, + 0, + 0 + ], + [ + -1.2336454999999995, + 2.136736684528712, + 0 + ], + [ + 0, + 0, + 7.71 + ] + ], + "constraints": [] + }, + "name": "h-BN", + "isNonPeriodic": false, + "external": { + "id": "mp-984", + "source": "materials project", + "doi": "10.17188/1281942", + "url": "https://next-gen.materialsproject.org/materials/mp-984/", + "origin": true + } +} diff --git a/package.json b/package.json index 0607848..8202e17 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "lint": "eslint --cache src/js tests/js && prettier --write src/js tests/js", "lint:fix": "eslint --fix --cache src/js tests/js && prettier --write src/js tests/js", "lint:staged": "lint-staged", - "postinstall": "npm run transpile", + "postinstall": "npm run transpile && cp -r src/js/runtime_data lib/", "prepare": "node bootstrap.js", "prettier": "prettier --check src/js tests/js", "test": "mocha", diff --git a/src/js/runtime_data/materials.json b/src/js/runtime_data/materials.json index 8e28744..0904b4a 100644 --- a/src/js/runtime_data/materials.json +++ b/src/js/runtime_data/materials.json @@ -1 +1 @@ -{"standataConfig":{"categories":{"type":["semiconductor","solar energy material","storage medium","organic electronics","battery/energy storage","composite","polymer","metals & alloys","solvent","catalysis","consumer packaged goods","glass","ceramic"],"form_factor":["bulk","surface","interface"],"dimensionality":["0D","1D","2D","3D","4D"],"electrical_conductivity":["metal","semi-metal","semiconductor","insulator"],"magnetism":["ferromagnetic","anti-ferromagnetic","paramagnetic","diamagnetic","non-magnetic"],"superconductivity":["type I","type II"],"composition":["oxide","nitride","carbide"]},"entities":[{"filename":"Na4Cl4.json","categories":["3D","bulk","insulator","non-magnetic"]},{"filename":"Si.json","categories":["3D","bulk","semiconductor"]}]},"filesMapByName":{"Na4Cl4.json":{"basis":{"elements":[{"id":0,"value":"Na"},{"id":1,"value":"Na"},{"id":2,"value":"Na"},{"id":3,"value":"Na"},{"id":4,"value":"Cl"},{"id":5,"value":"Cl"},{"id":6,"value":"Cl"},{"id":7,"value":"Cl"}],"coordinates":[{"id":0,"value":[0,0,0]},{"id":1,"value":[0,0.5,0.5]},{"id":2,"value":[0.5,0,0.5]},{"id":3,"value":[0.5,0.5,0]},{"id":4,"value":[0,0,0.5]},{"id":5,"value":[0,0.5,0]},{"id":6,"value":[0.5,0,0]},{"id":7,"value":[0.5,0.5,0.5]}],"units":"crystal","cell":[[1,0,6.123233995736766e-17],[1.6081226496766366e-16,1,6.123233995736766e-17],[0,0,1]]},"lattice":{"a":5.691694,"b":5.691694,"c":5.691694,"alpha":90,"beta":90,"gamma":90,"units":{"length":"angstrom","angle":"degree"},"type":"CUB","vectors":{"a":[5.691694,0,0],"b":[0,5.691694,0],"c":[0,0,5.691694],"alat":1,"units":"angstrom"}}},"Si.json":{"basis":{"elements":[{"id":0,"value":"Si"},{"id":1,"value":"Si"}],"coordinates":[{"id":0,"value":[0,0,0]},{"id":1,"value":[0.25,0.25,0.25]}]},"lattice":{"a":5,"b":5,"c":5,"alpha":90,"beta":90,"gamma":90,"type":"TRI","units":{"length":"angstrom","angle":"degree"}}}}} +{"standataConfig":{"categories":{"type":["semiconductor","solar energy material","storage medium","organic electronics","battery/energy storage","composite","polymer","metals & alloys","solvent","catalysis","consumer packaged goods","glass","ceramic"],"form_factor":["bulk","surface","interface"],"dimensionality":["0D","1D","2D","3D","4D"],"electrical_conductivity":["metal","semi-metal","semiconductor","insulator"],"magnetism":["ferromagnetic","anti-ferromagnetic","paramagnetic","diamagnetic","non-magnetic"],"superconductivity":["type I","type II"],"composition":["oxide","nitride","carbide"]},"entities":[{"filename":"Graphene.json","categories":["2D","surface","semi-metal","non-magnetic"]},{"filename":"h-BN.json","categories":["2D","surface","insulator","non-magnetic"]},{"filename":"Na4Cl4.json","categories":["3D","bulk","insulator","non-magnetic"]},{"filename":"Si.json","categories":["3D","bulk","semiconductor"]},{"filename":"WS2.json","categories":["2D","surface","semiconductor","non-magnetic"]}]},"filesMapByName":{"Graphene.json":{"lattice":{"a":2.467291,"b":2.467291,"c":20,"alpha":90,"beta":90,"gamma":120,"units":{"length":"angstrom","angle":"degree"},"type":"HEX","vectors":{"a":[2.467291,0,0],"b":[-1.233645,2.136737,0],"c":[0,0,20],"alat":1,"units":"angstrom"}},"basis":{"elements":[{"id":0,"value":"C"},{"id":1,"value":"C"}],"coordinates":[{"id":0,"value":[0,0,0]},{"id":1,"value":[0.333333,0.666667,0]}],"units":"crystal","cell":[[2.467291,0,0],[-1.2336454999999995,2.136736684528712,0],[0,0,20]],"constraints":[]},"name":"Graphene","isNonPeriodic":false,"external":{"id":"mp-1040425","source":"materials project","doi":"10.17188/1405723","url":"https://next-gen.materialsproject.org/materials/mp-1040425/","origin":true}},"h-BN.json":{"lattice":{"a":2.50899515,"b":2.50899515,"c":7.71,"alpha":90,"beta":90,"gamma":120,"units":{"length":"angstrom","angle":"degree"},"type":"HEX","vectors":{"a":[2.467291,0,0],"b":[-1.233645,2.136737,0],"c":[0,0,7.71],"alat":1,"units":"angstrom"}},"basis":{"elements":[{"id":0,"value":"B"},{"id":1,"value":"N"}],"coordinates":[{"id":0,"value":[0,0,0]},{"id":1,"value":[0.333333,0.666667,0]}],"units":"crystal","cell":[[2.467291,0,0],[-1.2336454999999995,2.136736684528712,0],[0,0,7.71]],"constraints":[]},"name":"h-BN","isNonPeriodic":false,"external":{"id":"mp-984","source":"materials project","doi":"10.17188/1281942","url":"https://next-gen.materialsproject.org/materials/mp-984/","origin":true}},"Na4Cl4.json":{"basis":{"elements":[{"id":0,"value":"Na"},{"id":1,"value":"Na"},{"id":2,"value":"Na"},{"id":3,"value":"Na"},{"id":4,"value":"Cl"},{"id":5,"value":"Cl"},{"id":6,"value":"Cl"},{"id":7,"value":"Cl"}],"coordinates":[{"id":0,"value":[0,0,0]},{"id":1,"value":[0,0.5,0.5]},{"id":2,"value":[0.5,0,0.5]},{"id":3,"value":[0.5,0.5,0]},{"id":4,"value":[0,0,0.5]},{"id":5,"value":[0,0.5,0]},{"id":6,"value":[0.5,0,0]},{"id":7,"value":[0.5,0.5,0.5]}],"units":"crystal","cell":[[1,0,0],[0,1,0],[0,0,1]]},"lattice":{"a":5.58813,"b":5.58813,"c":5.58813,"alpha":90,"beta":90,"gamma":90,"units":{"length":"angstrom","angle":"degree"},"type":"CUB","vectors":{"a":[5.58813,0,0],"b":[0,5.58813,0],"c":[0,0,5.58813],"alat":1,"units":"angstrom"}},"name":"Na4Cl4","isNonPeriodic":false,"external":{"id":"mp-22862","source":"materials project","doi":"10.17188/1199028","url":"https://next-gen.materialsproject.org/materials/mp-22862/","origin":true}},"Si.json":{"basis":{"elements":[{"id":0,"value":"Si"},{"id":1,"value":"Si"}],"coordinates":[{"id":0,"value":[0,0,0]},{"id":1,"value":[0.25,0.25,0.25]}]},"lattice":{"a":3.867,"b":3.867,"c":3.867,"alpha":60,"beta":60,"gamma":60,"type":"TRI","units":{"length":"angstrom","angle":"degree"}},"name":"Si","isNonPeriodic":false,"external":{"id":"mp-149","source":"materials project","doi":"10.17188/1190959","url":"https://next-gen.materialsproject.org/materials/mp-149/","origin":true}},"WS2.json":{"lattice":{"a":3.184222,"b":3.184222,"c":12.97828,"alpha":90,"beta":90,"gamma":120,"units":{"length":"angstrom","angle":"degree"},"type":"HEX","vectors":{"a":[1.5921114461115318,-2.7576179159771317,0],"b":[1.5921114461115318,2.7576179159771317,0],"c":[0,0,12.97828236],"alat":1,"units":"angstrom"}},"basis":{"elements":[{"id":0,"value":"W"},{"id":1,"value":"S"},{"id":2,"value":"S"}],"coordinates":[{"id":0,"value":[0.333333,0.666667,0.120195]},{"id":1,"value":[0,0,0]},{"id":2,"value":[0,0,0.24039]}],"units":"crystal","cell":[[1.5921114461115318,-2.7576179159771317,0],[1.5921114461115318,2.7576179159771317,0],[0,0,12.97828236]],"constraints":[]},"name":"WS2","isNonPeriodic":false,"external":{"id":"mp-224","source":"materials project","doi":"10.17188/1197614","url":"https://next-gen.materialsproject.org/materials/mp-224/","origin":true}}}} diff --git a/tests/js/fixtures/Graphene.json b/tests/js/fixtures/Graphene.json new file mode 120000 index 0000000..f34b750 --- /dev/null +++ b/tests/js/fixtures/Graphene.json @@ -0,0 +1 @@ +../../../materials/Graphene.json \ No newline at end of file diff --git a/tests/js/fixtures/Na4Cl4.json b/tests/js/fixtures/Na4Cl4.json new file mode 120000 index 0000000..0fb86d5 --- /dev/null +++ b/tests/js/fixtures/Na4Cl4.json @@ -0,0 +1 @@ +../../../materials/Na4Cl4.json \ No newline at end of file diff --git a/tests/js/fixtures/WS2.json b/tests/js/fixtures/WS2.json new file mode 120000 index 0000000..8e3772f --- /dev/null +++ b/tests/js/fixtures/WS2.json @@ -0,0 +1 @@ +../../../materials/WS2.json \ No newline at end of file diff --git a/tests/js/fixtures/h-BN.json b/tests/js/fixtures/h-BN.json new file mode 120000 index 0000000..e40fa9d --- /dev/null +++ b/tests/js/fixtures/h-BN.json @@ -0,0 +1 @@ +../../../materials/h-BN.json \ No newline at end of file diff --git a/tests/js/material.test.ts b/tests/js/material.test.ts index 0c1e744..da52fa9 100644 --- a/tests/js/material.test.ts +++ b/tests/js/material.test.ts @@ -2,6 +2,10 @@ import { expect } from "chai"; import { MaterialStandata } from "../../src/js"; import Si from "./fixtures/Si.json"; +import Na4Cl4 from "./fixtures/Na4Cl4.json"; +import Graphene from "./fixtures/Graphene.json"; +import h_BN from "./fixtures/h-BN.json"; +import WS2 from "./fixtures/WS2.json"; describe("Materials Standata", () => { it("can search materials by tags", () => { @@ -11,4 +15,13 @@ describe("Materials Standata", () => { expect(entities).to.deep.include.members([Si]); expect(entities.length).to.be.lessThan(std.entities.length); }); + + it("should return all entities with the same tag", () => { + const std = new MaterialStandata(); + const tags = ["2D"]; + const entities = std.find_entities(...tags); + expect(entities).to.deep.include.members([Graphene, h_BN, WS2]); + expect(entities).to.not.deep.include.members([Si, Na4Cl4]); + expect(entities.length).to.be.lessThan(std.entities.length); + }); });