generated from Exabyte-io/template-definitions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from Exabyte-io/chore/SOF-6322
refactor: mode context providers from mode to wode
- Loading branch information
Showing
9 changed files
with
618 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { BoundaryConditionsFormDataProvider } from "./providers/BoundaryConditionsFormDataProvider"; | ||
import { MLSettingsContextProvider } from "./providers/MLSettingsContextProvider"; | ||
import { MLTrainTestSplitContextProvider } from "./providers/MLTrainTestSplitContextProvider"; | ||
import { NEBFormDataProvider } from "./providers/NEBFormDataProvider"; | ||
import { PlanewaveCutoffsContextProvider } from "./providers/PlanewaveCutoffsContextProvider"; | ||
import { PointsGridFormDataProvider } from "./providers/PointsGridFormDataProvider"; | ||
import { | ||
ExplicitPointsPath2PIBAFormDataProvider, | ||
ExplicitPointsPathFormDataProvider, | ||
PointsPathFormDataProvider, | ||
} from "./providers/PointsPathFormDataProvider"; | ||
|
||
export default { | ||
BoundaryConditionsFormDataProvider, | ||
MLSettingsContextProvider, | ||
MLTrainTestSplitContextProvider, | ||
NEBFormDataProvider, | ||
PlanewaveCutoffsContextProvider, | ||
PointsGridFormDataProvider, | ||
PointsPathFormDataProvider, | ||
ExplicitPointsPathFormDataProvider, | ||
ExplicitPointsPath2PIBAFormDataProvider, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/context/providers/BoundaryConditionsFormDataProvider.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { JSONSchemaFormDataProvider, MaterialContextMixin } from "@exabyte-io/code.js/dist/context"; | ||
import { deepClone } from "@exabyte-io/code.js/dist/utils"; | ||
import { Made } from "@exabyte-io/made.js"; | ||
import { mix } from "mixwith"; | ||
|
||
export class BoundaryConditionsFormDataProvider extends mix(JSONSchemaFormDataProvider).with( | ||
MaterialContextMixin, | ||
) { | ||
static Material = Made.Material; | ||
|
||
get boundaryConditions() { | ||
return this.material.metadata.boundaryConditions || {}; | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
get defaultData() { | ||
return { | ||
type: this.boundaryConditions.type || "pbc", | ||
offset: this.boundaryConditions.offset || 0, | ||
electricField: 0, | ||
targetFermiEnergy: 0, | ||
}; | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
get uiSchema() { | ||
return { | ||
type: { "ui:disabled": true }, | ||
offset: { "ui:disabled": true }, | ||
electricField: {}, | ||
targetFermiEnergy: {}, | ||
}; | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
get humanName() { | ||
return "Boundary Conditions"; | ||
} | ||
|
||
yieldDataForRendering() { | ||
const data = deepClone(this.yieldData()); | ||
data.boundaryConditions.offset *= Made.coefficients.ANGSTROM_TO_BOHR; | ||
data.boundaryConditions.targetFermiEnergy *= Made.coefficients.EV_TO_RY; | ||
data.boundaryConditions.electricField *= Made.coefficients.EV_A_TO_RY_BOHR; | ||
return data; | ||
} | ||
|
||
get jsonSchema() { | ||
return { | ||
$schema: "http://json-schema.org/draft-04/schema#", | ||
type: "object", | ||
properties: { | ||
type: { | ||
type: "string", | ||
title: "Type", | ||
default: this.defaultData.type, | ||
}, | ||
offset: { | ||
type: "number", | ||
title: "Offset (A)", | ||
default: this.defaultData.offset, | ||
}, | ||
electricField: { | ||
type: "number", | ||
title: "Electric Field (eV/A)", | ||
default: this.defaultData.electricField, | ||
}, | ||
targetFermiEnergy: { | ||
type: "number", | ||
title: "Target Fermi Energy (eV)", | ||
default: this.defaultData.targetFermiEnergy, | ||
}, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Application } from "@exabyte-io/ade.js"; | ||
import { ApplicationContextMixin, ContextProvider } from "@exabyte-io/code.js/dist/context"; | ||
import { mix } from "mixwith"; | ||
|
||
export class MLSettingsContextProvider extends mix(ContextProvider).with(ApplicationContextMixin) { | ||
static Application = Application; | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
get uiSchema() { | ||
return { | ||
target_column_name: {}, | ||
problem_category: {}, | ||
}; | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
get defaultData() { | ||
return { | ||
target_column_name: "target", | ||
problem_category: "regression", | ||
}; | ||
} | ||
|
||
get jsonSchema() { | ||
return { | ||
$schema: "http://json-schema.org/draft-04/schema#", | ||
title: " ", | ||
description: "Settings important to machine learning runs.", | ||
type: "object", | ||
properties: { | ||
target_column_name: { | ||
type: "string", | ||
default: this.defaultData.target_column_name, | ||
}, | ||
problem_category: { | ||
type: "string", | ||
default: this.defaultData.problem_category, | ||
enum: ["regression", "classification", "clustering"], | ||
}, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Application } from "@exabyte-io/ade.js"; | ||
import { ApplicationContextMixin, ContextProvider } from "@exabyte-io/code.js/dist/context"; | ||
import { mix } from "mixwith"; | ||
|
||
export class MLTrainTestSplitContextProvider extends mix(ContextProvider).with( | ||
ApplicationContextMixin, | ||
) { | ||
static Application = Application; | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
get uiSchema() { | ||
return { | ||
target_column_name: {}, | ||
problem_category: {}, | ||
}; | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
get defaultData() { | ||
return { | ||
fraction_held_as_test_set: 0.2, | ||
}; | ||
} | ||
|
||
get jsonSchema() { | ||
return { | ||
$schema: "http://json-schema.org/draft-04/schema#", | ||
title: " ", | ||
description: | ||
"Fraction held as the test set. For example, a value of 0.2 corresponds to an 80/20 train/test split.", | ||
type: "object", | ||
properties: { | ||
fraction_held_as_test_set: { | ||
type: "number", | ||
default: this.defaultData.fraction_held_as_test_set, | ||
minimum: 0, | ||
maximum: 1, | ||
}, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { JSONSchemaFormDataProvider } from "@exabyte-io/code.js/dist/context"; | ||
|
||
export class NEBFormDataProvider extends JSONSchemaFormDataProvider { | ||
// eslint-disable-next-line class-methods-use-this | ||
get defaultData() { | ||
return { | ||
nImages: 1, | ||
}; | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
get uiSchema() { | ||
return { | ||
nImages: {}, | ||
}; | ||
} | ||
|
||
get jsonSchema() { | ||
return { | ||
$schema: "http://json-schema.org/draft-04/schema#", | ||
title: " ", | ||
description: "Number of intermediate NEB images.", | ||
type: "object", | ||
properties: { | ||
nImages: { | ||
type: "number", | ||
default: this.defaultData.nImages, | ||
}, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Application } from "@exabyte-io/ade.js"; | ||
import { ApplicationContextMixin, ContextProvider } from "@exabyte-io/code.js/dist/context"; | ||
import { mix } from "mixwith"; | ||
|
||
const cutoffConfig = { | ||
vasp: {}, // assuming default cutoffs for VASP | ||
espresso: { | ||
// assuming the default GBRV set of pseudopotentials is used | ||
wavefunction: 40, | ||
density: 200, | ||
}, | ||
}; | ||
|
||
export class PlanewaveCutoffsContextProvider extends mix(ContextProvider).with( | ||
ApplicationContextMixin, | ||
) { | ||
static Application = Application; | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
get uiSchema() { | ||
return { | ||
wavefunction: {}, | ||
density: {}, | ||
}; | ||
} | ||
|
||
get defaultData() { | ||
return { | ||
wavefunction: this.defaultECUTWFC, | ||
density: this.defaultECUTRHO, | ||
}; | ||
} | ||
|
||
get _cutoffConfigPerApplication() { | ||
return cutoffConfig[this.application.name]; | ||
} | ||
|
||
get defaultECUTWFC() { | ||
return this._cutoffConfigPerApplication.wavefunction || null; | ||
} | ||
|
||
get defaultECUTRHO() { | ||
return this._cutoffConfigPerApplication.density || null; | ||
} | ||
|
||
get jsonSchema() { | ||
return { | ||
$schema: "http://json-schema.org/draft-04/schema#", | ||
title: " ", | ||
description: | ||
"Planewave cutoff parameters for electronic wavefunctions and density. Units are specific to simulation engine.", | ||
type: "object", | ||
properties: { | ||
wavefunction: { | ||
type: "number", | ||
default: this.defaultECUTWFC, | ||
}, | ||
density: { | ||
type: "number", | ||
default: this.defaultECUTRHO, | ||
}, | ||
}, | ||
}; | ||
} | ||
} |
Oops, something went wrong.