From 654fb84ef0a2863fa3d06ff9a9ff6c5f2a464b09 Mon Sep 17 00:00:00 2001 From: VsevolodX Date: Fri, 16 Jan 2026 13:36:15 -0800 Subject: [PATCH 1/3] update: add wfn amplitude property --- dist/js/PropertyFactory.d.ts | 3 +- dist/js/PropertyFactory.js | 2 + ...efunctionAmplitudePropertySchemaMixin.d.ts | 5 + ...avefunctionAmplitudePropertySchemaMixin.js | 24 ++ dist/js/holders/mixins/PropertyHolderMixin.js | 1 - dist/js/index.d.ts | 1 + dist/js/index.js | 4 +- .../WavefunctionAmplitudeProperty.d.ts | 38 +++ .../WavefunctionAmplitudeProperty.js | 53 ++++ dist/js/settings.d.ts | 1 + dist/js/settings.js | 1 + package-lock.json | 277 ++++++++++++++++-- package.json | 2 +- src/js/PropertyFactory.ts | 3 + ...avefunctionAmplitudePropertySchemaMixin.ts | 37 +++ src/js/holders/mixins/PropertyHolderMixin.ts | 1 - src/js/index.ts | 1 + .../WavefunctionAmplitudeProperty.ts | 70 +++++ src/js/settings.ts | 1 + 19 files changed, 496 insertions(+), 29 deletions(-) create mode 100644 dist/js/generated/WavefunctionAmplitudePropertySchemaMixin.d.ts create mode 100644 dist/js/generated/WavefunctionAmplitudePropertySchemaMixin.js create mode 100644 dist/js/properties/non-scalar/WavefunctionAmplitudeProperty.d.ts create mode 100644 dist/js/properties/non-scalar/WavefunctionAmplitudeProperty.js create mode 100644 src/js/generated/WavefunctionAmplitudePropertySchemaMixin.ts create mode 100644 src/js/properties/non-scalar/WavefunctionAmplitudeProperty.ts diff --git a/dist/js/PropertyFactory.d.ts b/dist/js/PropertyFactory.d.ts index d0a0084..85845f7 100644 --- a/dist/js/PropertyFactory.d.ts +++ b/dist/js/PropertyFactory.d.ts @@ -19,6 +19,7 @@ import PhononDispersionsProperty from "./properties/non-scalar/PhononDispersions import PhononDOSProperty from "./properties/non-scalar/PhononDOSProperty"; import PotentialProfileProperty from "./properties/non-scalar/PotentialProfileProperty"; import ReactionEnergyProfileProperty from "./properties/non-scalar/ReactionEnergyProfileProperty"; +import WavefunctionAmplitudeProperty from "./properties/non-scalar/WavefunctionAmplitudeProperty"; import WorkflowProperty from "./properties/non-scalar/WorkflowProperty"; import TotalEnergyContributionsProperty from "./properties/object/TotalEnergyContributionsProperty"; import FermiEnergyProperty from "./properties/scalar/FermiEnergyProperty"; @@ -47,7 +48,7 @@ export default class PropertyFactory { static getScalarPropertyNames(): PropertyName[]; static getNonScalarPropertyNames(): PropertyName[]; private static filterPropertyNames; - static createProperty(config: AnyProperty): AveragePotentialProfileProperty | BandGapsProperty | BandStructureProperty | ChargeDensityProfileProperty | ConvergenceElectronicProperty | ConvergenceIonicProperty | DensityOfStatesProperty | DielectricTensorProperty | FileContentProperty | FinalStructureProperty | HubbardUProperty | HubbardVNNProperty | HubbardVProperty | IsRelaxedProperty | JupyterNotebookEndpointProperty | PhononDispersionsProperty | PhononDOSProperty | PotentialProfileProperty | ReactionEnergyProfileProperty | WorkflowProperty | TotalEnergyContributionsProperty | FermiEnergyProperty | IonizationPotentialElementalProperty | PressureProperty | ReactionEnergyBarrierProperty | SurfaceEnergyProperty | TotalEnergyProperty | TotalForcesProperty | ValenceBandOffsetProperty | ZeroPointEnergyProperty | AtomicForcesProperty | MagneticMomentsProperty | StressTensorProperty; + static createProperty(config: AnyProperty): AveragePotentialProfileProperty | BandGapsProperty | BandStructureProperty | ChargeDensityProfileProperty | ConvergenceElectronicProperty | ConvergenceIonicProperty | DensityOfStatesProperty | DielectricTensorProperty | FileContentProperty | FinalStructureProperty | HubbardUProperty | HubbardVNNProperty | HubbardVProperty | IsRelaxedProperty | JupyterNotebookEndpointProperty | PhononDispersionsProperty | PhononDOSProperty | PotentialProfileProperty | ReactionEnergyProfileProperty | WavefunctionAmplitudeProperty | WorkflowProperty | TotalEnergyContributionsProperty | FermiEnergyProperty | IonizationPotentialElementalProperty | PressureProperty | ReactionEnergyBarrierProperty | SurfaceEnergyProperty | TotalEnergyProperty | TotalForcesProperty | ValenceBandOffsetProperty | ZeroPointEnergyProperty | AtomicForcesProperty | MagneticMomentsProperty | StressTensorProperty; static createMetaProperty(config: AnyMetaProperty): MetaProperty; static createProtoProperty(config: AnyProtoProperty): AtomicConstraintsProperty | BoundaryConditionsProperty; } diff --git a/dist/js/PropertyFactory.js b/dist/js/PropertyFactory.js index b5af979..f10e9fa 100644 --- a/dist/js/PropertyFactory.js +++ b/dist/js/PropertyFactory.js @@ -23,6 +23,7 @@ const PhononDispersionsProperty_1 = __importDefault(require("./properties/non-sc const PhononDOSProperty_1 = __importDefault(require("./properties/non-scalar/PhononDOSProperty")); const PotentialProfileProperty_1 = __importDefault(require("./properties/non-scalar/PotentialProfileProperty")); const ReactionEnergyProfileProperty_1 = __importDefault(require("./properties/non-scalar/ReactionEnergyProfileProperty")); +const WavefunctionAmplitudeProperty_1 = __importDefault(require("./properties/non-scalar/WavefunctionAmplitudeProperty")); const WorkflowProperty_1 = __importDefault(require("./properties/non-scalar/WorkflowProperty")); const TotalEnergyContributionsProperty_1 = __importDefault(require("./properties/object/TotalEnergyContributionsProperty")); const FermiEnergyProperty_1 = __importDefault(require("./properties/scalar/FermiEnergyProperty")); @@ -64,6 +65,7 @@ const PROPERTY_CLASS_MAP = { [ReactionEnergyBarrierProperty_1.default.propertyName]: ReactionEnergyBarrierProperty_1.default, [ReactionEnergyProfileProperty_1.default.propertyName]: ReactionEnergyProfileProperty_1.default, [PotentialProfileProperty_1.default.propertyName]: PotentialProfileProperty_1.default, + [WavefunctionAmplitudeProperty_1.default.propertyName]: WavefunctionAmplitudeProperty_1.default, [ChargeDensityProfileProperty_1.default.propertyName]: ChargeDensityProfileProperty_1.default, [AveragePotentialProfileProperty_1.default.propertyName]: AveragePotentialProfileProperty_1.default, [ValenceBandOffsetProperty_1.default.propertyName]: ValenceBandOffsetProperty_1.default, diff --git a/dist/js/generated/WavefunctionAmplitudePropertySchemaMixin.d.ts b/dist/js/generated/WavefunctionAmplitudePropertySchemaMixin.d.ts new file mode 100644 index 0000000..661862c --- /dev/null +++ b/dist/js/generated/WavefunctionAmplitudePropertySchemaMixin.d.ts @@ -0,0 +1,5 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { WavefunctionAmplitudePropertySchema } from "@mat3ra/esse/dist/js/types"; +export type WavefunctionAmplitudePropertySchemaMixin = Omit; +export type WavefunctionAmplitudePropertyInMemoryEntity = InMemoryEntity & WavefunctionAmplitudePropertySchemaMixin; +export declare function wavefunctionAmplitudePropertySchemaMixin(item: InMemoryEntity): void; diff --git a/dist/js/generated/WavefunctionAmplitudePropertySchemaMixin.js b/dist/js/generated/WavefunctionAmplitudePropertySchemaMixin.js new file mode 100644 index 0000000..67d16cb --- /dev/null +++ b/dist/js/generated/WavefunctionAmplitudePropertySchemaMixin.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.wavefunctionAmplitudePropertySchemaMixin = wavefunctionAmplitudePropertySchemaMixin; +function wavefunctionAmplitudePropertySchemaMixin(item) { + // @ts-expect-error + const properties = { + get xAxis() { + return this.requiredProp("xAxis"); + }, + get yAxis() { + return this.requiredProp("yAxis"); + }, + get name() { + return this.requiredProp("name"); + }, + get xDataArray() { + return this.requiredProp("xDataArray"); + }, + get yDataSeries() { + return this.requiredProp("yDataSeries"); + }, + }; + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/dist/js/holders/mixins/PropertyHolderMixin.js b/dist/js/holders/mixins/PropertyHolderMixin.js index baaea41..fd55fc5 100644 --- a/dist/js/holders/mixins/PropertyHolderMixin.js +++ b/dist/js/holders/mixins/PropertyHolderMixin.js @@ -8,7 +8,6 @@ const utils_1 = require("@mat3ra/code/dist/js/utils"); const PropertyHolderSchemaMixin_1 = require("../../generated/PropertyHolderSchemaMixin"); const PropertyFactory_1 = __importDefault(require("../../PropertyFactory")); function propertyHolderMixin(item) { - // @ts-expect-error - this is a workaround to allow the propertyMixin to be used with any type of entity const properties = { get sourceInfo() { return this.requiredProp("source.info"); diff --git a/dist/js/index.d.ts b/dist/js/index.d.ts index 2751bd9..18d5246 100644 --- a/dist/js/index.d.ts +++ b/dist/js/index.d.ts @@ -13,6 +13,7 @@ export { default as TotalEnergyProperty } from "./properties/scalar/TotalEnergyP export { default as BandStructureProperty } from "./properties/non-scalar/BandStructureProperty"; export { default as ChargeDensityProfileProperty } from "./properties/non-scalar/ChargeDensityProfileProperty"; export { default as PotentialProfileProperty } from "./properties/non-scalar/PotentialProfileProperty"; +export { default as WavefunctionAmplitudeProperty } from "./properties/non-scalar/WavefunctionAmplitudeProperty"; export { default as ReactionEnergyProfileProperty } from "./properties/non-scalar/ReactionEnergyProfileProperty"; export { protoPropertyHolderMixin } from "./holders/mixins/ProtoPropertyHolderMixin"; export { propertyHolderMixin } from "./holders/mixins/PropertyHolderMixin"; diff --git a/dist/js/index.js b/dist/js/index.js index 5e675a0..1dfb431 100644 --- a/dist/js/index.js +++ b/dist/js/index.js @@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.metaPropertyHolderMixin = exports.propertyHolderMixin = exports.protoPropertyHolderMixin = exports.ReactionEnergyProfileProperty = exports.PotentialProfileProperty = exports.ChargeDensityProfileProperty = exports.BandStructureProperty = exports.TotalEnergyProperty = exports.SurfaceEnergyProperty = exports.ReactionEnergyBarrierProperty = exports.PressureProperty = exports.IsRelaxedProperty = exports.BandGapsProperty = exports.FinalStructureProperty = exports.PseudopotentialMetaProperty = exports.MetaProperty = exports.Property = exports.PropertyType = exports.PropertyName = exports.PropertyFactory = void 0; +exports.metaPropertyHolderMixin = exports.propertyHolderMixin = exports.protoPropertyHolderMixin = exports.ReactionEnergyProfileProperty = exports.WavefunctionAmplitudeProperty = exports.PotentialProfileProperty = exports.ChargeDensityProfileProperty = exports.BandStructureProperty = exports.TotalEnergyProperty = exports.SurfaceEnergyProperty = exports.ReactionEnergyBarrierProperty = exports.PressureProperty = exports.IsRelaxedProperty = exports.BandGapsProperty = exports.FinalStructureProperty = exports.PseudopotentialMetaProperty = exports.MetaProperty = exports.Property = exports.PropertyType = exports.PropertyName = exports.PropertyFactory = void 0; var PropertyFactory_1 = require("./PropertyFactory"); Object.defineProperty(exports, "PropertyFactory", { enumerable: true, get: function () { return __importDefault(PropertyFactory_1).default; } }); var settings_1 = require("./settings"); @@ -49,6 +49,8 @@ var ChargeDensityProfileProperty_1 = require("./properties/non-scalar/ChargeDens Object.defineProperty(exports, "ChargeDensityProfileProperty", { enumerable: true, get: function () { return __importDefault(ChargeDensityProfileProperty_1).default; } }); var PotentialProfileProperty_1 = require("./properties/non-scalar/PotentialProfileProperty"); Object.defineProperty(exports, "PotentialProfileProperty", { enumerable: true, get: function () { return __importDefault(PotentialProfileProperty_1).default; } }); +var WavefunctionAmplitudeProperty_1 = require("./properties/non-scalar/WavefunctionAmplitudeProperty"); +Object.defineProperty(exports, "WavefunctionAmplitudeProperty", { enumerable: true, get: function () { return __importDefault(WavefunctionAmplitudeProperty_1).default; } }); var ReactionEnergyProfileProperty_1 = require("./properties/non-scalar/ReactionEnergyProfileProperty"); Object.defineProperty(exports, "ReactionEnergyProfileProperty", { enumerable: true, get: function () { return __importDefault(ReactionEnergyProfileProperty_1).default; } }); var ProtoPropertyHolderMixin_1 = require("./holders/mixins/ProtoPropertyHolderMixin"); diff --git a/dist/js/properties/non-scalar/WavefunctionAmplitudeProperty.d.ts b/dist/js/properties/non-scalar/WavefunctionAmplitudeProperty.d.ts new file mode 100644 index 0000000..e1e8736 --- /dev/null +++ b/dist/js/properties/non-scalar/WavefunctionAmplitudeProperty.d.ts @@ -0,0 +1,38 @@ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { WavefunctionAmplitudePropertySchema } from "@mat3ra/esse/dist/js/types"; +import type { Options } from "highcharts"; +import { WavefunctionAmplitudePropertySchemaMixin } from "../../generated/WavefunctionAmplitudePropertySchemaMixin"; +import Property from "../../Property"; +import { PropertyName, PropertyType } from "../../settings"; +import { TwoDimensionalHighChartConfigMixin } from "../include/mixins/2d_plot"; +type Schema = WavefunctionAmplitudePropertySchema; +export declare class WavefunctionAmplitudeConfig extends TwoDimensionalHighChartConfigMixin { + readonly tooltipXAxisName: string; + readonly tooltipYAxisName: string; + get series(): { + animation: boolean; + name: string; + data: [number, number][]; + }[]; + get overrideConfig(): { + legend: { + layout: string; + align: string; + verticalAlign: string; + borderWidth: number; + }; + }; +} +type Base = typeof Property & Constructor; +declare const WavefunctionAmplitudeProperty_base: Base; +declare class WavefunctionAmplitudeProperty extends WavefunctionAmplitudeProperty_base implements Schema { + readonly subtitle: string; + readonly yAxisTitle: string; + readonly xAxisTitle: string; + readonly chartConfig: Options; + static readonly isRefined = true; + static readonly propertyName = PropertyName.wavefunction_amplitude; + static readonly propertyType = PropertyType.non_scalar; + constructor(config: Omit); +} +export default WavefunctionAmplitudeProperty; diff --git a/dist/js/properties/non-scalar/WavefunctionAmplitudeProperty.js b/dist/js/properties/non-scalar/WavefunctionAmplitudeProperty.js new file mode 100644 index 0000000..c201c3a --- /dev/null +++ b/dist/js/properties/non-scalar/WavefunctionAmplitudeProperty.js @@ -0,0 +1,53 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.WavefunctionAmplitudeConfig = void 0; +const zip_1 = __importDefault(require("lodash/zip")); +const WavefunctionAmplitudePropertySchemaMixin_1 = require("../../generated/WavefunctionAmplitudePropertySchemaMixin"); +const Property_1 = __importDefault(require("../../Property")); +const settings_1 = require("../../settings"); +const _2d_plot_1 = require("../include/mixins/2d_plot"); +class WavefunctionAmplitudeConfig extends _2d_plot_1.TwoDimensionalHighChartConfigMixin { + constructor() { + super(...arguments); + this.tooltipXAxisName = "z coordinate"; + this.tooltipYAxisName = "amplitude"; + } + get series() { + return this.yDataSeries.map((item, index) => { + return { + animation: false, + name: `wavefunction ${index + 1}`, + data: (0, zip_1.default)(this.xDataArray, item), + }; + }); + } + get overrideConfig() { + return { + ...super.overrideConfig, + legend: { + layout: "horizontal", + align: "center", + verticalAlign: "bottom", + borderWidth: 0, + }, + }; + } +} +exports.WavefunctionAmplitudeConfig = WavefunctionAmplitudeConfig; +class WavefunctionAmplitudeProperty extends Property_1.default { + constructor(config) { + super({ ...config, name: WavefunctionAmplitudeProperty.propertyName }); + this.subtitle = "Wavefunction Amplitude"; + this.yAxisTitle = "Amplitude"; + this.xAxisTitle = "Z Coordinate"; + this.chartConfig = new WavefunctionAmplitudeConfig(this).config; + } +} +WavefunctionAmplitudeProperty.isRefined = true; +WavefunctionAmplitudeProperty.propertyName = settings_1.PropertyName.wavefunction_amplitude; +WavefunctionAmplitudeProperty.propertyType = settings_1.PropertyType.non_scalar; +(0, WavefunctionAmplitudePropertySchemaMixin_1.wavefunctionAmplitudePropertySchemaMixin)(WavefunctionAmplitudeProperty.prototype); +exports.default = WavefunctionAmplitudeProperty; diff --git a/dist/js/settings.d.ts b/dist/js/settings.d.ts index 61c2751..5865d7e 100644 --- a/dist/js/settings.d.ts +++ b/dist/js/settings.d.ts @@ -34,6 +34,7 @@ export declare enum PropertyName { reaction_energy_barrier = "reaction_energy_barrier", reaction_energy_profile = "reaction_energy_profile", potential_profile = "potential_profile", + wavefunction_amplitude = "wavefunction_amplitude", charge_density_profile = "charge_density_profile", jupyter_notebook_endpoint = "jupyter_notebook_endpoint", average_potential_profile = "average_potential_profile", diff --git a/dist/js/settings.js b/dist/js/settings.js index 07fbeb4..5ad376a 100644 --- a/dist/js/settings.js +++ b/dist/js/settings.js @@ -42,6 +42,7 @@ var PropertyName; PropertyName["reaction_energy_barrier"] = "reaction_energy_barrier"; PropertyName["reaction_energy_profile"] = "reaction_energy_profile"; PropertyName["potential_profile"] = "potential_profile"; + PropertyName["wavefunction_amplitude"] = "wavefunction_amplitude"; PropertyName["charge_density_profile"] = "charge_density_profile"; PropertyName["jupyter_notebook_endpoint"] = "jupyter_notebook_endpoint"; PropertyName["average_potential_profile"] = "average_potential_profile"; diff --git a/package-lock.json b/package-lock.json index a5ee00a..b27d27e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/code": "2025.10.8-0", - "@mat3ra/esse": "2025.10.8-0", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse.git#6779868778167e8301d82b596c7b05d8f013dd33", "@mat3ra/made": "2025.10.7-0", "@mat3ra/tsconfig": "2024.6.3-0", "@types/lodash": "^4.17.20", @@ -2337,13 +2337,11 @@ } }, "node_modules/@babel/runtime": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.9.tgz", - "integrity": "sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz", + "integrity": "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==", "dev": true, - "dependencies": { - "regenerator-runtime": "^0.13.4" - }, + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -2883,13 +2881,6 @@ "node": ">=10" } }, - "node_modules/@mat3ra/code/node_modules/tiny-emitter": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", - "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", - "dev": true, - "license": "MIT" - }, "node_modules/@mat3ra/code/node_modules/typed-function": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/typed-function/-/typed-function-1.1.0.tgz", @@ -2900,9 +2891,9 @@ } }, "node_modules/@mat3ra/esse": { - "version": "2025.10.8-0", - "resolved": "https://registry.npmjs.org/@mat3ra/esse/-/esse-2025.10.8-0.tgz", - "integrity": "sha512-JwHWF0nXdcv9pceYePNpAixnjIkQLPtlB2fm4MatRXiH9CqrPrHBRH+t/0v5O1Em2uM5jsnqA+EYB0toOMHOVw==", + "version": "0.0.0", + "resolved": "git+ssh://git@github.com/Exabyte-io/esse.git#6779868778167e8301d82b596c7b05d8f013dd33", + "integrity": "sha512-8Tc4fUiMPXYaA8ORXdgH+LUf625LDTvNdp7Ja0BBQFrxubIdYWcafyKdHfqhfiXw2c6BnKSsylsAc5PaI53OPQ==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -2915,6 +2906,7 @@ "@babel/preset-typescript": "^7.27.0", "@babel/register": "^7.25.9", "@babel/runtime-corejs3": "^7.27.0", + "@mat3ra/utils": "^2025.11.20-0", "@types/chai": "^4.3.20", "@types/js-yaml": "^4.0.9", "@types/json-schema-merge-allof": "^0.6.5", @@ -3395,6 +3387,167 @@ "node": ">=14.0.0" } }, + "node_modules/@mat3ra/utils": { + "version": "2025.11.20-0", + "resolved": "https://registry.npmjs.org/@mat3ra/utils/-/utils-2025.11.20-0.tgz", + "integrity": "sha512-igkswFIPrvIsOKiGdLE6ifgKGa3nruepjq2pPs9us+gHRn4tCaFNsBJqHw3ysw1dLgCtoYhHyYbMdpQu46+FCw==", + "dev": true, + "license": "ISC", + "dependencies": { + "@babel/cli": "7.16.0", + "@babel/core": "7.24.1", + "@babel/eslint-parser": "7.16.3", + "@babel/plugin-proposal-class-properties": "7.16.0", + "@babel/preset-env": "7.16.4", + "@babel/preset-react": "7.16.7", + "@babel/preset-typescript": "^7.22.5", + "@babel/register": "^7.16.0", + "@babel/runtime-corejs3": "7.16.8", + "crypto-js": "^4.1.1", + "js-yaml": "^4.1.0", + "lodash": "^4.17.21", + "mathjs": "12.4.1", + "semver": "^7.5.3", + "ts-node": "^10.9.1", + "typescript": "^4.5.5", + "underscore": "^1.13.3", + "underscore.string": "^3.3.4", + "uuid": "8.3.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@mat3ra/utils/node_modules/@babel/core": { + "version": "7.24.1", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.1.tgz", + "integrity": "sha512-F82udohVyIgGAY2VVj/g34TpFUG606rumIHjTfVbssPg2zTR7PuuEpZcX8JA6sgBfIYmJrFtWgPvHQuJamVqZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.24.1", + "@babel/generator": "^7.24.1", + "@babel/helper-compilation-targets": "^7.23.6", + "@babel/helper-module-transforms": "^7.23.3", + "@babel/helpers": "^7.24.1", + "@babel/parser": "^7.24.1", + "@babel/template": "^7.24.0", + "@babel/traverse": "^7.24.1", + "@babel/types": "^7.24.0", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@mat3ra/utils/node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@mat3ra/utils/node_modules/@babel/preset-react": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/preset-react/-/preset-react-7.16.7.tgz", + "integrity": "sha512-fWpyI8UM/HE6DfPBzD8LnhQ/OcH8AgTaqcqP2nGOXEUV+VKBR5JRN9hCk9ai+zQQ57vtm9oWeXguBCPNUjytgA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-validator-option": "^7.16.7", + "@babel/plugin-transform-react-display-name": "^7.16.7", + "@babel/plugin-transform-react-jsx": "^7.16.7", + "@babel/plugin-transform-react-jsx-development": "^7.16.7", + "@babel/plugin-transform-react-pure-annotations": "^7.16.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@mat3ra/utils/node_modules/@babel/runtime-corejs3": { + "version": "7.16.8", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.16.8.tgz", + "integrity": "sha512-3fKhuICS1lMz0plI5ktOE/yEtBRMVxplzRkdn6mJQ197XiY0JnrzYV0+Mxozq3JZ8SBV9Ecurmw1XsGbwOf+Sg==", + "dev": true, + "license": "MIT", + "dependencies": { + "core-js-pure": "^3.20.2", + "regenerator-runtime": "^0.13.4" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@mat3ra/utils/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/@mat3ra/utils/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@mat3ra/utils/node_modules/js-yaml": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/@mat3ra/utils/node_modules/semver": { + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@mat3ra/utils/node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/@nicolo-ribaudo/chokidar-2": { "version": "2.1.8-no-fsevents.3", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8-no-fsevents.3.tgz", @@ -3564,13 +3717,6 @@ "decimal.js": "^10.0.0" } }, - "node_modules/@types/mathjs/node_modules/decimal.js": { - "version": "10.6.0", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", - "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/mocha": { "version": "10.0.10", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.10.tgz", @@ -4739,6 +4885,20 @@ "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", "dev": true }, + "node_modules/complex.js": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/complex.js/-/complex.js-2.4.3.tgz", + "integrity": "sha512-UrQVSUur14tNX6tiP4y8T4w4FeJAX3bi2cIv0pu/DTLFNxoq7z2Yh83Vfzztj6Px3X/lubqQ9IrPp7Bpn6p4MQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/rawify" + } + }, "node_modules/compute-gcd": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/compute-gcd/-/compute-gcd-1.2.1.tgz", @@ -4887,6 +5047,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "dev": true, + "license": "MIT" + }, "node_modules/deep-eql": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", @@ -6195,6 +6362,20 @@ "node": ">=8.0.0" } }, + "node_modules/fraction.js": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.4.tgz", + "integrity": "sha512-pwiTgt0Q7t+GHZA4yaLjObx4vXmmdcS0iSJ19o8d/goUGgItX9UZWKWNnLHehxviD8wU2IWRsnR8cD5+yOJP2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + }, + "funding": { + "type": "patreon", + "url": "https://github.com/sponsors/rawify" + } + }, "node_modules/fromentries": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz", @@ -7901,6 +8082,30 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", "dev": true }, + "node_modules/mathjs": { + "version": "12.4.1", + "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-12.4.1.tgz", + "integrity": "sha512-welnW3khgwYjPYvECFHO+xkCxAx9IKIIPDDWPi8B5rKAvmgoEHnQX9slEmHKZTNaJiE+OS4qrJJcB4sfDn/4sw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.24.0", + "complex.js": "^2.1.1", + "decimal.js": "^10.4.3", + "escape-latex": "^1.2.0", + "fraction.js": "4.3.4", + "javascript-natural-sort": "^0.7.1", + "seedrandom": "^3.0.5", + "tiny-emitter": "^2.1.0", + "typed-function": "^4.1.1" + }, + "bin": { + "mathjs": "bin/cli.js" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/md5": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz", @@ -9369,6 +9574,13 @@ "integrity": "sha512-34EQV6AAHQGhoc0tn/96a9Fsi6v2xdqe/dMUwljGRaFOzR3EgRmECvD0O8vi8X+/uQ50LGHfkNu/Eue5TPKZkQ==", "dev": true }, + "node_modules/seedrandom": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz", + "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==", + "dev": true, + "license": "MIT" + }, "node_modules/semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -9819,6 +10031,13 @@ "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, + "node_modules/tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", + "dev": true, + "license": "MIT" + }, "node_modules/tinyglobby": { "version": "0.2.14", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz", @@ -10042,6 +10261,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typed-function": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/typed-function/-/typed-function-4.2.2.tgz", + "integrity": "sha512-VwaXim9Gp1bngi/q3do8hgttYn2uC3MoT/gfuMWylnj1IeZBUAyPddHZlo1K05BDoj8DYPpMdiHqH1dDYdJf2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 18" + } + }, "node_modules/typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", diff --git a/package.json b/package.json index c339bf7..18403fd 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@babel/eslint-parser": "^7.16.3", "@exabyte-io/eslint-config": "2025.5.13-0", "@mat3ra/code": "2025.10.8-0", - "@mat3ra/esse": "2025.10.8-0", + "@mat3ra/esse": "git+https://github.com/Exabyte-io/esse.git#6779868778167e8301d82b596c7b05d8f013dd33", "@mat3ra/made": "2025.10.7-0", "@mat3ra/tsconfig": "2024.6.3-0", "@typescript-eslint/eslint-plugin": "^5.9.1", diff --git a/src/js/PropertyFactory.ts b/src/js/PropertyFactory.ts index e483b77..7ef7354 100644 --- a/src/js/PropertyFactory.ts +++ b/src/js/PropertyFactory.ts @@ -26,6 +26,7 @@ import PhononDispersionsProperty from "./properties/non-scalar/PhononDispersions import PhononDOSProperty from "./properties/non-scalar/PhononDOSProperty"; import PotentialProfileProperty from "./properties/non-scalar/PotentialProfileProperty"; import ReactionEnergyProfileProperty from "./properties/non-scalar/ReactionEnergyProfileProperty"; +import WavefunctionAmplitudeProperty from "./properties/non-scalar/WavefunctionAmplitudeProperty"; import WorkflowProperty from "./properties/non-scalar/WorkflowProperty"; import TotalEnergyContributionsProperty from "./properties/object/TotalEnergyContributionsProperty"; import FermiEnergyProperty from "./properties/scalar/FermiEnergyProperty"; @@ -74,6 +75,7 @@ type PropertyClassMap = { | Constructor | Constructor | Constructor + | Constructor | Constructor | Constructor | Constructor @@ -120,6 +122,7 @@ const PROPERTY_CLASS_MAP: PropertyClassMap = { [ReactionEnergyBarrierProperty.propertyName]: ReactionEnergyBarrierProperty, [ReactionEnergyProfileProperty.propertyName]: ReactionEnergyProfileProperty, [PotentialProfileProperty.propertyName]: PotentialProfileProperty, + [WavefunctionAmplitudeProperty.propertyName]: WavefunctionAmplitudeProperty, [ChargeDensityProfileProperty.propertyName]: ChargeDensityProfileProperty, [AveragePotentialProfileProperty.propertyName]: AveragePotentialProfileProperty, [ValenceBandOffsetProperty.propertyName]: ValenceBandOffsetProperty, diff --git a/src/js/generated/WavefunctionAmplitudePropertySchemaMixin.ts b/src/js/generated/WavefunctionAmplitudePropertySchemaMixin.ts new file mode 100644 index 0000000..9002587 --- /dev/null +++ b/src/js/generated/WavefunctionAmplitudePropertySchemaMixin.ts @@ -0,0 +1,37 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import type { WavefunctionAmplitudePropertySchema } from "@mat3ra/esse/dist/js/types"; + +export type WavefunctionAmplitudePropertySchemaMixin = Omit< + WavefunctionAmplitudePropertySchema, + "_id" | "slug" | "systemName" | "schemaVersion" +>; + +export type WavefunctionAmplitudePropertyInMemoryEntity = InMemoryEntity & + WavefunctionAmplitudePropertySchemaMixin; + +export function wavefunctionAmplitudePropertySchemaMixin(item: InMemoryEntity) { + // @ts-expect-error + const properties: InMemoryEntity & WavefunctionAmplitudePropertySchemaMixin = { + get xAxis() { + return this.requiredProp("xAxis"); + }, + get yAxis() { + return this.requiredProp("yAxis"); + }, + get name() { + return this.requiredProp("name"); + }, + get xDataArray() { + return this.requiredProp( + "xDataArray", + ); + }, + get yDataSeries() { + return this.requiredProp( + "yDataSeries", + ); + }, + }; + + Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties)); +} diff --git a/src/js/holders/mixins/PropertyHolderMixin.ts b/src/js/holders/mixins/PropertyHolderMixin.ts index 749b8c4..9d2d2a3 100644 --- a/src/js/holders/mixins/PropertyHolderMixin.ts +++ b/src/js/holders/mixins/PropertyHolderMixin.ts @@ -22,7 +22,6 @@ export type PropertyHolderMixin = PropertyHolderSchemaMixin & { export type PropertyInMemoryEntity = InMemoryEntity & PropertyHolderMixin; export function propertyHolderMixin(item: InMemoryEntity) { - // @ts-expect-error - this is a workaround to allow the propertyMixin to be used with any type of entity const properties: InMemoryEntity & PropertyHolderMixin = { get sourceInfo() { return this.requiredProp("source.info"); diff --git a/src/js/index.ts b/src/js/index.ts index a36a295..69cfabf 100644 --- a/src/js/index.ts +++ b/src/js/index.ts @@ -13,6 +13,7 @@ export { default as TotalEnergyProperty } from "./properties/scalar/TotalEnergyP export { default as BandStructureProperty } from "./properties/non-scalar/BandStructureProperty"; export { default as ChargeDensityProfileProperty } from "./properties/non-scalar/ChargeDensityProfileProperty"; export { default as PotentialProfileProperty } from "./properties/non-scalar/PotentialProfileProperty"; +export { default as WavefunctionAmplitudeProperty } from "./properties/non-scalar/WavefunctionAmplitudeProperty"; export { default as ReactionEnergyProfileProperty } from "./properties/non-scalar/ReactionEnergyProfileProperty"; export { protoPropertyHolderMixin } from "./holders/mixins/ProtoPropertyHolderMixin"; export { propertyHolderMixin } from "./holders/mixins/PropertyHolderMixin"; diff --git a/src/js/properties/non-scalar/WavefunctionAmplitudeProperty.ts b/src/js/properties/non-scalar/WavefunctionAmplitudeProperty.ts new file mode 100644 index 0000000..69b05b2 --- /dev/null +++ b/src/js/properties/non-scalar/WavefunctionAmplitudeProperty.ts @@ -0,0 +1,70 @@ +/* eslint-disable class-methods-use-this */ +/* eslint-disable max-classes-per-file */ +import type { Constructor } from "@mat3ra/code/dist/js/utils/types"; +import type { WavefunctionAmplitudePropertySchema } from "@mat3ra/esse/dist/js/types"; +import type { Options } from "highcharts"; +import zip from "lodash/zip"; + +import { + WavefunctionAmplitudePropertySchemaMixin, + wavefunctionAmplitudePropertySchemaMixin, +} from "../../generated/WavefunctionAmplitudePropertySchemaMixin"; +import Property from "../../Property"; +import { PropertyName, PropertyType } from "../../settings"; +import { TwoDimensionalHighChartConfigMixin } from "../include/mixins/2d_plot"; + +type Schema = WavefunctionAmplitudePropertySchema; + +export class WavefunctionAmplitudeConfig extends TwoDimensionalHighChartConfigMixin { + readonly tooltipXAxisName: string = "z coordinate"; + + readonly tooltipYAxisName: string = "amplitude"; + + get series() { + return this.yDataSeries.map((item, index) => { + return { + animation: false, + name: `wavefunction ${index + 1}`, + data: zip(this.xDataArray, item) as [number, number][], + }; + }); + } + + get overrideConfig() { + return { + ...super.overrideConfig, + legend: { + layout: "horizontal", + align: "center", + verticalAlign: "bottom", + borderWidth: 0, + }, + }; + } +} + +type Base = typeof Property & Constructor; + +class WavefunctionAmplitudeProperty extends (Property as Base) implements Schema { + readonly subtitle: string = "Wavefunction Amplitude"; + + readonly yAxisTitle: string = "Amplitude"; + + readonly xAxisTitle: string = "Z Coordinate"; + + readonly chartConfig: Options = new WavefunctionAmplitudeConfig(this).config; + + static readonly isRefined = true; + + static readonly propertyName = PropertyName.wavefunction_amplitude; + + static readonly propertyType = PropertyType.non_scalar; + + constructor(config: Omit) { + super({ ...config, name: WavefunctionAmplitudeProperty.propertyName }); + } +} + +wavefunctionAmplitudePropertySchemaMixin(WavefunctionAmplitudeProperty.prototype); + +export default WavefunctionAmplitudeProperty; diff --git a/src/js/settings.ts b/src/js/settings.ts index 08133fb..1cb6451 100644 --- a/src/js/settings.ts +++ b/src/js/settings.ts @@ -38,6 +38,7 @@ export enum PropertyName { reaction_energy_barrier = "reaction_energy_barrier", reaction_energy_profile = "reaction_energy_profile", potential_profile = "potential_profile", + wavefunction_amplitude = "wavefunction_amplitude", charge_density_profile = "charge_density_profile", jupyter_notebook_endpoint = "jupyter_notebook_endpoint", average_potential_profile = "average_potential_profile", From 5eadfce740523c42075509bcfb47a3bec5534e12 Mon Sep 17 00:00:00 2001 From: VsevolodX Date: Fri, 16 Jan 2026 13:44:27 -0800 Subject: [PATCH 2/3] chore: revert back --- dist/js/holders/mixins/PropertyHolderMixin.js | 1 + src/js/holders/mixins/PropertyHolderMixin.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/js/holders/mixins/PropertyHolderMixin.js b/dist/js/holders/mixins/PropertyHolderMixin.js index fd55fc5..baaea41 100644 --- a/dist/js/holders/mixins/PropertyHolderMixin.js +++ b/dist/js/holders/mixins/PropertyHolderMixin.js @@ -8,6 +8,7 @@ const utils_1 = require("@mat3ra/code/dist/js/utils"); const PropertyHolderSchemaMixin_1 = require("../../generated/PropertyHolderSchemaMixin"); const PropertyFactory_1 = __importDefault(require("../../PropertyFactory")); function propertyHolderMixin(item) { + // @ts-expect-error - this is a workaround to allow the propertyMixin to be used with any type of entity const properties = { get sourceInfo() { return this.requiredProp("source.info"); diff --git a/src/js/holders/mixins/PropertyHolderMixin.ts b/src/js/holders/mixins/PropertyHolderMixin.ts index 9d2d2a3..749b8c4 100644 --- a/src/js/holders/mixins/PropertyHolderMixin.ts +++ b/src/js/holders/mixins/PropertyHolderMixin.ts @@ -22,6 +22,7 @@ export type PropertyHolderMixin = PropertyHolderSchemaMixin & { export type PropertyInMemoryEntity = InMemoryEntity & PropertyHolderMixin; export function propertyHolderMixin(item: InMemoryEntity) { + // @ts-expect-error - this is a workaround to allow the propertyMixin to be used with any type of entity const properties: InMemoryEntity & PropertyHolderMixin = { get sourceInfo() { return this.requiredProp("source.info"); From 96283cc57f0be09c8a9803c0e0ed5a100cd32211 Mon Sep 17 00:00:00 2001 From: VsevolodX Date: Fri, 16 Jan 2026 13:55:09 -0800 Subject: [PATCH 3/3] update: add test for wfn prop --- .../properties/wavefunction_amplitude.test.ts | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/js/properties/wavefunction_amplitude.test.ts diff --git a/tests/js/properties/wavefunction_amplitude.test.ts b/tests/js/properties/wavefunction_amplitude.test.ts new file mode 100644 index 0000000..243b31e --- /dev/null +++ b/tests/js/properties/wavefunction_amplitude.test.ts @@ -0,0 +1,65 @@ +/* eslint-disable no-unused-expressions */ +import type { WavefunctionAmplitudePropertySchema } from "@mat3ra/esse/dist/js/types"; +import { expect } from "chai"; + +import WavefunctionAmplitudeProperty from "../../../src/js/properties/non-scalar/WavefunctionAmplitudeProperty"; +import { PropertyName, PropertyType } from "../../../src/js/settings"; + +describe("WavefunctionAmplitudeProperty", () => { + const config: Omit = { + xDataArray: [-6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0], + yDataSeries: [ + [0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0, 0.9, 0.7, 0.5, 0.3, 0.1, 0.0] as [ + number, + ...number[], + ], + ], + xAxis: { + label: "z coordinate", + }, + yAxis: { + label: "amplitude", + }, + }; + + it("should create a wavefunction amplitude property with correct constructor, propertyType, propertyName, and defined properties", () => { + const wavefunctionAmplitudeProperty = new WavefunctionAmplitudeProperty(config); + + // Test basic properties + expect(wavefunctionAmplitudeProperty).to.be.instanceOf(WavefunctionAmplitudeProperty); + expect(WavefunctionAmplitudeProperty.propertyType).equal(PropertyType.non_scalar); + expect(WavefunctionAmplitudeProperty.propertyName).equal( + PropertyName.wavefunction_amplitude, + ); + expect(WavefunctionAmplitudeProperty.isRefined).to.be.true; + + // Test defined properties + expect(wavefunctionAmplitudeProperty.subtitle).to.equal("Wavefunction Amplitude"); + expect(wavefunctionAmplitudeProperty.yAxisTitle).to.equal("Amplitude"); + expect(wavefunctionAmplitudeProperty.xAxisTitle).to.equal("Z Coordinate"); + expect(wavefunctionAmplitudeProperty.chartConfig).to.exist; + expect(wavefunctionAmplitudeProperty.chartConfig).to.be.an("object"); + }); + + it("should handle multiple wavefunction series", () => { + const multiSeriesConfig: Omit = { + xDataArray: [-2.0, -1.0, 0.0, 1.0, 2.0], + yDataSeries: [ + [0.0, 0.5, 1.0, 0.5, 0.0] as [number, ...number[]], + [0.1, 0.3, 0.5, 0.3, 0.1] as [number, ...number[]], + ], + xAxis: { + label: "z coordinate", + }, + yAxis: { + label: "amplitude", + }, + }; + + const wavefunctionAmplitudeProperty = new WavefunctionAmplitudeProperty(multiSeriesConfig); + + expect(wavefunctionAmplitudeProperty).to.be.instanceOf(WavefunctionAmplitudeProperty); + expect(wavefunctionAmplitudeProperty.yDataSeries).to.have.lengthOf(2); + expect(wavefunctionAmplitudeProperty.chartConfig).to.exist; + }); +});