During the conceptual design of an accelerator or beamline, first-order beam dynamics models are essential for studying beam properties. However, they can only produce approximate results. During commissioning, these approximate results are compared to measurements, which will rarely coincide if the model does not include the relevant physics. It is therefore essential that this linear model is extended to include higher-order effects. In this paper, the effects of particle-matter interaction have been included in the model of the transport lines in the proton therapy facility at the Paul Scherrer Institut (PSI) in Switzerland. The first-order models of these beamlines provide an approximated estimation of beam size, energy loss and transmission. To improve the performance of the facility, a more precise model was required and has been developed with OPAL (Object oriented Particle Accelerator Library), a multi-particle open source beam dynamics code. In OPAL, the Monte Carlo simulations of Coulomb scattering and energy loss are performed seamless with the particle tracking. Beside the linear optics, the influence of the passive elements (e.g. degrader, collimators, scattering foils and air gaps) on the beam emittance and energy spread can be analysed in the new model. This allows for a significantly improved precision in the prediction of beam transmission and beam properties. The accuracy of the OPAL model has been confirmed by numerous measurements.