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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as math from '../../math';
|
|
2
|
+
import { create_trajectory_frame, is_valid_element_symbol, validate_3x3_matrix, } from '../helpers';
|
|
3
|
+
export function parse_vasp_xdatcar(content, filename) {
|
|
4
|
+
const lines = content.trim().split(/\r?\n/);
|
|
5
|
+
if (lines.length < 10)
|
|
6
|
+
throw new Error(`XDATCAR file too short`);
|
|
7
|
+
const scale = parseFloat(lines[1]);
|
|
8
|
+
if (isNaN(scale))
|
|
9
|
+
throw new Error(`Invalid scale factor`);
|
|
10
|
+
const lattice_matrix = validate_3x3_matrix(lines.slice(2, 5).map((line) => line.trim().split(/\s+/).map((x) => parseFloat(x) * scale)));
|
|
11
|
+
const element_names = lines[5].trim().split(/\s+/);
|
|
12
|
+
const element_counts = lines[6].trim().split(/\s+/).map(Number);
|
|
13
|
+
if (element_names.length !== element_counts.length) {
|
|
14
|
+
throw new Error(`XDATCAR element names/counts mismatch: names=${element_names.length}, counts=${element_counts.length}`);
|
|
15
|
+
}
|
|
16
|
+
if (element_counts.some((count) => !Number.isFinite(count) || !Number.isInteger(count) || count <= 0)) {
|
|
17
|
+
throw new Error(`XDATCAR contains invalid element counts: expected finite positive integers`);
|
|
18
|
+
}
|
|
19
|
+
const validated_element_names = element_names.map((name) => {
|
|
20
|
+
if (!is_valid_element_symbol(name)) {
|
|
21
|
+
throw new Error(`Invalid element symbol in XDATCAR: ${name}`);
|
|
22
|
+
}
|
|
23
|
+
return name;
|
|
24
|
+
});
|
|
25
|
+
const elements = validated_element_names.flatMap((name, idx) => Array(element_counts[idx]).fill(name));
|
|
26
|
+
const frames = [];
|
|
27
|
+
let line_idx = 7;
|
|
28
|
+
const frac_to_cart = math.create_frac_to_cart(lattice_matrix);
|
|
29
|
+
while (line_idx < lines.length) {
|
|
30
|
+
const config_idx = lines.findIndex((line, idx) => idx >= line_idx && line.includes(`Direct configuration=`));
|
|
31
|
+
if (config_idx === -1)
|
|
32
|
+
break;
|
|
33
|
+
const config_line = lines[config_idx];
|
|
34
|
+
line_idx = config_idx + 1;
|
|
35
|
+
const step_match = config_line.match(/configuration=\s*(\d+)/);
|
|
36
|
+
const step = step_match ? parseInt(step_match[1]) : frames.length + 1;
|
|
37
|
+
const positions = [];
|
|
38
|
+
for (let idx = 0; idx < elements.length && line_idx < lines.length; idx++) {
|
|
39
|
+
const coords = lines[line_idx].trim().split(/\s+/).slice(0, 3).map(Number);
|
|
40
|
+
if (coords.length === 3 && !coords.some(isNaN)) {
|
|
41
|
+
positions.push(frac_to_cart(coords));
|
|
42
|
+
}
|
|
43
|
+
line_idx++;
|
|
44
|
+
}
|
|
45
|
+
if (positions.length === elements.length) {
|
|
46
|
+
const pbc = [true, true, true];
|
|
47
|
+
const { volume } = math.calc_lattice_params(lattice_matrix);
|
|
48
|
+
frames.push(create_trajectory_frame(positions, elements, lattice_matrix, pbc, step, {
|
|
49
|
+
volume,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
frames,
|
|
55
|
+
metadata: {
|
|
56
|
+
filename,
|
|
57
|
+
source_format: `vasp_xdatcar`,
|
|
58
|
+
frame_count: frames.length,
|
|
59
|
+
total_atoms: elements.length,
|
|
60
|
+
periodic_boundary_conditions: [true, true, true],
|
|
61
|
+
elements: element_names,
|
|
62
|
+
element_counts,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as math from '../../math';
|
|
2
|
+
import { coerce_element_symbol, create_trajectory_frame } from '../helpers';
|
|
3
|
+
export function parse_xyz_trajectory(content) {
|
|
4
|
+
const lines = content.trim().split(/\r?\n/);
|
|
5
|
+
const frames = [];
|
|
6
|
+
let line_idx = 0;
|
|
7
|
+
while (line_idx < lines.length) {
|
|
8
|
+
if (!lines[line_idx]?.trim()) {
|
|
9
|
+
line_idx++;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const num_atoms = parseInt(lines[line_idx].trim(), 10);
|
|
13
|
+
if (isNaN(num_atoms) || num_atoms <= 0 || line_idx + num_atoms + 1 >= lines.length) {
|
|
14
|
+
line_idx++;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const comment = lines[++line_idx] || ``;
|
|
18
|
+
const metadata = {};
|
|
19
|
+
// Extract properties efficiently
|
|
20
|
+
const extractors = {
|
|
21
|
+
step: /(?:step|frame|ionic_step)\s*[=:]?\s*(\d+)/i,
|
|
22
|
+
energy: /(?:energy|E|etot|total_energy)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
23
|
+
volume: /(?:volume|vol|V)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
24
|
+
pressure: /(?:pressure|press|P)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
25
|
+
temperature: /(?:temperature|temp|T)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
26
|
+
force_max: /(?:max_force|force_max|fmax)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
27
|
+
bandgap: /(?:bandgap|E_gap|gap)\s*[=:]?\s*([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/i,
|
|
28
|
+
};
|
|
29
|
+
const step_match = extractors.step.exec(comment);
|
|
30
|
+
const step = step_match?.[1] ? parseInt(step_match[1]) : frames.length;
|
|
31
|
+
Object.entries(extractors).forEach(([key, pattern]) => {
|
|
32
|
+
if (key === `step`)
|
|
33
|
+
return;
|
|
34
|
+
const match = pattern.exec(comment);
|
|
35
|
+
if (match)
|
|
36
|
+
metadata[key] = parseFloat(match[1]);
|
|
37
|
+
});
|
|
38
|
+
// Extract lattice matrix
|
|
39
|
+
const lattice_match = comment.match(/Lattice\s*=\s*"([^"]+)"/i);
|
|
40
|
+
let lattice_matrix;
|
|
41
|
+
if (lattice_match) {
|
|
42
|
+
const values = lattice_match[1].split(/\s+/).map(Number);
|
|
43
|
+
if (values.length === 9 && values.every((value) => Number.isFinite(value))) {
|
|
44
|
+
lattice_matrix = [[values[0], values[1], values[2]], [
|
|
45
|
+
values[3],
|
|
46
|
+
values[4],
|
|
47
|
+
values[5],
|
|
48
|
+
], [values[6], values[7], values[8]]];
|
|
49
|
+
metadata.volume = math.calc_lattice_params(lattice_matrix).volume;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Parse atoms
|
|
53
|
+
const positions = [];
|
|
54
|
+
const elements = [];
|
|
55
|
+
const forces = [];
|
|
56
|
+
const has_forces = comment.includes(`forces:R:3`);
|
|
57
|
+
for (let idx = 0; idx < num_atoms; idx++) {
|
|
58
|
+
line_idx++;
|
|
59
|
+
if (line_idx >= lines.length)
|
|
60
|
+
break;
|
|
61
|
+
const parts = lines[line_idx].trim().split(/\s+/);
|
|
62
|
+
if (parts.length >= 4) {
|
|
63
|
+
const x_coord = parseFloat(parts[1]);
|
|
64
|
+
const y_coord = parseFloat(parts[2]);
|
|
65
|
+
const z_coord = parseFloat(parts[3]);
|
|
66
|
+
if (!Number.isFinite(x_coord) || !Number.isFinite(y_coord) ||
|
|
67
|
+
!Number.isFinite(z_coord)) {
|
|
68
|
+
console.warn(`Skipping XYZ atom with invalid coordinates in frame ${frames.length} at line ${line_idx + 1}`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const raw_symbol = parts[0];
|
|
72
|
+
const element_symbol = coerce_element_symbol(raw_symbol);
|
|
73
|
+
if (!element_symbol) {
|
|
74
|
+
console.warn(`Skipping XYZ atom with unknown element symbol "${raw_symbol}" in frame ${frames.length}`);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
elements.push(element_symbol);
|
|
78
|
+
positions.push([x_coord, y_coord, z_coord]);
|
|
79
|
+
if (has_forces && parts.length >= 7) {
|
|
80
|
+
const force_x = parseFloat(parts[4]);
|
|
81
|
+
const force_y = parseFloat(parts[5]);
|
|
82
|
+
const force_z = parseFloat(parts[6]);
|
|
83
|
+
if (Number.isFinite(force_x) &&
|
|
84
|
+
Number.isFinite(force_y) &&
|
|
85
|
+
Number.isFinite(force_z)) {
|
|
86
|
+
forces.push([force_x, force_y, force_z]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (forces.length > 0) {
|
|
92
|
+
metadata.forces = forces;
|
|
93
|
+
const magnitudes = forces.map((force) => Math.hypot(...force));
|
|
94
|
+
metadata.force_max = Math.max(...magnitudes);
|
|
95
|
+
// Calculate RMS (root mean square) of force magnitudes
|
|
96
|
+
metadata.force_norm = Math.sqrt(magnitudes.reduce((sum, mag) => sum + mag ** 2, 0) / magnitudes.length);
|
|
97
|
+
}
|
|
98
|
+
frames.push(create_trajectory_frame(positions, elements, lattice_matrix, lattice_matrix ? [true, true, true] : undefined, step, metadata));
|
|
99
|
+
line_idx++;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
frames,
|
|
103
|
+
metadata: {
|
|
104
|
+
source_format: `xyz_trajectory`,
|
|
105
|
+
frame_count: frames.length,
|
|
106
|
+
total_atoms: frames[0]?.structure.sites.length || 0,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ElementSymbol } from '../element';
|
|
2
|
+
export type AtomTypeMapping = Record<number, ElementSymbol>;
|
|
3
|
+
export interface LoadingOptions {
|
|
4
|
+
use_indexing?: boolean;
|
|
5
|
+
buffer_size?: number;
|
|
6
|
+
index_sample_rate?: number;
|
|
7
|
+
extract_plot_metadata?: boolean;
|
|
8
|
+
bin_file_threshold?: number;
|
|
9
|
+
text_file_threshold?: number;
|
|
10
|
+
atom_type_mapping?: AtomTypeMapping;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare function merge_nested<T extends Record<string, unknown>>(obj1: T, obj2?: Partial<T>): T;
|
|
2
2
|
export declare const escape_html: (unsafe_string: string) => string;
|
|
3
|
+
export declare const normalize_unicode_minus: (value: string) => string;
|
|
4
|
+
export declare const normalize_scientific_notation: (value: string) => string;
|
package/dist/utils.js
CHANGED
|
@@ -17,3 +17,7 @@ export const escape_html = (unsafe_string) => unsafe_string
|
|
|
17
17
|
.replaceAll(`>`, `>`)
|
|
18
18
|
.replaceAll(`"`, `"`)
|
|
19
19
|
.replaceAll(`'`, `'`);
|
|
20
|
+
// Normalize unicode minus (U+2212) to ASCII hyphen-minus.
|
|
21
|
+
export const normalize_unicode_minus = (value) => value.replace(/−/g, `-`);
|
|
22
|
+
// Normalize scientific notation variants (d/D exponent, Mathematica *^).
|
|
23
|
+
export const normalize_scientific_notation = (value) => normalize_unicode_minus(value).toLowerCase().replace(/d/g, `e`).replace(/\*\^/g, `e`);
|
package/dist/xrd/XrdPlot.svelte
CHANGED
|
@@ -10,10 +10,12 @@ import { compute_broadened_pattern, DEFAULT_BROADENING } from './broadening';
|
|
|
10
10
|
function is_xrd_pattern(obj) {
|
|
11
11
|
if (!obj || typeof obj !== `object`)
|
|
12
12
|
return false;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const pattern_obj = obj;
|
|
14
|
+
const x = pattern_obj.x;
|
|
15
|
+
const y = pattern_obj.y;
|
|
16
|
+
return (Array.isArray(x) &&
|
|
17
|
+
Array.isArray(y) &&
|
|
18
|
+
x.length === y.length);
|
|
17
19
|
}
|
|
18
20
|
function format_hkl(hkl, format) {
|
|
19
21
|
if (format === `compact`) {
|
package/dist/xrd/calc-xrd.js
CHANGED
|
@@ -162,7 +162,6 @@ export function compute_xrd_pattern(structure, options = {}) {
|
|
|
162
162
|
if (ELEMENT_Z[element_symbol] === undefined) {
|
|
163
163
|
throw new Error(`Unknown atomic number for element ${element_symbol}`);
|
|
164
164
|
}
|
|
165
|
-
// Cast needed: imported JSON has different type structure than our union type
|
|
166
165
|
const raw_coeff = ATOMIC_SCATTERING_PARAMS[element_symbol];
|
|
167
166
|
if (!raw_coeff) {
|
|
168
167
|
throw new Error(`No atomic scattering coefficients for ${element_symbol}. Extend ATOMIC_SCATTERING_PARAMS.`);
|
package/package.json
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
"homepage": "https://janosh.github.io/matterviz",
|
|
6
6
|
"repository": "https://github.com/janosh/matterviz",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"version": "0.3.
|
|
8
|
+
"version": "0.3.2",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
11
|
+
"node": ">=24"
|
|
12
12
|
},
|
|
13
13
|
"svelte": "./dist/index.js",
|
|
14
14
|
"bugs": "https://github.com/janosh/matterviz/issues",
|
|
@@ -17,15 +17,17 @@
|
|
|
17
17
|
"build": "vite build",
|
|
18
18
|
"preview": "vite preview",
|
|
19
19
|
"test": "vitest --run && playwright test",
|
|
20
|
-
"package": "
|
|
21
|
-
"
|
|
22
|
-
"
|
|
20
|
+
"package-dist-assets": "node scripts/package-dist-assets.mjs",
|
|
21
|
+
"package:dist": "svelte-package && pnpm run package-dist-assets",
|
|
22
|
+
"package": "pnpm run package:dist",
|
|
23
|
+
"prepare": "NODE_OPTIONS=--experimental-strip-types svelte-kit sync && pnpm run package:dist",
|
|
24
|
+
"prepublishOnly": "pnpm run package:dist"
|
|
23
25
|
},
|
|
24
26
|
"dependencies": {
|
|
25
|
-
"@spglib/moyo-wasm": "^0.7.
|
|
26
|
-
"@sveltejs/kit": "
|
|
27
|
-
"@threlte/core": "^8.
|
|
28
|
-
"@threlte/extras": "^9.
|
|
27
|
+
"@spglib/moyo-wasm": "^0.7.9",
|
|
28
|
+
"@sveltejs/kit": "2.53.4",
|
|
29
|
+
"@threlte/core": "^8.4.1",
|
|
30
|
+
"@threlte/extras": "^9.8.1",
|
|
29
31
|
"@types/d3-force": "^3.0.10",
|
|
30
32
|
"@types/d3-hierarchy": "^3.1.7",
|
|
31
33
|
"@types/js-yaml": "^4.0.9",
|
|
@@ -40,17 +42,18 @@
|
|
|
40
42
|
"d3-scale-chromatic": "^3.1.0",
|
|
41
43
|
"d3-shape": "^3.2.0",
|
|
42
44
|
"fflate": "^0.8.2",
|
|
43
|
-
"h5wasm": "^0.
|
|
45
|
+
"h5wasm": "^0.9.0",
|
|
44
46
|
"highlight.js": "^11.11.1",
|
|
45
47
|
"js-yaml": "^4.1.1",
|
|
46
|
-
"svelte": "5.
|
|
47
|
-
"svelte-multiselect": "^11.6.
|
|
48
|
-
"
|
|
48
|
+
"svelte": "5.52.0",
|
|
49
|
+
"svelte-multiselect": "^11.6.2",
|
|
50
|
+
"svelte-toc": "^0.6.3",
|
|
51
|
+
"three": "^0.183.2"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
|
-
"@playwright/test": "^1.58.
|
|
54
|
+
"@playwright/test": "^1.58.2",
|
|
52
55
|
"@rollup/plugin-yaml": "^4.1.2",
|
|
53
|
-
"@stylistic/eslint-plugin": "^5.
|
|
56
|
+
"@stylistic/eslint-plugin": "^5.9.0",
|
|
54
57
|
"@sveltejs/adapter-static": "3.0.10",
|
|
55
58
|
"@sveltejs/package": "^2.5.7",
|
|
56
59
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
@@ -62,23 +65,26 @@
|
|
|
62
65
|
"@types/d3-scale-chromatic": "^3.1.0",
|
|
63
66
|
"@types/d3-shape": "^3.1.8",
|
|
64
67
|
"@types/d3-time-format": "^4.0.3",
|
|
65
|
-
"@types/three": "^0.
|
|
68
|
+
"@types/three": "^0.183.1",
|
|
69
|
+
"@typescript/native-preview": "7.0.0-dev.20260304.1",
|
|
66
70
|
"@vitest/coverage-v8": "^4.0.18",
|
|
67
71
|
"@wooorm/starry-night": "^3.9.0",
|
|
68
72
|
"abstract-syntax-tree": "^2.22.0",
|
|
69
73
|
"d3-time-format": "^4.1.0",
|
|
70
|
-
"eslint": "^
|
|
71
|
-
"eslint-plugin-svelte": "^3.
|
|
72
|
-
"happy-dom": "^20.
|
|
73
|
-
"matterviz-wasm": "^0.0.
|
|
74
|
+
"eslint": "^10.0.2",
|
|
75
|
+
"eslint-plugin-svelte": "^3.15.0",
|
|
76
|
+
"happy-dom": "^20.8.3",
|
|
77
|
+
"matterviz-wasm": "^0.0.7",
|
|
74
78
|
"mdsvex": "^0.12.6",
|
|
75
79
|
"rehype-katex": "^7.0.1",
|
|
76
80
|
"remark-math": "3.0.1",
|
|
77
|
-
"svelte-check-rs": "0.
|
|
81
|
+
"svelte-check-rs": "0.9.5",
|
|
78
82
|
"svelte-preprocess": "^6.0.3",
|
|
79
|
-
"svelte2tsx": "^0.7.
|
|
83
|
+
"svelte2tsx": "^0.7.51",
|
|
84
|
+
"typedoc": "^0.28.17",
|
|
85
|
+
"typedoc-plugin-markdown": "^4.10.0",
|
|
80
86
|
"typescript": "5.9.3",
|
|
81
|
-
"typescript-eslint": "^8.
|
|
87
|
+
"typescript-eslint": "^8.56.1",
|
|
82
88
|
"vite": "^7.3.1",
|
|
83
89
|
"vitest": "^4.0.18"
|
|
84
90
|
},
|
|
@@ -115,6 +121,10 @@
|
|
|
115
121
|
"types": "./dist/composition/index.d.ts",
|
|
116
122
|
"default": "./dist/composition/index.js"
|
|
117
123
|
},
|
|
124
|
+
"./chempot-diagram": {
|
|
125
|
+
"types": "./dist/chempot-diagram/index.d.ts",
|
|
126
|
+
"default": "./dist/chempot-diagram/index.js"
|
|
127
|
+
},
|
|
118
128
|
"./colors": {
|
|
119
129
|
"types": "./dist/colors/index.d.ts",
|
|
120
130
|
"default": "./dist/colors/index.js"
|
package/readme.md
CHANGED
|
@@ -55,7 +55,7 @@ Rich element pages with physical properties, electron configurations, Bohr atom
|
|
|
55
55
|
## 🔨   Installation
|
|
56
56
|
|
|
57
57
|
```sh
|
|
58
|
-
|
|
58
|
+
pnpm add -D matterviz
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
## 📙   Usage
|
|
@@ -114,10 +114,10 @@ npm install --dev matterviz
|
|
|
114
114
|
|
|
115
115
|
## 🙏   Acknowledgements
|
|
116
116
|
|
|
117
|
-
- Element properties in `src/lib/element
|
|
117
|
+
- Element properties in `src/lib/element/data.ts` were combined from [`Bowserinator/Periodic-Table-JSON`](https://github.com/Bowserinator/Periodic-Table-JSON/blob/master/PeriodicTableJSON.json) under Creative Commons license and [`robertwb/Periodic Table of Elements.csv`](https://gist.github.com/robertwb/22aa4dbfb6bcecd94f2176caa912b952) (unlicensed).
|
|
118
118
|
- Thanks to [Images of Elements](https://images-of-elements.com) for providing photos of elemental crystals and glowing excited gases.
|
|
119
119
|
- Thanks to [@kadinzhang](https://github.com/kadinzhang) and their [Periodicity project](https://ptable.netlify.app) [[code](https://github.com/kadinzhang/Periodicity)] for the idea to display animated Bohr model atoms and inset a scatter plot into the periodic table to visualize the periodic nature of elemental properties.
|
|
120
|
-
- Big thanks to all sources of element images. See [`fetch-elem-images.ts`](https://github.com/janosh/matterviz/blob/-/src/fetch-elem-images.ts) and [`static/elements`](https://github.com/janosh/matterviz/tree/main/static/elements).
|
|
120
|
+
- Big thanks to all sources of element images. See [`fetch-elem-images.ts`](https://github.com/janosh/matterviz/blob/-/src/scripts/fetch-elem-images.ts) and [`static/elements`](https://github.com/janosh/matterviz/tree/main/static/elements).
|
|
121
121
|
- Thanks to [@ixxie](https://github.com/ixxie) ([shenhav.fyi](https://shenhav.fyi)) for great suggestions.
|
|
122
122
|
|
|
123
123
|
This project would not have been possible as a one-person side project without many fine open-source projects. 🙏 To name just a few:
|
|
@@ -141,6 +141,6 @@ Use [`citation.cff`](citation.cff) or cite the [Zenodo record](https://zenodo.or
|
|
|
141
141
|
url = {https://github.com/janosh/matterviz},
|
|
142
142
|
note = {10.5281/zenodo.17094509 - https://github.com/janosh/matterviz},
|
|
143
143
|
urldate = {2026-01-23}, % optional, replace with your date of access
|
|
144
|
-
version = {0.
|
|
144
|
+
version = {0.3.1}, % replace with the version you use
|
|
145
145
|
}
|
|
146
146
|
```
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { ElementSymbol } from '../element';
|
|
2
|
-
import type { FrameIndex, FrameLoader, ParseProgress, TrajectoryFrame, TrajectoryMetadata, TrajectoryType } from './index';
|
|
3
|
-
export declare const MAX_SAFE_STRING_LENGTH: number;
|
|
4
|
-
export declare const MAX_METADATA_SIZE: number;
|
|
5
|
-
export declare const LARGE_FILE_THRESHOLD: number;
|
|
6
|
-
export declare const INDEX_SAMPLE_RATE = 100;
|
|
7
|
-
export declare const MAX_BIN_FILE_SIZE: number;
|
|
8
|
-
export declare const MAX_TEXT_FILE_SIZE: number;
|
|
9
|
-
export type AtomTypeMapping = Record<number, ElementSymbol>;
|
|
10
|
-
export interface LoadingOptions {
|
|
11
|
-
use_indexing?: boolean;
|
|
12
|
-
buffer_size?: number;
|
|
13
|
-
index_sample_rate?: number;
|
|
14
|
-
extract_plot_metadata?: boolean;
|
|
15
|
-
bin_file_threshold?: number;
|
|
16
|
-
text_file_threshold?: number;
|
|
17
|
-
atom_type_mapping?: AtomTypeMapping;
|
|
18
|
-
}
|
|
19
|
-
export declare function is_trajectory_file(filename: string, content?: string): boolean;
|
|
20
|
-
export declare class TrajFrameReader implements FrameLoader {
|
|
21
|
-
private format;
|
|
22
|
-
private global_numbers?;
|
|
23
|
-
constructor(filename: string);
|
|
24
|
-
get_total_frames(data: string | ArrayBuffer): Promise<number>;
|
|
25
|
-
build_frame_index(data: string | ArrayBuffer, sample_rate: number, on_progress?: (progress: ParseProgress) => void): Promise<FrameIndex[]>;
|
|
26
|
-
load_frame(data: string | ArrayBuffer, frame_number: number): Promise<TrajectoryFrame | null>;
|
|
27
|
-
extract_plot_metadata(data: string | ArrayBuffer, options?: {
|
|
28
|
-
sample_rate?: number;
|
|
29
|
-
properties?: string[];
|
|
30
|
-
}, on_progress?: (progress: ParseProgress) => void): Promise<TrajectoryMetadata[]>;
|
|
31
|
-
private load_xyz_frame;
|
|
32
|
-
private load_ase_frame;
|
|
33
|
-
private parse_xyz_metadata;
|
|
34
|
-
private parse_ase_metadata;
|
|
35
|
-
}
|
|
36
|
-
export declare function parse_trajectory_data(data: unknown, filename?: string, atom_type_mapping?: AtomTypeMapping): Promise<TrajectoryType>;
|
|
37
|
-
export declare function get_unsupported_format_message(filename: string, content: string): string | null;
|
|
38
|
-
export declare function parse_trajectory_async(data: ArrayBuffer | string, filename: string, on_progress?: (progress: ParseProgress) => void, options?: LoadingOptions): Promise<TrajectoryType>;
|
|
39
|
-
export declare function create_frame_loader(filename: string): FrameLoader;
|
|
40
|
-
export declare const XYZFrameLoader: typeof TrajFrameReader;
|
|
41
|
-
export declare const ASEFrameLoader: typeof TrajFrameReader;
|
|
42
|
-
export declare function load_binary_traj(resp: Response, type: string, fallback?: boolean): Promise<ArrayBuffer | string>;
|