TopasOpt: An open-source library for optimization with Topas Monte Carlo
Related Experiment Video
Updated: Aug 18, 2025

Scalable Nanohelices for Predictive Studies and Enhanced 3D Visualization
Published on: November 12, 2014
Brendan Whelan1,2, Billy W Loo2,3, Jinghui Wang2,4
1Image X Institute, School of Health Sciences, Faculty of Medicine and Health, University of Sydney, Sydney, Australia.
Purpose:
To describe and test TopasOpt: a free, open-source and extensible library for performing mathematical optimization of Monte Carlo simulations in Topas.
Methods:
TopasOpt enables any Topas model to be transformed into an optimization problem, and any parameter within the model to be treated as an optimization variable. Three case studies are presented. The starting model consists of a 10 MeV electron beam striking a tungsten target. The resulting bremsstrahlung X-ray spectrum is collimated by a primary and secondary collimator before being scored in a water tank. In the first case study (electron phase space optimization), five parameters describing the electron beam were treated as optimization variables and assigned a random starting value. An objective function was defined based on differences of depth-dose and profiles in water between the original (ground truth) model and a given model generated by TopasOpt. The problem was solved using Bayesian Optimization and the Nelder-Mead method. One hundred iterations were run in each case. In the second case study, (collimator geometry optimization), this process was repeated, but three geometric parameters defining the secondary collimator were treated as optimization variables and assigned random starting values, and forty iterations were run. In the third case study, the optimization was repeated with different number of primary particles to study the effect of noise on convergence.
Results:
For case 1 (phase space optimization), both optimization algorithms successfully minimized the objective function, with absolute mean differences in profile dose of 0.4% (Bayesian) and 0.3% (Nelder-Mead) and 0.2% in depth-dose for both algorithms. The beam energy was recovered to within 1%, however some parameters had relative errors of up to 171% - a result consistent with the known X-ray dose is insensitivity to many electron beam parameters. For case 2 (geometry optimization), absolute mean differences in profile dose were 0.6% (Bayesian) and 0.9% (Nelder-Mead), and 0.5% and 0.9% in depth-dose. The maximum percentage error in any parameter was 9% with Bayesian Optimization and 28% with Nelder-Mead. Finally, the Bayesian Optimization algorithm was demonstrated to be robust to moderate levels of noise; when the standard deviation of the objective function was 16% of the mean, the maximum error in any parameter value was 16%, and the absolute mean difference in dose was 0.9% (profile) and 0.8% (depth-dose).
Conclusions:
An open-source library for optimization with Topas Monte Carlo has been developed, tested, and released. This tool will improve accuracy and efficiency in any situation in which the optimal value of a parameter in a Monte Carlo simulation is unknown. Applications for this tool include (1) The design of new components (2) Reverse engineering of models based on limited experimental or published data, and (3) Tuning of Monte Carlo "hyper parameters" such as variance reduction, physics settings, or scoring parameters.
More Related Videos
Related Concept Videos
Mechanistic Models: Compartment Models in Algorithms for Numerical Problem Solving
In individual population analyses, different algorithms are employed, such as Cauchy's method, which uses a...
Methods of Obtaining Topography
Maxwell-Boltzmann Distribution: Problem Solving
This distribution function f(v) is defined by saying that the expected number N (v1,v2) of particles with speeds between v1 and v2 is given by
Net Torque Calculations
Statistical Software for Data Analysis and Clinical Trials
Ampere-Maxwell's Law: Problem-Solving
To solve the problem, we can use the equations from the analysis of an RC circuit and Maxwell's version of Ampère's law.
For the first part of...

