OPEN "I", #1, "c:\cw1\o-dichlorobenzene.txt" IM = 2 ^ n
DIM TP
(4096), F
(4096), X
(IM
, IM
), E
(IM
, IM
) DIM aj
(28, 28), VH
(n
), XX
(4000), Y
(4000), YD
(30), XD
(40) REM INPUT OF SPIN
-SPIN COUPLING J12
,J13...J23
,J24..etc
INPUT #1, fmin
, fmax
, t2
, itg
fmin = fmin * spop: fmax = fmax * spop
REM CALCULATING ELEMENTS IN HAMILTONIAN MATRIX
xsca = 960: ysca = 480 'spectrum size
N2 = IM
II = i
JJ = 2 ^ IN
AH(i + 1, IN + 1) = TJ
E(i, i) = 0: AX(i, i) = 0
E(i, i) = E(i, i) + VH(L) * .5 * AH(i, L)
TD = AH(i, L) * .25
E(i, i) = E(i, i) + aj(L, k) * TD * AH(i, k)
X(i, i) = 1
MA = 0: MB = 0: K1 = 0: K2 = 0
X(i, L) = 0: X(L, i) = 0
TG = AH(i, k) * AH(L, k) - 1
MA = MA + TG
MB = MB + TG * AH(L, k)
E(i, L) = .5 * aj(K1, K2)
E(L, i) = E(i, L)
'E matrix has the eigenvalues (energies)
'X matrix has the eigenvectors (wavefunction mixtures)
IAY = 0
IAY = IAY + AH(i, k) * AH(j, k)
IF IAY
= n
- 2 THEN AX
(i
, j
) = 1 ELSE AX
(i
, j
) = 0 AX(j, i) = AX(i, j)
IAY = 0
m = 0
FOR L
= 1 TO N2
- 1 'we have 4 nested loops - this is slow! ff
= ABS(E
(k
, k
) - E
(L
, L
)) 'frequencies tpp = 0
IF AX
(j
, i
) <> 0 THEN tpp
= tpp
+ X
(k
, i
) * X
(L
, j
) m = m + 1
F(m) = ff
TP(m) = tpp * tpp 'transition probabilities
sort:
FM = F(i): JM = i
IF F
(j
) > FM
THEN FM
= F
(j
): JM
= j
F(JM) = F(i): F(i) = FM
TPT = TP(JM)
TP(JM) = TP(i): TP(i) = TPT
lorentz:
REM CONSTRUCTING LORENTZIANS
'lineshapes are lorentzian
SW = fmax - fmin
MM = 3600
AI = SW / MM
XX(N5) = fmin + AI * (N5 - 1)
Y(N5) = 0
WID = 4 / t2
TA = 4 * 3.14159 * 3.14159 * t2 * t2
TB = WID / AI
C2 = (F(N5) - fmin) / AI
IF ABS(F
(N5
)) > 10000 GOTO 100 'this really needs to include spop C1 = 2 * t2 * TP(N5)
C3 = F(N5) - XX(MI)
Y(MI) = Y(MI) + C1 / (1 + TA * C3 * C3)
jacobi:
REM DIAGONALISATION
USING JACOBI
'S METHOD (D.S.) 'removes biggest off-diagonal elements first
m = (N2 * N2 - N2) / 2
TRA = m * .001
Q = 0: AM = -1
Q = Q + Z
IF Z
> AM
THEN AM
= Z: IX
= i: JX
= j
A1 = E(IX, IX) - E(JX, JX)
A5 = E(IX, JX)
A6 = 2 * A1 * A1 + 3 * A5 * A5
C = -2 * A1 * A5 / A6 'this is not the best approx.
s = 1 - A5 * A5 / A6 'but it stops the routine stagnating
A2
= SQR(A1
* A1
+ 4 * A5
* A5
) A3 = (A1 + A2) / (2 * A5)
C = A3 * s
TM = E(JX, j) * s + E(IX, j) * C
E(IX, j) = E(IX, j) * s - E(JX, j) * C
E(JX, j) = TM
TM = X(JX, j) * s + X(IX, j) * C
X(IX, j) = X(IX, j) * s - X(JX, j) * C
X(JX, j) = TM
TM = E(j, JX) * s + E(j, IX) * C
E(j, IX) = E(j, IX) * s - E(j, JX) * C
E(j, JX) = TM
'program ends up here if the matrix does not
'diagonalize in 2M iterations
charsep1:
REM SEPARATING
INPUT CHARACTER INTO NUMBERS
charsep2:
REM SEPARATING
INPUT CHARACTER INTO NUMBERS
outscr:
font1&
= _LOADFONT("c:\windows\fonts\times.ttf", 32, "bold")
YMIN = 5000!: YMAX = -1!: xmin = 5000!: xmax = 0!
C1 = (fmax - fmin) / 3600: i = 3600
YQM = 0
IF YMIN
> Y
(k
) THEN YMIN
= Y
(k
) IF YMAX
< Y
(k
) THEN YMAX
= Y
(k
) XX(k) = (C1 * k + fmin) / spop
IF xmin
> XX
(k
) THEN xmin
= XX
(k
) IF xmax
< XX
(k
) THEN xmax
= XX
(k
) YQM = YQM + Y(k)
XO = XX(i): YO = Y(i)
XO = ((xmax - XX(i)) / (xmax - xmin) * xsca) + 40
YO = ((Y(i) - YMIN) / (YMAX - YMIN) * ysca) - 20
YYO = 100: YYY = 100
XX = ((xmax - XX(k)) / (xmax - xmin) * xsca) + 40
YY = ((Y(k) - YMIN) / (YMAX - YMIN) * ysca) - 20
YN = (YY + YO * TC) / (1 + TC)
LINE (XO
, ysca
- YO
)-(XX
, ysca
- YY
) YYY = YYY + Y(k) * ysca * .8 / YQM
'integration line
IF itg
= 1 THEN LINE (XO
, ysca
- YYO
)-(XX
, ysca
- YYY
) YYYO = YYY
XO = XX: YO = YN: YYO = YYY
LINE (40, 10)-(40, ysca
+ 40) LINE (40, ysca
+ 40)-(xsca
+ 40, ysca
+ 40) LINE (40, 10)-(xsca
+ 40, 10) LINE (xsca
+ 40, ysca
+ 40)-(xsca
+ 40, 10) kg = -1
20 k = 0
kg = kg + 1
g(0) = .05: g(1) = .1: g(2) = .2: g(3) = .5: g(4) = 1: g(6) = 20: g(7) = 50: g(8) = 100: g(9) = 200
IF xmin
<> 0 THEN xs
= xmin
- g
(kg
) xi = xs
30 xi = xi + g(kg)
'PRINT xi; g(kg); k; xmin; xmax; xs; kg: INPUT sa$
k = k + 1
XD(k) = xi
XD(k + 1) = xi
XXD = (((xmax - XD(i)) / (xmax - xmin)) * xsca) + 40
XC
= INT(((XXD
- 10) / xsca
) * xsca
) LINE (XXD
, ysca
+ 40)-(XXD
, ysca
+ 50) A$ = "Chemical Shift ë (ppm)"
ypos = (ytop - ysca) / 8
xpos = xsca / 12
'input p to store as a bitmap
onebit:
'1-bit bitmap loader
pow2%(0) = 1
pow2%(j%) = pow2%(j% - 1) + pow2%(j% - 1)
filetype$ = "BM"
offset& = 62&
pixwidth& = 1600&
pixht& = 820&
ppbyte& = 8&
header& = 40&
datsize& = (pixwidth& * pixht& / ppbyte&)
filesize& = datsize& + offset&
reserved% = 0
planes% = 1
bpp% = 1
compress& = 0&
ppm& = 3880&
numcol& = 2&
impcol& = 0&
'storing file header
'storing DIB header
'storing black and white
'storing bitmap
pix%
= POINT(xvalue%
+ bits%
, yvalue%
) 'change to pix% > 0 to get white on black
IF pix%
= 0 THEN pixel%
= (pixel%
OR pow2%
(7 - bits%
)) pixel% = 0