#!/usr/bin/perl
# 
# compute a maxwellian distribution
#
# MWR 9/13/2018


$pi = 3.14159;
# mass of hydrogen atom
$mh = 1.67E-27;
# mass of molecules
$m = 16.0*$mh;
$kb = 1.38E-23;
$T = 300.0;

# velocities in m/s
$start_v = 1.0;
$end_v = 20000.0;
$dv = 10.0;

for ($v = $start_v; $v <= $end_v; $v += $dv) {

  $top1 = 0.0 - $m*$v*$v;
  $bot1 = 2.0*$kb*$T;
  $x = exp($top1/$bot1);
  $y = ($m / (2.0*$pi*$kb*$T) );
  $w = 4.0*$pi*$y*$x*$v*$v;

  printf " v %8.1f  w %12.5e \n", $v, $w;
}




exit 0;
