;random ionization program (quadsor.prg) ;This program simulates ionization by randomly turning electrons ;into ions. Ionization occurs at random positions along the x axis. ;One could alternatively use random times. It would also be nice to check ;for sufficient electron energy. ; ;Steven M. Colby; Scientific Instrument Services, Inc. ;All rights reserved. Version May 22, 1996 ;http://www.sisweb.com ; ; ; definition of user adjustable variables ; ; Adjustable at beginning of flight --------------------- ; defa IonMass 100 ; mass of ion produced defa IonCharge 1 ; Charge of ion produced defa IonEnergy 0.025 ; Energy of ion produced (0.025 is thermal) ; 0.025 eV is thermal defa PercentEnergyVar 0.10 ; percentage energy variation defa Probability 1.0 ; Chance electron will from ion within ; the period "TotalTime" (percent) defa startx 0.0 ; starting position (x in gu) defa Ionplace 0.0 ; x distance when ionization takes place defa xlimit 150.0 ; distance within which ionization occurs defa IonStart 0.0 ; starting position (x in gu) ; ; static variables ----------------------- ; defs ionized 0.0 ; Boolean: have we ionized? defs IonColor 3 ; Set color when ionized ; ; ------------- Program Segments Below ------------------- ; seg initialize 1 sto Rerun_Flym ; Turn on Rerun ; turns traj file saving off rcl Ion_Px_gu ; get starting position sto IonStart ; store it ; rand ; get random # rcl xlimit * ; multiply it by the ionization ; position window rcl Probability * ; multiply it by the probability sto Ionplace ; store it as the position of ionization ;------------------------------------------------------------ seg Other_Actions ; rcl ionized ; check to see if we have already ionized x>0 exit ; if yes, don't do it twice rcl Ion_Px_gu ; Get ion position rcl IonStart - ; subtract the starting position abs ; take absolute value rcl Ionplace ; recall ionization place x>y exit ; if we aren't there yet we leave ; mark ; rcl IonColor sto Ion_Color ; change the ions color ; rcl IonCharge sto Ion_Charge ; change the ions charge ; rcl IonMass sto Ion_Mass ; change the ions mass ; rand 2 * 1 - ; random # between 1 and -1 rcl PercentEnergyVar * ; multiply by the energy variation rcl IonEnergy * ; multiply by the median energy rcl IonEnergy + ; add to the median energy ; to get new energy ; rcl ion_mass ; recall ion mass x>spd ; convert to speed sto speed ; hold in temp variable ; converted new energy to speed ; 360 rand * ; get a random el angle 180 rand * ; get a random az angle rcl speed ; ; now x= speed, y=az, z=el >r3d ; convert to rectangular 3d coordinates sto Ion_Vx_mm ; change the ions velocity rlup sto Ion_Vy_mm rlup sto Ion_Vz_mm ; 1 sto Ionized ; change boolean (we have done it) ; ; exit ; done