DOI: 10.5061/dryad.6t1g1jx65
title: Resonant Soft X-ray Scattering Reveals the Distribution of Dopants in Semicrystalline Conjugated Polymers

description: The distribution of counterions and dopants within electrically doped
 semicrystalline conductive polymers, such as
 poly(3-hexylthiophene-2,5-diyl) (P3HT), plays a pivotal role in charge
 transport. The distribution of counterions in doped films of P3HT with
 controlled crystallinity was examined using polarized resonant soft X-ray
 scattering (P-RSoXS). The changes in scattering of doped P3HT films
 containing trifluoromethanesulfonimide (TFSI−) and
 2,3,5,6-tetrafluoro-7,7,8,8-tetracyanoquinodimethane (F4TCNQ•−) as
 counterions to the charge carriers revealed distinct differences in their
 nanostructure. The scattering anisotropy of P-RSoXS from doped blends of
 P3HT was examined as a function of the soft X-ray absorption edge and
 found to vary systematically with the composition of crystalline and
 amorphous domains and by the identity of the counterion. A computational
 methodology was developed and used to simulate the soft X-ray scattering
 as a function of morphology and molecular orientation of the counterions.
 Modeling of the P-RSoXS at N and F K-edges was consistent with a structure
 where the conjugated plane of F4TCNQ•− aligns perpendicularly to that of
 the P3HT backbone in ordered domains. In contrast, TFSI− was distributed
 more uniformly between domains with no significant molecular alignment.
 The approach developed here demonstrates the capabilities of P-RSoXS in
 identifying orientation, structural, and compositional distributions
 within doped conjugated polymers using a computational workflow that is
 broadly extendable to other soft matter systems.
description: <strong>Materials and Processing Conditions.
 </strong>Low number-average molecular mass regioregular (RRe) P3HT
 [4.5 kg/mol, dispersity (Đ) = 1.6], high molecular mass RRe P3HT (23
 kg/mol, Đ = 1.8), and regiorandom (RRa) P3HT (16.3 kg/mol, Đ = 2.5)
 (Figure 2), were dissolved in an equal-volume mixture of chlorobenzene and
 dichlorobenzene. P3HT solutions of varying blend composition were drop
 cast onto substrates to form (700 to 1000) nm thick films. P3HT films were
 doped in an inert nitrogen glovebox atmosphere, enclosing the film and ≈3
 mg of F4TCNQ crystals within a jar in the orientation depicted in Figure
 3.36 The jar was heated to 200 °C for 45 min, allowing for sublimation of
 F4TCNQ to oxidize the P3HT film. TFSI−-containing samples were formed by
 anion exchange from immersion in a concentrated LiTFSI solution (0.03 mass
 fraction in acetonitrile) for 120 min at 60 °C. Table S1 in the
 corresponding article summarizes the varying P3HT blend compositions
 utilized in this study, resultant levels of aggregation, and dopant
 counterion concentrations. <strong>Atomic Force
 Microscopy.</strong> An Asylum MFP-3D atomic force microscope was
 used in tapping mode to examine the surface roughness of the P3HT blend
 films. The AFM tip was a silicon cantilever with a resonance frequency of
 approximately 61 kHz and a spring constant of about 1.6 N/m.
 <strong>UV−Vis Absorbance Spectroscopy.</strong> All
 ultraviolet−visible (UV−vis) spectra were acquired using an Agilent
 Technologies Cary 60 UV−vis spectrometer. Samples were drop cast from
 solution onto quartz substrates to form optically transparent films.
 Spectra for P3HT films of varying composition were fit to the Spano model
 via a custom Python script to quantify aggregate mole fractions.
 <strong>X-ray Photoelectron Spectroscopy.</strong>
 X-ray photo-electron spectroscopy (XPS) measurements were performed using
 an Escalab Xi+ Spectrometer from ThermoFisher Scientific. The spectrometer
 operated under a high vacuum condition of 10−6 Pa and utilized a
 monochromatic aluminum Kα X-ray source. To stabilize charge during the
 measurements, we used a dual ion-electron low-energy flood source.
 For acquiring survey spectra, we set the pass energy to 100 eV and
 conducted five scans at intervals of 0.25 eV, each with a dwell time of 50
 ms. Depth profiling was done using an ion gun with a 1000-atom Ar+ cluster
 and an ion energy of 6000 eV. Ion sputtering covered a square region
 measuring (1.5 × 1.5) mm<sup>2</sup>. Within this area, we
 collected photoexcited electrons from the inner (400 × 400)
 μm<sup>2</sup> region to selectively isolate signal from
 crater centers. All spectra are presented in the Supporting Information
 along with an AFM images of the topography of the films.
 <strong>Grazing Incidence Wide Angle X-ray Scattering.
 </strong>Grazing incidence wide-angle X-ray scattering (GIWAXS) was
 performed at the BioPACFIC MIP user facilities at UC Santa Barbara and
 experimental station 11-3 at the Stanford Synchrotron Radiation
 Lightsource. Angle-resolved GIWAXS scans were acquired with 120 s
 exposures at grazing incidence angles of 0.05°, 0.10°, and 0.13° using an
 X-ray energy of 12.7 keV. 2D detector images were remapped to q-space
 using Nika and the WAXSTools Igor packages. Partial pole figure analysis
 was done using <strong>GIWAXS_Tools</strong>, a custom
 open-source software.  <strong>Resonant Soft
 X-ray Scattering.</strong> Polarized resonant soft X-ray scattering
 (P-RSoXS) experiments were performed at the Spectroscopy Soft and Tender
 (SST-1) beamline funded and operated by the National Institute of
 Standards and Technology (NIST) at the National Synchrotron Light Source
 II (NSLS-II). Data reduction was performed using
 <strong>PyHyperScattering</strong>, an open source package for
 hyperspectral scattering reduction and analysis. Thin film samples on
 transparent silicon nitride windows were mounted normal to the incident
 X-ray beam with samples measured in transmission mode under high vacuum
 conditions. <strong>Computation of Near Edge
 X-ray Absorption Fine Structure.</strong> Near edge X-ray absorption
 fine structure (NEXAFS) simulations were carried out using the PWscf and
 XSpectra software packages of the <strong>Quantum
 ESPRESSO</strong> distribution. The simulation process consists of
 (1) sourcing equilibrated or equilibrating atomic coordinates for a given
 molecule, (2) obtaining the electronic structure for each core-hole
 configuration of the molecule, and calculating the polarization-dependent
 X-ray absorbance spectra for each core-hole configuration. The
 configuration-specific spectra are offset by their relative total
 energies. The sum of spectra for each polarization direction are offset to
 experimental absorption onsets (e.g., the C 1s →
 π*<sub>C=C</sub> peak measured at 285.25 eV) to obtain
 oriented NEXAFS. The NEXAFS are normalized to the bare atom scattering
 factors to obtain the imaginary component of the refractive
 indices, <em>β</em>, which can be used to solve for the
 real portion, <em>δ</em>, using the Kramers−Kronig
 relations. To calculate P3HT NEXAFS, atomic coordinates for unit cells of
 low-energy crystalline polymorphs of P3HT were sourced from literature. We
 adopt the approach of using a supercell consisting of 3-hexylthiophene
 8-mer with periodic boundary conditions to represent a single polymer
 chain. This is consistent with prior work demonstrating that 6 repeat
 units is sufficient to isolate adjacent core-hole excitons. Our tests also
 confirmed that π-stacking effects are minimal and that
 <em>k</em>-point sampling density variations produce
 negligible spectral changes (Figures S10−S13). This further confirms that
 the chosen supercell is sufficient to capture key attributes of the
 simulated NEXAFS.  For the simulations involving dopant
 counterions, atomic coordinates were geometrically optimized through a
 relaxation calculation in Quantum ESPRESSO. A single dopant molecule
 within a sufficiently large cubic lattice was used to ensure the isolation
 of core-hole exciton effects. The optimization process employed the
 generalized gradient approximation (GGA), following the
 Perdew−Burke−Ernzerhof (PBE) scheme, and utilized a plane-wave cutoff
 energy of 30 Ry.  <strong>P-RSoXS
 Simulations.</strong> P-RSoXS simulations were carried out using the
 <strong>NIST RSoXS Simulation Suite (NRSS)</strong> which
 incorporates tools to validate input models and
 <strong>CyRSoXS</strong>, a virtual beamline instrument.
 Simulated morphologies were generated using
 <strong>DopantModeling</strong>, a custom open-source software
 developed specifically for this work.
description: # Resonant Soft X-ray Scattering Reveals the Distribution of Dopants in
 Semicrystalline Conjugated Polymers
 [https://doi.org/10.5061/dryad.6t1g1jx65](https://doi.org/10.5061/dryad.6t1g1jx65) ## Description of the data and file structure This work focuses on the analysis of Polarized Resonant Soft X-Ray Scattering (P-RSoXS) from a conjugated polymer, poly(3-hexylthiophene-2,5-diyl) (P3HT), doped with two distinct small molecules: trifluoromethanesulfonimide (TFSI⁻) and 2,3,5,6-tetrafluoro-7,7,8,8-tetracyanoquinodimethane (F4TCNQ•⁻). A digital twin of the material system was developed to simulate the P-RSoXS experiments. To support the model's development, various physical characterization methods were employed, including Atomic Force Microscopy (AFM) to assess sample surface morphology, Grazing Incidence Wide Angle X-Ray Scattering (GIWAXS) to determine crystal orientation distribution, UV-vis spectroscopy to evaluate sample crystallinity, and X-Ray Photoelectron Spectroscopy (XPS) to analyze chemical composition. Analysis code, provided in Jupyter notebooks, parses data, performs analyses, and generates plots featured in the article and/or inputs for modeling software. Additional model inputs, such as complex refractive indices, inform how the material interacts with X-rays. Scripts for simulating refractive indices and corresponding Jupyter notebooks for analysis are provided. Custom software and scripts to construct the models and simulate the resultant scattering are provided. Finally, Jupyter notebooks for analyzing the experimental and simulated P-RSoXS in an identical manner are provided, facilitating direct comparisons as detailed in the corresponding article. ### Files and variables #### File: UV\_Vis\_Spectroscopy.zip **Description:**  Subfolder(s): * Figure 2 Crystallinity Versus P3HT Blend Composition * Contains `.csv` files of UV-vis absorbance spectra (absorbance and wavelength in nm) for various P3HT blend formulations. This data is used to generate Figure 2 in the article. A Jupyter notebook (`Spano_Model_Fitting.ipynb`) parses the data, calculates blend crystallinities, and generates the plot shown in Figure 2. #### File: X-Ray\_Photoelectron\_Spectroscopy\_(XPS).zip **Description:**  All `.xlsx` and `.xls` files were exported directly from XPS instrument software (Thermo Scientific Avantage 5.9925). Subfolder(s): * Figure 3 Dopant Concentration Versus P3HT Blend Composition * Depth profile data includes etch time (s) and atomic percent (%) for analyzed elements. The Jupyter notebook (`Dopant_Quantification_From_XPS.ipynb`) parses the data and produces the plot shown in Figure 3. - Figure S2 XPS Depth Profile of LiTFSI Exchanged, 100% Regioregular P3HT Film * Contains survey spectra data, with intensity (counts/s) as a function of binding energy (eV) and etch time (s). The Jupyter notebook (`XPS_Depth_Profile_of_LiTFSI_Exchanged_100pct_Regioregular_P3HT_Film.ipynb`) parses the data and generates the plot shown in Figure S2. - Figure S3 Quantified XPS Depth Profile of F4TCNQ Vapor Doped P3HT * Depth profile data includes etch time (s) and atomic percent (%) for analyzed elements. The Jupyter notebook (`F4TCNQ_Vapor_Doping_Penetration_Depth.ipynb`) parses the data and generates the plots shown in Figure S3. - Figure S4 Quantified XPS Depth Profile of Doped, TFSI- Anion Exchanged P3HT * Depth profile data includes etch time (s) and atomic percent (%) for analyzed elements. The Jupyter notebook (`TFSI_Anion_Exchange_Penetration_Depth.ipynb`) parses the data and generates the plots shown in Figure S4. - Figure S6 XPS Survey Spectra of F4TCNQ Surface Layer on P3HT * Contains survey spectra data, with intensity (counts/s) as a function of binding energy (eV) and etch time (s). The Jupyter notebook (`Dopant_Quantification_From_XPS.ipynb`) parses the data and produces the plot shown in Figure S6. #### File: Atomic\_Force\_Microscopy\_(AFM).zip **Description:**  Contains `.ibw` files used to generate the figures indicated by subfolder names. AFM data from the `.ibw` files were visualized with **Gwyddion**, an open-source software for data visualization and analysis. Subfolder(s): * Figure S1 Atomic Force Microscopy of Least and Most Crystalline P3HT Blend * Figure S5 Atomic Force Microscopy of F4TCNQ Vapor-Doped and TFSI- Anion Exchanged Films #### File: Grazing\_Incidence\_Wide\_Angle\_X-Ray\_Scattering\_(GIWAXS).zip **Description:**  Folder(s): * Doped Blends * Contains GIWAXS data for various P3HT blends doped with TFSI⁻ or F4TCNQ•-. Each blend includes three GIWAXS datasets corresponding to grazing incidence angles of 0.1°, 0.05°, and 0.13°. Each dataset contains a `.tif` file and a `.txt` metadata file, following the naming convention: `{Sample_ID}_{incidence_angle}_{exposure_time}_{beamline-generated_ID}_0001.tif`. * lab6_cal * Contains GIWAXS data for LaB6 at an incidence angle of 3° (rocked continuously by 0.5°) with an exposure time of 10 seconds. This dataset is used as a reference for determining beam center and sample-to-detector distance. * Neutral_Blends * Similar structure to "Doped Blends," containing GIWAXS data for undoped P3HT blends. * Processed_Datasets * Contains `.nc` (NetCDF) files with processed GIWAXS data outputs, generated using the Jupyter notebook `GIWAXS_Analysis.ipynb`. File(s): * GIWAXS_Analysis.ipynb * Utilizes **GIWAXS_Tools** to import, analyze, and process GIWAXS data from the SSRL 11-3 beamline instrument. Outputs are saved as `.nc` files in the "Processed_Datasets" folder. Parts or all of Figure S7, Figure S8, and Figure S11 are generated by this notebook.  #### File: Near-Edge\_X-Ray\_Absorbance\_Fine\_Structure\_(NEXAFS).zip **Description:**\ Folder(s): * Optical Constants Database P3HT * "P3HT_db" is a folder containing experimentally derived absorbance spectra for P3HT at the C K-edge, provided in both `.txt` and `.csv` formats. * The Jupyter notebook (`kkcalc_P3HT_C_K_Edge_Calculation.ipynb`) processes the absorbance spectra by (1) normalizing to the bare atom scattering factors pre- and post-edge, (2) re-normalizing to absorbance, (3) calculating reflectance, and (4) saving the outputs as `.txt` files in the same directory. * Additional Jupyter notebooks (`kkcalc_P3HT_F_K_Edge_Calculation.ipynb` and `kkcalc_P3HT_N_K_Edge_Calculation.ipynb`) calculate the expected absorbance and reflectance for other relevant edges, saving results to `.txt` files. * Avogadro_Structures * This folder contains `.cml` files generated using **Avogadro**, a molecular visualization software. These files represent the 3D structures of dopant molecules. The atom positions in these `.cml` files were used as starting inputs for **Quantum Espresso** relaxation calculations. * mbxas_spectra * This folder contains output files from **MBXAS**, a tool for calculating X-ray absorbance spectra. The Jupyter notebook (`mbxas_plotting.ipynb`) processes these output files to generate plots of absorbance spectra and saves the plots as `.tiff` files. Results are included for F4TCNQ, KTFSI, and NaTFSI. These results are supplementary to X-ray absorbance spectra calculated using the **XSpectra** module of **Quantum Espresso** and are not used for results presented in the corresponding article main text. * Quantum_ESPRESSO_HPC * Contains input and output files for calculating electronic configurations for various unit cells of different chemical species and core-hole configuration-specific absorbance spectra. * Folder(s): * Pseudopotentials * Contains original pseudopotential files (from the [SSSP Efficiency Library](https://materialscloud.org/sssp)) and custom core-hole pseudopotential files. Core-hole pseudopotentials were created by modifying the original pseudopotential inputs and regenerating `.UPF` files using **Quantum Espresso**'s `ld1.x` module. These files are required for X-ray absorbance spectrum calculations. * F4TCNQ * Configuration files for neutral F4TCNQ (not used in the corresponding article). Includes folders named "Relaxation" with input files (`.in`), bash scripts (`job.s`) for SLURM submission, and output files reporting relaxed atomic positions. Also includes subfolders for X-ray absorbance spectra calculations at the C, N, and F K-edges, with Python scripts (`generate_*_input_files.py`) to generate SCF and **XSpectra** input files, bash scripts for job submission to SLURM, and output files. The following subfolders in this section have the same structure. * Reduced_F4TCNQ * Configuration and output files for NEXAFS calculations of F4TCNQ•- (used in the corresponding article). * TFSI * Configuration and output files for NEXAFS calculations of TFSI- (not used in the corresponding article).  * TFSI_2 * Configuration and output files for NEXAFS calculations of TFSI- (used in the corresponding article).  * P3HT_3 * Configuration and output files for NEXAFS calculations of four π-stacked 8-mers of 3-hexylthiophene (3HT), sampling only the *Γ*-point.  * P3HT_4 * Configuration and output files for NEXAFS calculations of four π-stacked 8-mers of 3HT, sampling a 2×2×2 *k*-point grid.  * P3HT_5 * Configuration and output files for NEXAFS calculations of a non-π-stacked 8-mer of 3HT, sampling only the *Γ*-point (used in the main text of the corresponding article).  * P3HT_6 * Configuration and output files for NEXAFS calculations of a non-π-stacked 8-mer of 3HT, sampling a 2×2×2 *k*-point grid.  * Jupyter_Notebooks * Contains Jupyter notebooks for parsing **XSpectra** output files, performing calculations (normalization, reflectance, contrast), and generating plots for the corresponding article. * File(s): * `Simulated_2x2x2k_P3HT_C_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S13 are generated by this notebook.  * `Simulated_F4TCNQ_C_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S15 and Figure S25 are generated by this notebook.  * `Simulated_F4TCNQ_F_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S17 and Figure S27 are generated by this notebook.  * `Simulated_F4TCNQ_N_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S16 and Figure S26 are generated by this notebook.  * `Simulated_P3HT_C_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure 4, Figure 7, Figure S5, Figure S12, and Figure S24 are generated by this notebook. * `Simulated_P3HT_S_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S14 are generated by this notebook. * `Simulated_Pi_Stacked_2x2x2k_P3HT_C_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S11 are generated by this notebook.  * `Simulated_Pi_Stacked_P3HT_C_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S10 are generated by this notebook.  * `Simulated_Reduced_F4TCNQ_C_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S18 and Figure S28 are generated by this notebook.  * `Simulated_Reduced_F4TCNQ_F_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S20 and Figure S30 are generated by this notebook.  * `Simulated_Reduced_F4TCNQ_N_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S19 and Figure S29 are generated by this notebook.  * `Simulated_TFSI_C_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S21 and Figure S31 are generated by this notebook.  * `Simulated_TFSI_F_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S23 and Figure S33 are generated by this notebook.  * `Simulated_TFSI_N_K_Edge_Refractive_Indices.ipynb` * Parts or all of Figure S22 and Figure S32 are generated by this notebook.  * kkcalc * Local copy of **kkcalc**, used for calculating complex refractive indices from NEXAFS. Dependency for notebooks in "Jupyter_Notebooks". #### File: Experimental Polarized Resonant Soft X-Ray Scattering (P-RSoXS).zip **Description:**\ Folder(s): * SST-1 September 2022 RSoXS Data * Contains subfolders with raw P-RSoXS datasets generated by the SST-1 beamline instrument. Data is in the native output format of the beamline instrument, optimized for parsing with **PyHyperScattering**. * Processed_Experimental_Datasets * Contains `.nc` files that are outputs from the batch analysis performed in `PyHyperScattering_Batch_Processing.ipynb`. These files are used for further processing and plot generation. File(s): * `Mosaic_Figures.ipynb` * Reads `.nc` files in "Processed_Experimental_Datasets" to generate various plots. Parts or all of Figure 6, Figure 9, Figure 10, and Figure S35 - Figure S39 and are generated by this notebook.  * `PyHyperScattering_Batch_Processing.ipynb` * Uses **PyHyperScattering** to batch process P-RSoXS datasets output by the SST-1 beamline. Saves processed data to "Processed_Experimental_Datasets" as `.nc` files. * `PyHyperScattering_Single_Processing.ipynb` * Uses **PyHyperScattering** to import P-RSoXS data files and perform detailed analysis on individual scans. Parts or all of Figure 4, Figure 7, and Figure S34 are generated by this notebook.  * `SST1_Nov2022_WAXS_mask.hdf` * Mask file created using **Nika**, an open-source software for analyzing X-ray scattering data in Igor Pro. Used in `PyHyperScattering_Batch_Processing.ipynb` and `PyHyperScattering_Single_Processing.ipynb` to exclude specific regions of the X-ray scattering detector during analysis.  #### File: Computational\_Polarized\_Resonant\_Soft\_X-Ray\_Scattering\_(P-RSoXS).zip **Description:**  * Subfolder(s): * Simulation_Outputs * Contains P-RSoXS simulation files, including Python scripts for setting up and running CyRSoXS simulations. * Subfolders include "full_sims", "full_sims_dopant_x0p8", "full_sims_dopant_x1p2", "full_sims_polymer_x0p8", and "full_sims_polymer_x1p2". These subfolders contain simulation files which use distinct refractive indices for dopants or polymers, scaled by 0.8 or 1.2 to simulate ±20% changes in dopant concentration or polymer density. Further subfolders within each are "C_1s", "F_1s", and "N_1s". These contain simulations performed at the C, F, and N K-edges, respectively. * `cyrsoxs.{instance_id}.out` files are log files generated to capture console outputs when run on High Performance Computing (HPC) nodes. `{instance_id}` is a numerical ID generated by the system. * There are further subfolders "C_1s", "F_1s", and "N_1s", which are specific to the elemental edge at which the simulations within are carried out.  * Within each elemental edge subfolder, `params.py` and `run.py` files are included to set up and run the CyRSoXS simulations. The `params.py` file contains user-specified parameters used by **DopantModeling** for morphology generation. The `run.py` script sweeps over different simulation parameters, including the center-to-center distance of fibrils, the type of dopant, the distribution of dopant across P3HT crystalline/amorphous domains, and the orientation of the dopant relative to the polymer, and uses **NRSS** to run the simulation.  * The simulation outputs are saved in nested directories which follow the parameter sweep structure. Key files and outputs include: * `params.py`, `run.py`: Setup and execute simulations with parameter sweeps over fibril spacing, dopant type, dopant distribution, and dopant orientation. * "HDF5" folder: Contains `.h5` simulation output files, parsed using **PyHyperScattering**. * "0_reduced"-prefixed folder: Contains plots of processed data, generated by `PyHyperScattering_Batch_CyRSoXS.ipynb`. * `config.txt`, `CyRSoXS.log`: Metadata files for simulation configuration and execution details. * `mat*_checkH5.png`: Morphology visualizations for vacuum, crystalline P3HT, amorphous P3HT, and dopants. These plots are generated by **NRSS** as an optional check that models are generated as expected. * `Material*.txt`: Contain energy- and orientation-dependent refractive indices for vacuum, crystalline P3HT, amorphous P3HT, and dopants. * `parameters_doped.txt`, `parameters_undoped.txt`: Metadata on model properties before and after dopant addition. * Simulation_Results * Contains analyzed simulation results in `.nc` format, created by `PyHyperScattering_Batch_CyRSoXS.ipynb`. Note that "C_1s_10_c2c_single", "best_match_10_c2c", "*_F4TCNQ_orientation_10_c2c", and "theta_orientation" folders were created manually and individual `.nc` files were copied within from other folders. These folders are used for generating plots in Figure 7, Figure 9, Figure 10, and Figure S9, respectively.  * Folders have name nomenclature as `{elemental edge}_{polymer/dopant}_{x0p8/x1p2}_{center-to-center distance}`. * `{elemental edge}` refers to the elemental edge at which those simulations were performed. * `{polymer/dopant}_{x0p8/x1p2}` refers to the specific set of refractive indices used in those simulations. For example, "polymer_x0p8" would refer to using P3HT refractive indices that have been scaled by 0.8. Similar interpretation can be applied to other folder names. The corresponding refractive indices can be found in `...\Computational Polarized Resonant Soft X-Ray Scattering (P-RSoXS)\DopantModeling\data`. * `{center-to-center distance}` refers to the distance between fibrils in the model and correlates with the model's mole fraction crystallinity. * `.nc` files have the naming convention `{elemental edge}_{CMF}_{dopant}_{dopant orientation}_{CDF/uniform}.nc`.  * `{elemental edge}` refers to the elemental edge at which those simulations were performed. * `{CMF}` (Crystalline Mole Fraction): Refers to the mole fraction of crystalline P3HT in the model before the addition of dopants. This parameter reflects the initial crystallinity of the polymer matrix. * `{dopant}` Specifies the type of dopant in the model. Examples include: * `Reduced_F4TCNQ_C_Kedge`: F4TCNQ•⁻ dopant. * `TFSI_2_C_Kedge`: TFSI⁻ dopant. * `vacuum`: Represents an undoped or empty system. * `{dopant orientation}`: Describes the alignment of the dopant relative to crystalline P3HT within the same voxel. Possible orientations include: * ISO (isotropic): Dopants are randomly oriented. * ISO_S0: Dopants are randomly oriented with an alignment parameter (S) of 0, indicating no preferred alignment. * PAR (parallel): Dopants are aligned parallel to the crystalline P3HT. * PERP (perpendicular): Dopants are aligned orthogonally to the crystalline P3HT. * `{CDF/uniform}` (crystalline dopant fraction or uniform): Refers to the distribution of dopants in the simulation: * CDF (Crystalline Dopant Fraction): Describes the mole fraction of total dopant within voxels that contain crystalline P3HT. * uniform: Indicates that dopants are evenly distributed across the entire morphology, regardless of crystalline regions. * File(s): * `PyHyperScattering_Batch_CyRSoXS.ipynb` * Parses simulation outputs in "Simulation_Outputs", analyzes the data, and saves results to "Simulation_Results" in `.nc` format. Generates plots saved in "0_reduced"-prefixed folders and creates subfolders for analyzed data. Parts or all of Figure 7, Figure 9, Figure 10, Figure S9, and Figure S40 - Figure S60 are generated by this notebook. #### File: DopantModeling.yml **Description:** `DopantModeling.yml` contains the specifications for the Python environment used to perform modeling, data analysis, and visualization related to this study. This environment was created and managed using Conda. ## Code/software * **[NIST RSoXS Simulation Suite (NRSS) 0.1.0](https://github.com/usnistgov/NRSS/releases/tag/0.0.1)**: Used to simulate P-RSoXS data. This includes **[CyRSoXS](https://github.com/usnistgov/cyrsoxs)**, a virtual RSoXS beamline instrument. * **[PyHyperScattering v0.2.3](https://github.com/usnistgov/PyHyperScattering/releases/tag/0.2.3)**: Used to parse experimental P-RSoXS data files. * **[DopantModeling ](https://github.com/devoncallan/DopantModeling/releases/tag/v1.0.0)[v1.0.0](https://github.com/devoncallan/DopantModeling/tree/v1.0.0)**: A custom tool developed specifically for this work to generate input models for **CyRSoXS** simulations. * **[Quantum ESPRESSO v.6.8](https://github.com/QEF/q-e/releases/tag/qe-6.8)**: * **PWscf module**: Used for atomic position relaxation and subsequent SCF calculations to obtain core-hole configuration-specific electronic configurations. * **XSpectra module**: Used to calculate X-ray absorbance spectra for specific core-hole configurations. * **[GIWAXS_Tools v1.0.0](https://github.com/phonghnguyen/GIWAXS_Tools/releases/tag/v1.0.0)**: Used for analyzing GIWAXS data and calculating P3HT (020) orientational distributions. * **[kkcalc 0.7.5](https://github.com/benajamin/kkcalc)**: Used for normalizing calculated X-ray absorbance spectra to absorbance and calculating reflectance using the Kramers-Kronig relations. * **[Gwyddion](http://gwyddion.net/)**: Used for plotting AFM data.  * **[Nika](https://www.aps.anl.gov/Science/Scientific-Software/Nika)**: Used for creating mask files for regions of the P-RSoXS X-ray detector.  * **[Avogadro](https://avogadro.cc/)**: Used for initial 3D visualization and atomic coordinates of dopant molecules prior to relaxation calculations. * **MBXAS**: Used for supplementary calculation of X-ray absorbance spectra. Available through the Molecular Foundry at Lawrence Berkeley National Laboratory. #### Additional Code * The remaining scripts and workflows used for data parsing, analysis, and plotting are provided within Jupyter notebooks. These are described in detail in the **Files and Variables** section of this README. ## Access information Other publicly accessible locations of the data: * P3HT refractive indices are available through the [Optical-Constants-Database](https://github.com/EliotGann/Optical-Constants-Database) * Pseudopotential files are available through the [SSSP Efficiency Library](https://materialscloud.org/sssp)