This is lorentz.bas in view mode; [Download] [Up]
1 'LORENTZ.BAS 2 'Bruno Bienfait 1989 ( BASIC translation by Benoit De Boeck 1990) 3 'BASIC example (lorentzian) for generating a lineshape file 4 'for the FDC-ESR program 5 'The output file *.asc is a ASCII file which must be compiled by 6 'the "COMPILER" program. 10 filename$ = "lineshap.asc" 20 N = 150 30 number = 16000 'This number will give you a ~150K file 40 widthratio = 16 50 maxheight = 32767 : ' May not be larger than 65535 60 wi1 = 0 70 X = 0 80 X0 = 0 90 Y = 0 100 print "Lorentzian lineshape ASCII file generator" 110 print "for the FDC-ESR program" 120 print 130 print "Please wait" 140 open "O",#1,filename$ 141 ' <1> write name of the lineshape ( string of maximun N characters ). 142 ' It will be displayed in FDC-ESR while loading the data from disk 150 print #1,"Lorentzian" 155 ' <2> write comment for the linewidth ( string of maximun N characters). 157 ' It will be displayed in FDC-ESR when entering the line width 160 print "Calculating the Lorentzian lineshape" 170 print #1,"half height linewidth" 171 ' <3> write total number of element in the lineshape 180 print #1,number 181 ' <4> write width of the lineshape ( corresponding to comment at <2> ) 190 wi1 = number/widthratio 195 print #1,wi1 196 ' <5> write symmetry of the lineshape 200 print #1,"SYMETRIC" : ' For the 1st derivative, it would be "ANTISYMETRIC" 201 ' <6> write the largest unsigned integer value for the digital lineshape , 202 ' all data values (see <7> and <8> )will be scaled and rounded 203 ' to a 0 - maxheight range by the "COMPILER" program. 205 ' low : decrease precision but decrease overflow risk 210 if maxheight > 0 and maxheight <= 65535 then print#1,maxheight : goto 250 220 print "maxheight is not correct" 230 end 231 ' <7> The first calculated value comes here 232 ' lorentzian function : Y = A*W*W / (W*W + 4*(X0-X)*(X0-X) ) 233 ' absolute height is not important ( A*W*W is a constant ) 234 ' => Y = constant / (W*W + 4*(X0-X)*(X0-X) ) 250 constant = 100000 260 W = wi1 270 X0 = number/2 280 for X=0 to number 290 Y = constant/(W*W + 4*(X0-X)*(X0-X)) 295 ' print X,Y 300 print #1,Y 310 next X 311 ' <8> end of the program 320 close 330 print "finished" 340 end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.