matterviz 0.3.7 → 0.4.0
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/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +1 -1
- package/dist/api/optimade.js +32 -26
- package/dist/app.css +0 -3
- package/dist/brillouin/BrillouinZone.svelte +8 -3
- package/dist/brillouin/BrillouinZone.svelte.d.ts +2 -1
- package/dist/brillouin/BrillouinZoneScene.svelte +52 -6
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -0
- package/dist/brillouin/BrillouinZoneTooltip.svelte +16 -25
- package/dist/brillouin/compute.js +10 -14
- package/dist/chempot-diagram/ChemPotDiagram.svelte +14 -13
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +12 -15
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +8 -10
- package/dist/chempot-diagram/async-compute.svelte.js +3 -1
- package/dist/chempot-diagram/chempot-worker.js +2 -1
- package/dist/chempot-diagram/compute.d.ts +1 -1
- package/dist/chempot-diagram/compute.js +17 -19
- package/dist/colors/index.js +6 -5
- package/dist/composition/FormulaFilter.svelte +12 -6
- package/dist/composition/PieChart.svelte +6 -5
- package/dist/composition/chem-sys.d.ts +8 -0
- package/dist/composition/chem-sys.js +85 -0
- package/dist/composition/format.js +4 -2
- package/dist/composition/index.d.ts +1 -0
- package/dist/composition/index.js +1 -0
- package/dist/composition/parse.js +25 -13
- package/dist/convex-hull/ConvexHull2D.svelte +12 -10
- package/dist/convex-hull/ConvexHull3D.svelte +5 -5
- package/dist/convex-hull/ConvexHull4D.svelte +5 -9
- package/dist/convex-hull/ConvexHullStats.svelte +12 -12
- package/dist/convex-hull/GasPressureControls.svelte +4 -4
- package/dist/convex-hull/TemperatureSlider.svelte +2 -2
- package/dist/convex-hull/demo-temperature.d.ts +1 -1
- package/dist/convex-hull/demo-temperature.js +20 -22
- package/dist/convex-hull/gas-thermodynamics.d.ts +2 -2
- package/dist/convex-hull/gas-thermodynamics.js +22 -30
- package/dist/convex-hull/helpers.d.ts +3 -0
- package/dist/convex-hull/helpers.js +17 -9
- package/dist/convex-hull/index.d.ts +1 -1
- package/dist/convex-hull/thermodynamics.js +83 -78
- package/dist/convex-hull/types.d.ts +1 -1
- package/dist/coordination/CoordinationBarPlot.svelte +23 -23
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSlice.svelte +13 -5
- package/dist/fermi-surface/FermiSurface.svelte +11 -5
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +3 -0
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +8 -34
- package/dist/fermi-surface/compute.js +59 -59
- package/dist/fermi-surface/export.js +3 -2
- package/dist/fermi-surface/parse.js +7 -4
- package/dist/fermi-surface/types.d.ts +1 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +23 -21
- package/dist/heatmap-matrix/index.js +1 -1
- package/dist/io/decompress.js +4 -2
- package/dist/io/export.d.ts +4 -4
- package/dist/io/export.js +47 -25
- package/dist/io/fetch.js +5 -1
- package/dist/io/file-drop.d.ts +1 -1
- package/dist/io/file-drop.js +35 -36
- package/dist/io/url-drop.js +64 -33
- package/dist/isosurface/parse.js +6 -7
- package/dist/isosurface/slice.js +5 -4
- package/dist/isosurface/types.js +1 -1
- package/dist/keyboard.d.ts +3 -0
- package/dist/keyboard.js +23 -0
- package/dist/labels.d.ts +1 -1
- package/dist/labels.js +8 -7
- package/dist/layout/PropertyFilter.svelte +3 -2
- package/dist/layout/SettingsSection.svelte +1 -1
- package/dist/layout/json-tree/JsonNode.svelte +1 -1
- package/dist/layout/json-tree/JsonTree.svelte +2 -2
- package/dist/layout/json-tree/utils.js +5 -4
- package/dist/marching-cubes.js +8 -13
- package/dist/math.d.ts +5 -1
- package/dist/math.js +24 -9
- package/dist/overlays/DraggablePane.svelte +4 -4
- package/dist/periodic-table/PeriodicTable.svelte +20 -9
- package/dist/periodic-table/PropertySelect.svelte +1 -0
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +9 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +1 -1
- package/dist/phase-diagram/build-diagram.js +2 -2
- package/dist/phase-diagram/parse.js +6 -5
- package/dist/phase-diagram/types.d.ts +1 -1
- package/dist/phase-diagram/utils.d.ts +3 -3
- package/dist/phase-diagram/utils.js +8 -12
- package/dist/plot/{BarPlot.svelte → bar/BarPlot.svelte} +229 -587
- package/dist/plot/{BarPlot.svelte.d.ts → bar/BarPlot.svelte.d.ts} +5 -5
- package/dist/plot/{BarPlotControls.svelte → bar/BarPlotControls.svelte} +6 -5
- package/dist/plot/{BarPlotControls.svelte.d.ts → bar/BarPlotControls.svelte.d.ts} +3 -3
- package/dist/plot/{SpacegroupBarPlot.svelte → bar/SpacegroupBarPlot.svelte} +6 -6
- package/dist/plot/{SpacegroupBarPlot.svelte.d.ts → bar/SpacegroupBarPlot.svelte.d.ts} +1 -1
- package/dist/plot/bar/data.d.ts +40 -0
- package/dist/plot/bar/data.js +154 -0
- package/dist/plot/bar/geometry.d.ts +39 -0
- package/dist/plot/bar/geometry.js +60 -0
- package/dist/plot/bar/index.d.ts +3 -0
- package/dist/plot/bar/index.js +3 -0
- package/dist/plot/box/BoxPlot.svelte +1462 -0
- package/dist/plot/box/BoxPlot.svelte.d.ts +94 -0
- package/dist/plot/box/BoxPlotControls.svelte +109 -0
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +19 -0
- package/dist/plot/box/Violin.svelte +14 -0
- package/dist/plot/box/Violin.svelte.d.ts +70 -0
- package/dist/plot/box/box-plot.d.ts +55 -0
- package/dist/plot/box/box-plot.js +126 -0
- package/dist/plot/box/index.d.ts +5 -0
- package/dist/plot/box/index.js +5 -0
- package/dist/plot/box/kde.d.ts +16 -0
- package/dist/plot/box/kde.js +160 -0
- package/dist/plot/box/quantile.d.ts +3 -0
- package/dist/plot/box/quantile.js +53 -0
- package/dist/plot/{auto-place.js → core/auto-place.js} +2 -2
- package/dist/plot/core/axis-utils.d.ts +46 -0
- package/dist/plot/core/axis-utils.js +110 -0
- package/dist/plot/{AxisLabel.svelte → core/components/AxisLabel.svelte} +2 -2
- package/dist/plot/{AxisLabel.svelte.d.ts → core/components/AxisLabel.svelte.d.ts} +1 -1
- package/dist/plot/{ColorBar.svelte → core/components/ColorBar.svelte} +36 -33
- package/dist/plot/{ColorBar.svelte.d.ts → core/components/ColorBar.svelte.d.ts} +2 -2
- package/dist/plot/{ColorScaleSelect.svelte → core/components/ColorScaleSelect.svelte} +4 -3
- package/dist/plot/{ColorScaleSelect.svelte.d.ts → core/components/ColorScaleSelect.svelte.d.ts} +2 -2
- package/dist/plot/core/components/ControlPane.svelte +46 -0
- package/dist/plot/core/components/ControlPane.svelte.d.ts +13 -0
- package/dist/plot/{FillArea.svelte → core/components/FillArea.svelte} +17 -6
- package/dist/plot/{FillArea.svelte.d.ts → core/components/FillArea.svelte.d.ts} +1 -1
- package/dist/plot/{InteractiveAxisLabel.svelte → core/components/InteractiveAxisLabel.svelte} +3 -3
- package/dist/plot/{InteractiveAxisLabel.svelte.d.ts → core/components/InteractiveAxisLabel.svelte.d.ts} +2 -2
- package/dist/plot/{Line.svelte → core/components/Line.svelte} +30 -13
- package/dist/plot/{PlotAxis.svelte → core/components/PlotAxis.svelte} +7 -5
- package/dist/plot/{PlotAxis.svelte.d.ts → core/components/PlotAxis.svelte.d.ts} +3 -2
- package/dist/plot/{PlotControls.svelte → core/components/PlotControls.svelte} +17 -29
- package/dist/plot/core/components/PlotControls.svelte.d.ts +4 -0
- package/dist/plot/{PlotLegend.svelte → core/components/PlotLegend.svelte} +21 -10
- package/dist/plot/{PlotLegend.svelte.d.ts → core/components/PlotLegend.svelte.d.ts} +3 -2
- package/dist/plot/{PlotTooltip.svelte → core/components/PlotTooltip.svelte} +17 -1
- package/dist/plot/{PlotTooltip.svelte.d.ts → core/components/PlotTooltip.svelte.d.ts} +8 -0
- package/dist/plot/{PortalSelect.svelte → core/components/PortalSelect.svelte} +11 -7
- package/dist/plot/{ReferenceLine.svelte → core/components/ReferenceLine.svelte} +3 -3
- package/dist/plot/{ReferenceLine.svelte.d.ts → core/components/ReferenceLine.svelte.d.ts} +1 -1
- package/dist/plot/{ReferenceLine3D.svelte → core/components/ReferenceLine3D.svelte} +4 -4
- package/dist/plot/{ReferenceLine3D.svelte.d.ts → core/components/ReferenceLine3D.svelte.d.ts} +2 -2
- package/dist/plot/{ReferencePlane.svelte → core/components/ReferencePlane.svelte} +7 -7
- package/dist/plot/{ReferencePlane.svelte.d.ts → core/components/ReferencePlane.svelte.d.ts} +2 -2
- package/dist/plot/{ZeroLines.svelte → core/components/ZeroLines.svelte} +3 -3
- package/dist/plot/{ZeroLines.svelte.d.ts → core/components/ZeroLines.svelte.d.ts} +3 -3
- package/dist/plot/{ZoomRect.svelte → core/components/ZoomRect.svelte} +1 -1
- package/dist/plot/{ZoomRect.svelte.d.ts → core/components/ZoomRect.svelte.d.ts} +1 -1
- package/dist/plot/core/components/index.d.ts +17 -0
- package/dist/plot/core/components/index.js +17 -0
- package/dist/plot/{data-cleaning.d.ts → core/data-cleaning.d.ts} +71 -1
- package/dist/plot/{data-cleaning.js → core/data-cleaning.js} +3 -5
- package/dist/plot/{data-transform.d.ts → core/data-transform.d.ts} +2 -2
- package/dist/plot/{data-transform.js → core/data-transform.js} +3 -3
- package/dist/plot/core/fill-utils.d.ts +33 -0
- package/dist/plot/core/fill-utils.js +388 -0
- package/dist/plot/{hover-lock.svelte.js → core/hover-lock.svelte.js} +5 -6
- package/dist/plot/core/index.d.ts +10 -0
- package/dist/plot/core/index.js +11 -0
- package/dist/plot/core/interactions.d.ts +35 -0
- package/dist/plot/core/interactions.js +195 -0
- package/dist/plot/{layout.d.ts → core/layout.d.ts} +1 -0
- package/dist/plot/{layout.js → core/layout.js} +16 -8
- package/dist/plot/{reference-line.d.ts → core/reference-line.d.ts} +1 -1
- package/dist/plot/{reference-line.js → core/reference-line.js} +23 -36
- package/dist/plot/{scales.d.ts → core/scales.d.ts} +2 -2
- package/dist/plot/{scales.js → core/scales.js} +84 -85
- package/dist/plot/core/svg.d.ts +2 -0
- package/dist/plot/core/svg.js +41 -0
- package/dist/plot/{types.d.ts → core/types.d.ts} +19 -79
- package/dist/plot/{types.js → core/types.js} +1 -1
- package/dist/plot/{utils → core/utils}/label-placement.d.ts +2 -2
- package/dist/plot/core/utils/series-visibility.d.ts +26 -0
- package/dist/plot/{utils → core/utils}/series-visibility.js +29 -2
- package/dist/plot/core/utils.d.ts +11 -0
- package/dist/plot/core/utils.js +27 -0
- package/dist/plot/{Histogram.svelte → histogram/Histogram.svelte} +154 -294
- package/dist/plot/{Histogram.svelte.d.ts → histogram/Histogram.svelte.d.ts} +2 -2
- package/dist/plot/{HistogramControls.svelte → histogram/HistogramControls.svelte} +6 -6
- package/dist/plot/{HistogramControls.svelte.d.ts → histogram/HistogramControls.svelte.d.ts} +4 -4
- package/dist/plot/histogram/index.d.ts +2 -0
- package/dist/plot/histogram/index.js +2 -0
- package/dist/plot/index.d.ts +8 -41
- package/dist/plot/index.js +10 -39
- package/dist/plot/sankey/Sankey.svelte +700 -0
- package/dist/plot/sankey/Sankey.svelte.d.ts +74 -0
- package/dist/plot/sankey/SankeyControls.svelte +98 -0
- package/dist/plot/sankey/SankeyControls.svelte.d.ts +19 -0
- package/dist/plot/sankey/index.d.ts +4 -0
- package/dist/plot/sankey/index.js +3 -0
- package/dist/plot/sankey/sankey-types.d.ts +42 -0
- package/dist/plot/sankey/sankey-types.js +4 -0
- package/dist/plot/sankey/sankey.d.ts +52 -0
- package/dist/plot/sankey/sankey.js +187 -0
- package/dist/plot/{BinnedScatterPlot.svelte → scatter/BinnedScatterPlot.svelte} +61 -59
- package/dist/plot/{BinnedScatterPlot.svelte.d.ts → scatter/BinnedScatterPlot.svelte.d.ts} +4 -4
- package/dist/plot/{ElementScatter.svelte → scatter/ElementScatter.svelte} +6 -6
- package/dist/plot/{ElementScatter.svelte.d.ts → scatter/ElementScatter.svelte.d.ts} +2 -2
- package/dist/plot/{ScatterPlot.svelte → scatter/ScatterPlot.svelte} +221 -642
- package/dist/plot/{ScatterPlot.svelte.d.ts → scatter/ScatterPlot.svelte.d.ts} +7 -7
- package/dist/plot/{ScatterPlotControls.svelte → scatter/ScatterPlotControls.svelte} +6 -5
- package/dist/plot/{ScatterPlotControls.svelte.d.ts → scatter/ScatterPlotControls.svelte.d.ts} +1 -1
- package/dist/plot/{ScatterPoint.svelte → scatter/ScatterPoint.svelte} +7 -7
- package/dist/plot/{ScatterPoint.svelte.d.ts → scatter/ScatterPoint.svelte.d.ts} +3 -3
- package/dist/plot/{adaptive-density.d.ts → scatter/adaptive-density.d.ts} +14 -4
- package/dist/plot/{adaptive-density.js → scatter/adaptive-density.js} +46 -20
- package/dist/plot/{binned-scatter-types.d.ts → scatter/binned-scatter-types.d.ts} +3 -3
- package/dist/plot/scatter/index.d.ts +7 -0
- package/dist/plot/scatter/index.js +5 -0
- package/dist/plot/scatter/scatter-data.d.ts +19 -0
- package/dist/plot/scatter/scatter-data.js +212 -0
- package/dist/plot/{ScatterPlot3D.svelte → scatter-3d/ScatterPlot3D.svelte} +12 -10
- package/dist/plot/{ScatterPlot3D.svelte.d.ts → scatter-3d/ScatterPlot3D.svelte.d.ts} +7 -7
- package/dist/plot/{ScatterPlot3DControls.svelte → scatter-3d/ScatterPlot3DControls.svelte} +5 -4
- package/dist/plot/{ScatterPlot3DControls.svelte.d.ts → scatter-3d/ScatterPlot3DControls.svelte.d.ts} +2 -2
- package/dist/plot/{ScatterPlot3DScene.svelte → scatter-3d/ScatterPlot3DScene.svelte} +11 -11
- package/dist/plot/{ScatterPlot3DScene.svelte.d.ts → scatter-3d/ScatterPlot3DScene.svelte.d.ts} +3 -3
- package/dist/plot/{Surface3D.svelte → scatter-3d/Surface3D.svelte} +1 -1
- package/dist/plot/{Surface3D.svelte.d.ts → scatter-3d/Surface3D.svelte.d.ts} +1 -1
- package/dist/plot/scatter-3d/index.d.ts +4 -0
- package/dist/plot/scatter-3d/index.js +4 -0
- package/dist/plot/sunburst/Sunburst.svelte +1045 -0
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +96 -0
- package/dist/plot/sunburst/SunburstControls.svelte +200 -0
- package/dist/plot/sunburst/SunburstControls.svelte.d.ts +26 -0
- package/dist/plot/sunburst/index.d.ts +4 -0
- package/dist/plot/sunburst/index.js +4 -0
- package/dist/plot/sunburst/render.d.ts +34 -0
- package/dist/plot/sunburst/render.js +122 -0
- package/dist/plot/sunburst/sunburst.d.ts +62 -0
- package/dist/plot/sunburst/sunburst.js +266 -0
- package/dist/rdf/RdfPlot.svelte +2 -1
- package/dist/rdf/calc-rdf.js +11 -24
- package/dist/sanitize.js +1 -1
- package/dist/settings.d.ts +65 -1
- package/dist/settings.js +262 -0
- package/dist/spectral/Bands.svelte +39 -29
- package/dist/spectral/Bands.svelte.d.ts +3 -4
- package/dist/spectral/BandsAndDos.svelte +1 -1
- package/dist/spectral/BrillouinBandsDos.svelte +39 -27
- package/dist/spectral/Dos.svelte +10 -19
- package/dist/spectral/Dos.svelte.d.ts +2 -2
- package/dist/spectral/helpers.d.ts +3 -1
- package/dist/spectral/helpers.js +95 -29
- package/dist/structure/AtomLegend.svelte +8 -9
- package/dist/structure/CellSelect.svelte +1 -2
- package/dist/structure/Cylinder.svelte +12 -8
- package/dist/structure/Cylinder.svelte.d.ts +4 -1
- package/dist/structure/Structure.svelte +78 -72
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +5 -6
- package/dist/structure/StructureScene.svelte +11 -10
- package/dist/structure/atom-properties.js +6 -6
- package/dist/structure/bond-order-perception.js +1 -1
- package/dist/structure/bonding.d.ts +1 -0
- package/dist/structure/bonding.js +43 -15
- package/dist/structure/export.js +27 -23
- package/dist/structure/index.d.ts +2 -4
- package/dist/structure/index.js +1 -3
- package/dist/structure/label-placement.js +4 -4
- package/dist/structure/measure.d.ts +3 -2
- package/dist/structure/measure.js +6 -5
- package/dist/structure/parse.js +121 -103
- package/dist/structure/pbc.js +4 -0
- package/dist/symmetry/SymmetryStats.svelte +2 -2
- package/dist/symmetry/index.d.ts +1 -1
- package/dist/symmetry/index.js +22 -24
- package/dist/symmetry/spacegroups.d.ts +7 -0
- package/dist/symmetry/spacegroups.js +48 -13
- package/dist/table/HeatmapTable.svelte +63 -11
- package/dist/table/HeatmapTable.svelte.d.ts +1 -1
- package/dist/table/index.d.ts +1 -3
- package/dist/table/index.js +1 -1
- package/dist/theme/index.js +8 -8
- package/dist/tooltip/KCoords.svelte +45 -0
- package/dist/tooltip/KCoords.svelte.d.ts +8 -0
- package/dist/tooltip/index.d.ts +1 -0
- package/dist/tooltip/index.js +1 -0
- package/dist/trajectory/Trajectory.svelte +66 -40
- package/dist/trajectory/Trajectory.svelte.d.ts +2 -1
- package/dist/trajectory/TrajectoryExportPane.svelte +2 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte +2 -1
- package/dist/trajectory/format-detect.d.ts +1 -0
- package/dist/trajectory/format-detect.js +25 -11
- package/dist/trajectory/frame-reader.js +17 -50
- package/dist/trajectory/helpers.js +1 -1
- package/dist/trajectory/index.js +1 -1
- package/dist/trajectory/parse/hdf5.js +1 -1
- package/dist/trajectory/parse/index.js +14 -6
- package/dist/trajectory/parse/vasp.js +36 -17
- package/dist/trajectory/parse/xyz.d.ts +24 -0
- package/dist/trajectory/parse/xyz.js +102 -89
- package/dist/trajectory/plotting.d.ts +1 -1
- package/dist/trajectory/plotting.js +15 -15
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +6 -4
- package/dist/xrd/XrdPlot.svelte +2 -1
- package/dist/xrd/calc-xrd.js +15 -12
- package/dist/xrd/parse.js +2 -2
- package/package.json +22 -18
- package/dist/plot/PlotControls.svelte.d.ts +0 -4
- package/dist/plot/axis-utils.d.ts +0 -19
- package/dist/plot/axis-utils.js +0 -78
- package/dist/plot/defaults.d.ts +0 -19
- package/dist/plot/defaults.js +0 -9
- package/dist/plot/fill-utils.d.ts +0 -46
- package/dist/plot/fill-utils.js +0 -322
- package/dist/plot/interactions.d.ts +0 -12
- package/dist/plot/interactions.js +0 -101
- package/dist/plot/svg.d.ts +0 -1
- package/dist/plot/svg.js +0 -11
- package/dist/plot/utils/series-visibility.d.ts +0 -15
- package/dist/plot/utils.d.ts +0 -1
- package/dist/plot/utils.js +0 -14
- /package/dist/plot/{auto-place.d.ts → core/auto-place.d.ts} +0 -0
- /package/dist/plot/{Line.svelte.d.ts → core/components/Line.svelte.d.ts} +0 -0
- /package/dist/plot/{PortalSelect.svelte.d.ts → core/components/PortalSelect.svelte.d.ts} +0 -0
- /package/dist/plot/{hover-lock.svelte.d.ts → core/hover-lock.svelte.d.ts} +0 -0
- /package/dist/plot/{utils → core/utils}/label-placement.js +0 -0
- /package/dist/plot/{binned-scatter-types.js → scatter/binned-scatter-types.js} +0 -0
package/dist/structure/export.js
CHANGED
|
@@ -108,6 +108,7 @@ export function generate_mtl_content(scene) {
|
|
|
108
108
|
const materials = Array.isArray(object.material) ? object.material : [object.material];
|
|
109
109
|
for (const mat of materials) {
|
|
110
110
|
// Skip if already processed or no name
|
|
111
|
+
// oxlint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- empty name should use default
|
|
111
112
|
const mat_name = mat.name || `default_material`;
|
|
112
113
|
if (processed_materials.has(mat_name))
|
|
113
114
|
continue;
|
|
@@ -294,10 +295,10 @@ function convert_instanced_meshes_to_regular(scene) {
|
|
|
294
295
|
// Generate a filename for structure exports based on structure metadata
|
|
295
296
|
// Sanitize string for use in filenames by removing problematic characters.
|
|
296
297
|
const sanitize_filename_part = (text) => text
|
|
297
|
-
.
|
|
298
|
-
.
|
|
299
|
-
.
|
|
300
|
-
.
|
|
298
|
+
.replaceAll(/<\/?[^>]+>/g, ``) // strip HTML tags
|
|
299
|
+
.replaceAll(/[/\\:*?"<>|]/g, `_`) // replace filesystem-invalid chars
|
|
300
|
+
.replaceAll(/_+/g, `_`) // condense consecutive underscores
|
|
301
|
+
.replaceAll(/^_|_$/g, ``); // remove leading/trailing underscores
|
|
301
302
|
export function create_structure_filename(structure, extension) {
|
|
302
303
|
if (!structure)
|
|
303
304
|
return `structure.${extension}`;
|
|
@@ -432,7 +433,7 @@ function get_cif_block_name(structure) {
|
|
|
432
433
|
if (structure.id) {
|
|
433
434
|
// Remove invalid CIF characters (keep alphanumerics and underscores)
|
|
434
435
|
// and condense consecutive underscores for cleaner block names
|
|
435
|
-
return structure.id.
|
|
436
|
+
return structure.id.replaceAll(/[^a-zA-Z0-9_]/g, `_`).replaceAll(/_+/g, `_`);
|
|
436
437
|
}
|
|
437
438
|
return `structure`;
|
|
438
439
|
}
|
|
@@ -469,7 +470,8 @@ export function structure_to_cif_str(structure) {
|
|
|
469
470
|
const symmetry = structure.symmetry;
|
|
470
471
|
const { space_group_number, space_group_symbol } = symmetry;
|
|
471
472
|
if (typeof space_group_symbol === `string` && space_group_symbol) {
|
|
472
|
-
|
|
473
|
+
// Quote H-M symbols: their spaces (e.g. 'F m -3 m') would break CIF tokenization
|
|
474
|
+
lines.push(`_space_group_name_H-M_alt '${space_group_symbol}'`);
|
|
473
475
|
}
|
|
474
476
|
if ((typeof space_group_number === `number` || typeof space_group_number === `string`) &&
|
|
475
477
|
space_group_number) {
|
|
@@ -477,6 +479,9 @@ export function structure_to_cif_str(structure) {
|
|
|
477
479
|
}
|
|
478
480
|
}
|
|
479
481
|
lines.push(``);
|
|
482
|
+
// Explicit identity-only symmetry-ops loop (like pymatgen's CifWriter): sites are the
|
|
483
|
+
// full P1 list, so without it parsers would re-apply the H-M ops and multiply sites
|
|
484
|
+
lines.push(`loop_`, `_symmetry_equiv_pos_as_xyz`, ` 'x, y, z'`, ``);
|
|
480
485
|
// Atom site loop header
|
|
481
486
|
lines.push(`loop_`);
|
|
482
487
|
lines.push(`_atom_site_label`);
|
|
@@ -487,24 +492,15 @@ export function structure_to_cif_str(structure) {
|
|
|
487
492
|
lines.push(`_atom_site_occupancy`);
|
|
488
493
|
// Cache inverse transpose for Cartesian→fractional conversion (avoids recomputing per site)
|
|
489
494
|
const cart_to_frac = lattice.matrix?.length === 3 ? math.create_cart_to_frac(lattice.matrix) : null;
|
|
490
|
-
// Atom sites
|
|
495
|
+
// Atom sites: one row per species entry so disordered (multi-species) sites
|
|
496
|
+
// keep every component with its own occupancy instead of only species[0]
|
|
491
497
|
for (let idx = 0; idx < structure.sites.length; idx++) {
|
|
492
498
|
const site = structure.sites[idx];
|
|
493
499
|
if (!site)
|
|
494
500
|
continue; // Skip if site is undefined
|
|
495
|
-
// Extract element symbol from species
|
|
496
|
-
let element_symbol = `X`; // default fallback
|
|
497
|
-
let occupancy = 1;
|
|
498
|
-
if (site.species && Array.isArray(site.species) && site.species.length > 0) {
|
|
499
|
-
const first_species = site.species[0];
|
|
500
|
-
if (first_species && `element` in first_species && first_species.element) {
|
|
501
|
-
element_symbol = first_species.element;
|
|
502
|
-
occupancy = first_species?.occu ?? 1;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
501
|
// Get fractional coordinates
|
|
506
502
|
let frac_coords;
|
|
507
|
-
if (
|
|
503
|
+
if (Array.isArray(site.abc) && site.abc.length >= 3) {
|
|
508
504
|
frac_coords = site.abc.slice(0, 3);
|
|
509
505
|
}
|
|
510
506
|
else if (site.xyz?.length >= 3 && cart_to_frac) {
|
|
@@ -512,9 +508,17 @@ export function structure_to_cif_str(structure) {
|
|
|
512
508
|
}
|
|
513
509
|
else
|
|
514
510
|
throw new Error(`No valid coordinates found for site ${idx}`);
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
|
|
511
|
+
const coords_str = frac_coords.map((coord) => coord.toFixed(8)).join(` `);
|
|
512
|
+
const species_list = site.species?.length ? site.species : [{ element: `X`, occu: 1 }];
|
|
513
|
+
for (const [spec_idx, species] of species_list.entries()) {
|
|
514
|
+
const elem = species?.element || `X`;
|
|
515
|
+
// Row format: label element x y z occupancy. Labels must be unique per row,
|
|
516
|
+
// so disordered sites get a per-species suffix.
|
|
517
|
+
const label = species_list.length > 1
|
|
518
|
+
? `${elem}${idx + 1}_${spec_idx}`
|
|
519
|
+
: site.label || `${elem}${idx + 1}`;
|
|
520
|
+
lines.push(`${label} ${elem} ${coords_str} ${(species?.occu ?? 1).toFixed(8)}`);
|
|
521
|
+
}
|
|
518
522
|
}
|
|
519
523
|
return lines.join(`\n`);
|
|
520
524
|
}
|
|
@@ -528,8 +532,8 @@ export function structure_to_poscar_str(structure) {
|
|
|
528
532
|
const lines = [];
|
|
529
533
|
// Use plain text formula for POSCAR title to avoid HTML tags
|
|
530
534
|
const formula = get_electro_neg_formula(structure, true);
|
|
531
|
-
const title = structure.id ||
|
|
532
|
-
(formula && formula !== `Unknown` ? formula : null) ||
|
|
535
|
+
const title = structure.id || // oxlint-disable-line @typescript-eslint/prefer-nullish-coalescing -- first non-empty string
|
|
536
|
+
(formula && formula !== `Unknown` ? formula : null) || // oxlint-disable-line @typescript-eslint/prefer-nullish-coalescing -- first non-empty string
|
|
533
537
|
`Generated from structure`;
|
|
534
538
|
lines.push(title);
|
|
535
539
|
lines.push(`1.0`); // Scale factor (1.0 for direct coordinates)
|
|
@@ -36,9 +36,7 @@ export type Site = {
|
|
|
36
36
|
properties: Record<string, unknown>;
|
|
37
37
|
};
|
|
38
38
|
export declare const LATTICE_PARAM_KEYS: readonly ["a", "b", "c", "alpha", "beta", "gamma"];
|
|
39
|
-
export type LatticeParams =
|
|
40
|
-
[key in (typeof LATTICE_PARAM_KEYS)[number]]: number;
|
|
41
|
-
};
|
|
39
|
+
export type LatticeParams = Record<(typeof LATTICE_PARAM_KEYS)[number], number>;
|
|
42
40
|
export type LatticeType = {
|
|
43
41
|
matrix: math.Matrix3x3;
|
|
44
42
|
pbc: Pbc;
|
|
@@ -84,7 +82,7 @@ export declare const atomic_radii: CompositionType;
|
|
|
84
82
|
export declare function get_density(structure: Crystal): number;
|
|
85
83
|
export declare function get_center_of_mass(structure: AnyStructure): Vec3;
|
|
86
84
|
export declare const VECTOR_KEY_PREFIXES: readonly ["force", "forces", "magmom", "magmoms", "spin", "spins"];
|
|
87
|
-
export declare
|
|
85
|
+
export declare const is_vector_key: (key: string) => boolean;
|
|
88
86
|
export declare const VECTOR_PALETTE: readonly ["#e74c3c", "#3498db", "#2ecc71", "#f39c12", "#9b59b6", "#1abc9c"];
|
|
89
87
|
export declare const default_vector_configs: (keys: string[]) => {
|
|
90
88
|
[k: string]: {
|
package/dist/structure/index.js
CHANGED
|
@@ -94,9 +94,7 @@ export const VECTOR_KEY_PREFIXES = [
|
|
|
94
94
|
`spin`,
|
|
95
95
|
`spins`,
|
|
96
96
|
];
|
|
97
|
-
export
|
|
98
|
-
return VECTOR_KEY_PREFIXES.some((prefix) => key === prefix || key.startsWith(`${prefix}_`));
|
|
99
|
-
}
|
|
97
|
+
export const is_vector_key = (key) => VECTOR_KEY_PREFIXES.some((prefix) => key === prefix || key.startsWith(`${prefix}_`));
|
|
100
98
|
// Default color palette for distinguishing multiple vector layers
|
|
101
99
|
export const VECTOR_PALETTE = [
|
|
102
100
|
`#e74c3c`,
|
|
@@ -26,8 +26,8 @@ export const choose_site_label_offset = (bond_directions, base_offset) => {
|
|
|
26
26
|
if (offset_length < LABEL_OFFSET_EPS || bond_directions.length === 0) {
|
|
27
27
|
return base_offset;
|
|
28
28
|
}
|
|
29
|
-
const preferred_direction = math.
|
|
30
|
-
const repulsion_direction = math.
|
|
29
|
+
const preferred_direction = math.normalize_vec(base_offset, [0, 1, 0]);
|
|
30
|
+
const repulsion_direction = math.normalize_vec(bond_directions.reduce((offset_sum, bond_direction) => math.subtract(offset_sum, bond_direction), [0, 0, 0]), preferred_direction);
|
|
31
31
|
let best_direction = preferred_direction;
|
|
32
32
|
let best_score = -Infinity;
|
|
33
33
|
for (const candidate_direction of [
|
|
@@ -35,7 +35,7 @@ export const choose_site_label_offset = (bond_directions, base_offset) => {
|
|
|
35
35
|
repulsion_direction,
|
|
36
36
|
...LABEL_OFFSET_DIRECTIONS,
|
|
37
37
|
]) {
|
|
38
|
-
const direction = math.
|
|
38
|
+
const direction = math.normalize_vec(candidate_direction, preferred_direction);
|
|
39
39
|
const score = label_direction_score(direction, bond_directions, preferred_direction);
|
|
40
40
|
if (score <= best_score + LABEL_OFFSET_EPS)
|
|
41
41
|
continue;
|
|
@@ -59,7 +59,7 @@ export const label_screen_position = (atom_position, label_offset, visual_radius
|
|
|
59
59
|
const offset_length = Math.hypot(offset_x, offset_y);
|
|
60
60
|
const direction_x = offset_length > LABEL_OFFSET_EPS ? offset_x / offset_length : 0;
|
|
61
61
|
const direction_y = offset_length > LABEL_OFFSET_EPS ? offset_y / offset_length : label_offset[1] >= 0 ? -1 : 1;
|
|
62
|
-
const radius_direction = math.
|
|
62
|
+
const radius_direction = math.normalize_vec(label_offset, [0, 1, 0]);
|
|
63
63
|
const radius_edge = math.add(atom_position, math.scale(radius_direction, visual_radius));
|
|
64
64
|
const radius_screen = project_to_screen(radius_edge, label_camera, size);
|
|
65
65
|
const atom_screen_radius = Math.hypot(radius_screen[0] - atom_screen[0], radius_screen[1] - atom_screen[1]);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LatticeConverters, Matrix3x3, Vec3 } from '../math';
|
|
2
|
+
import type { Pbc } from './pbc';
|
|
2
3
|
export type AngleMode = `degrees` | `radians`;
|
|
3
4
|
export declare const MAX_SELECTED_SITES = 8;
|
|
4
|
-
export declare function displacement_pbc(from: Vec3, to: Vec3, lattice_matrix: Matrix3x3 | null | undefined, converters?: LatticeConverters): Vec3;
|
|
5
|
-
export declare function distance_pbc(a: Vec3, b: Vec3, lattice_matrix: Matrix3x3): number;
|
|
5
|
+
export declare function displacement_pbc(from: Vec3, to: Vec3, lattice_matrix: Matrix3x3 | null | undefined, converters?: LatticeConverters, pbc?: Pbc): Vec3;
|
|
6
|
+
export declare function distance_pbc(a: Vec3, b: Vec3, lattice_matrix: Matrix3x3, converters?: LatticeConverters, pbc?: Pbc): number;
|
|
6
7
|
export declare function angle_between_vectors(v1: Vec3, v2: Vec3, mode?: AngleMode): number;
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
import { min_image_displacement, subtract } from '../math';
|
|
3
3
|
export const MAX_SELECTED_SITES = 8;
|
|
4
4
|
// Calculate minimum image displacement between two points under PBC
|
|
5
|
-
// If lattice_matrix is null/undefined, returns Euclidean displacement
|
|
6
|
-
|
|
5
|
+
// If lattice_matrix is null/undefined, returns Euclidean displacement.
|
|
6
|
+
// pbc flags disable wrapping along non-periodic axes (e.g. slab vacuum directions).
|
|
7
|
+
export function displacement_pbc(from, to, lattice_matrix, converters, pbc) {
|
|
7
8
|
if (!lattice_matrix)
|
|
8
9
|
return subtract(to, from);
|
|
9
|
-
return min_image_displacement(from, to, lattice_matrix, converters);
|
|
10
|
+
return min_image_displacement(from, to, lattice_matrix, converters, pbc);
|
|
10
11
|
}
|
|
11
|
-
export function distance_pbc(a, b, lattice_matrix) {
|
|
12
|
-
const [dx, dy, dz] = displacement_pbc(a, b, lattice_matrix);
|
|
12
|
+
export function distance_pbc(a, b, lattice_matrix, converters, pbc) {
|
|
13
|
+
const [dx, dy, dz] = displacement_pbc(a, b, lattice_matrix, converters, pbc);
|
|
13
14
|
return Math.hypot(dx, dy, dz);
|
|
14
15
|
}
|
|
15
16
|
export function angle_between_vectors(v1, v2, mode = `degrees`) {
|