Skip to content

About

Synthetic XRD pattern generator for the PolyXRD ecosystem - simulates diffraction patterns to support phase analysis and algorithm validation

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

PolyXRD SynthPattern

PolyXRD SynthPattern

A small XRD pattern synthesis tool — starting from CIF structure factors, it generates simulated diffraction patterns with realistic instrumental features, which can be imported directly into third-party search/refinement software for phase identification, method validation and teaching demonstrations. Two release forms are provided: the Setup installer (public release, with registration mechanism) and the single-file internal evaluation build (no installation, for internal use, no registration mechanism).

Current version v1.4.1 · UI supports Simplified Chinese / English / Japanese in three languages, switchable at runtime from the "Language" menu at the top right of the menu bar (the choice is stored locally).

Current version v1.4.1 · UI available in Simplified Chinese / English / Japanese, switchable at runtime from the Language menu (top-right); choice is remembered locally.

Version v1.4.1 · UI supports Simplified Chinese / English / Japanese, switchable at runtime from the "Language" menu at the top right (settings are saved locally).

Member of the PolyXRD family: PolyXRD (data analysis) · PolyXRD-Converter (format conversion) · SynthPattern (pattern synthesis)

Features

Method 1 · CIF synthesis

  • Select one or more CIFs (COD standard format); multiple phases are mixed by mass fraction
  • Pipeline: space-group expansion → structure factor F(hkl) → Lorentz-Polarization → pseudo-Voigt peak shape + background + noise → intensity integerization
  • Two modes for the factor values:
    • a) Recommended values (parameters for a conventional laboratory Cu source, ready to use out of the box)
    • b) Back-calculated from a measured standard sample: import an instrument-measured Si/LaB6 pattern (or generate one from the built-in Si/LaB6 in a single click), then automatically back-calculate the peak shape (U/V/W), η, background and noise and superimpose them on the CIF pattern

Method 2 · Measured-pattern superposition

  • Two or more measured patterns are superimposed on the same 2θ grid using their respective scale factors

Export formats

  • .txt — Profile Data Ascii Dump (XRD) compatible (/// banner + measurement-conditions block + <2Theta> <I>, line width 81)
  • .xy / .dat — fixed-width two columns
  • .csv — two columns with a header

Parameter calibration (important)

The default parameters are calibrated so that "third-party search software can correctly match the phase" (verified against a measured reference set); parameters that are too "clean" result in an empty candidate list:

Parameter Default value Description
FWHM 0.15° constant Conventional laboratory Cu source level, does not broaden with 2θ
Noise σ = 0.3% × Imax Constant Gaussian, not Poisson; too small a value causes search failures
Imax 50000 counts Noise is based on Imax
Background a=300, b=1.0

These defaults are guarded point-by-point by a golden baseline in tests/golden_default.json — any refactor that makes them drift is blocked by CI.

Optional physics corrections (added in v1.3.0, all off by default)

The "Physics corrections (advanced)" group at the bottom left of the UI. Enabling any one of them makes the pattern deviate from the calibrated pattern above, so whether third-party search software can still match the phase must be re-verified — this is a deliberate trade-off and is not the default.

Item Model Description
Kα1/Kα2 doublet The two components each satisfy the Bragg relation Iα2/Iα1 defaults to 0.5; the separation increases with tanθ. When enabled, the wavelength input box is disabled
Preferred orientation March–Dollase W = (r²cos²α + r⁻¹sin²α)^(-3/2) Set h k l r row by row in the phase table (leave blank = no preferred orientation); r<1 plate-like, r=1 no preferred orientation, r>1 columnar
Crystallite size Scherrer β = Kλ/(L·cosθ), Lorentzian type When enabled, η(2θ) is given by the Voigt approximation and the η input box is disabled
Microstrain β = 4ε·tanθ, Gaussian type UI unit is %, 0.1% is already a rather large value for bulk materials
Finite-thickness absorption A(θ) = 1 − exp(−2μt/sinθ) Input μ(1/cm) and thickness (µm); reduces the relative intensity on the high-angle side

Size and strain are combined as "Gaussian part = instrument ⊕ strain, Lorentzian part = size", then the Olivero–Longbothum approximation gives the FWHM and η of the equivalent pseudo-Voigt.

Registration and release forms (added in v1.4.0)

The registration mechanism reuses the family-wide unified PolyXRD-Reg scheme: registration code = PXRD1- + Base32 (institution/department name + truncated HMAC-SHA256), validated offline, no network connection and no machine code needed; the same registration code can be used on multiple computers within the same institution.

Release form Build Registration mechanism Status bar indicator
Setup installer (public release) build_installer.bat → dist\PolyXRD-SynthPattern-Setup-vX.Y.Z.exe ✅ Far right (right-aligned): Registered: <institution/department name> / Unregistered
Single-file internal evaluation build (for internal use) build_exe.bat → dist\PolyXRD-SynthPattern-internal.exe ❌ Centered: Internal Evaluation Version (bold + red, since v1.4.1)

Installer behaviour:

  • When unregistered, every startup pops up a notice: "This software is unregistered. All rights reserved. Commercial use is prohibited. To register, please contact sshztx@outlook.com" — click "OK" to close it and continue using the software normally; it is only a notice;
  • Paste the registration code in the notice box or via "Help → Enter Registration Code (R)…"; once validation passes registration is complete and no further prompts appear;
  • After successful registration, the right side (right-aligned) of the bottom row of the main window shows the registered institution/department name;
  • Registration state is stored in %APPDATA%\PolyXRD\Registration\SynthPattern.json, and the registration code is re-validated on every startup; hand-editing the JSON to fake "Registered" has no effect.

Developer-side code generation: use the keygen in the PolyXRD-Reg repository (PolyXRD-RegTool.exe GUI version / make_reg_code.py command line) to generate a registration code from the "institution/department name" provided by the user.

Structural integrity notes

The CIF parser reads _symmetry_equiv_pos_as_xyz / _space_group_symop_operation_xyz and expands the symmetry operations, so COD CIFs that list only the asymmetric unit are also computed correctly. The built-in Si/LaB6 standard samples are likewise complete unit cells written out in full (diamond Si with 8 atoms, LaB6 with 1 La + 6 B). Reflections extinguished by destructive interference leave "numerical noise peaks" of about 1e-32 relative intensity due to floating-point residuals; the engine already filters them out using a relative threshold of 1e-9 × |F|²_max.

⚠ v1.3.0 fixed a correctness defect in v1.2.1: previously the parser ignored symmetry operations and the built-in Si had only 2 atoms written, causing diamond Si to produce forbidden (100)@16.3°, (110)@23.1° reflections whose intensities even exceeded the true (111)@28.44°. Method 1 b) standard-sample calibration benefits from this; please regenerate any patterns produced by older versions.

Known trade-offs

  • The intensity scale for multi-phase mixtures uses only the main term ∝ w_p / V_cell_p; no Brindley-type absorption-contrast correction is applied (strongly absorbing phases are slightly overestimated in mixtures).
  • Atomic thermal vibration uses only the U_iso/B factors given in the CIF; no extra Debye–Waller term is added when absent.
  • Fluorescence-induced background elevation is not modelled, nor is detector dead time.

Tests

pip install numpy pytest PySide6-Essentials
QT_QPA_PLATFORM=offscreen pytest -q

tests/ covers: point-by-point golden baselines for the default parameters, symmetry expansion and forbidden reflections, Kα doublet, preferred orientation, size/strain broadening, absorption, byte-level conventions of the export formats, trilingual hot-switching and end-to-end GUI generation, registration-code round-trips and the UI behaviour of both build variants.

Usage

For public releases use the Setup installer: download PolyXRD-SynthPattern-Setup-vX.Y.Z.exe from Releases and double-click to install; the wizard lets you choose the installation location. The single-file internal evaluation build is not released publicly.

Build (run in cmd.exe; invoking it via Git Bash breaks due to encoding):

build_installer.bat   # Setup installer: PyInstaller onedir + Inno Setup -> dist\PolyXRD-SynthPattern-Setup-vX.Y.Z.exe
build_exe.bat         # Internal evaluation build: PyInstaller onefile -> dist\PolyXRD-SynthPattern-internal.exe (+ copy with version number)

The installer script is in packaging/installer.iss (fixed AppId, reinstall/upgrade does not create parallel entries; the UI languages include Simplified Chinese / English / Japanese).

Language / Language / Language

Language Menu item Switching method
Simplified Chinese Language → Simplified Chinese The "Language" menu at the top right of the menu bar, switch instantly at runtime
English Language → English Top-right Language menu, switch at runtime
Japanese Language → Japanese Switch at runtime from the "Language" menu at the top right

The language preference is saved via QSettings (registry / local configuration) and restored automatically on the next startup.

The "Help" menu contains "Copyright & License" in addition to "About": a scrollable copyright page that gives the key license terms in Chinese-English parallel (dual license, scope of the academic license, commercial licensing requirements, citation requirements, termination clauses) and contact information. The formal terms are those in LICENSE (Chinese version) in the repository.

License

Consistent with the PolyXRD family, a dual license is used: free for academic research, teaching and non-commercial use; commercial use requires prior contact with the copyright holder to obtain separate written authorization. See LICENSE (Chinese version) for details.

Contact

sshztx@outlook.com · © 2026 PolyXRD Family

About

Synthetic XRD pattern generator for the PolyXRD ecosystem - simulates diffraction patterns to support phase analysis and algorithm validation

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages