|
| 1 | +from pyxtal import pyxtal |
| 2 | +from pyxtal.reciprocal import RECP |
| 3 | +import matplotlib.pyplot as plt |
| 4 | +import numpy as np |
| 5 | +np.random.seed(42) |
| 6 | + |
| 7 | +# Use a modern style |
| 8 | +plt.style.use('seaborn-v0_8-darkgrid') |
| 9 | + |
| 10 | +# Customize plot appearance |
| 11 | +plt.rcParams.update({ |
| 12 | + #'font.family': 'serif', |
| 13 | + 'font.size': 12, |
| 14 | + 'axes.labelsize': 14, |
| 15 | + 'axes.titlesize': 14, |
| 16 | + 'legend.fontsize': 12, |
| 17 | + 'axes.grid': True, |
| 18 | + 'grid.alpha': 0.3, |
| 19 | + 'lines.linewidth': 2, |
| 20 | + 'figure.dpi': 300 |
| 21 | +}) |
| 22 | + |
| 23 | +data = [(227, ['8a'], [3.567]), |
| 24 | + (216, ['4a', '4d'], [3.567]), |
| 25 | + (210, ['8b'], [3.567]), |
| 26 | + (203, ['8a'], [3.567]), |
| 27 | + (166, ['6c'], [2.522, 6.178, 0.125]), |
| 28 | + (141, ['4a'], [2.522, 3.567]), |
| 29 | + (122, ['4b'], [2.522, 3.567]), |
| 30 | + (119, ['2b', '2d'], [2.522, 3.567]), |
| 31 | + (109, ['4a'], [2.522, 3.567, 0.875]), |
| 32 | + (98, ['4b'], [2.522, 3.567]), |
| 33 | + (88, ['4a'], [2.522, 3.567], ), |
| 34 | + #(74, ['4e'], [2.522, 2.522, 3.567, 0.875]), |
| 35 | + (70, ['8a'], [3.567, 3.567, 3.567])] |
| 36 | + |
| 37 | +data0 = [] |
| 38 | +recp = RECP(dmax=10.0, nmax=10, lmax=10, rbasis='Bessel') |
| 39 | + |
| 40 | + |
| 41 | +xtal = pyxtal() |
| 42 | +xtal.from_prototype('diamond') |
| 43 | +xtal_sub = xtal.subgroup_once(H=141, eps=0) |
| 44 | + |
| 45 | +fig, axs = plt.subplots(3, 2, figsize=(12, 7.5)) |
| 46 | +for row, eps in enumerate([0, 0.02, 0.05]): |
| 47 | + data1 = [] |
| 48 | + for i, d in enumerate(data): |
| 49 | + if i == 0: |
| 50 | + xtal0 = xtal.copy() |
| 51 | + else: |
| 52 | + xtal0 = xtal.subgroup_once(H=d[0], eps=eps) |
| 53 | + if xtal0 is not None: |
| 54 | + p, rdf = recp.compute(xtal0.to_ase(), norm=True) |
| 55 | + else: |
| 56 | + xtal0 = xtal_sub.subgroup_once(H=d[0], eps=eps) |
| 57 | + if xtal0 is None: |
| 58 | + print('problem', d[0]); import sys; sys.exit() |
| 59 | + p, rdf = recp.compute(xtal0.to_ase(), norm=True) |
| 60 | + data1.append((p, rdf, f'{xtal0.group.number}')) |
| 61 | + |
| 62 | + # Plot p values |
| 63 | + axs[row, 0].set_title(f'$P$ (noise={eps})', y=0.80, x=0.05, loc='left') |
| 64 | + for p, _, label in data1: |
| 65 | + axs[row, 0].plot(p, label=label, alpha=0.5, lw=1.0) |
| 66 | + |
| 67 | + |
| 68 | + axs[row, 0].set_ylabel('$P_{nl}$') |
| 69 | + if row == 2: |
| 70 | + axs[row, 0].set_xlabel('Power Spectrum Index') |
| 71 | + |
| 72 | + # Plot rdf values |
| 73 | + axs[row, 1].set_title(f'$G$ (noise={eps})', y=0.80, x=0.05, loc='left') |
| 74 | + for _, rdf, label in data1: |
| 75 | + axs[row, 1].plot(rdf, label=label, alpha=0.5, lw=1.0) |
| 76 | + if row == 2: |
| 77 | + axs[row, 1].set_xlabel(r'$d$ ($\mathrm{\AA}^{-1}$)') |
| 78 | + else: |
| 79 | + axs[row, 0].set_xticklabels([]) |
| 80 | + axs[row, 1].set_xticklabels([]) |
| 81 | + |
| 82 | + axs[row, 1].set_ylabel('$G(d)$') |
| 83 | + if row == 0: axs[row, 1].legend(ncol=2, loc='upper right') |
| 84 | + |
| 85 | +plt.tight_layout() |
| 86 | +plt.savefig('test1-diamond.png') |
| 87 | +plt.close() |
| 88 | + |
| 89 | + |
| 90 | + |
0 commit comments