  Methods: A phase space file in a plane at 202 mm downstream of the beam exit
window is generated through tuning parameters to match FDC results with
measured or MCNPX Monte Carlo-simulated integrated depth-dose distribution
(IDD) and lateral dose profiles. To spread out the Bragg peak, widen the beam
and reduce the penumbra, a ridge filter (RF), a high-Z material scatterer and a
collimator with compensator are inserted in the beam path and their shapes and
sizes have been optimized. The FDC calculations are validated by comparing
Geant4 Monte Carlo simulations. In addition, a set of algorithms to
automatically choose the optimum dimensions of the beam shaping elements is
developed and tested using the same beams. At the last part, dose rates for
optimized beams were estimated by scaling their dose distributions to that of
their original beams. Results: The optimized 86.4 MeV beam had an 8.5 mm wide
spread-out Bragg peak (SOBP) (proximal 90% to distal 90% of the maximum dose),
14.5 mm, 12.0 mm and 11.0 lateral widths with dose above 50%, 80% and 90%
respectively and a 2.5 mm penumbra from 80% to 20% in the lateral profile for
the energy. The 159.5 MeV beam had a SOBP of 39.0 mm and the lateral widths
with dose above 50%, 80% and 90% of 20.5 mm, 15.0 and 12.5 mm when the source
to surface distance (SSD) was 550 mm. Wider lateral widths was obtained with
increased SSD. The FDC calculations had passing rates higher than 96% using
3mm/3% as the gamma-index criterion comparing with Geant4 simulations for both
energies. The set of automatic algorithms can choose the proper dimensions for
the high-density scatterer, RF, collimator and compensator efficiently. And the
optimized 159.5 MeV beam with different SDDs had entrance dose rate higher than
40 Gy/s if the entrance dose rate of the original beam was 150 Gy/s.
