Scripting Resources for DigitalMicrograph™ |
Relativistic Wavelength Calculator |
|
Function |
Computes the relativisitic wavelength of electrons. |
Version |
version:20080229 |
Author |
D. R. G. Mitchell |
Acknowledgements |
|
Comments |
Wavelength is returned in Ã… and m. |
System Requirements |
Should be compatible with all recent versions of DigitalMicrograph. |
Known Issues |
|
Supported |
Yes |
Included Files |
Main script file. |
Source Code |
// function to calculate the relatavistic wavelength of electrons // beamvoltage is in kV, and the wavelength is returned in m and Angstroms
// version:20080229
// D. R. G. Mitchell, adminnospam@dmscripting.com (remove the nospam to make this email address work) // v1.0, February 2008
number relativisticwavelength(number beamvoltage) {
beamvoltage=beamvoltage*1000 // it is easier to handle voltages as kV outside the function number c=2.998e8 // velocity of light number m=9.1095e-31 // rest mass of electron
number h=6.6261e-34 // Planck's constant number e=1.6022e-19 // charge on electron
number lambda // relativistically corrected electron wavelength number scatfact // atomic scattering factor
// calculate the relativistically corrected electron wavelength
lambda=h/sqrt((2*m*beamvoltage*e*(1+(e*beamvoltage)/(2*m*c**2))))
return lambda
}
// Main program starts here
number lambda, beamvoltage, defaultvoltage=200
if(!getnumber("Enter beam voltage /kV",defaultvoltage,beamvoltage)) exit(0)
lambda=relativisticwavelength(beamvoltage) showalert("Beam Voltage = "+beamvoltage+" kV\n\nWavelength = "+lambda+" m\n\nWavelength = "+lambda/1e-10+" A",2)
Result("\nBeam Voltage = "+beamvoltage+" kV\nWavelength = "+lambda+" m\nWavelength = "+lambda/1e-10+" A\n") |