For photons (X-rays/gamma rays), the attenuation of the primary beam follows the
Beer-Lambert Law. The linear attenuation coefficient is obtained from the mass attenuation coefficients tabulated in the
NIST XCOM database, multiplied by the tissue density:
$$\mu = \left(\frac{\mu}{\rho}\right) \rho \qquad\qquad D(z) = D_0 \cdot e^{-\mu z}$$
The model considers only the continuous attenuation and the exit dose, without representing the surface build-up region, for didactic simplification.
For charged particles (proton/helium), the energy loss is calculated by numerical integration of the
Bethe-Bloch equation, which reproduces the Bragg Peak:
$$-\left\langle \frac{dE}{dx} \right\rangle = K z^2 \frac{Z}{A} \frac{1}{\beta^2} \left[ \frac{1}{2} \ln\left( \frac{2 m_e c^2 \beta^2 \gamma^2 T_{max}}{I^2} \right) - \beta^2 \right]$$