matterviz 0.3.2 → 0.3.3
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/EmptyState.svelte +10 -2
- package/dist/FilePicker.svelte +123 -82
- package/dist/Icon.svelte +18 -12
- package/dist/MillerIndexInput.svelte +27 -21
- package/dist/api/optimade.js +6 -6
- package/dist/app.css +216 -207
- package/dist/brillouin/BrillouinZone.svelte +292 -149
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
- package/dist/brillouin/BrillouinZoneExportPane.svelte +69 -42
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
- package/dist/brillouin/BrillouinZoneScene.svelte +275 -163
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneTooltip.svelte +17 -7
- package/dist/brillouin/compute.js +11 -6
- package/dist/chempot-diagram/ChemPotDiagram.svelte +162 -27
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +451 -281
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +2148 -1642
- package/dist/chempot-diagram/ChemPotScene3D.svelte +8 -5
- package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
- package/dist/chempot-diagram/async-compute.svelte.js +77 -0
- package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
- package/dist/chempot-diagram/chempot-worker.js +11 -0
- package/dist/chempot-diagram/color.js +1 -2
- package/dist/chempot-diagram/compute.d.ts +10 -0
- package/dist/chempot-diagram/compute.js +250 -88
- package/dist/chempot-diagram/index.d.ts +2 -1
- package/dist/chempot-diagram/index.js +2 -1
- package/dist/chempot-diagram/temperature.js +8 -9
- package/dist/chempot-diagram/types.d.ts +3 -0
- package/dist/chempot-diagram/types.js +1 -0
- package/dist/colors/index.d.ts +1 -1
- package/dist/colors/index.js +5 -3
- package/dist/composition/BarChart.svelte +128 -55
- package/dist/composition/BubbleChart.svelte +102 -49
- package/dist/composition/Composition.svelte +100 -79
- package/dist/composition/Formula.svelte +108 -62
- package/dist/composition/FormulaFilter.svelte +665 -537
- package/dist/composition/PieChart.svelte +183 -108
- package/dist/composition/format.d.ts +5 -0
- package/dist/composition/format.js +20 -3
- package/dist/composition/parse.js +14 -9
- package/dist/convex-hull/ConvexHull.svelte +93 -40
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +549 -360
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +1296 -827
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +1004 -688
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullControls.svelte +115 -28
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
- package/dist/convex-hull/ConvexHullStats.svelte +425 -328
- package/dist/convex-hull/ConvexHullTooltip.svelte +40 -16
- package/dist/convex-hull/GasPressureControls.svelte +104 -61
- package/dist/convex-hull/StructurePopup.svelte +25 -4
- package/dist/convex-hull/TemperatureSlider.svelte +45 -25
- package/dist/convex-hull/barycentric-coords.js +13 -7
- package/dist/convex-hull/demo-temperature.js +8 -4
- package/dist/convex-hull/gas-thermodynamics.js +17 -12
- package/dist/convex-hull/helpers.d.ts +9 -0
- package/dist/convex-hull/helpers.js +77 -34
- package/dist/convex-hull/thermodynamics.js +61 -56
- package/dist/convex-hull/types.d.ts +9 -14
- package/dist/convex-hull/types.js +0 -17
- package/dist/coordination/CoordinationBarPlot.svelte +227 -154
- package/dist/element/BohrAtom.svelte +55 -12
- package/dist/element/ElementHeading.svelte +7 -2
- package/dist/element/ElementPhoto.svelte +15 -9
- package/dist/element/ElementStats.svelte +10 -4
- package/dist/element/ElementTile.svelte +137 -73
- package/dist/element/Nucleus.svelte +39 -11
- package/dist/feedback/ClickFeedback.svelte +16 -5
- package/dist/feedback/DragOverlay.svelte +10 -2
- package/dist/feedback/Spinner.svelte +4 -2
- package/dist/feedback/StatusMessage.svelte +8 -2
- package/dist/fermi-surface/FermiSlice.svelte +118 -88
- package/dist/fermi-surface/FermiSurface.svelte +328 -187
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +535 -342
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
- package/dist/fermi-surface/compute.js +16 -20
- package/dist/fermi-surface/parse.js +24 -14
- package/dist/fermi-surface/symmetry.js +2 -7
- package/dist/fermi-surface/types.d.ts +3 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1019 -765
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +1 -1
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +76 -22
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +2 -3
- package/dist/icons.js +47 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.d.ts +3 -0
- package/dist/io/export.js +129 -143
- package/dist/io/is-binary.js +2 -3
- package/dist/io/url-drop.js +1 -2
- package/dist/isosurface/Isosurface.svelte +202 -148
- package/dist/isosurface/IsosurfaceControls.svelte +46 -28
- package/dist/isosurface/parse.js +34 -29
- package/dist/isosurface/slice.js +5 -10
- package/dist/isosurface/types.d.ts +2 -1
- package/dist/isosurface/types.js +61 -12
- package/dist/labels.js +11 -8
- package/dist/layout/FullscreenToggle.svelte +11 -2
- package/dist/layout/InfoCard.svelte +38 -6
- package/dist/layout/InfoTag.svelte +63 -32
- package/dist/layout/PropertyFilter.svelte +82 -37
- package/dist/layout/SettingsSection.svelte +85 -55
- package/dist/layout/SubpageGrid.svelte +10 -2
- package/dist/layout/json-tree/JsonNode.svelte +183 -138
- package/dist/layout/json-tree/JsonTree.svelte +499 -413
- package/dist/layout/json-tree/JsonValue.svelte +127 -99
- package/dist/layout/json-tree/utils.js +4 -2
- package/dist/marching-cubes.js +25 -2
- package/dist/math.d.ts +13 -17
- package/dist/math.js +133 -67
- package/dist/overlays/ContextMenu.svelte +65 -40
- package/dist/overlays/DraggablePane.svelte +211 -139
- package/dist/periodic-table/PeriodicTable.svelte +278 -145
- package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
- package/dist/periodic-table/PropertySelect.svelte +25 -7
- package/dist/periodic-table/TableInset.svelte +8 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +446 -309
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramControls.svelte +102 -43
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +63 -40
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +71 -28
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +158 -101
- package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
- package/dist/phase-diagram/build-diagram.js +9 -9
- package/dist/phase-diagram/colors.js +1 -3
- package/dist/phase-diagram/parse.js +10 -9
- package/dist/phase-diagram/svg-to-diagram.js +53 -49
- package/dist/phase-diagram/utils.d.ts +1 -0
- package/dist/phase-diagram/utils.js +80 -25
- package/dist/plot/AxisLabel.svelte +28 -3
- package/dist/plot/BarPlot.svelte +1182 -734
- package/dist/plot/BarPlot.svelte.d.ts +2 -2
- package/dist/plot/BarPlotControls.svelte +31 -5
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +479 -329
- package/dist/plot/ColorScaleSelect.svelte +27 -6
- package/dist/plot/ElementScatter.svelte +36 -15
- package/dist/plot/FillArea.svelte +152 -95
- package/dist/plot/Histogram.svelte +934 -571
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +53 -9
- package/dist/plot/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/InteractiveAxisLabel.svelte +34 -11
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/Line.svelte +63 -28
- package/dist/plot/PlotControls.svelte +157 -114
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +174 -91
- package/dist/plot/PlotTooltip.svelte +45 -6
- package/dist/plot/PortalSelect.svelte +175 -147
- package/dist/plot/ReferenceLine.svelte +76 -22
- package/dist/plot/ReferenceLine3D.svelte +132 -107
- package/dist/plot/ReferencePlane.svelte +146 -121
- package/dist/plot/ScatterPlot.svelte +1681 -1091
- package/dist/plot/ScatterPlot.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3D.svelte +256 -131
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +113 -63
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot3DScene.svelte +608 -403
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +65 -25
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ScatterPoint.svelte +98 -26
- package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
- package/dist/plot/SpacegroupBarPlot.svelte +142 -85
- package/dist/plot/Surface3D.svelte +159 -108
- package/dist/plot/ZeroLines.svelte +55 -3
- package/dist/plot/ZoomRect.svelte +4 -2
- package/dist/plot/axis-utils.js +1 -3
- package/dist/plot/data-cleaning.js +12 -28
- package/dist/plot/data-transform.js +2 -1
- package/dist/plot/fill-utils.js +2 -0
- package/dist/plot/layout.d.ts +4 -1
- package/dist/plot/layout.js +33 -14
- package/dist/plot/reference-line.d.ts +2 -2
- package/dist/plot/reference-line.js +7 -5
- package/dist/plot/scales.js +24 -36
- package/dist/plot/types.d.ts +11 -23
- package/dist/plot/types.js +6 -11
- package/dist/plot/utils/label-placement.d.ts +32 -15
- package/dist/plot/utils/label-placement.js +227 -66
- package/dist/plot/utils/series-visibility.js +2 -3
- package/dist/rdf/RdfPlot.svelte +143 -91
- package/dist/rdf/calc-rdf.js +4 -5
- package/dist/sanitize.d.ts +4 -0
- package/dist/sanitize.js +107 -0
- package/dist/settings.d.ts +18 -6
- package/dist/settings.js +46 -16
- package/dist/spectral/Bands.svelte +632 -453
- package/dist/spectral/BandsAndDos.svelte +90 -49
- package/dist/spectral/BrillouinBandsDos.svelte +151 -93
- package/dist/spectral/Dos.svelte +389 -258
- package/dist/spectral/helpers.js +55 -43
- package/dist/state.svelte.d.ts +1 -1
- package/dist/state.svelte.js +3 -2
- package/dist/structure/Arrow.svelte +59 -20
- package/dist/structure/AtomLegend.svelte +215 -134
- package/dist/structure/Bond.svelte +73 -47
- package/dist/structure/CanvasTooltip.svelte +10 -2
- package/dist/structure/CellSelect.svelte +72 -45
- package/dist/structure/Cylinder.svelte +33 -17
- package/dist/structure/Lattice.svelte +88 -33
- package/dist/structure/Structure.svelte +1063 -797
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureControls.svelte +349 -118
- package/dist/structure/StructureExportPane.svelte +124 -89
- package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +304 -237
- package/dist/structure/StructureScene.svelte +879 -443
- package/dist/structure/StructureScene.svelte.d.ts +15 -7
- package/dist/structure/atom-properties.js +8 -8
- package/dist/structure/bonding.js +6 -7
- package/dist/structure/export.js +14 -29
- package/dist/structure/ferrox-wasm.js +1 -1
- package/dist/structure/index.d.ts +13 -3
- package/dist/structure/index.js +83 -23
- package/dist/structure/measure.d.ts +2 -2
- package/dist/structure/measure.js +4 -44
- package/dist/structure/parse.js +113 -141
- package/dist/structure/partial-occupancy.js +7 -10
- package/dist/structure/pbc.d.ts +1 -0
- package/dist/structure/pbc.js +16 -6
- package/dist/structure/supercell.d.ts +2 -2
- package/dist/structure/supercell.js +12 -22
- package/dist/structure/validation.js +1 -2
- package/dist/symmetry/SymmetryStats.svelte +84 -41
- package/dist/symmetry/WyckoffTable.svelte +26 -6
- package/dist/symmetry/cell-transform.js +5 -3
- package/dist/symmetry/index.js +8 -7
- package/dist/symmetry/spacegroups.js +148 -148
- package/dist/table/HeatmapTable.svelte +790 -554
- package/dist/table/HeatmapTable.svelte.d.ts +1 -1
- package/dist/table/ToggleMenu.svelte +125 -92
- package/dist/table/index.js +2 -4
- package/dist/theme/ThemeControl.svelte +21 -12
- package/dist/time.js +4 -1
- package/dist/tooltip/TooltipContent.svelte +33 -8
- package/dist/trajectory/Trajectory.svelte +758 -558
- package/dist/trajectory/TrajectoryError.svelte +14 -3
- package/dist/trajectory/TrajectoryExportPane.svelte +137 -83
- package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
- package/dist/trajectory/extract.js +10 -26
- package/dist/trajectory/format-detect.js +5 -5
- package/dist/trajectory/frame-reader.d.ts +1 -1
- package/dist/trajectory/frame-reader.js +5 -12
- package/dist/trajectory/helpers.d.ts +0 -1
- package/dist/trajectory/helpers.js +2 -17
- package/dist/trajectory/index.js +14 -12
- package/dist/trajectory/parse/ase.js +5 -4
- package/dist/trajectory/parse/hdf5.js +26 -18
- package/dist/trajectory/parse/index.js +13 -18
- package/dist/trajectory/parse/lammps.js +17 -7
- package/dist/trajectory/parse/vasp.js +5 -2
- package/dist/trajectory/parse/xyz.js +8 -7
- package/dist/trajectory/plotting.js +13 -8
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +13 -0
- package/dist/xrd/XrdPlot.svelte +337 -247
- package/dist/xrd/broadening.js +14 -9
- package/dist/xrd/calc-xrd.js +12 -18
- package/dist/xrd/parse.d.ts +1 -1
- package/dist/xrd/parse.js +17 -17
- package/package.json +99 -103
- package/readme.md +1 -1
- /package/dist/theme/{themes.js → themes.mjs} +0 -0
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import * as math from '../math';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const wrapped = ((coord % 1) + 1) % 1;
|
|
5
|
-
return wrapped >= 1 - 1e-10 ? 0 : wrapped;
|
|
6
|
-
};
|
|
2
|
+
import { scale_lattice_matrix } from '../math';
|
|
3
|
+
import { wrap_frac_coord } from './pbc';
|
|
7
4
|
// Parse supercell scaling input from various formats. Can be "2x2x2", "2", [2,2,2], or a single number.
|
|
8
5
|
// Returns [x, y, z] scaling factors.
|
|
9
6
|
export function parse_supercell_scaling(scaling) {
|
|
@@ -21,7 +18,11 @@ export function parse_supercell_scaling(scaling) {
|
|
|
21
18
|
}
|
|
22
19
|
if (typeof scaling === `string`) {
|
|
23
20
|
// Parse "2x2x2" format
|
|
24
|
-
const parts = scaling
|
|
21
|
+
const parts = scaling
|
|
22
|
+
.trim()
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.split(/[x×,\s]+/)
|
|
25
|
+
.filter((part) => part.length > 0);
|
|
25
26
|
if (parts.length === 1 || parts.length === 3) {
|
|
26
27
|
// Check that all parts are strictly digits to avoid scientific notation/hex/etc per tests
|
|
27
28
|
if (parts.every((part) => /^\d+$/.test(part))) {
|
|
@@ -51,19 +52,8 @@ export function generate_lattice_points(scaling_factors) {
|
|
|
51
52
|
}
|
|
52
53
|
return points;
|
|
53
54
|
}
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
// Returns new scaled lattice matrix
|
|
57
|
-
export function scale_lattice_matrix(orig_matrix, scaling_factors) {
|
|
58
|
-
const [nx, ny, nz] = scaling_factors;
|
|
59
|
-
const [a, b, c] = orig_matrix;
|
|
60
|
-
// Scale each lattice vector by its corresponding factor
|
|
61
|
-
return [
|
|
62
|
-
[a[0] * nx, a[1] * nx, a[2] * nx],
|
|
63
|
-
[b[0] * ny, b[1] * ny, b[2] * ny],
|
|
64
|
-
[c[0] * nz, c[1] * nz, c[2] * nz],
|
|
65
|
-
];
|
|
66
|
-
}
|
|
55
|
+
// Re-export from $lib/math for backward compatibility
|
|
56
|
+
export { scale_lattice_matrix };
|
|
67
57
|
// Create a supercell from a Crystal
|
|
68
58
|
// Takes original structure, scaling factors, and whether to fold coordinates back to unit cell (default: true)
|
|
69
59
|
// Returns new supercell structure
|
|
@@ -111,9 +101,9 @@ export function make_supercell(structure, scaling, to_unit_cell = true) {
|
|
|
111
101
|
let new_b = (site.abc[1] + jj) / sy;
|
|
112
102
|
let new_c = (site.abc[2] + kk) / sz;
|
|
113
103
|
if (to_unit_cell) {
|
|
114
|
-
new_a =
|
|
115
|
-
new_b =
|
|
116
|
-
new_c =
|
|
104
|
+
new_a = wrap_frac_coord(new_a);
|
|
105
|
+
new_b = wrap_frac_coord(new_b);
|
|
106
|
+
new_c = wrap_frac_coord(new_c);
|
|
117
107
|
}
|
|
118
108
|
new_sites[write_idx++] = {
|
|
119
109
|
species: site.species,
|
|
@@ -5,7 +5,6 @@ export function is_crystal(obj) {
|
|
|
5
5
|
const sites = structure_obj.sites;
|
|
6
6
|
const lattice = structure_obj.lattice;
|
|
7
7
|
const has_sites = Array.isArray(sites) && sites.length > 0;
|
|
8
|
-
const has_lattice = lattice !== undefined && lattice !== null &&
|
|
9
|
-
typeof lattice === `object`;
|
|
8
|
+
const has_lattice = lattice !== undefined && lattice !== null && typeof lattice === `object`;
|
|
10
9
|
return has_sites && has_lattice;
|
|
11
10
|
}
|
|
@@ -1,49 +1,92 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { MoyoDataset } from '@spglib/moyo-wasm'
|
|
3
|
+
import type { Snippet } from 'svelte'
|
|
4
|
+
import { tooltip } from 'svelte-multiselect'
|
|
5
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
6
|
+
import { SETTINGS_CONFIG } from '../settings'
|
|
7
|
+
import type { SymmetrySettings } from './index'
|
|
8
|
+
import { default_sym_settings, wyckoff_positions_from_moyo } from './index'
|
|
9
|
+
import * as spg from './spacegroups'
|
|
10
|
+
|
|
11
|
+
type SymmetrySnippet = Snippet<
|
|
12
|
+
[{ sym_data?: MoyoDataset | null; settings: SymmetrySettings }]
|
|
13
|
+
>
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
sym_data,
|
|
17
|
+
settings = $bindable(default_sym_settings),
|
|
18
|
+
show_tooltips = true,
|
|
19
|
+
children,
|
|
20
|
+
label = `Symmetry`,
|
|
21
|
+
header,
|
|
22
|
+
...rest
|
|
23
|
+
}: HTMLAttributes<HTMLDivElement> & {
|
|
24
|
+
sym_data?: MoyoDataset | null
|
|
25
|
+
settings?: SymmetrySettings
|
|
26
|
+
show_tooltips?: boolean
|
|
27
|
+
children?: SymmetrySnippet
|
|
28
|
+
label?: SymmetrySnippet | string
|
|
29
|
+
header?: SymmetrySnippet
|
|
30
|
+
} = $props()
|
|
31
|
+
|
|
32
|
+
const wyckoff_count = $derived(
|
|
33
|
+
sym_data ? wyckoff_positions_from_moyo(sym_data).length : 0,
|
|
34
|
+
)
|
|
35
|
+
const display_hm_symbol = $derived(sym_data?.hm_symbol?.replace(/\s+/g, ``) ?? `?`)
|
|
36
|
+
|
|
37
|
+
const sym_ops_counts = $derived.by(() => {
|
|
38
|
+
const EPS = 1e-10
|
|
10
39
|
if (!sym_data?.operations) {
|
|
11
|
-
|
|
40
|
+
return { translations: 0, rotations: 0, roto_translations: 0 }
|
|
12
41
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
else
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
|
|
43
|
+
return sym_data.operations.reduce(
|
|
44
|
+
(acc, op) => {
|
|
45
|
+
const has_translation = op.translation.some((coord) => Math.abs(coord) > EPS)
|
|
46
|
+
const is_identity = String(op.rotation) === `1,0,0,0,1,0,0,0,1`
|
|
47
|
+
|
|
48
|
+
if (is_identity && has_translation) acc.translations++
|
|
49
|
+
else if (!has_translation) acc.rotations++
|
|
50
|
+
else acc.roto_translations++
|
|
51
|
+
|
|
52
|
+
return acc
|
|
53
|
+
},
|
|
54
|
+
{ translations: 0, rotations: 0, roto_translations: 0 },
|
|
55
|
+
)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const titles = {
|
|
59
|
+
symprec:
|
|
60
|
+
`Symmetry precision control in spglib/moyo. Lower values (e.g. 1e-4, the default) are more strict, higher values (e.g. 1e-1) are more tolerant of numerical errors in atomic positions.`,
|
|
61
|
+
algo:
|
|
62
|
+
`Symmetry detection algorithm: Moyo uses moyo's newer recommended settings, Spglib is useful if you need compatible results to an existing set of spglib-detected symmetries.`,
|
|
63
|
+
space_group:
|
|
64
|
+
`International Tables Space group number (1-230) - unique identifier for each space group. Higher numbers indicate more symmetries in the crystal.`,
|
|
65
|
+
crystal_system:
|
|
66
|
+
`Crystal system classification based on the unit cell symmetry. Seven systems: triclinic, monoclinic, orthorhombic, tetragonal, trigonal, hexagonal, and cubic.`,
|
|
67
|
+
hermann_mauguin:
|
|
68
|
+
`Hermann-Mauguin symbol describes symmetry operations. Format: Lattice type + Point group symmetry. Example: P4/mmm = Primitive + 4-fold rotation + mirror planes`,
|
|
69
|
+
hall_number:
|
|
70
|
+
`Hall number: alternative numbering system for space groups. Useful for crystallographic software compatibility.`,
|
|
71
|
+
pearson_symbol:
|
|
72
|
+
`Pearson symbol. Format: Crystal system + Number of atoms per unit cell. Example: tP2 = tetragonal primitive with 2 atoms`,
|
|
73
|
+
symmetry_operations:
|
|
74
|
+
`Total symmetry operations that map the crystal structure onto itself. Includes rotations, translations, and combinations.`,
|
|
75
|
+
distinct_orbits:
|
|
76
|
+
`Number of unique Wyckoff positions (symmetry-equivalent atomic sites) in the crystal structure.`,
|
|
35
77
|
translations: `Number of translations in the crystal structure.`,
|
|
36
78
|
rotations: `Number of rotations in the crystal structure.`,
|
|
37
79
|
roto_translations: `Number of roto-translations in the crystal structure.`,
|
|
38
|
-
}
|
|
39
|
-
const tooltips = $derived(show_tooltips ? titles : {})
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const exponent = Math.floor(Math.log10(value))
|
|
44
|
-
return Math.pow(10, exponent)
|
|
45
|
-
}
|
|
46
|
-
|
|
80
|
+
}
|
|
81
|
+
const tooltips: Record<string, string> = $derived(show_tooltips ? titles : {})
|
|
82
|
+
|
|
83
|
+
function get_step_from_order_of_magnitude(value: number): number {
|
|
84
|
+
if (!Number.isFinite(value) || value <= 0) return 1e-5
|
|
85
|
+
const exponent = Math.floor(Math.log10(value))
|
|
86
|
+
return Math.pow(10, exponent)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const symprec_step = $derived(get_step_from_order_of_magnitude(settings.symprec))
|
|
47
90
|
</script>
|
|
48
91
|
|
|
49
92
|
<div {...rest} class="symmetry-stats {rest.class ?? ``}">
|
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { contrast_color } from '../colors'
|
|
3
|
+
import { format_fractional } from '../labels'
|
|
4
|
+
import { colors } from '../state.svelte'
|
|
5
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
6
|
+
import type { WyckoffPos } from '.'
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
wyckoff_positions,
|
|
10
|
+
on_hover,
|
|
11
|
+
on_click,
|
|
12
|
+
active_color = `#2563eb`,
|
|
13
|
+
...rest
|
|
14
|
+
}: HTMLAttributes<HTMLTableElement> & {
|
|
15
|
+
wyckoff_positions: WyckoffPos[]
|
|
16
|
+
on_hover?: (site_indices: number[] | null) => void
|
|
17
|
+
on_click?: (site_indices: number[] | null) => void
|
|
18
|
+
active_color?: string
|
|
19
|
+
} = $props()
|
|
20
|
+
|
|
21
|
+
let selected_key = $state<string | null>(null)
|
|
22
|
+
|
|
23
|
+
const get_row_key = (wyckoff_pos: WyckoffPos, row_idx: number) =>
|
|
24
|
+
`${wyckoff_pos.wyckoff}-${wyckoff_pos.elem}-${
|
|
25
|
+
wyckoff_pos.site_indices?.join(`,`) ?? `none`
|
|
26
|
+
}-${row_idx}`
|
|
7
27
|
</script>
|
|
8
28
|
|
|
9
29
|
{#if wyckoff_positions && wyckoff_positions.length > 0}
|
|
@@ -19,7 +19,7 @@ original_structure) {
|
|
|
19
19
|
];
|
|
20
20
|
// Calculate lattice parameters from matrix
|
|
21
21
|
const lattice_params = math.calc_lattice_params(lattice_matrix);
|
|
22
|
-
const
|
|
22
|
+
const frac_to_cart = math.create_frac_to_cart(lattice_matrix);
|
|
23
23
|
// Build sites from positions and atomic numbers
|
|
24
24
|
const sites = cell.positions.map((abc, idx) => {
|
|
25
25
|
const atomic_number = cell.numbers[idx];
|
|
@@ -29,8 +29,7 @@ original_structure) {
|
|
|
29
29
|
}
|
|
30
30
|
// Wrap fractional coordinates to [0, 1) range (moyo-wasm may return outside)
|
|
31
31
|
const wrapped_abc = wrap_to_unit_cell(abc);
|
|
32
|
-
|
|
33
|
-
const xyz = math.mat3x3_vec3_multiply(lattice_T, wrapped_abc);
|
|
32
|
+
const xyz = frac_to_cart(wrapped_abc);
|
|
34
33
|
// Oxidation state is set to 0 (unknown) because moyo-wasm only provides atomic numbers.
|
|
35
34
|
// transformed cell may have different/reordered sites, making it non-trivial to
|
|
36
35
|
// map oxidation states from original structure.
|
|
@@ -48,12 +47,14 @@ original_structure) {
|
|
|
48
47
|
// The conventional cell is the standard crystallographic setting for the space group.
|
|
49
48
|
export function get_conventional_cell(original_structure, // The original input structure
|
|
50
49
|
sym_data) {
|
|
50
|
+
// The conventional cell as a Crystal
|
|
51
51
|
return moyo_cell_to_structure(sym_data.std_cell, original_structure);
|
|
52
52
|
}
|
|
53
53
|
// Get the primitive cell from symmetry analysis data.
|
|
54
54
|
// The primitive cell is the smallest unit cell with one lattice point.
|
|
55
55
|
export function get_primitive_cell(original_structure, // The original input structure
|
|
56
56
|
sym_data) {
|
|
57
|
+
// The primitive cell as a Crystal
|
|
57
58
|
return moyo_cell_to_structure(sym_data.prim_std_cell, original_structure);
|
|
58
59
|
}
|
|
59
60
|
// Transform a structure based on the selected cell type.
|
|
@@ -61,6 +62,7 @@ sym_data) {
|
|
|
61
62
|
export function transform_cell(structure, // The original structure
|
|
62
63
|
cell_type, // The desired cell type ('original', 'conventional', or 'primitive')
|
|
63
64
|
sym_data) {
|
|
65
|
+
//transformed structure (or original if no transformation needed)
|
|
64
66
|
if (cell_type === `original` || !sym_data) {
|
|
65
67
|
return structure;
|
|
66
68
|
}
|
package/dist/symmetry/index.js
CHANGED
|
@@ -38,8 +38,7 @@ function get_site_atomic_number(site, site_idx) {
|
|
|
38
38
|
continue;
|
|
39
39
|
occupancy_by_element.set(element, (occupancy_by_element.get(element) ?? 0) + occu);
|
|
40
40
|
}
|
|
41
|
-
let selected_element = site
|
|
42
|
-
.species[0]?.element;
|
|
41
|
+
let selected_element = site.species[0]?.element;
|
|
43
42
|
let best_occupancy = -Infinity;
|
|
44
43
|
occupancy_by_element.forEach((occupancy, element) => {
|
|
45
44
|
if (occupancy > best_occupancy ||
|
|
@@ -49,11 +48,11 @@ function get_site_atomic_number(site, site_idx) {
|
|
|
49
48
|
}
|
|
50
49
|
});
|
|
51
50
|
if (selected_element === undefined) {
|
|
52
|
-
throw new Error(`Unknown element at site ${site_idx}: ${
|
|
51
|
+
throw new Error(`Unknown element at site ${site_idx}: ${selected_element}`);
|
|
53
52
|
}
|
|
54
53
|
const atomic_number = SYMBOL_TO_ATOMIC_NUMBER[selected_element];
|
|
55
54
|
if (atomic_number === undefined) {
|
|
56
|
-
throw new Error(`Unknown element at site ${site_idx}: ${
|
|
55
|
+
throw new Error(`Unknown element at site ${site_idx}: ${selected_element}`);
|
|
57
56
|
}
|
|
58
57
|
return atomic_number;
|
|
59
58
|
}
|
|
@@ -122,7 +121,9 @@ export function simplicity_score(vec) {
|
|
|
122
121
|
const near_zero = (v) => Math.min(v, 1 - v);
|
|
123
122
|
const near_half = (v) => Math.abs(v - 0.5);
|
|
124
123
|
const [ax, ay, az] = vec?.map(to_unit) ?? [];
|
|
125
|
-
return (near_zero(ax) +
|
|
124
|
+
return (near_zero(ax) +
|
|
125
|
+
near_zero(ay) +
|
|
126
|
+
near_zero(az) +
|
|
126
127
|
0.5 * (near_half(ax) + near_half(ay) + near_half(az)));
|
|
127
128
|
}
|
|
128
129
|
// Generate Wyckoff table rows from symmetry data
|
|
@@ -138,7 +139,7 @@ export function wyckoff_positions_from_moyo(sym_data) {
|
|
|
138
139
|
for (let idx = 0; idx < numbers.length; idx++) {
|
|
139
140
|
// Use wyckoff letter if available, otherwise mark as non-symmetric
|
|
140
141
|
const full = idx < wyckoffs.length ? wyckoffs[idx] : null;
|
|
141
|
-
const letter =
|
|
142
|
+
const letter = full?.match(/[a-z]+$/)?.[0] ?? full ?? ``;
|
|
142
143
|
const atomic_num = numbers[idx];
|
|
143
144
|
const elem = ATOMIC_NUMBER_TO_SYMBOL[atomic_num] ?? `?`;
|
|
144
145
|
const position = positions[idx];
|
|
@@ -206,7 +207,7 @@ export function map_wyckoff_to_all_atoms(wyckoff_positions, displayed_structure,
|
|
|
206
207
|
const periodic_distance = (pos1, pos2) => Math.sqrt(pos1.reduce((sum, coord, idx) => {
|
|
207
208
|
// Wrap delta into [-0.5, 0.5) using safe modulo
|
|
208
209
|
const delta = coord - pos2[idx];
|
|
209
|
-
const wrapped = (((delta + 0.5) % 1) + 1) % 1 - 0.5;
|
|
210
|
+
const wrapped = ((((delta + 0.5) % 1) + 1) % 1) - 0.5;
|
|
210
211
|
const d = Math.abs(wrapped);
|
|
211
212
|
return sum + d * d;
|
|
212
213
|
}, 0));
|