Monte Carlo Code


Code described in this project can be found here



  • Inputs
  • Initial calculation
  • Running a flight
  • Outputs



    Inputs

    The code first prompts the user for a number of input values.
  • Number of flights The number of flights calculated
  • Timestep The time step overwhich position, velocity, and force are updated
  • Plasma density in m^-3
  • Plasma temperature in eV
  • Surface temperature in Kelvin
  • Magnetic field the x, y, and z components
  • Output trajectories whether or not to output the trajectories


    Inital Calculations

    A number of parameters were calculated by the code initially. The Debye length was calculated using the formula

    where the numerator contains the product of the plasma temperature and the permittivity and the denominator contains the plasma density. The Larmor radius was calculated using the formula

    and the rate coefficients were calculated using the equations



    Running a flight

    First the flight was initialized. The intial position of the particle was set to (0,0,0), the magnitude of the initial velocity was calculated from the surface energy, and the direction of the initial velocity was chosen randomly. Also, the initial state of the particle was set to (CH4). Next, the trajectory of the particle was followed until either the particle redeposited, returned to the divertor surface, or exited the simulation box. In each timestep of this loop, the position, velocity, and force of the molecule was updated. The code then checked for an ionization reaction which occurred with a calculated probability. Next, the code checked to see whether to repeat or exit this loop.


    Outputs

    Flights were repeated the desired number of times. The code outputs a number of parameters. One parameter, the redeposition fraction, is the fraction of flights where the particle returns to the divertor surface as opposed to exiting the simulation box. The fraction of flights which redeposit where the reseposited particle is neutral is another output. A third output is the ionization distance, the distance the CH4 molecule travels before the first ionizing collision is encountered. The final ionization species is another output. The average time of the flights and the average energy of the particles that are redeposited are also returned.