Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOF-7298: non-collinear magnetization context provider #79

Merged
merged 31 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d812c50
SOF-7298: non-collinear magnetization context provider
pranabdas Apr 20, 2024
ff8d368
SOF-7298: update deps
pranabdas Apr 20, 2024
7a7add7
SOF-7298: update json-schema to draft-7
pranabdas Apr 20, 2024
da531f4
SOF-7298: chore ==> remove unnecessary eslint disable comment
pranabdas Apr 20, 2024
66cd8fb
SOF-7298: fix constructor method is undefined
pranabdas Apr 20, 2024
1dccbba
SOF-7298: fix the constrained_magnetization enum values
pranabdas Apr 20, 2024
e34b779
SOF-7298: reorganization of data structure
pranabdas Apr 20, 2024
aa35da3
SOF-7298: fix uiSchemaStyled
pranabdas Apr 20, 2024
3d190f3
SOF-7298: set col width under constrainedMagnetization wider
pranabdas Apr 21, 2024
9261b83
SOF-7298: try fixing styles
pranabdas Apr 21, 2024
08c125b
SOF-7298: try fixing styles x2
pranabdas Apr 21, 2024
433a427
SOF-7298: try fixing styles x3
pranabdas Apr 21, 2024
1f292fc
SOF-7298: reorder constrained mag and charge density items
pranabdas Apr 21, 2024
2be0b47
SOF-7298: more reordering of items
pranabdas Apr 21, 2024
953b891
SOF-7298: more style adjustments
pranabdas Apr 21, 2024
ec396d2
SOF-7298: more experiment with styles
pranabdas Apr 21, 2024
4832d18
SOF-7298: more experiment with styles x2
pranabdas Apr 21, 2024
222fe60
SOF-7298: implement fixed magnetization and set constrained magnetiza…
pranabdas Apr 21, 2024
0f2a86a
SOF-7298: fix constrainedMagnetization data
pranabdas Apr 21, 2024
f028301
SOF-7298: fix arbitrary magnetization direction readonly status
pranabdas Apr 21, 2024
5d330a2
SOF-7298: fix fixed magnetization readonly status
pranabdas Apr 21, 2024
e2b9fc8
SOF-7298: evaluate compound statements outside of object return
pranabdas Apr 21, 2024
1752234
SOF-7298: fix readonly status for fixed magnetization
pranabdas Apr 21, 2024
b26b91b
SOF-7298: update mode
pranabdas Apr 21, 2024
dba1db3
SOF-7298: update deps
pranabdas Apr 21, 2024
27b6e3e
SOF-7298: include lforcet
pranabdas Apr 22, 2024
1680a7c
SOF-7298: reorder items
pranabdas Apr 22, 2024
c957fe1
SOF-7298: update deps
pranabdas Apr 23, 2024
18e5e00
SOF-7298: update deps after additional templates
pranabdas Apr 24, 2024
4699890
SOF-7298: update deps
pranabdas Apr 24, 2024
4db1ee6
SOF-7298: update deps with published version
pranabdas Apr 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
"underscore.string": "^3.3.4"
},
"devDependencies": {
"@exabyte-io/ade.js": "2024.4.19-0",
"@exabyte-io/application-flavors.js": "2024.4.19-0",
"@exabyte-io/ade.js": "git+https://github.com/Exabyte-io/ade.js.git#bb63043fc49fad751c67c5329dc6615f234bb6f3",
"@exabyte-io/application-flavors.js": "git+https://github.com/Exabyte-io/application-flavors.git#470a6e10c92a9df001053b6c6836edd55c856cee",
"@exabyte-io/eslint-config": "^2022.11.17-0",
"@exabyte-io/ide.js": "2024.3.26-0",
"@exabyte-io/mode.js": "2024.4.19-0",
"@exabyte-io/mode.js": "2024.4.23-0",
"@mat3ra/code": "2024.3.25-3",
"@mat3ra/esse": "2024.4.19-1",
"@mat3ra/made": "2024.3.26-0",
Expand Down
2 changes: 2 additions & 0 deletions src/context/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IonDynamicsContextProvider } from "./providers/IonDynamicsContextProvid
import { MLSettingsContextProvider } from "./providers/MLSettingsContextProvider";
import { MLTrainTestSplitContextProvider } from "./providers/MLTrainTestSplitContextProvider";
import { NEBFormDataProvider } from "./providers/NEBFormDataProvider";
import { NonCollinearMagnetizationContextProvider } from "./providers/NonCollinearMagnetizationContextProvider";
import { PlanewaveCutoffsContextProvider } from "./providers/PlanewaveCutoffsContextProvider";
import { PointsGridFormDataProvider } from "./providers/PointsGridFormDataProvider";
import {
Expand All @@ -32,4 +33,5 @@ export default {
HubbardContextProviderLegacy,
IonDynamicsContextProvider,
CollinearMagnetizationContextProvider,
NonCollinearMagnetizationContextProvider,
};
5 changes: 5 additions & 0 deletions src/context/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
HubbardContextProviderLegacy,
IonDynamicsContextProvider,
CollinearMagnetizationContextProvider,
NonCollinearMagnetizationContextProvider,
} = context;

const CONTEXT_DOMAINS = {
Expand Down Expand Up @@ -107,4 +108,8 @@ export const wodeProviders = {
providerCls: CollinearMagnetizationContextProvider,
config: _makeImportant({ name: "collinearMagnetization" }),
},
NonCollinearMagnetizationDataManager: {
providerCls: NonCollinearMagnetizationContextProvider,
config: _makeImportant({ name: "nonCollinearMagnetization" }),
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class BoundaryConditionsFormDataProvider extends mix(JSONSchemaFormDataPr

get jsonSchema() {
return {
$schema: "http://json-schema.org/draft-04/schema#",
$schema: "http://json-schema.org/draft-07/schema#",
type: "object",
properties: {
type: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class CollinearMagnetizationContextProvider extends mix(JSONSchemaFormDat
};
};

// eslint-disable-next-line class-methods-use-this
get uiSchemaStyled() {
return {
startingMagnetization: {
Expand Down
2 changes: 1 addition & 1 deletion src/context/providers/MLSettingsContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class MLSettingsContextProvider extends mix(ContextProvider).with(Applica

get jsonSchema() {
return {
$schema: "http://json-schema.org/draft-04/schema#",
$schema: "http://json-schema.org/draft-07/schema#",
title: " ",
description: "Settings important to machine learning runs.",
type: "object",
Expand Down
2 changes: 1 addition & 1 deletion src/context/providers/MLTrainTestSplitContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class MLTrainTestSplitContextProvider extends mix(ContextProvider).with(

get jsonSchema() {
return {
$schema: "http://json-schema.org/draft-04/schema#",
$schema: "http://json-schema.org/draft-07/schema#",
title: " ",
description:
"Fraction held as the test set. For example, a value of 0.2 corresponds to an 80/20 train/test split.",
Expand Down
2 changes: 1 addition & 1 deletion src/context/providers/NEBFormDataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class NEBFormDataProvider extends JSONSchemaFormDataProvider {

get jsonSchema() {
return {
$schema: "http://json-schema.org/draft-04/schema#",
$schema: "http://json-schema.org/draft-07/schema#",
title: " ",
description: "Number of intermediate NEB images.",
type: "object",
Expand Down
270 changes: 270 additions & 0 deletions src/context/providers/NonCollinearMagnetizationContextProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
import { JSONSchemaFormDataProvider, MaterialContextMixin } from "@mat3ra/code/dist/js/context";
import { Made } from "@mat3ra/made";
import lodash from "lodash";
import { mix } from "mixwith";

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

constructor(config) {
super(config);
this.isStartingMagnetization = lodash.get(this.data, "isStartingMagnetization", true);
this.isConstrainedMagnetization = lodash.get(
this.data,
"isConstrainedMagnetization",
false,
);
this.isExistingChargeDensity = lodash.get(this.data, "isExistingChargeDensity", false);
this.isArbitrarySpinDirection = lodash.get(this.data, "isArbitrarySpinDirection", false);
this.isFixedMagnetization = lodash.get(this.data, "isFixedMagnetization", false);
this.constrainedMagnetization = lodash.get(this.data, "constrainedMagnetization", {});
}

get uniqueElementsWithLabels() {
const elementsWithLabelsArray = this.material?.Basis?.elementsWithLabelsArray || [];
return [...new Set(elementsWithLabelsArray)];
}

get defaultData() {
const startingMagnetization = this.uniqueElementsWithLabels.map((element, index) => {
return {
index: index + 1,
atomicSpecies: element,
value: 0.0,
};
});

const spinAngles = this.uniqueElementsWithLabels.map((element, index) => {
return {
index: index + 1,
atomicSpecies: element,
angle1: 0.0,
angle2: 0.0,
};
});

return {
isExistingChargeDensity: false,
isStartingMagnetization: true,
isConstrainedMagnetization: false,
isArbitrarySpinAngle: false,
isFixedMagnetization: false,
lforcet: true,
spinAngles,
startingMagnetization,
constrainedMagnetization: {
lambda: 0.0,
constrainType: "atomic direction",
},
fixedMagnetization: {
x: 0.0,
y: 0.0,
z: 0.0,
},
};
}

get uiSchemaStyled() {
return {
isExistingChargeDensity: {},
lforcet: {
"ui:readonly": !this.isExistingChargeDensity,
"ui:widget": "radio",
"ui:options": {
inline: true,
},
},
isArbitrarySpinDirection: {},
spinAngles: {
items: {
atomicSpecies: {
...this.defaultFieldStyles,
"ui:readonly": true,
},
angle1: this.defaultFieldStyles,
angle2: this.defaultFieldStyles,
},
"ui:readonly": !this.isArbitrarySpinDirection,
"ui:options": {
addable: false,
orderable: false,
removable: false,
},
},
isStartingMagnetization: {},
startingMagnetization: {
items: {
atomicSpecies: {
...this.defaultFieldStyles,
"ui:readonly": true,
},
value: {
"ui:classNames": "col-xs-6",
},
},
"ui:readonly": !this.isStartingMagnetization,
"ui:options": {
addable: false,
orderable: false,
removable: false,
},
},
isConstrainedMagnetization: {},
constrainedMagnetization: {
constrainType: this.defaultFieldStyles,
lambda: this.defaultFieldStyles,
"ui:readonly": !this.isConstrainedMagnetization,
},
isFixedMagnetization: {
"ui:readonly": !(
this.isConstrainedMagnetization &&
this.constrainedMagnetization?.constrainType === "total"
),
},
fixedMagnetization: {
x: this.defaultFieldStyles,
y: this.defaultFieldStyles,
z: this.defaultFieldStyles,
"ui:readonly": !(
this.isFixedMagnetization &&
this.isConstrainedMagnetization &&
this.constrainedMagnetization?.constrainType === "total"
),
},
};
}

get jsonSchema() {
return {
$schema: "http://json-schema.org/draft-07/schema#",
title: "",
description:
"Set initial parameters for non-collinear spin magnetic (SOC) calculation.",
type: "object",
properties: {
isStartingMagnetization: {
type: "boolean",
title: "Set starting magnetization",
default: true,
},
startingMagnetization: {
type: "array",
minItems: this.uniqueElementsWithLabels.length,
maxItems: this.uniqueElementsWithLabels.length,
items: {
type: "object",
properties: {
atomicSpecies: {
type: "string",
title: "Atomic species",
},
value: {
type: "number",
title: "Starting magnetization",
default: 0.0,
minimum: -1.0,
maximum: 1.0,
},
},
},
},
isExistingChargeDensity: {
type: "boolean",
title: "Start calculation from existing charge density",
default: false,
},
lforcet: {
title: "Set lforcet to",
type: "boolean",
oneOf: [
{ const: true, title: "True" },
{ const: false, title: "False" },
],
},
isArbitrarySpinDirection: {
type: "boolean",
title: "Set spin directions",
default: false,
},
spinAngles: {
type: "array",
minItems: this.uniqueElementsWithLabels.length,
maxItems: this.uniqueElementsWithLabels.length,
items: {
type: "object",
properties: {
atomicSpecies: {
type: "string",
title: "Atomic species",
},
angle1: {
type: "number",
title: "Angle1 (deg)",
default: 0.0,
},
angle2: {
type: "number",
title: "Angle2 (deg)",
default: 0.0,
},
},
},
},
isConstrainedMagnetization: {
type: "boolean",
title: "Set constrained magnetization",
default: false,
},
constrainedMagnetization: {
type: "object",
properties: {
constrainType: {
type: "string",
title: "Constrain type",
enum: [
"none",
"total",
"atomic",
"total direction",
"atomic direction",
],
default: "atomic direction",
},
lambda: {
type: "number",
title: "lambda",
default: 0.0,
},
},
},
isFixedMagnetization: {
type: "boolean",
title: "Set Fixed magnetization (only applicable to constrained magnetization of 'total' type)",
default: true,
},
fixedMagnetization: {
type: "object",
properties: {
x: {
type: "number",
title: "X-component",
default: 0.0,
},
y: {
type: "number",
title: "Y-component",
default: 0.0,
},
z: {
type: "number",
title: "Z-component",
default: 0.0,
},
},
},
},
};
}
}
Loading
Loading