The tutorial 6th

Contents

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
██╗    ██╗██████╗ ███████╗███╗   ███╗
██║    ██║██╔══██╗██╔════╝████╗ ████║
██║ █╗ ██║██████╔╝█████╗  ██╔████╔██║
██║███╗██║██╔═══╝ ██╔══╝  ██║╚██╔╝██║
╚███╔███╔╝██║     ███████╗██║ ╚═╝ ██║
 ╚══╝╚══╝ ╚═╝     ╚══════╝╚═╝     ╚═╝                                                  

A Diffraction Refinement Software : WPEM
Bin Cao, Advanced Materials Thrust, Hong Kong University of Science and Technology (Guangzhou)
URL : https://github.com/Bin-Cao/WPEM
Executed on : 2025-07-22 11:13:34  | Have a great day.
====================================================================================================

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)
../../_images/aef21596334ce6f490a2526bc5fad55f09e54a82db7a9cd1be5d6bbd153f14ff.png ../../_images/16171239acea6bfcc15d02295c612fc20ca8c05252e8d4be1da7c0185068dd57.png ../../_images/bd82c740555d0962c82da60bb973052160e8eb6ac62a5b2e7291124e8db988d0.png ../../_images/11049e0b7d8aafa36de7c37dfe510fdeca704dcf18e8ccc5a933a5e75f64b536.png
================================
<Figure size 640x480 with 0 Axes>

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))
the space group of input crystal is : I 21 3
cif file parse completed
atom locations claculated by parsed cif file
retrieval of all reciprocal vectors satisfying the diffraction geometry is done
extinction peaks are distinguished
There are 21 extinction peaks
Diffraction condition judgment end !
The input crystal system is: Cubic  |  The initial lattice constants : 9.41 9.41 9.41 90.0 90.0 90.0

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, 
    )
Started at Tue Jul 22 11:13:50 2025 

Initialization
--------------------------------------------------------------------------------
The input HKL document is matched with WPEM
Diffraction indexs have been obtained by WPEM


The input crystal system is: Cubic  |  The initial lattice constants : 9.41 9.41 9.41 90.0 90.0 90.0
—————————— Initilize the parameters by WPEM ——————————
Parameter initialization has been completed 
  0%|                                                     | 0/5 [00:00<?, ?it/s]
WARNING:tensorflow:From /Users/jacob/miniconda3/lib/python3.9/site-packages/tensorflow/python/util/deprecation.py:576: calling function (from tensorflow.python.eager.polymorphic_function.polymorphic_function) with experimental_relax_shapes is deprecated and will be removed in a future version.
Instructions for updating:
experimental_relax_shapes is deprecated, use reduce_retracing instead
WPEM 1-th iteration
[array([ 9.40989,  9.40989,  9.40989, 90.     , 90.     , 90.     ])]
 20%|█████████                                    | 1/5 [00:07<00:28,  7.09s/it]
Rp:3.603 | Rwp:5.039 | Rsquare:4.349
WARNING:tensorflow:From /Users/jacob/miniconda3/lib/python3.9/site-packages/tensorflow/python/util/deprecation.py:576: calling function (from tensorflow.python.eager.polymorphic_function.polymorphic_function) with experimental_relax_shapes is deprecated and will be removed in a future version.
Instructions for updating:
experimental_relax_shapes is deprecated, use reduce_retracing instead
WPEM 2-th iteration
[array([ 9.40961,  9.40961,  9.40961, 90.     , 90.     , 90.     ])]
 40%|██████████████████                           | 2/5 [00:13<00:20,  6.78s/it]
Rp:3.385 | Rwp:4.664 | Rsquare:3.518
WARNING:tensorflow:From /Users/jacob/miniconda3/lib/python3.9/site-packages/tensorflow/python/util/deprecation.py:576: calling function (from tensorflow.python.eager.polymorphic_function.polymorphic_function) with experimental_relax_shapes is deprecated and will be removed in a future version.
Instructions for updating:
experimental_relax_shapes is deprecated, use reduce_retracing instead
WPEM 3-th iteration
[array([ 9.40934,  9.40934,  9.40934, 90.     , 90.     , 90.     ])]
 60%|███████████████████████████                  | 3/5 [00:20<00:13,  6.70s/it]
Rp:3.241 | Rwp:4.423 | Rsquare:3.047
WARNING:tensorflow:From /Users/jacob/miniconda3/lib/python3.9/site-packages/tensorflow/python/util/deprecation.py:576: calling function (from tensorflow.python.eager.polymorphic_function.polymorphic_function) with experimental_relax_shapes is deprecated and will be removed in a future version.
Instructions for updating:
experimental_relax_shapes is deprecated, use reduce_retracing instead
WPEM 4-th iteration
[array([ 9.40913,  9.40913,  9.40913, 90.     , 90.     , 90.     ])]
 80%|████████████████████████████████████         | 4/5 [00:26<00:06,  6.66s/it]
Rp:3.140 | Rwp:4.243 | Rsquare:2.758
WARNING:tensorflow:From /Users/jacob/miniconda3/lib/python3.9/site-packages/tensorflow/python/util/deprecation.py:576: calling function (from tensorflow.python.eager.polymorphic_function.polymorphic_function) with experimental_relax_shapes is deprecated and will be removed in a future version.
Instructions for updating:
experimental_relax_shapes is deprecated, use reduce_retracing instead
WPEM 5-th iteration
[array([ 9.40901,  9.40901,  9.40901, 90.     , 90.     , 90.     ])]
100%|█████████████████████████████████████████████| 5/5 [00:33<00:00,  6.63s/it]
100%|█████████████████████████████████████████████| 5/5 [00:33<00:00,  6.69s/it]
Rp:3.062 | Rwp:4.109 | Rsquare:2.577

After update the background :   Rp = 1.555 | Rwp = 3.076 | Rsquare = 1.690
../../_images/775928bcfdc02036451df7b0bec83cb51ef9e3dc96a7c68f96ebb63ff7f2f43a.png ../../_images/71c85b5daec8a90059dbf2f5589b75579eaba24753816838cff228188dab8aa6.png ../../_images/190307293664ee80df15ed5b3a02370514e177dd9b071a827e3f4f0697d46f73.png
Mass fraction without structure factor estimate in % : [100.0] 
 Saved at the result documents
5-th iterations, reach the maximum number of iteration steps.
 Rp: 1.555
Rwp: 3.076 


WPEM program running time :  0 hours 0 minute  38 second  
('0 hours 0 minute  38 second  ',
 [array([ 9.40901,  9.40901,  9.40901, 90.     , 90.     , 90.     ])])
<Figure size 640x480 with 0 Axes>

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,
)
the space group of input crystal is : I 21 3
cif file parse completed
atom locations claculated by parsed cif file
retrieval of all reciprocal vectors satisfying the diffraction geometry is done
extinction peaks are distinguished
There are 29 extinction peaks
Diffraction condition judgment end !
The input crystal system is: Cubic  |  The initial lattice constants : 9.41 9.41 9.41 90.0 90.0 90.0
initial error is 6.1900258466634135
WPEM uses a random optimization method based on the current settings
WPEM Site optimization | 1-th | random 
WPEM Site optimization | 2-th | random 
WPEM Site optimization | 3-th | random 
WPEM Site optimization | 4-th | random 
WPEM Site optimization | 5-th | random 
WPEM Site optimization | 6-th | random 
WPEM Site optimization | 7-th | random 
WPEM Site optimization | 8-th | random 
WPEM Site optimization | 9-th | random 
WPEM Site optimization | 10-th | random 
WPEM Site optimization | 11-th | random 
WPEM Site optimization | 12-th | random 
WPEM Site optimization | 13-th | random 
WPEM Site optimization | 14-th | random 
WPEM Site optimization | 15-th | random 
optimized error is 5.582748221411304
../../_images/a91d26804a1cfc50a4e3b9639e666b5dff2976389100e03f692b7fc6543373d5.png
[['Ru2+', 0.25, 0.25, 0.25],
 ['Ru2+', 0.021, 0.0, 0.25],
 ['Ru2+', 0.542, 0.0, 0.25],
 ['O2-', 0.125, 0.125, 0.375],
 ['O2-', 0.125, 0.375, 0.375],
 ['Ru2+', 0.75, 0.25, 0.75],
 ['Ru2+', 0.75, 0.75, 0.25],
 ['Mn3+', 0.25, 0.75, 0.75],
 ['Mn3+', 0.75, 0.75, 0.75],
 ['Mn3+', 0.25, 0.75, 0.25],
 ['Mn3+', 0.25, 0.25, 0.75],
 ['Ru2+', 0.75, 0.25, 0.25],
 ['Ru2+', 0.0, 0.25, 0.021],
 ['Ru2+', 0.25, 0.021, 0.0],
 ['Mn3+', 0.521, 0.5, 0.75],
 ['Mn3+', 0.5, 0.25, 0.979],
 ['Mn3+', 0.75, 0.479, -0.0],
 ['Ru2+', 0.979, 0.5, 0.25],
 ['Mn3+', -0.0, 0.75, 0.479],
 ['Ru2+', 0.75, 0.521, 0.5],
 ['Ru2+', 0.479, -0.0, 0.75],
 ['Ru2+', 0.5, 0.75, 0.521],
 ['Mn3+', 0.25, 0.979, 0.5],
 ['Ru2+', 0.0, 0.25, 0.542],
 ['Ru2+', 0.25, 0.542, 0.0],
 ['Ru2+', 0.042, 0.5, 0.75],
 ['Ru2+', 0.5, 0.25, 0.457],
 ['Ru2+', 0.75, 0.958, -0.0],
 ['Mn3+', 0.457, 0.5, 0.25],
 ['Ru2+', -0.0, 0.75, 0.958],
 ['Mn3+', 0.75, 0.042, 0.5],
 ['Mn3+', 0.958, -0.0, 0.75],
 ['Mn3+', 0.5, 0.75, 0.042],
 ['Ru2+', 0.25, 0.457, 0.5],
 ['O2-', 0.125, 0.375, 0.125],
 ['O2-', 0.375, 0.125, 0.125],
 ['O2-', 0.625, 0.375, 0.625],
 ['O2-', 0.625, 0.125, 0.875],
 ['O2-', 0.875, 0.375, 0.875],
 ['O2-', 0.875, 0.625, 0.125],
 ['O2-', 0.875, 0.875, 0.375],
 ['O2-', 0.625, 0.625, 0.375],
 ['O2-', 0.375, 0.875, 0.875],
 ['O2-', 0.375, 0.625, 0.625],
 ['O2-', 0.125, 0.875, 0.625],
 ['O2-', 0.625, 0.625, 0.875],
 ['O2-', 0.625, 0.875, 0.625],
 ['O2-', 0.875, 0.625, 0.625],
 ['O2-', 0.125, 0.875, 0.125],
 ['O2-', 0.125, 0.625, 0.375],
 ['O2-', 0.375, 0.875, 0.375],
 ['O2-', 0.375, 0.125, 0.625],
 ['O2-', 0.375, 0.375, 0.875],
 ['O2-', 0.125, 0.125, 0.875],
 ['O2-', 0.875, 0.375, 0.375],
 ['O2-', 0.875, 0.125, 0.125],
 ['O2-', 0.625, 0.375, 0.125],
 ['O2-', 0.375, 0.375, 0.125],
 ['O2-', 0.375, 0.125, 0.375],
 ['O2-', 0.625, 0.125, 0.625],
 ['O2-', 0.875, 0.125, 0.875],
 ['O2-', 0.875, 0.375, 0.625],
 ['O2-', 0.875, 0.875, 0.125],
 ['O2-', 0.625, 0.875, 0.375],
 ['O2-', 0.625, 0.625, 0.125],
 ['O2-', 0.375, 0.625, 0.875],
 ['O2-', 0.125, 0.625, 0.625],
 ['O2-', 0.125, 0.875, 0.875],
 ['O2-', 0.625, 0.875, 0.875],
 ['O2-', 0.875, 0.875, 0.625],
 ['O2-', 0.875, 0.625, 0.875],
 ['O2-', 0.125, 0.625, 0.125],
 ['O2-', 0.375, 0.625, 0.375],
 ['O2-', 0.375, 0.875, 0.125],
 ['O2-', 0.375, 0.375, 0.625],
 ['O2-', 0.125, 0.375, 0.875],
 ['O2-', 0.125, 0.125, 0.625],
 ['O2-', 0.875, 0.125, 0.375],
 ['O2-', 0.625, 0.125, 0.125],
 ['O2-', 0.625, 0.375, 0.375]]

See also

After searching the solid solution configurations, the one that provides the best fit to the experimental PXRD data is selected.