ÿþ<HTML> <HEAD> <META content="Chemical Exchange" name=description> <META content="Chemical exchange, NMR, dynamic NMR, kinetics, chemistry" name=keywords> <TITLE>Chemical Exchange</TITLE> <SCRIPT LANGUAGE="JavaScript"> // JavaScript by Tom Shattuck, Department of Chemistry, Colby College // twshattu@colby.edu. Please feel free to grab this application, // but please leave the acknowledgements. var ar1 = new Array(2) ; var ar2 = new Array(2) ; var ai1 = new Array(2) ; var ai2 = new Array(2) ; var iamp = new Array() ; var v = new Array() ; var expx = new Array() ; var expy = new Array() ; var vstart = 0 ; var vstep = 0 ; var scale = 500 ; var pi = 3.1416 ; function exch(form) { // set up plotting range v1 = 0.5*form.vs.value ; v2 = -v1 ; vstart = -1.5*v1 ; tau = form.tau.value ; k = form.k.value ; tau = ( tau == "" ) ? 1/2/k : tau ; var T2 = form.t2.value ; var fa = form.fa.value ; if ( (fa<0.05)||(fa>0.95) ) fa = 0.5 ; var fb = 1.0-fa ; document.Output.Out.value = "frequency(Hz) intensity\r" ; // get experimental values sy = 0 ; sa = 0 ; expx[0] = 0 ; expy[0] = 0 ; for (ie=0 ; ie<7 ; ie++ ) { ix = document.Exper.elements[ie*2].value ; if ( (ix == "")||(isNaN(ix)) ) break ; x = parseInt(ix) ; if (( x < 3*vstart) || ( x > -3*vstart )) break ; expx[ie] = x ; expy[ie] = parseInt(document.Exper.elements[ie*2+1].value) ; if ( x<vstart ) vstart = x ; sa += spec(x,v1,v2,T2,tau) ; sy += expy[ie] ; } ; // end for ie if ( ie > 0 ) scale = sy/sa ; vstep = -vstart/75. ; for ( k=0 ; k<151 ; k++) { vplot = vstart+k*vstep ; amp = spec(vplot,v1,v2,T2,tau,fa,fb) ; iamp[k] = parseInt(scale*amp) ; v[k] = vplot ; document.Output.Out.value += fmt(vplot,"####.###") + "\t" + iamp[k] + "\r" ; } ; // end for k plot(expx,expy,vstart,vstep,iamp) ; } ; // end exch // amplitude function spec(vplot,v1,v2,T2,tau,fa,fb) { ar1[1] = vplot-v1 ; ai1[1] = 1.0/2/pi/T2 +fb*1.0/2/pi/tau ; ar2[1] = 0.0 ; ar1[2] = 0.0 ; ai2[1] = -fb*1.0/2/pi/tau ; ai1[2] = -fa*1.0/2/pi/tau ; ar2[2] = vplot-v2 ; ai2[2] = 1.0/2/pi/T2 +fa*1.0/2/pi/tau ; imverse() ; // add up elements of inverse matrix ; var amp = -(ai1[1]+ai2[1]+ai1[2]+ai2[2]) ; return amp ; } ; // end spec // calculate inverse of a complex 2x2 matrix ; function imverse() { detr = ar1[1]*ar2[2]-ai1[1]*ai2[2]-ar2[1]*ar2[1]+ai2[1]*ai2[1] ; deti = ai1[1]*ar2[2]+ar1[1]*ai2[2]-2*ar2[1]*ai2[1] ; tempr = ar1[1] ; tempi = ai1[1] ; ar1[1] =ar2[2] ; ai1[1] = ai2[2] ; ar2[2] = tempr ; ai2[2] = tempi ; ar2[1] = -ar2[1] ; ar1[2] = ar2[1] ; ai2[1] = -ai2[1] ; ai1[2] = ai2[1] ; // divide elements by determinant ssdet = detr*detr+deti*deti ; for ( j=1 ; j<3 ; j++ ) { tempr = (ar1[j]*detr+ai1[j]*deti)/ssdet ; ai1[j] = (ai1[j]*detr-ar1[j]*deti)/ssdet ; ar1[j] = tempr ; tempr = (ar2[j]*detr+ai2[j]*deti)/ssdet ; ai2[j] = (ai2[j]*detr-ar2[j]*deti)/ssdet ; ar2[j] = tempr ; } ; // end for columns } ; // end imverse // plot two arrays function plot(ax,ay,bxstart,bxstep,by) { // plot a set of data points in ax,ay along with a fit function bx,by // that starts at bxstep and evenly spaced points thereafter. // It is assumed that the bx,by array has a wider range than ax,ay. // Use the Java 2D Graph Package by Leigh Brookshaw to do a scatter plot // with the fit function var nda = ay.length ; var ndb = by.length ; var datastr = "" ; var fcnstr = "" ; var xp = 0.0 ; // setup data string datastr = ""+ax[0]+","+ay[0] ; for ( i=1 ; i<nda ; i++ ) { datastr += ","+ax[i]+","+ay[i] } ; // setup function string fcnstr = ""+by[0] ; for ( i=1 ; i<ndb ; i++ ) { fcnstr += ","+by[i] } ; plt = open("","Plot","toolbar=0,menubar=1,scrollbars=0,width=620,height=570") ; with (plt.document) { clear() ; writeln("<HTML><HEAD><TITLE>Nonlinear Curve Fitting</TITLE></HEAD><BODY>") ; writeln("<CENTER>") ; writeln("<applet code=datainc.class width=600 height=550 codebase=classes>") ; writeln("<param name=data value='"+datastr+"'>") ; writeln("<param name=minimum value='"+bxstart+"'>") ; writeln("<param name=increment value='"+bxstep+"'>") ; writeln("<param name=function value='"+fcnstr+"'>") ; writeln("<param name=xlabel value='v (Hz)'>") ; writeln("<param name=ylabel value='Intensity'>") ; writeln("</applet>") ; writeln("</CENTER></BODY> </HTML>") ; } ; // end with plt } ; // end fcn plot function fmt(xfx,format) { // typical call example fmt(x,'#####.####') var spc = ' ' ; var idecfmt = format.indexOf('.',0) ; var iendfmt = format.length-idecfmt-1 ; var ipstdecpt = format.length-idecfmt-1 ; if ( xfx>0 ) { xfx += 0.5*Math.pow(10,-ipstdecpt) } else { xfx -= 0.5*Math.pow(10,-ipstdecpt) } xstr = ''+xfx ; // casting idec = xstr.indexOf('.',0) ; if ( idec < 0 ) { xstr = xstr + '.' ; idec = xstr.length-1 ; } ilgth = xstr.length ; iend = ilgth-idec-1 ; trunc = xstr.length-iend+iendfmt ; zeros = idecfmt-iend-1 ; xstr = (iend>iendfmt) ? xstr.substring(0,trunc) : xstr+spc.substring(0,zeros) ; // replace trailing zeros ilgth = xstr.length ; for ( i=ilgth-1 ; i>idec+1 ; i--) { if ( xstr.substring(i,i+1) != "0" ) break ; xstr = xstr.substring(0,i)+" "+xstr.substring(i+2,ilgth) } ; // end for i replace // str = spc.substring(0,idecfmt-idec)+xstr ; return str ; } ; // end fmt </SCRIPT> </HEAD> <BODY BGCOLOR="moccasin"> <P> <FONT FACE=sans-serif COLOR="red"><H3>Exchange: Chemical Exchange Lineshapes</H3></FONT> This application calculates the NMR line shapes for chemical exchange for two equivalent sites, Java version*. You can also input your experimental data, so that you can graphically compare with the simulated lineshape, but the experimental data is not needed. An <A HREF="ex2020.html">example</A> may help. </P> <FORM method="POST"> <FONT COLOR="blue"><B>Simulation constants:</B></FONT><BR> Line separation with no exchange: <INPUT TYPE="text" NAME="vs" SIZE=5> Hz <BR> T<sub>2</sub>, relaxation time with no exchange: <INPUT TYPE="text" NAME="t2" VALUE=5 SIZE=5> sec.<BR> Enter one, but not both of the following parameters for the exchange:<BR> Tau, exchange lifetime:<INPUT TYPE="text" NAME="tau" SIZE=6> sec. &nbsp;&nbsp; or &nbsp; k, exchange rate:<INPUT TYPE="text" NAME="k" SIZE=6> sec<sup>-1</sup><BR> Fraction A sites: <INPUT TYPE="text" NAME="fa" VALUE=0.5 SIZE=5><BR> <CENTER> <INPUT TYPE=button VALUE=Submit onClick="exch(this.form);"> &nbsp;&nbsp;&nbsp; <INPUT TYPE=Reset VALUE=Reset></CENTER><BR></FORM> <FORM NAME="Exper"> <FONT COLOR="blue"><B>Experimental data:</B></FONT><BR> Make sure your frequencies are relative to the center of the spectrum. That is, the center of the spectrum should be at 0 Hz.<BR> <TABLE BORDER=1><TR><TH>Frequency(Hz)</TH><TH>Intensity</TH></TR> <TR><TD><INPUT TYPE=text SIZE=14></TD><TD><INPUT TYPE=text SIZE=14></TD></TR> <TR><TD><INPUT TYPE=text SIZE=14></TD><TD><INPUT TYPE=text SIZE=14></TD></TR> <TR><TD><INPUT TYPE=text SIZE=14></TD><TD><INPUT TYPE=text SIZE=14></TD></TR> <TR><TD><INPUT TYPE=text SIZE=14></TD><TD><INPUT TYPE=text SIZE=14></TD></TR> <TR><TD><INPUT TYPE=text SIZE=14></TD><TD><INPUT TYPE=text SIZE=14></TD></TR> <TR><TD><INPUT TYPE=text SIZE=14></TD><TD><INPUT TYPE=text SIZE=14></TD></TR> <TR><TD><INPUT TYPE=text SIZE=14></TD><TD><INPUT TYPE=text SIZE=14></TD></TR> </TR></TABLE></FORM> <P> <FORM NAME="Output"> <FONT COLOR="blue"><B>Output:</B></FONT><BR> <TEXTAREA NAME="Out" COLS=40 ROWS=10></TEXTAREA> </FORM> <P> <A HREF="exchlit.html">Background Literature References</A> <P> * If you don't want to use this Java dependent version you can also use <A HREF="http://www.colby.edu/chemistry/NMR/exch.html">Exchange(Netscape) </A> for Netscape users or <A HREF="http://www.colby.edu/chemistry/NMR/exchIE.html">Exchange(IE)</A> for Internet Explorer. <P> The Java plotting routines are courtesy of <A HREF="http://www.sci.usq.edu.au/staff/leighb/graph/">Leigh Brookshaw</A>. <P> This material is based upon work supported by the National Science Foundation under Grant No. 0079569. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation. <P> <FONT COLOR=red><I>T. W. Shattuck, Colby College Chemistry, 6/9/2003</I><FONT><BR> </BODY> </HTML>