This document defines the numerical quantities and validation rules emitted by DiffractScout. Any change to these contracts requires regression tests, a changelog entry, and review by a contributor with relevant diffraction or elasticity expertise.
- The exact input CIF is copied into
inputs/and identified by SHA-256. - A structure-bearing data block must contain six finite unit-cell parameters and at least one fractional atomic site.
- Cell lengths must be positive; angles must lie strictly between 0° and 180°; the computed cell volume must be finite and positive.
- DiffractScout records the selected CIF data-block name.
- Local inputs remain unchanged. A dedicated Gemmi structure copy is used for structure-factor occupancy conversion.
- Partial occupancies are retained as an average-structure model and generate an explicit warning.
- DiffractScout does not invent or repair atom labels, occupancies, compositions, oxidation states, disorder models, or crystallographic settings.
adapt_cifis outside that rule. It writes a new file from caller-supplied composition and, when a citation is supplied, caller-supplied lattice parameters or fractional coordinates. It leaves the source CIF unchanged.analyze,discover, andrundo not call it, and it does not extract numbers from literature.prepare_cifsis a separate explicit derivation workflow. It checks actual metal-site topology as well as the phase-family space group, restores chemically verified fully enumerated P1 structures into standard conventional cells atsymprec=0.001 Å, archives the original bytes, and records the transformation. It never relabels an incompatible non-P1 structure. Nominal/bulk occupancy and any inherited lattice/internal coordinates are starting assumptions. Cited caller values are not verified experimental measurements by the software. Derived CIF formula, Z and formula mass are consistent with expanded occupied sites. Detailed contracts are in INITIAL_CIFS.md.
Space-group identity is resolved in the following order and the chosen source is recorded:
- explicit CIF Hermann–Mauguin symbol;
- explicit International Tables number;
- Gemmi inference from the parsed small structure;
- P1 fallback with a warning when no reliable declaration can be resolved.
A disagreement between explicit symbol and number, or between the declared group and the independent spglib search, is recorded as a diagnostic. The diffraction calculation uses the resolved Gemmi group; users must review any mismatch before interpreting systematic absences.
The schema field formula_weight_g_mol is the expanded crystallographic
unit-cell mass in g/mol. It sums the masses of all occupied sites in the
expanded unit cell, including the crystallographic multiplicity Z; it is not
the empirical formula molar mass. The derived density_g_cm3 uses this
unit-cell mass and the crystallographic cell volume. These meanings apply to
the existing schema names and should not be relabeled as empirical-formula
quantities.
Energy and wavelength are related by
Built-in effective single-wavelength presets are:
| Source | Wavelength (Å) |
|---|---|
| Cu Kα | 1.5406 |
| Co Kα | 1.78897 |
| Fe Kα | 1.93604 |
| Mo Kα | 0.7093 |
| Ag Kα | 0.5594 |
Explicit energy and wavelength inputs must be finite and positive. The active
radiation mode is strict: energy accepts only energy_keV, wavelength
accepts only wavelength_A, source=Custom accepts only wavelength_A, and
built-in source presets accept neither numeric override. Inactive numeric
fields are rejected during validate_analysis_settings so direct API analysis
cannot persist an ambiguous radiation definition. A custom source therefore
requires an explicit wavelength.
The presets represent one effective wavelength. Kα1/Kα2 doublets, spectral bandwidth, harmonic contamination, and source polarization are not expanded in the current version.
For each allowed reflection,
Gemmi supplies unique Miller indices, space-group operations, and systematic-absence checks. The exported representative hkl is a deterministic member of its symmetry family. multiplicity is the number of distinct symmetry- and Friedel-related indices used by the implemented family construction.
The scan window must satisfy
0 <= 2θ_min < 2θ_max <= 180°
and the display-profile step and FWHM must be finite and positive. The pseudo-Voigt mixing fraction must lie in [0, 1].
Candidate generation uses a relative nextafter(d_min, 0) to avoid floating-point exclusion of a reflection exactly at the upper
When a d-spacing filter is enabled, its inclusive Bragg-angle interval is
intersected with the requested 2θ interval. Equality is a nonempty
single-point intersection; only a lower bound greater than the upper bound is
empty. A d_max_A below the physical limit lambda/2 is an empty filter
window, and no reciprocal candidates are evaluated for an empty intersection.
For compatibility, phase metadata two_theta_range_deg records the configured
analysis bounds (the requested bounds are retained for an empty effective
window). profile_sampled_two_theta_range_deg records the first and last
coordinates actually emitted by the finite-step profile grid. The explicit metadata fields
requested_two_theta_range_deg, effective_two_theta_range_deg (or null),
and effective_window_empty distinguish user intent from the applied filter.
geometric_d_min_A is the Bragg lower spacing implied by the configured
analysis upper angle used for reflection search; it is not the last sampled
profile coordinate or the user filter d_min_A. In the Excel Summary, legacy
two_theta_range_deg remains the requested range, while
analysis_two_theta_range_deg carries the configured per-phase bounds.
Gemmi calculates the X-ray structure factor for the average CIF structure. Before calculation, DiffractScout calls Gemmi's crystallographic-occupancy conversion on a dedicated structure-factor copy. This accounts for special-position multiplicity while preserving original CIF occupancies for validation and composition reporting. The analytic FCC regression test verifies
for a monoatomic conventional Fm-3m fixture.
DiffractScout reports
where
The exported per-multiplicity structure-factor helpers are defined by
Here “mean” retains the CIF2Peaks-compatible name for the per-equivalent-family
value. It does not average unrelated reflections or divide
and
Two project-defined volume-normalized channels are exported:
The preferred output names are:
volume_normalized_intensity_with_lp
volume_normalized_intensity_no_lp
The legacy names below remain for CIF2Peaks schema compatibility:
material_scattering_factor_R_hkl
material_scattering_factor_R_hkl_no_lp
Those aliases refer exactly to the two
The highest I_with_LP line within each phase is normalized to 100 for display. This phase-internal normalization does not make intensities comparable across separate structures, experiments, instruments, or compositions.
The current implementation does not infer or fit:
- Debye–Waller parameters that are absent from the CIF;
- anomalous-dispersion corrections tied to a specific absorption edge;
- preferred orientation;
- absorption, fluorescence, extinction, polarization geometry beyond the stated LP expression;
- sample amount or phase fraction;
- instrument response and wavelength doublets.
Each discrete line is broadened with the selected profile_model: pseudo_voigt,
gaussian, or lorentzian. For pseudo_voigt, the line profile is
The mixing fraction profile_eta is meaningful and effective only for
pseudo_voigt; for gaussian and lorentzian it does not change the emitted
profile. It is stored in provenance. For gaussian, the single-component profile is
For lorentzian, the single-component profile is
The summed profile is normalized to a maximum of 100 for every model. FWHM and the selected profile model are user inputs stored in provenance. The profile is a visualization and interoperability product. It is not a fitted instrument function and contains no inferred axial divergence, spectral doublet, microstrain, crystallite size, detector response, or background.
When pattern_axis is d_spacing, q, or g, the profile remains sampled on
the same uniform 2theta grid and the emitted coordinates are coordinate
transforms of those samples. The profile is not uniformly resampled in q or
d, and no Jacobian is applied. The canonical columns remain
two_theta_deg, d_A, q_invA, g_invA, x_axis_mode, x, and
relative_intensity; pattern_axis selects the x coordinate for the
continuous CSV/Excel profile only.
Large angular grids, small-$d$ reflection searches, and unrestricted chemical-subsystem expansion can consume substantial memory, API quota, and runtime. DiffractScout applies three explicit guards before the expensive operation begins:
max_profile_pointslimits the requested continuous grid size;max_reflection_estimatelimits a conservative reciprocal-space estimate and the actual generated Miller-candidate count;max_subsystemslimits the number of chemical-subsystem provider queries implied by the parsed element set andmax_subsystem_order.
The conservative estimate is proportional to the reciprocal-space sphere implied by the minimum accessible spacing and the direct-cell volume. It is a safety estimate, not a physical prediction of allowed reflections. Both configured limits, the estimate, and the actual candidate count are recorded in analysis metadata.
Increasing any limit is an explicit user decision. Lowering the profile step or extending to very high angle can trigger the profile guard. Large unit cells and small accessible max_subsystems.
The accepted stiffness matrix is a finite 6×6 matrix in GPa using Voigt order
[11, 22, 33, 23, 13, 12]
with engineering shear strain. Sidecars may declare Pa, kPa, MPa, GPa, or TPa; values are converted to GPa before validation and the conversion is recorded. Generic matrix fields without a unit retain legacy GPa interpretation with an explicit warning. Unknown units stop directional evaluation. DiffractScout:
- requires an exact 6×6 shape;
- rejects non-finite entries;
- symmetrizes a matrix outside tolerance using
$(C+C^T)/2$ and records a warning; - rejects singular matrices;
- rejects matrices that are not positive definite;
- records a warning for severe ill-conditioning;
- preserves provider, record ID, source URL, methodology URL, nature of data, coordinate frame, and original sidecar path.
For a unit vector hkl, define
With compliance
The normal is obtained from the reciprocal-lattice vector and normalized in the CIF Cartesian frame. The compliance inverse is cached within one tensor object because a phase can contain many reflections.
A numerical tensor is paired only when the relation to the CIF is unique. Pairing can use an exact {cif_stem}_elasticity.json, an explicit paired_cif/cif_filename, an unambiguous material identifier, or an unambiguous index row. The following cases stop automatic directional evaluation and generate diagnostics:
- an exact-name sidecar declares a different paired CIF;
- several sidecars match the same CIF;
- several index rows match the same CIF;
- the payload is malformed or lacks a valid 6×6 tensor;
- the tensor coordinate frame is absent or incompatible;
- a provider query failed.
For Materials Project downloads, the raw/POSCAR-format tensor is retained with
the conventional-standard CIF for numerical provenance, but automatic
directional coupling is disabled. The provider does not persist enough of the
upstream ElasticityDoc.structure orientation to verify a transform into the
Cartesian basis emitted by Pymatgen CIF serialization. The raw/POSCAR frame is
therefore not a supported directional frame and receives
frame_transform_required with usable_for_hkl_modulus=false.
The retained provenance label is
materials_project_conventional_cif_cartesian
It identifies the raw/POSCAR basis; it does not assert CIF Cartesian
equivalence. The IEEE-format tensor is likewise retained for provenance
because it may differ by a rotation. Raw/POSCAR and IEEE records receive
status frame_transform_required; all hkl-normal modulus fields remain
empty until an explicit, verified transform into the CIF Cartesian frame is
available. A generic JSON tensor with no coordinate_frame is also fail-closed
with this status. Direct user matrix helpers remain explicit CIF Cartesian
inputs. Primitive-cell downloads are rejected when automatic elasticity
coupling is enabled.
Materials Project tensors are labeled DFT_calculated and not_experimental=true. A missing record remains missing. DiffractScout does not convert literature search results into numerical tensors.
A database record is a candidate reference. It is not proof that the phase exists in an experiment. energy_above_hull and stability flags remain provider metadata and are not experimental stability measurements. Candidate ranking is deterministic and does not constitute phase-probability inference.
Database query failure, no property document, a document without a tensor, a tensor requiring a frame transformation, and a run where elasticity was disabled are exported as distinct statuses. The disabled state is not_requested; it is not counted as missing data. This distinction prevents service outages or user choices from being silently reported as valid negative results.
Analysis result bundles and prepare-cifs packages are first written to a staging directory. CSV and workbook files use temporary-file replacement. The completed staging bundle is verified before publication to the target directory. The low-level fetch-prototypes command creates raw CIFs and its index individually without overwrite; it is not a transactional result bundle and concurrent fetches should use separate directories.
The manifest verifier checks SHA-256, byte size, path safety, duplicate paths, symbolic links, root escapes, missing files, modified files, and files present on disk but absent from the manifest. A pre-existing bundle must itself pass verification before overwrite is allowed.
Spreadsheet cells derived from external provider/CIF text are prefixed when they begin with spreadsheet formula-control characters (=, +, -, @, tab, carriage return, or newline). This prevents exported metadata from being interpreted as an active spreadsheet formula.
The top-level provenance.json output_flags records the effective optional
outputs: include_excel, include_patterns, include_figures, and
effective_export_lab_views. results.xlsx is present only when Excel output
is enabled; pattern_profiles.csv is present only when continuous patterns
are enabled; figure files are present only when figure output is enabled and a
phase is analyzed. Definitions for these artifacts are conditional on their
being emitted and must not be read as guarantees when a flag is false.
The current version does not perform:
- experimental phase identification or automated phase assignment;
- Rietveld, Le Bail, or Pawley refinement;
- quantitative phase analysis;
- preferred-orientation, absorption, fluorescence, or extinction correction;
- background, zero-shift, specimen-displacement, or detector-geometry fitting;
- crystallite-size or microstrain extraction;
- instrument calibration or absolute intensity calibration;
- uncertainty propagation from CIF parameters, database calculations, or experimental observables;
- thermodynamic phase-fraction prediction;
- automatic literature extraction of structures or elastic tensors.