Skip to content

Commit

Permalink
Merge pull request #37 from Exabyte-io/feat/SOF-6631
Browse files Browse the repository at this point in the history
SOF-6631: implementation of Hubbard card context provider
  • Loading branch information
pranabdas committed Aug 26, 2023
2 parents 7918531 + 1ab1dae commit 838ab3b
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/context/context.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BoundaryConditionsFormDataProvider } from "./providers/BoundaryConditionsFormDataProvider";
import { HubbardContextProvider } from "./providers/HubbardContextProvider";
import { MLSettingsContextProvider } from "./providers/MLSettingsContextProvider";
import { MLTrainTestSplitContextProvider } from "./providers/MLTrainTestSplitContextProvider";
import { NEBFormDataProvider } from "./providers/NEBFormDataProvider";
Expand All @@ -20,4 +21,5 @@ export default {
PointsPathFormDataProvider,
ExplicitPointsPathFormDataProvider,
ExplicitPointsPath2PIBAFormDataProvider,
HubbardContextProvider,
};
5 changes: 5 additions & 0 deletions src/context/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
PointsPathFormDataProvider,
ExplicitPointsPathFormDataProvider,
ExplicitPointsPath2PIBAFormDataProvider,
HubbardContextProvider,
} = context;

const CONTEXT_DOMAINS = {
Expand Down Expand Up @@ -60,6 +61,10 @@ export const wodeProviders = {
providerCls: ExplicitPointsPath2PIBAFormDataProvider,
config: _makeImportant({ name: "explicitKPath2PIBA" }),
},
HubbardContextManager: {
providerCls: HubbardContextProvider,
config: _makeImportant({ name: "hubbard" }),
},
// NEBFormDataManager context is stored under the same key (`input`) as InputDataManager contexts.
NEBFormDataManager: {
providerCls: NEBFormDataProvider,
Expand Down
93 changes: 93 additions & 0 deletions src/context/providers/HubbardContextProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { JSONSchemaFormDataProvider, MaterialContextMixin } from "@exabyte-io/code.js/dist/context";
import { Made } from "@exabyte-io/made.js";
import { mix } from "mixwith";

const defaultHubbardConfig = {
atomicSpecies: "",
atomicOrbital: "2p",
hubbardUValue: 0.01,
};

export class HubbardContextProvider extends mix(JSONSchemaFormDataProvider).with(
MaterialContextMixin,
) {
static Material = Made.Material;

constructor(config) {
super(config);
this.uniqueElements = this.material?.Basis?.uniqueElements || [];
}

get defaultData() {
return [{ ...defaultHubbardConfig, atomicSpecies: this.uniqueElements }];
}

get uiSchemaStyled() {
return {
"ui:options": {
addable: true,
orderable: false,
removable: true,
},
title: {
classNames: "col-xs-12",
},
items: {
atomicSpecies: this.defaultFieldStyles,
atomicOrbital: this.defaultFieldStyles,
hubbardUValue: this.defaultFieldStyles,
},
};
}

get jsonSchema() {
return {
$schema: "http://json-schema.org/draft-04/schema#",
title: "",
description: "Hubbard parameters for DFT+U calculation.",
type: "array",
items: {
type: "object",
properties: {
atomicSpecies: {
type: "string",
title: "Atomic species",
enum: this.uniqueElements,
default: this.uniqueElements?.length > 0 ? this.uniqueElements[0] : "",
},
atomicOrbital: {
type: "string",
title: "Atomic orbital",
enum: [
"2p",
"3s",
"3p",
"3d",
"4s",
"4p",
"4d",
"4f",
"5s",
"5p",
"5d",
"5f",
"6s",
"6p",
"6d",
"7s",
"7p",
"7d",
],
default: defaultHubbardConfig.atomicOrbital,
},
hubbardUValue: {
type: "number",
title: "Hubbard U value",
default: defaultHubbardConfig.hubbardUValue,
},
},
},
minItems: 1,
};
}
}

0 comments on commit 838ab3b

Please sign in to comment.