#!/usr/bin/perl -w
use strict;

# very quick and dirty perl for calculating debroglie wavelengths of stuff
# also output physical size of nuclei when stationary (0 deg K, I suppose)
# gnu license v2 - share and enjoy, improve if you want to, and share back, please.
# dcfusor@gmail.com  12/6/2013

my $h = 6.62606885e-27; # planck in CGS units (all these from Wikipedia, 2013)
my $amu = 1.660538782; # amu in grams
my $mE = 9.10938215e-28; # mass of electron, grams
my $e = 4.80320427e-10; # unit charge in stat-coulomb
my $r0 = 1.37e-13; # radius/nucleon roughly (from Halliday, old neutron scattering number)
my $input; # from console
my $wavelength; # debroglie wavelength
my $volts;
my $weight;
my $radius;
my $diameter;

print ("Electron or amu (e or a), A>");
$input = lc <>;
chomp $input;
if ($input eq 'e')
{
 print "Volts?>";
 $volts = <>;
 chomp $volts;
 
 $wavelength = $h/sqrt($mE*$e*$volts/150);

 print "Electron wavelength for $volts volts is:$wavelength cm\n"

}
else
{
 print "Number of amu?>";
 $input = <>;
 chomp $input;
 $weight = $amu * $input; # now have in grams

 print "Volts?>";
 $volts = <>;
 chomp $volts;

 $wavelength = $h/sqrt($weight*$e*$volts/150); 
 print "DeBroglie wavelength for nucleus at $volts volts is:$wavelength cm\n";
 $radius = $r0 * ($input**.33333333);
 $diameter = $radius * 2;

 print "Approximate physical diameter for nucleus of $input amu is: $diameter cm \n";
}

print "done\n"
