|
| 1 | +import { JSONSchemaFormDataProvider, MaterialContextMixin } from "@exabyte-io/code.js/dist/context"; |
| 2 | +import { Made } from "@exabyte-io/made.js"; |
| 3 | +import { mix } from "mixwith"; |
| 4 | + |
| 5 | +const defaultHubbardConfig = { |
| 6 | + atomicSpecies: "", |
| 7 | + atomicOrbital: "2p", |
| 8 | + hubbardUValue: 0.01, |
| 9 | +}; |
| 10 | + |
| 11 | +export class HubbardContextProvider extends mix(JSONSchemaFormDataProvider).with( |
| 12 | + MaterialContextMixin, |
| 13 | +) { |
| 14 | + static Material = Made.Material; |
| 15 | + |
| 16 | + constructor(config) { |
| 17 | + super(config); |
| 18 | + this.uniqueElements = this.material?.Basis?.uniqueElements || []; |
| 19 | + } |
| 20 | + |
| 21 | + get defaultData() { |
| 22 | + return [{ ...defaultHubbardConfig, atomicSpecies: this.uniqueElements }]; |
| 23 | + } |
| 24 | + |
| 25 | + get uiSchemaStyled() { |
| 26 | + return { |
| 27 | + "ui:options": { |
| 28 | + addable: true, |
| 29 | + orderable: false, |
| 30 | + removable: true, |
| 31 | + }, |
| 32 | + title: { |
| 33 | + classNames: "col-xs-12", |
| 34 | + }, |
| 35 | + items: { |
| 36 | + atomicSpecies: this.defaultFieldStyles, |
| 37 | + atomicOrbital: this.defaultFieldStyles, |
| 38 | + hubbardUValue: this.defaultFieldStyles, |
| 39 | + }, |
| 40 | + }; |
| 41 | + } |
| 42 | + |
| 43 | + get jsonSchema() { |
| 44 | + return { |
| 45 | + $schema: "http://json-schema.org/draft-04/schema#", |
| 46 | + title: "", |
| 47 | + description: "Hubbard parameters for DFT+U calculation.", |
| 48 | + type: "array", |
| 49 | + items: { |
| 50 | + type: "object", |
| 51 | + properties: { |
| 52 | + atomicSpecies: { |
| 53 | + type: "string", |
| 54 | + title: "Atomic species", |
| 55 | + enum: this.uniqueElements, |
| 56 | + default: this.uniqueElements?.length > 0 ? this.uniqueElements[0] : "", |
| 57 | + }, |
| 58 | + atomicOrbital: { |
| 59 | + type: "string", |
| 60 | + title: "Atomic orbital", |
| 61 | + enum: [ |
| 62 | + "2p", |
| 63 | + "3s", |
| 64 | + "3p", |
| 65 | + "3d", |
| 66 | + "4s", |
| 67 | + "4p", |
| 68 | + "4d", |
| 69 | + "4f", |
| 70 | + "5s", |
| 71 | + "5p", |
| 72 | + "5d", |
| 73 | + "5f", |
| 74 | + "6s", |
| 75 | + "6p", |
| 76 | + "6d", |
| 77 | + "7s", |
| 78 | + "7p", |
| 79 | + "7d", |
| 80 | + ], |
| 81 | + default: defaultHubbardConfig.atomicOrbital, |
| 82 | + }, |
| 83 | + hubbardUValue: { |
| 84 | + type: "number", |
| 85 | + title: "Hubbard U value", |
| 86 | + default: defaultHubbardConfig.hubbardUValue, |
| 87 | + }, |
| 88 | + }, |
| 89 | + }, |
| 90 | + minItems: 1, |
| 91 | + }; |
| 92 | + } |
| 93 | +} |
0 commit comments