matterviz 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FilePicker.svelte +37 -20
- package/dist/Icon.svelte +2 -2
- package/dist/MillerIndexInput.svelte +60 -0
- package/dist/MillerIndexInput.svelte.d.ts +7 -0
- package/dist/app.css +38 -2
- package/dist/brillouin/BrillouinZone.svelte +20 -62
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneExportPane.svelte +12 -20
- package/dist/brillouin/BrillouinZoneScene.svelte +2 -2
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram.svelte +192 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +677 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +2688 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +8 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- package/dist/chempot-diagram/color.d.ts +10 -0
- package/dist/chempot-diagram/color.js +33 -0
- package/dist/chempot-diagram/compute.d.ts +38 -0
- package/dist/chempot-diagram/compute.js +650 -0
- package/dist/chempot-diagram/index.d.ts +5 -0
- package/dist/chempot-diagram/index.js +5 -0
- package/dist/chempot-diagram/pointer.d.ts +16 -0
- package/dist/chempot-diagram/pointer.js +40 -0
- package/dist/chempot-diagram/temperature.d.ts +15 -0
- package/dist/chempot-diagram/temperature.js +37 -0
- package/dist/chempot-diagram/types.d.ts +83 -0
- package/dist/chempot-diagram/types.js +27 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +4 -0
- package/dist/composition/BarChart.svelte +13 -22
- package/dist/composition/BubbleChart.svelte +5 -3
- package/dist/composition/FormulaFilter.svelte +770 -90
- package/dist/composition/FormulaFilter.svelte.d.ts +37 -1
- package/dist/composition/PieChart.svelte +43 -18
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -0
- package/dist/convex-hull/ConvexHull.svelte +14 -1
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +14 -45
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +396 -134
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +93 -42
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullControls.svelte +94 -31
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +4 -2
- package/dist/convex-hull/ConvexHullStats.svelte +697 -128
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +1 -0
- package/dist/convex-hull/GasPressureControls.svelte +72 -38
- package/dist/convex-hull/GasPressureControls.svelte.d.ts +2 -1
- package/dist/convex-hull/TemperatureSlider.svelte +46 -19
- package/dist/convex-hull/TemperatureSlider.svelte.d.ts +2 -1
- package/dist/convex-hull/demo-temperature.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +36 -0
- package/dist/convex-hull/gas-thermodynamics.js +16 -5
- package/dist/convex-hull/helpers.d.ts +7 -1
- package/dist/convex-hull/helpers.js +45 -15
- package/dist/convex-hull/index.d.ts +15 -1
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +106 -17
- package/dist/convex-hull/types.d.ts +7 -0
- package/dist/convex-hull/types.js +11 -0
- package/dist/coordination/CoordinationBarPlot.svelte +29 -46
- package/dist/element/BohrAtom.svelte +1 -1
- package/dist/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/index.d.ts +1 -1
- package/dist/element/index.js +1 -0
- package/dist/element/types.d.ts +1 -0
- package/dist/fermi-surface/FermiSurface.svelte +21 -65
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/compute.js +1 -21
- package/dist/fermi-surface/marching-cubes.d.ts +2 -13
- package/dist/fermi-surface/marching-cubes.js +2 -519
- package/dist/fermi-surface/parse.js +17 -23
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1273 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +171 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +31 -0
- package/dist/heatmap-matrix/index.d.ts +53 -0
- package/dist/heatmap-matrix/index.js +100 -0
- package/dist/heatmap-matrix/shared.d.ts +2 -0
- package/dist/heatmap-matrix/shared.js +4 -0
- package/dist/icons.d.ts +119 -0
- package/dist/icons.js +119 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/io/export.js +15 -3
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +43 -0
- package/dist/io/index.d.ts +2 -2
- package/dist/io/index.js +2 -112
- package/dist/io/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +118 -0
- package/dist/isosurface/Isosurface.svelte +231 -0
- package/dist/isosurface/Isosurface.svelte.d.ts +8 -0
- package/dist/isosurface/IsosurfaceControls.svelte +273 -0
- package/dist/isosurface/IsosurfaceControls.svelte.d.ts +9 -0
- package/dist/isosurface/index.d.ts +5 -0
- package/dist/isosurface/index.js +6 -0
- package/dist/isosurface/parse.d.ts +6 -0
- package/dist/isosurface/parse.js +548 -0
- package/dist/isosurface/slice.d.ts +11 -0
- package/dist/isosurface/slice.js +145 -0
- package/dist/isosurface/types.d.ts +55 -0
- package/dist/isosurface/types.js +178 -0
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +1 -0
- package/dist/layout/InfoTag.svelte +62 -62
- package/dist/layout/SubpageGrid.svelte +74 -0
- package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +226 -53
- package/dist/layout/json-tree/JsonTree.svelte +425 -51
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +218 -97
- package/dist/layout/json-tree/types.d.ts +27 -2
- package/dist/layout/json-tree/utils.d.ts +14 -1
- package/dist/layout/json-tree/utils.js +254 -0
- package/dist/marching-cubes.d.ts +14 -0
- package/dist/marching-cubes.js +519 -0
- package/dist/math.d.ts +8 -0
- package/dist/math.js +374 -7
- package/dist/overlays/ContextMenu.svelte +3 -2
- package/dist/overlays/DraggablePane.svelte +163 -58
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +232 -77
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +32 -11
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +103 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +102 -95
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +7 -0
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +100 -26
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- package/dist/phase-diagram/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +865 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +7 -4
- package/dist/phase-diagram/utils.js +149 -59
- package/dist/plot/AxisLabel.svelte +26 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +473 -228
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +3 -2
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +54 -54
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ElementScatter.svelte +4 -3
- package/dist/plot/FillArea.svelte +4 -1
- package/dist/plot/Histogram.svelte +320 -230
- package/dist/plot/Histogram.svelte.d.ts +2 -2
- package/dist/plot/HistogramControls.svelte +29 -10
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +2 -2
- package/dist/plot/PlotControls.svelte +109 -27
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +1 -1
- package/dist/plot/PortalSelect.svelte +2 -1
- package/dist/plot/ReferenceLine.svelte +2 -1
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferencePlane.svelte +1 -3
- package/dist/plot/ScatterPlot.svelte +343 -209
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +203 -250
- package/dist/plot/ScatterPlot3DScene.svelte +4 -7
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +95 -55
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ZeroLines.svelte +44 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +21 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- package/dist/plot/data-cleaning.js +1 -5
- package/dist/plot/index.d.ts +6 -2
- package/dist/plot/index.js +6 -2
- package/dist/plot/interactions.d.ts +8 -10
- package/dist/plot/interactions.js +10 -19
- package/dist/plot/layout.d.ts +7 -1
- package/dist/plot/layout.js +12 -4
- package/dist/plot/reference-line.d.ts +4 -21
- package/dist/plot/reference-line.js +7 -81
- package/dist/plot/types.d.ts +42 -17
- package/dist/plot/types.js +10 -0
- package/dist/plot/utils/label-placement.js +14 -11
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +55 -66
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/index.d.ts +1 -1
- package/dist/rdf/index.js +1 -1
- package/dist/settings.d.ts +5 -0
- package/dist/settings.js +37 -3
- package/dist/spectral/Bands.svelte +515 -143
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- package/dist/spectral/helpers.d.ts +23 -1
- package/dist/spectral/helpers.js +65 -9
- package/dist/spectral/types.d.ts +2 -0
- package/dist/structure/AtomLegend.svelte +31 -10
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/CellSelect.svelte +92 -22
- package/dist/structure/Lattice.svelte +2 -0
- package/dist/structure/Structure.svelte +716 -173
- package/dist/structure/Structure.svelte.d.ts +7 -2
- package/dist/structure/StructureControls.svelte +26 -14
- package/dist/structure/StructureControls.svelte.d.ts +5 -1
- package/dist/structure/StructureInfoPane.svelte +7 -1
- package/dist/structure/StructureScene.svelte +386 -95
- package/dist/structure/StructureScene.svelte.d.ts +15 -4
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +38 -25
- package/dist/structure/export.js +10 -7
- package/dist/structure/ferrox-wasm-types.d.ts +3 -2
- package/dist/structure/ferrox-wasm-types.js +0 -3
- package/dist/structure/ferrox-wasm.d.ts +3 -2
- package/dist/structure/ferrox-wasm.js +1 -2
- package/dist/structure/index.d.ts +7 -0
- package/dist/structure/index.js +22 -0
- package/dist/structure/parse.js +19 -16
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +102 -0
- package/dist/structure/validation.js +6 -3
- package/dist/symmetry/SymmetryStats.svelte +18 -4
- package/dist/symmetry/WyckoffTable.svelte +18 -10
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +83 -18
- package/dist/table/HeatmapTable.svelte +468 -69
- package/dist/table/HeatmapTable.svelte.d.ts +13 -1
- package/dist/table/ToggleMenu.svelte +291 -44
- package/dist/table/ToggleMenu.svelte.d.ts +4 -1
- package/dist/table/index.d.ts +3 -0
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tooltip/index.js +1 -0
- package/dist/trajectory/Trajectory.svelte +147 -145
- package/dist/trajectory/TrajectoryExportPane.svelte +13 -9
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +3 -5
- package/dist/trajectory/format-detect.d.ts +9 -0
- package/dist/trajectory/format-detect.js +76 -0
- package/dist/trajectory/frame-reader.d.ts +17 -0
- package/dist/trajectory/frame-reader.js +339 -0
- package/dist/trajectory/helpers.d.ts +15 -0
- package/dist/trajectory/helpers.js +187 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +11 -4
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +76 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +121 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +304 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +169 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +65 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +109 -0
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +4 -0
- package/dist/xrd/XrdPlot.svelte +6 -4
- package/dist/xrd/calc-xrd.js +0 -1
- package/package.json +33 -23
- package/readme.md +4 -4
- package/dist/trajectory/parse.d.ts +0 -42
- package/dist/trajectory/parse.js +0 -1267
- /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
package/dist/symmetry/index.d.ts
CHANGED
|
@@ -29,12 +29,15 @@ export type WyckoffPos = {
|
|
|
29
29
|
abc: Vec3;
|
|
30
30
|
site_indices?: number[];
|
|
31
31
|
};
|
|
32
|
+
export type SymmetryDataset = MoyoDataset & {
|
|
33
|
+
orig_indices?: number[];
|
|
34
|
+
orig_site_indices_by_std_idx?: number[][];
|
|
35
|
+
};
|
|
32
36
|
export declare function ensure_moyo_wasm_ready(wasm_url?: string): Promise<void>;
|
|
33
37
|
export declare function to_cell_json(structure: Crystal): string;
|
|
34
|
-
export declare function
|
|
38
|
+
export declare function map_std_to_orig_site_indices(std_positions: Vec3[], std_numbers: number[], input_positions: Vec3[], input_numbers: number[], orig_site_indices_by_input_idx: number[][]): number[][];
|
|
39
|
+
export declare function analyze_structure_symmetry(struct_or_mol: AnyStructure, settings: Partial<SymmetrySettings>): Promise<SymmetryDataset>;
|
|
35
40
|
export declare function simplicity_score(vec: number[]): number;
|
|
36
|
-
export declare function wyckoff_positions_from_moyo(sym_data:
|
|
37
|
-
orig_indices?: number[];
|
|
38
|
-
}) | null): WyckoffPos[];
|
|
41
|
+
export declare function wyckoff_positions_from_moyo(sym_data: SymmetryDataset | null): WyckoffPos[];
|
|
39
42
|
export declare function apply_symmetry_operations(position: Vec3, operations: MoyoDataset[`operations`], _tolerance?: number): Vec3[];
|
|
40
43
|
export declare function map_wyckoff_to_all_atoms(wyckoff_positions: WyckoffPos[], displayed_structure: Crystal, orig_structure: Crystal, sym_data: MoyoDataset | null, tolerance?: number): WyckoffPos[];
|
package/dist/symmetry/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ATOMIC_NUMBER_TO_SYMBOL, SYMBOL_TO_ATOMIC_NUMBER } from '../composition/parse';
|
|
2
2
|
import { DEFAULTS } from '../settings';
|
|
3
|
+
import { merge_split_partial_sites } from '../structure/partial-occupancy';
|
|
3
4
|
import init, { analyze_cell } from '@spglib/moyo-wasm';
|
|
4
5
|
import moyo_wasm_url from '@spglib/moyo-wasm/moyo_wasm_bg.wasm?url';
|
|
5
6
|
export * from './cell-transform';
|
|
@@ -21,6 +22,7 @@ export const default_sym_settings = {
|
|
|
21
22
|
algo: DEFAULTS.symmetry.algo,
|
|
22
23
|
};
|
|
23
24
|
let initialized = false;
|
|
25
|
+
const OCCUPANCY_EPS = 1e-8;
|
|
24
26
|
export async function ensure_moyo_wasm_ready(wasm_url) {
|
|
25
27
|
if (initialized)
|
|
26
28
|
return;
|
|
@@ -29,34 +31,90 @@ export async function ensure_moyo_wasm_ready(wasm_url) {
|
|
|
29
31
|
await init({ module_or_path: url });
|
|
30
32
|
initialized = true;
|
|
31
33
|
}
|
|
32
|
-
|
|
34
|
+
function get_site_atomic_number(site, site_idx) {
|
|
35
|
+
const occupancy_by_element = new Map();
|
|
36
|
+
for (const { element, occu } of site.species) {
|
|
37
|
+
if (occu <= OCCUPANCY_EPS)
|
|
38
|
+
continue;
|
|
39
|
+
occupancy_by_element.set(element, (occupancy_by_element.get(element) ?? 0) + occu);
|
|
40
|
+
}
|
|
41
|
+
let selected_element = site
|
|
42
|
+
.species[0]?.element;
|
|
43
|
+
let best_occupancy = -Infinity;
|
|
44
|
+
occupancy_by_element.forEach((occupancy, element) => {
|
|
45
|
+
if (occupancy > best_occupancy ||
|
|
46
|
+
(occupancy === best_occupancy && element.localeCompare(selected_element ?? ``) < 0)) {
|
|
47
|
+
selected_element = element;
|
|
48
|
+
best_occupancy = occupancy;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (selected_element === undefined) {
|
|
52
|
+
throw new Error(`Unknown element at site ${site_idx}: ${String(selected_element)}`);
|
|
53
|
+
}
|
|
54
|
+
const atomic_number = SYMBOL_TO_ATOMIC_NUMBER[selected_element];
|
|
55
|
+
if (atomic_number === undefined) {
|
|
56
|
+
throw new Error(`Unknown element at site ${site_idx}: ${String(selected_element)}`);
|
|
57
|
+
}
|
|
58
|
+
return atomic_number;
|
|
59
|
+
}
|
|
60
|
+
function build_moyo_input_cell(structure) {
|
|
61
|
+
const merged_render_sites = merge_split_partial_sites(structure.sites);
|
|
62
|
+
return {
|
|
63
|
+
positions: merged_render_sites.map(({ site }) => site.abc),
|
|
64
|
+
numbers: merged_render_sites.map(({ site, site_idx }) => get_site_atomic_number(site, site_idx)),
|
|
65
|
+
orig_site_indices_by_input_idx: merged_render_sites.map(({ source_site_indices }) => source_site_indices),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function build_moyo_cell(structure, positions, numbers) {
|
|
33
69
|
// nalgebra Matrix3 deserializes as a flat list in COLUMN-MAJOR of the internal basis B
|
|
34
70
|
// Internal B = transpose(row-basis RB). column-major(B) == row-major(RB).
|
|
35
71
|
// So supply row-major of the pymatgen lattice.matrix (RB).
|
|
36
72
|
const [v_a, v_b, v_c] = structure.lattice.matrix;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
73
|
+
return {
|
|
74
|
+
lattice: { basis: [...v_a, ...v_b, ...v_c] },
|
|
75
|
+
positions,
|
|
76
|
+
numbers,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function to_cell_json(structure) {
|
|
80
|
+
const { positions, numbers } = build_moyo_input_cell(structure);
|
|
81
|
+
return JSON.stringify(build_moyo_cell(structure, positions, numbers));
|
|
82
|
+
}
|
|
83
|
+
const fractional_sq_dist = (pos_1, pos_2) => (pos_1[0] - pos_2[0] - Math.round(pos_1[0] - pos_2[0])) ** 2 +
|
|
84
|
+
(pos_1[1] - pos_2[1] - Math.round(pos_1[1] - pos_2[1])) ** 2 +
|
|
85
|
+
(pos_1[2] - pos_2[2] - Math.round(pos_1[2] - pos_2[2])) ** 2;
|
|
86
|
+
export function map_std_to_orig_site_indices(std_positions, std_numbers, input_positions, input_numbers, orig_site_indices_by_input_idx) {
|
|
87
|
+
return std_positions.map((std_pos, std_idx) => {
|
|
88
|
+
const std_number = std_numbers[std_idx];
|
|
89
|
+
let nearest_input_idx = -1;
|
|
90
|
+
let nearest_sq_dist = Infinity;
|
|
91
|
+
for (let input_idx = 0; input_idx < input_positions.length; input_idx += 1) {
|
|
92
|
+
if (input_numbers[input_idx] !== std_number)
|
|
93
|
+
continue;
|
|
94
|
+
const sq_dist = fractional_sq_dist(std_pos, input_positions[input_idx]);
|
|
95
|
+
if (sq_dist < nearest_sq_dist) {
|
|
96
|
+
nearest_sq_dist = sq_dist;
|
|
97
|
+
nearest_input_idx = input_idx;
|
|
98
|
+
}
|
|
44
99
|
}
|
|
45
|
-
|
|
100
|
+
if (nearest_input_idx === -1)
|
|
101
|
+
return [];
|
|
102
|
+
return orig_site_indices_by_input_idx[nearest_input_idx] ?? [];
|
|
46
103
|
});
|
|
47
|
-
const cell = { lattice: { basis }, positions, numbers };
|
|
48
|
-
return JSON.stringify(cell);
|
|
49
104
|
}
|
|
50
105
|
export async function analyze_structure_symmetry(struct_or_mol, settings) {
|
|
51
106
|
await ensure_moyo_wasm_ready();
|
|
52
107
|
if (!(`lattice` in struct_or_mol)) {
|
|
53
108
|
throw new Error(`Symmetry analysis requires a periodic structure with a lattice`);
|
|
54
109
|
}
|
|
55
|
-
const
|
|
110
|
+
const moyo_input_cell = build_moyo_input_cell(struct_or_mol);
|
|
111
|
+
const cell_json = JSON.stringify(build_moyo_cell(struct_or_mol, moyo_input_cell.positions, moyo_input_cell.numbers));
|
|
56
112
|
const { symprec, algo } = { ...default_sym_settings, ...settings };
|
|
57
113
|
// Map "Moyo" to "Standard" for moyo-wasm
|
|
58
114
|
const moyo_algo = algo === `Moyo` ? `Standard` : algo;
|
|
59
|
-
|
|
115
|
+
const sym_data = analyze_cell(cell_json, symprec, moyo_algo);
|
|
116
|
+
const orig_site_indices_by_std_idx = map_std_to_orig_site_indices(sym_data.std_cell.positions, sym_data.std_cell.numbers, moyo_input_cell.positions, moyo_input_cell.numbers, moyo_input_cell.orig_site_indices_by_input_idx);
|
|
117
|
+
return { ...sym_data, orig_site_indices_by_std_idx };
|
|
60
118
|
}
|
|
61
119
|
// Helper function to score coordinate simplicity for Wyckoff table
|
|
62
120
|
export function simplicity_score(vec) {
|
|
@@ -72,7 +130,7 @@ export function wyckoff_positions_from_moyo(sym_data) {
|
|
|
72
130
|
if (!sym_data)
|
|
73
131
|
return [];
|
|
74
132
|
const { positions, numbers } = sym_data.std_cell;
|
|
75
|
-
const { wyckoffs, orig_indices } = sym_data;
|
|
133
|
+
const { wyckoffs, orig_indices, orig_site_indices_by_std_idx } = sym_data;
|
|
76
134
|
// Group sites by letter-element combination and track all indices
|
|
77
135
|
const groups = new Map();
|
|
78
136
|
// Process all atoms in the standardized cell
|
|
@@ -97,11 +155,18 @@ export function wyckoff_positions_from_moyo(sym_data) {
|
|
|
97
155
|
return score < best.score ? { pos, score } : best;
|
|
98
156
|
}, { pos: positions[0], score: simplicity_score(positions[0]) }).pos;
|
|
99
157
|
// Map standardized cell indices back to original structure indices
|
|
100
|
-
const orig_site_indices =
|
|
101
|
-
? indices.
|
|
102
|
-
:
|
|
158
|
+
const orig_site_indices = orig_site_indices_by_std_idx
|
|
159
|
+
? indices.flatMap((std_idx) => orig_site_indices_by_std_idx[std_idx] ?? [])
|
|
160
|
+
: orig_indices
|
|
161
|
+
? indices.map((std_idx) => orig_indices[std_idx]).filter((idx) => idx !== undefined)
|
|
162
|
+
: indices;
|
|
103
163
|
const wyckoff = letter ? `${indices.length}${letter}` : `1`;
|
|
104
|
-
return {
|
|
164
|
+
return {
|
|
165
|
+
wyckoff,
|
|
166
|
+
elem,
|
|
167
|
+
abc: best_pos,
|
|
168
|
+
site_indices: [...new Set(orig_site_indices)].sort((idx_a, idx_b) => idx_a - idx_b),
|
|
169
|
+
};
|
|
105
170
|
});
|
|
106
171
|
rows.sort((w1, w2) => {
|
|
107
172
|
const [w1_mult, w2_mult] = [parseInt(w1.wyckoff), parseInt(w2.wyckoff)];
|