  Polarized Resonant Soft X-ray scattering (P-RSoXS) has emerged as a powerful
synchrotron-based tool that combines principles of X-ray scattering and X-ray
spectroscopy. P-RSoXS provides unique sensitivity to molecular orientation and
chemical heterogeneity in soft materials such as polymers and biomaterials.
Quantitative extraction of orientation information from P-RSoXS pattern data is
challenging because the scattering processes originate from sample properties
that must be represented as energy-dependent three-dimensional tensors with
heterogeneities at nanometer to sub-nanometer length scales. We overcome this
challenge by developing an open-source virtual instrument that uses GPUs to
simulate P-RSoXS patterns from real-space material representations with
nanoscale resolution. Our computational framework CyRSoXS
(https://github.com/usnistgov/cyrsoxs) is designed to maximize GPU performance.
We demonstrate the accuracy and robustness of our approach by validating
against an extensive set of test cases, which include both analytical solutions
and numerical comparisons, demonstrating a speedup of over three orders
relative to the current state-of-the-art simulation software. Such fast
simulations open up a variety of applications that were previously
computationally infeasible, including (a) pattern fitting, (b) co-simulation
with the physical instrument for operando analytics, data exploration, and
decision support, (c) data creation and integration into machine learning
workflows, and (d) utilization in multi-modal data assimilation approaches.
Finally, we abstract away the complexity of the computational framework from
the end-user by exposing CyRSoXS to Python using Pybind. This eliminates I/O
requirements for large-scale parameter exploration and inverse design, and
democratizes usage by enabling seamless integration with a Python ecosystem
(https://github.com/usnistgov/nrss).
