Skip to main content

    PyWPEM

    GPU-powered X-ray diffraction refinement, simulation, and spectroscopy analysis.

    pywpem

    PyWPEM lets you simulate a theoretical diffraction pattern from a crystal structure and refine experimental XRD data against known structures with GPU-accelerated Rietveld analysis. Reach for it when you have a CIF structure or measured data and need refinement, phase quantification, PDF analysis, or peak fitting. Where OpXRD searches a database of experimental patterns for phase identification, PyWPEM computes and fits patterns directly — and it can simulate the diffraction expected from a structure that XTalNet predicts. See the Materials & Crystals overview for where this fits.

    PyWPEM overview

    PyWPEM (PyXplore) provides GPU-accelerated X-ray diffraction analysis through 14 operations. It handles everything from simulating theoretical diffraction patterns to refining experimental data against known crystal structures. Computationally intensive operations run on Modal GPU instances for fast turnaround.

    How it works

    XRD data and a CIF structure are dispatched to the GPU-backed PyWPEM API, which runs the chosen operation and returns refined parameters, patterns, or diagnostics. Full operation list below.

    All 14 operations

    OperationDescriptionRequired Inputs
    fit_backgroundPiecewise polynomial background fittingxrd_data_url
    simulate_xrdGenerate a theoretical pattern from a crystal structurecif_url or cif_content
    refine_xrdWhole-pattern refinement (WPEM algorithm) to determine lattice constants — one or more phases via phases[]xrd_data_url + phases
    fit_amorphousFit Gaussian mixtures to amorphous contributionsxrd_data_url
    preprocess_cifExtract lattice parameters and peak positions from a structurecif_url or cif_content
    calculate_rdfRadial distribution function from amorphous XRD dataxrd_data_url
    generate_crystal_graphBuild crystal connectivity graphs for GNN input (CGCNN, MEGNet)cif_url or cif_content
    search_substitutional_sitesFind energetically favorable substitutional defect sitescif_url + target_element + substitute_element
    fit_xpsX-ray photoelectron spectroscopy peak fittingxps_data_url + peaks
    fit_exafsExtended X-ray absorption fine structure analysisxafs_data_url
    plot_componentsGenerate publication-quality component plotsplot_type
    convert_file_formatConvert between XRD file formats (CSV, XY, XYE, CIF, JSON, RAW, BRML)input_url + input_format + output_format
    compute_graph_matrixCompute adjacency or Laplacian matrices from a crystal structurecif_url or cif_content
    split_ml_datasetsSplit crystallographic data for ML training/validation/testdata_url or data_urls

    Multi-phase refinement isn't a separate operation — refine_xrd's phases parameter takes an array, so one or more phases refine in the same call.

    When to use PyWPEM

    Use PyWPEM when:

    • You need to simulate a theoretical diffraction pattern from a crystal structure (CIF file)
    • You have experimental XRD data and need whole-pattern (WPEM) refinement against one or more phases
    • You need XPS or EXAFS spectroscopy peak fitting
    • You need a crystal connectivity graph for GNN input, a radial distribution function, or a substitutional-site search
    • You need peak-broadening simulation, background subtraction, or XRD file-format conversion

    Use OpXRD instead when:

    • You need to search a database of experimental patterns for phase identification
    • You want to find reference patterns for specific element combinations
    • You need CrystalNN fingerprint-based similarity search

    Limitations

    • CIF files must be well-formed with complete symmetry information. Partial CIFs may cause simulation failures.
    • Whole-pattern refinement requires good starting parameters. Poor initial guesses may cause divergence.
    • GPU allocation adds ~5-10 seconds of cold-start time for the first job in a session.

    Citations

    Cao B, Zhang Q, Feng Z, Zhang T, Huang J, Weng LT, Zhang TY. AI-Driven Structure Refinement of X-ray Diffraction. 2026. arXiv: 2602.16372 (PyWPEM software: https://github.com/Bin-Cao/PyWPEM)

    Rietveld HM. A profile refinement method for nuclear and magnetic structures. J Appl Crystallogr. 1969;2(2):65-71. doi: 10.1107/S0021889869006558

    FAQ

    Was this page helpful?

    On this page

    On this page

    Loading...