# Error-Bounded Learned Scientific Data Compression with Preservation of Derived Quantities
## 2 XGC Application  
XGC [31; 32] is one of the most important first principles fusion codes used to understand the physics in the edge of a fusion experiment, and is part of the DOE Exascale Computing Program. XGC uses a Particle-In-Cell (PIC) technique and evolves a massively large number of particles based on a five-dimensional gyrokinetic equation of motion, three in physical space and two in the velocity space. In XGC, particles are moved according to the physics equations in a time-stepping manner, and then regularly summarized to a discretized 3D space by planes and meshes for solving electric and magnetic field equations. One of the large datasets gathered in the mesh is a particle distribution function, known as a velocity histogram, called \(F\)-data (Figure 1).  
XGC scientists typically reduce the trillions of particles to build \(F\)-data and examine them at every timestep. The size of \(F\)-data ranges from hundreds of GB to tens of TBs, depending on the simulation scale. To study the next-generation fusion devices, such as ITER and DEMO, data compression of \(F\)-data is necessary for multiple purposes, such as saving memory/disk spaces and analysis speed-up. However, XGC scientists are eager to ensure that various physics properties derived from the distribution, such as mass, canonical angular momentum, and energy, are conserved. Therefore, reducing compression error is needed for this XGC dataset.  
More specifically, for \(F\)-data compression, XGC scientists are concerned with QoI preservation as well as compression errors. We investigate six physics quantities specified by XGC scientists. The QoI we consider are density \(n\), parallel flow \(u_{\parallel}\), perpendicular temperature \(T_{\perp}\), parallel temperature \(T_{\parallel}\), flux surface averaged density \(n_{0}^{avg}\), and flux surface averaged temperature \(T_{0}^{avg}\). In the XGC dataset, each mesh node \(x\) has a 2D velocity histogram \(f\). The density \(n\) and parallel flow \(u_{\parallel}\) are computed by integrating \(f\) with volume weights and with the parallel velocity, respectively:  
\[n(x,t) = \int f(x,v,t)\text{vol}(x,v)dv_{\perp}dv_{\parallel}, \tag{1}\] \[u_{\parallel}(x,t) = \frac{\int f(x,v,t)\text{vol}(x,v)v_{\parallel}(v)dv_{\perp}dv_{ \parallel}}{n(x,t)}, \tag{2}\]  
where \(t\) represents the timestep, \(\text{vol}(x,v)\) is the volume of the \(x\)th mesh node, and \(v_{\parallel}\) is the parallel velocity. \(T_{\perp}\) and \(T_{\parallel}\) are the integrals of perpendicular and parallel kinetic energy, \(mv^{2}\),  
\[T_{\perp}(x,t) = \frac{1}{2}\frac{\int f(x,v,t)\text{vol}(x,v)mv_{\perp}^{2}(v)dv_ {\perp}dv_{\parallel}}{n(x,t)}, \tag{3}\] \[T_{\parallel}(x,t) = \frac{1}{2}\frac{\int f(x,v,t)\text{vol}(x,v)m\Big{(}v_{ \parallel}(v)-u_{\parallel}(x,t)\Big{)}^{2}dv_{\perp}dv_{\parallel}}{n(x,t)}, \tag{4}\]  
where \(m\) is the mass of atomic particles corresponding to \(f\) and \(v_{\perp}\) is the perpendicular velocity. The flux surface averaged density \(n_{0}^{avg}\) and flux surface averaged temperature \(T_{0}^{avg}\) are computed by averaging the density and temperature over a thin volume between toroidal magnetic flux surface contours. For simplicity, we omit the detailed equations for  
Figure 1: Coordinates of the XGC dataset (**left**) and an example particle distribution histogram (**right**). The XGC simulates a massively large number of particles in a 5D physics space and regularly calculates particles distributions at each discretized node. This is one of the large datasets in XGC.  
the flux surface averaged quantities [33]. Except for density, these QoI are non-linear on \(f\) and are obtained via post-analysis of the data. In summary, the QoI described here result in four derived quantities (density, parallel flow, perpendicular, and parallel temperatures) which can be used in a constraint satisfaction procedure connecting the primary data (\(f\)) and the QoI. This is precisely the route taken in this paper.