The tutorial 5th

Contents

The tutorial 5th#

Shows how to calculate atomic distances based on the radial distribution function derived from diffraction patterns.

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:06:32  | 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=3.8,poly_n=12,bac_split=8,bac_num=100)
../../_images/198d89c1fe0df80d28e64e7923407a7eb6146420ede030df63e4b1aedb412ff3.png ../../_images/dbd9c98931627aa94f2069845881a0af95176ac30003dd4c430e879b7ca9568b.png ../../_images/a6584bddb6d21fbca1a7ebf77fa2722fae6ff7f8bb01397a52a7cb0d23d80ce6.png ../../_images/0b58998ae7da7745fd267485168fd0ece51a94fae597333c80783818f2e0a50c.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.

Parse the .cif file as demonstrated in the crystal fitting section, and generate the peak0.csv file.

# The wavelength is set according to the actual light source
wavelength = [1.03]
# 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 = [[17.53,17.53,6.47,90,90,120],]

# Execute the model

WPEM.XRDfit(
    wavelength, var, Lattice_constants,no_bac_intensity_file, original_file, bacground_file, 
    subset_number=3,low_bound=6,up_bound=16,bta = 0.78,iter_max = 50, asy_C = 0,InitializationEpoch=0, 
    )
Started at Tue Jul 22 11:06:37 2025 

Initialization
--------------------------------------------------------------------------------
Diffraction indexs have been obtained by WPEM


The input crystal system is: Hexagonal  |  The initial lattice constants : 17.53 17.53 6.47 90 90 120
—————————— Initilize the parameters by WPEM ——————————
Parameter initialization has been completed 
  0%|                                                    | 0/50 [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
  2%|▉                                           | 1/50 [00:05<04:14,  5.19s/it]
WPEM 1-th iteration
[array([ 17.5303 ,  17.5303 ,   6.46268,  90.     ,  90.     , 120.     ])]
Rp:6.705 | Rwp:8.563 | Rsquare:2.703
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
  4%|█▊                                          | 2/50 [00:10<04:00,  5.02s/it]
WPEM 2-th iteration
[array([ 17.52878,  17.52878,   6.45665,  90.     ,  90.     , 120.     ])]
Rp:5.644 | Rwp:7.336 | Rsquare:1.867
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
  6%|██▋                                         | 3/50 [00:14<03:47,  4.85s/it]
WPEM 3-th iteration
[array([ 17.52798,  17.52798,   6.45154,  90.     ,  90.     , 120.     ])]
Rp:5.279 | Rwp:6.809 | Rsquare:1.619
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
  8%|███▌                                        | 4/50 [00:19<03:38,  4.76s/it]
WPEM 4-th iteration
[array([ 17.52969,  17.52969,   6.44637,  90.     ,  90.     , 120.     ])]
Rp:5.010 | Rwp:6.429 | Rsquare:1.455
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
 10%|████▍                                       | 5/50 [00:24<03:32,  4.72s/it]
WPEM 5-th iteration
[array([ 17.53209,  17.53209,   6.44193,  90.     ,  90.     , 120.     ])]
Rp:4.769 | Rwp:6.121 | Rsquare:1.324
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
 12%|█████▎                                      | 6/50 [00:28<03:25,  4.67s/it]
WPEM 6-th iteration
[array([ 17.53448,  17.53448,   6.43842,  90.     ,  90.     , 120.     ])]
Rp:4.553 | Rwp:5.868 | Rsquare:1.221
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
 14%|██████▏                                     | 7/50 [00:33<03:19,  4.65s/it]
WPEM 7-th iteration
[array([ 17.53661,  17.53661,   6.43579,  90.     ,  90.     , 120.     ])]
Rp:4.375 | Rwp:5.656 | Rsquare:1.138
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
 16%|███████                                     | 8/50 [00:37<03:14,  4.63s/it]
WPEM 8-th iteration
[array([ 17.53843,  17.53843,   6.43389,  90.     ,  90.     , 120.     ])]
Rp:4.227 | Rwp:5.475 | Rsquare:1.067
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
 18%|███████▉                                    | 9/50 [00:42<03:09,  4.61s/it]
WPEM 9-th iteration
[array([ 17.53994,  17.53994,   6.43257,  90.     ,  90.     , 120.     ])]
Rp:4.103 | Rwp:5.316 | Rsquare:1.007
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
 20%|████████▌                                  | 10/50 [00:46<03:04,  4.60s/it]
WPEM 10-th iteration
[array([ 17.54114,  17.54114,   6.43171,  90.     ,  90.     , 120.     ])]
Rp:3.993 | Rwp:5.173 | Rsquare:0.953
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
 22%|█████████▍                                 | 11/50 [00:51<02:59,  4.61s/it]
WPEM 11-th iteration
[array([ 17.54207,  17.54207,   6.43121,  90.     ,  90.     , 120.     ])]
Rp:3.893 | Rwp:5.044 | Rsquare:0.905
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
 24%|██████████▎                                | 12/50 [00:56<02:54,  4.60s/it]
WPEM 12-th iteration
[array([ 17.54274,  17.54274,   6.431  ,  90.     ,  90.     , 120.     ])]
Rp:3.800 | Rwp:4.926 | Rsquare:0.862
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
 26%|███████████▏                               | 13/50 [01:00<02:49,  4.58s/it]
WPEM 13-th iteration
[array([ 17.54317,  17.54317,   6.43102,  90.     ,  90.     , 120.     ])]
Rp:3.715 | Rwp:4.817 | Rsquare:0.823
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
 28%|████████████                               | 14/50 [01:05<02:47,  4.64s/it]
WPEM 14-th iteration
[array([ 17.54341,  17.54341,   6.43122,  90.     ,  90.     , 120.     ])]
Rp:3.638 | Rwp:4.716 | Rsquare:0.786
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
 30%|████████████▉                              | 15/50 [01:10<02:41,  4.63s/it]
WPEM 15-th iteration
[array([ 17.54347,  17.54347,   6.43157,  90.     ,  90.     , 120.     ])]
Rp:3.567 | Rwp:4.621 | Rsquare:0.752
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
 32%|█████████████▊                             | 16/50 [01:14<02:37,  4.63s/it]
WPEM 16-th iteration
[array([ 17.5434 ,  17.5434 ,   6.43203,  90.     ,  90.     , 120.     ])]
Rp:3.499 | Rwp:4.533 | Rsquare:0.721
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
 34%|██████████████▌                            | 17/50 [01:19<02:32,  4.63s/it]
WPEM 17-th iteration
[array([ 17.54321,  17.54321,   6.43256,  90.     ,  90.     , 120.     ])]
Rp:3.434 | Rwp:4.451 | Rsquare:0.691
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
 36%|███████████████▍                           | 18/50 [01:23<02:26,  4.58s/it]
WPEM 18-th iteration
[array([ 17.54295,  17.54295,   6.43315,  90.     ,  90.     , 120.     ])]
Rp:3.374 | Rwp:4.374 | Rsquare:0.663
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
 38%|████████████████▎                          | 19/50 [01:29<02:30,  4.85s/it]
WPEM 19-th iteration
[array([ 17.54264,  17.54264,   6.43376,  90.     ,  90.     , 120.     ])]
Rp:3.318 | Rwp:4.302 | Rsquare:0.637
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
 40%|█████████████████▏                         | 20/50 [01:34<02:33,  5.10s/it]
WPEM 20-th iteration
[array([ 17.5423 ,  17.5423 ,   6.43439,  90.     ,  90.     , 120.     ])]
Rp:3.265 | Rwp:4.235 | Rsquare:0.612
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
 42%|██████████████████                         | 21/50 [01:39<02:24,  4.98s/it]
WPEM 21-th iteration
[array([ 17.54195,  17.54195,   6.435  ,  90.     ,  90.     , 120.     ])]
Rp:3.215 | Rwp:4.173 | Rsquare:0.589
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
 44%|██████████████████▉                        | 22/50 [01:44<02:17,  4.93s/it]
WPEM 22-th iteration
[array([ 17.54161,  17.54161,   6.4356 ,  90.     ,  90.     , 120.     ])]
Rp:3.168 | Rwp:4.114 | Rsquare:0.568
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
 46%|███████████████████▊                       | 23/50 [01:48<02:10,  4.81s/it]
WPEM 23-th iteration
[array([ 17.54128,  17.54128,   6.43617,  90.     ,  90.     , 120.     ])]
Rp:3.124 | Rwp:4.060 | Rsquare:0.548
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
 48%|████████████████████▋                      | 24/50 [01:53<02:03,  4.76s/it]
WPEM 24-th iteration
[array([ 17.54098,  17.54098,   6.43672,  90.     ,  90.     , 120.     ])]
Rp:3.083 | Rwp:4.010 | Rsquare:0.529
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
 50%|█████████████████████▌                     | 25/50 [01:58<01:57,  4.68s/it]
WPEM 25-th iteration
[array([ 17.5407 ,  17.5407 ,   6.43722,  90.     ,  90.     , 120.     ])]
Rp:3.044 | Rwp:3.963 | Rsquare:0.511
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
 52%|██████████████████████▎                    | 26/50 [02:02<01:51,  4.65s/it]
WPEM 26-th iteration
[array([ 17.54045,  17.54045,   6.43769,  90.     ,  90.     , 120.     ])]
Rp:3.008 | Rwp:3.920 | Rsquare:0.495
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
 54%|███████████████████████▏                   | 27/50 [02:07<01:46,  4.61s/it]
WPEM 27-th iteration
[array([ 17.54023,  17.54023,   6.43812,  90.     ,  90.     , 120.     ])]
Rp:2.974 | Rwp:3.880 | Rsquare:0.480
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
 56%|████████████████████████                   | 28/50 [02:11<01:40,  4.56s/it]
WPEM 28-th iteration
[array([ 17.54003,  17.54003,   6.43852,  90.     ,  90.     , 120.     ])]
Rp:2.942 | Rwp:3.842 | Rsquare:0.466
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
 58%|████████████████████████▉                  | 29/50 [02:16<01:35,  4.54s/it]
WPEM 29-th iteration
[array([ 17.53987,  17.53987,   6.43888,  90.     ,  90.     , 120.     ])]
Rp:2.912 | Rwp:3.808 | Rsquare:0.453
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
 60%|█████████████████████████▊                 | 30/50 [02:20<01:30,  4.51s/it]
WPEM 30-th iteration
[array([ 17.53973,  17.53973,   6.43921,  90.     ,  90.     , 120.     ])]
Rp:2.885 | Rwp:3.775 | Rsquare:0.440
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
 62%|██████████████████████████▋                | 31/50 [02:25<01:25,  4.49s/it]
WPEM 31-th iteration
[array([ 17.53961,  17.53961,   6.43951,  90.     ,  90.     , 120.     ])]
Rp:2.858 | Rwp:3.745 | Rsquare:0.429
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
 64%|███████████████████████████▌               | 32/50 [02:29<01:20,  4.47s/it]
WPEM 32-th iteration
[array([ 17.53951,  17.53951,   6.43978,  90.     ,  90.     , 120.     ])]
Rp:2.834 | Rwp:3.717 | Rsquare:0.418
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
 66%|████████████████████████████▍              | 33/50 [02:33<01:15,  4.46s/it]
WPEM 33-th iteration
[array([ 17.53942,  17.53942,   6.44003,  90.     ,  90.     , 120.     ])]
Rp:2.811 | Rwp:3.692 | Rsquare:0.408
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
 68%|█████████████████████████████▏             | 34/50 [02:38<01:11,  4.46s/it]
WPEM 34-th iteration
[array([ 17.53936,  17.53936,   6.44025,  90.     ,  90.     , 120.     ])]
Rp:2.789 | Rwp:3.668 | Rsquare:0.399
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
 70%|██████████████████████████████             | 35/50 [02:42<01:07,  4.48s/it]
WPEM 35-th iteration
[array([ 17.5393 ,  17.5393 ,   6.44045,  90.     ,  90.     , 120.     ])]
Rp:2.768 | Rwp:3.645 | Rsquare:0.390
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
 72%|██████████████████████████████▉            | 36/50 [02:47<01:02,  4.45s/it]
WPEM 36-th iteration
[array([ 17.53926,  17.53926,   6.44064,  90.     ,  90.     , 120.     ])]
Rp:2.749 | Rwp:3.624 | Rsquare:0.382
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
 74%|███████████████████████████████▊           | 37/50 [02:51<00:57,  4.46s/it]
WPEM 37-th iteration
[array([ 17.53922,  17.53922,   6.4408 ,  90.     ,  90.     , 120.     ])]
Rp:2.730 | Rwp:3.605 | Rsquare:0.375
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
 76%|████████████████████████████████▋          | 38/50 [02:56<00:53,  4.46s/it]
WPEM 38-th iteration
[array([ 17.5392 ,  17.5392 ,   6.44095,  90.     ,  90.     , 120.     ])]
Rp:2.713 | Rwp:3.586 | Rsquare:0.368
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
 78%|█████████████████████████████████▌         | 39/50 [03:00<00:49,  4.46s/it]
WPEM 39-th iteration
[array([ 17.53918,  17.53918,   6.44109,  90.     ,  90.     , 120.     ])]
Rp:2.696 | Rwp:3.569 | Rsquare:0.361
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
 80%|██████████████████████████████████▍        | 40/50 [03:05<00:44,  4.46s/it]
WPEM 40-th iteration
[array([ 17.53917,  17.53917,   6.44122,  90.     ,  90.     , 120.     ])]
Rp:2.681 | Rwp:3.553 | Rsquare:0.355
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
 82%|███████████████████████████████████▎       | 41/50 [03:09<00:40,  4.46s/it]
WPEM 41-th iteration
[array([ 17.53916,  17.53916,   6.44133,  90.     ,  90.     , 120.     ])]
Rp:2.666 | Rwp:3.538 | Rsquare:0.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
 84%|████████████████████████████████████       | 42/50 [03:13<00:35,  4.44s/it]
WPEM 42-th iteration
[array([ 17.53915,  17.53915,   6.44143,  90.     ,  90.     , 120.     ])]
Rp:2.652 | Rwp:3.524 | Rsquare:0.344
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
 86%|████████████████████████████████████▉      | 43/50 [03:18<00:31,  4.44s/it]
WPEM 43-th iteration
[array([ 17.53915,  17.53915,   6.44152,  90.     ,  90.     , 120.     ])]
Rp:2.638 | Rwp:3.511 | Rsquare:0.338
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
 88%|█████████████████████████████████████▊     | 44/50 [03:22<00:26,  4.42s/it]
WPEM 44-th iteration
[array([ 17.53915,  17.53915,   6.44161,  90.     ,  90.     , 120.     ])]
Rp:2.626 | Rwp:3.499 | Rsquare:0.334
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
 90%|██████████████████████████████████████▋    | 45/50 [03:27<00:22,  4.42s/it]
WPEM 45-th iteration
[array([ 17.53916,  17.53916,   6.44169,  90.     ,  90.     , 120.     ])]
Rp:2.613 | Rwp:3.487 | Rsquare:0.329
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
 92%|███████████████████████████████████████▌   | 46/50 [03:31<00:17,  4.44s/it]
WPEM 46-th iteration
[array([ 17.53916,  17.53916,   6.44176,  90.     ,  90.     , 120.     ])]
Rp:2.602 | Rwp:3.476 | Rsquare:0.325
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
 94%|████████████████████████████████████████▍  | 47/50 [03:36<00:13,  4.42s/it]
WPEM 47-th iteration
[array([ 17.53916,  17.53916,   6.44182,  90.     ,  90.     , 120.     ])]
Rp:2.590 | Rwp:3.466 | Rsquare:0.321
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
 96%|█████████████████████████████████████████▎ | 48/50 [03:40<00:08,  4.42s/it]
WPEM 48-th iteration
[array([ 17.53917,  17.53917,   6.44188,  90.     ,  90.     , 120.     ])]
Rp:2.580 | Rwp:3.456 | Rsquare:0.317
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
 98%|██████████████████████████████████████████▏| 49/50 [03:44<00:04,  4.41s/it]
WPEM 49-th iteration
[array([ 17.53918,  17.53918,   6.44194,  90.     ,  90.     , 120.     ])]
Rp:2.570 | Rwp:3.447 | Rsquare:0.313
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
100%|███████████████████████████████████████████| 50/50 [03:49<00:00,  4.40s/it]
100%|███████████████████████████████████████████| 50/50 [03:49<00:00,  4.58s/it]
WPEM 50-th iteration
[array([ 17.53918,  17.53918,   6.44198,  90.     ,  90.     , 120.     ])]
Rp:2.561 | Rwp:3.439 | Rsquare:0.310
After update the background :   Rp = 2.375 | Rwp = 3.429 | Rsquare = 0.296

../../_images/d0140e8788bf50ee84a5949d208a9c8f5738506a8d1fac12dc089967d739a6b6.png ../../_images/e9cf87a46b39dd7eacdbf48da1e434b299dd03916c167b0b3befb74334a06440.png ../../_images/07a15745c6aff3461fc516acad9ce399c4a64731d4a272a67ccafa84695c1b77.png
Mass fraction without structure factor estimate in % : [100.0] 
 Saved at the result documents
50-th iterations, reach the maximum number of iteration steps.
 Rp: 2.375
Rwp: 3.429 


WPEM program running time :  0 hours 3 minute  53 second  
('0 hours 3 minute  53 second  ',
 [array([ 17.53918,  17.53918,   6.44198,  90.     ,  90.     , 120.     ])])
<Figure size 640x480 with 0 Axes>

After processing the crystalline signals, the remaining signals corresponding to the amorphous phase are saved.

Fit the amorphous signal using the following code:

WPEM.Amorphous_fit(mix_component=3, sigma2_coef = 0.5, max_iter = 5000,peak_location = None,Wavelength=1.03
                )
Number of Iterations: 200
W_list: [1185.12819262 1119.26679446 1052.49632478]
mu_list: [ 7.76302399 12.68996442 13.71204058]
sigma2_list: [3.37732832 1.65921789 2.41546213]
Number of Iterations: 400
W_list: [1185.49473992 1152.83843531 1018.55813663]
mu_list: [ 7.76376354 12.69123709 13.74556784]
sigma2_list: [3.37853699 1.66719305 2.39450036]
Number of Iterations: 600
W_list: [1186.10248817 1191.37946561  979.40935807]
mu_list: [ 7.76504724 12.69074866 13.78980852]
sigma2_list: [3.38078704 1.67263895 2.36260016]
Number of Iterations: 800
W_list: [1186.78376803 1236.56598451  933.54155932]
mu_list: [ 7.76652543 12.69221187 13.84358608]
sigma2_list: [3.38347896 1.67746109 2.32449253]
Number of Iterations: 1000
W_list: [1187.55939546 1289.0345183   880.2973981 ]
mu_list: [ 7.76825618 12.69656684 13.90885422]
sigma2_list: [3.38675259 1.68141332 2.27913892]
Number of Iterations: 1200
W_list: [1188.47713266 1349.4010493   819.0131299 ]
mu_list: [ 7.77035791 12.70486694 13.98836335]
sigma2_list: [3.39086413 1.68427079 2.22487638]
Number of Iterations: 1400
W_list: [1189.61861585 1418.36859023  748.90410577]
mu_list: [ 7.77302613 12.71841302 14.08614601]
sigma2_list: [3.39622158 1.6859776  2.15914804]
Number of Iterations: 1600
W_list: [1191.11997088 1496.99409984  668.77724114]
mu_list: [ 7.77658348 12.73894492 14.20882298]
sigma2_list: [3.40349126 1.68678878 2.07753377]
Number of Iterations: 1800
W_list: [1193.22686579 1587.57903486  576.08541121]
mu_list: [ 7.78161574 12.76926333 14.36949945]
sigma2_list: [3.41389168 1.68754091 1.97077624]
Number of Iterations: 2000
W_list: [1196.53053388 1697.23401637  463.1267616 ]
mu_list: [ 7.78955272 12.81588326 14.60402761]
sigma2_list: [3.43044595 1.69048491 1.81193177]
Number of Iterations: 2200
W_list: [1204.30264349 1864.39879715  288.18987122]
mu_list: [ 7.80841706 12.91177567 15.12582788]
sigma2_list: [3.4703969  1.70617182 1.42301273]
Convergence get at 2380 iterations!
W_list: [1197.27309131 2087.94594198   71.67227856]
mu_list: [ 7.79464934 13.08232997 16.57523755]
sigma2_list: [3.45031766 1.93333885 0.10433542]
estimated interatomic distances : 9.319730
Rp =  7.588248351119466
../../_images/184c812586bfa204ac97b12bb043e22e7d0d447cb007c93138aadd2df9d196ac.png
<Figure size 640x480 with 0 Axes>

After coverage, the amorphous components (referred to as “holes”) are derived. You can visualize each amorphous hole using the provided plotting functions. The results are saved in the DecomposedComponents folder.

WPEM.Plot_Components(lowboundary = 4, upboundary = 19, wavelength = wavelength, Macromolecule = True,phase = 1)
../../_images/2cb49ef4b8b9a858a1a81b076fe09541932a4afc096dbc111d46a8d2a674837c.png
Relative bulk crystallinity % (calculated by integral area): 39.83147026233813 
 Saved at the WPEMFittingResults

The relative bulk crystallinity can be estimated from the diffraction intensity ratio

after subtracting the amorphous signal, which is saved in the ‘DecomposedComponents’ folder as ‘Amorphous.csv’.

Additionally, the radial distribution function (RDF) can be applied to the remaining signal to calculate the nearest-neighbor atomic distance based on features within the diffraction pattern.

WPEM.AmorphousRDFun( r_max = 4,density_zero=None,Nf2=1,highlight= 6,)
../../_images/6fe8b2536c2676bf80ea13168e69ad6459ebba1839a932afca28015fb415b034.png ../../_images/3eaa898aef9ba24a0e01139d007f9079ba2a5c6bf7e8f9e58cb2cddaa8371af7.png ../../_images/c7e44c3fc7740e5a79ce2cc3e1ebc2e12bd13be156fb85f6656a54c8aa94bb1e.png
interatomic distances is 0.940000 A°
[0.42, 0.93, 1.36, 1.8, 2.23, 2.68]
<Figure size 640x480 with 0 Axes>

See also

The peak positions at 0.42, 0.93, 1.36, 1.80, 2.23, and 2.68 correspond to a series of atomic clusters.