caobin's picture
Upload 224 files
56c956f verified
metadata
jupytext:
  formats: md:myst
  text_representation:
    extension: .md
    format_name: myst
    format_version: 0.13
    jupytext_version: 1.11.5
kernelspec:
  display_name: Python 3
  language: python
  name: python3

The tutorial 6th

Demonstrates how to determine solid solution structures using powder XRD.

coding

1. Save your diffraction data to the root directory and rename the file to intensity.csv.

# import PyXplore package
from PyXplore import WPEM
import pandas as pd

2. Parse your diffraction data (, intensity) and perform background processing.

intensity_csv = pd.read_csv(r'intensity.csv',header=None )
var = WPEM.BackgroundFit(intensity_csv,lowAngleRange=17,poly_n=13,bac_split=16,bac_num=300)

3. After running the code, a new folder named ConvertedDocuments will be created in the root directory. This folder contains the background information.

Copy the two important files — bac.csv and no_bac_intensity.csv — from ConvertedDocuments into the root directory, as they are required for the next steps.

4. After background subtraction, the next step is to parse the reference structure.

Save the reference .cif file in the root directory. For example, if the structure is Mn₂O₃, place a file named Mn2O3.cif in the root directory as the reference phase.

If you are unsure of the reference phase, you must perform phase identification first. Please visit our website for assistance: https://xqueryer.caobin.asia/

latt, AtomCoordinates,des = WPEM.CIFpreprocess(filepath='Mn2O3.cif',two_theta_range=(15,75))

5. After running the code, a new folder named output_xrd will be created.

Inside this folder, locate the file named xxxHKL.csv, copy it to the root directory, and rename it to peak0.csv. This file will be used in the refinement step.

# The wavelength is set according to the actual light source
wavelength = [1.540593, 1.544414]
# The file name of non-background data (2theta-intensity data)
no_bac_intensity_file = "no_bac_intensity.csv" 
# The file name of raw/original data (2theta-intensity data)
original_file = "intensity.csv"  
# The file name of background data (2theta-intensity data)
bacground_file = "bac.csv"  


# Input the initial lattice constants {a, b, c, α, β, γ}, whose values need to be assumed at initialization.
Lattice_constants = [latt,]

# Execute the model

WPEM.XRDfit(
    wavelength, var, Lattice_constants,no_bac_intensity_file, original_file, bacground_file, 
    subset_number=11,low_bound=20,up_bound=70,bta = 0.85,iter_max = 5, asy_C = 0,InitializationEpoch=0, 
    )

Copy the decomposed file CrystalSystem0_WPEMout.csv from the WPEMFittingResults folder to the root directory.

WPEM.SubstitutionalSearch(
    xrd_pattern='CrystalSystem0_WPEMout_2025.7.20_17.27.csv', cif_file='Mn2O3.cif',
    random_num=20, wavelength='CuKa',search_cap=5,SolventAtom = 'Mn3+', SoluteAtom= 'Ru2+',max_iter = 15,cal_extinction=True,
)
After searching the solid solution configurations, the one that provides the best fit to the experimental PXRD data is selected.