Presentation #400.04 in the session Galactic Bars.
We present a parametric method to construct the 3D density distribution of barred galaxies from their surface brightness distributions, which is then used for dynamical modeling using the Schwarzschild orbit superposition method. N-body simulations and observations of barred galaxies show a distinct X or peanut (X/P) shape in the central regions, which is usually attributed to bar buckling and resonance orbit trapping. We model this peanut shape by varying the vertical scale height of the bar across the major axis. We analyze a suite of N-body simulations of barred galaxies to obtain mock photometric data, which we perform the deprojection on to recover the 3D density. We verify the accuracy of our fit by comparing the gravitational potential and forces of the deprojected model and the N-body snapshot, and find reasonable agreement between them. The deprojected density and potential are then used to construct a dynamical model of the galaxy using the FORSTAND code, which implements the Schwarzschild algorithm. An accurate model of the bar, including the X/P shape, is required to construct the gravitational potential of the galaxy, and we highlight the advantages of our method compared to the standard approach of using multi-gaussian expansion (MGE).