925-456-1020 info@acornnmr.com

Spin simulation

Spectrum Simulation (NS) (requires 1D version)

Read about improvements to Spin Simulation in wxNUTS,
including an example of multiplet analysis

This subroutine allows calculation of a 1D spectrum based on user-input values for chemical shifts and coupling constants. The program uses the current values for spectrometer frequency, sweep width and data size, so a data file must be opened before entering the NS routine. If no data file is available, a blank data set can be created with the new command. By default, a data size of 8K points is created, but this can be specified, such as new 16384. SF and SW values must also be set before entering the NS routine.

The spin simulation has been revised as of June, 2008. The major change is that it now handles equivalent nuclei as a single “spin” with Multiplicity greater than 1. For example, a methyl group is entered as a single spin with Mult = 3. Previous versions required that 3 separate spins be entered for a methyl group. Note that the total number of spins (eg, counting a methyl as 3) cannot exceed 12.

The changes have resulted in substantial improvement in the ability to fit the calculated spectrum to the experimental spectrum. Before attempting optimization, carefully read the description.

This subroutine calculates and displays a spectrum based on user-input values for chemical shifts and coupling constants. The subroutine uses the values of Spectrometer Frequency, Sweep Width, Spectrum Offset and Number of Points from the current spectrum for its calculation, so an actual data file must be loaded before starting the NS subroutine.

Subcommands are single-letter commands and are listed below, and are also available from the menus. Quick Help is available by typing ?

When the subroutine is started, if the spin system has not yet been entered, the first step is to set the number of spins. The dialog box shown below can be displayed at any time while in the simulation subroutine with the command E or be selecting Edit parameters from the Edit menu. The lower part of the dialog box, with entries for each of the spins in the simulation, displays information for only the number of spins defined before opening the dialog box. If the number of spins is changed, exit the dialog box with OK, then type E again to begin entering spin information.

The Spin ID fields allow the user to assign a text label to each spin, if desired. This can make it easier to relate the spin simulation parameters to a structure. By default, they are numbered starting with 1. In the example used here, labels have been assigned corresponding to the numbering on the structure of codeine.

The Nucleus labels are used by the calculation only to determine whether or not second order spin interactions need to be included. It does not matter what the actual labels are, just whether or not different spins have the same nucleus label, or different nucleus labels. By default, all are set to H.

The Mult field allows the user to enter the number of equivalent nuclei, eg, 3 for a methyl group. By default, all are set to 1.

The Display Parameters buttons determine whether or not the shifts and coupling constants should be displayed on the screen. The Calculation Type refers to 2 choices for the matrix diagonalization process. QL is faster, but doesn’t always converge, so Jacobi can be used if QL fails. The other fields should be self-explanatory.

After closing the dialog box shown above, chemical shifts and coupling constants must be entered. Typing C or selecting Chemical shifts from the Edit menu displays the dialog box below:

It is important to notice that, in this case, only 6 of the chemical shift fields contain values, and the other fields are empty. This is because the number of spins was set to 6 before opening this dialog box. Six, and only 6, shift values can be entered in this case. To enter more shift values, first change the number of spins!

The fields labeled “Lock To” allow a chemical shift of a chosen spin to be “locked” to another spin during optimization. See details.

Note that the spectrum is not calculated until a Recalculate command is executed, using either the R command or by selecting Recalculate spectrum from the Edit menu.

Important: When the spectrum is calculated, a list of transition frequencies and intensities is generated. The final step is to create a spectrum by convolution with a Lorentzian line. To maximize speed, the convolution is only performed on the displayed region of the spectrum. If the zoom region is changed, you must manually force a recalculation, most easily done by adjusting the offset or scaling. Any of the commands I, D, U, L, N or W will accomplish this. Failure to do this can result in display of a spectrum that is not the result of the current parameters, and can be very misleading.

Similarly, coupling constants are entered using the dialog box shown below, which is displayed with the J command or by selecting Coupling constants from the Edit menu. The Spin ID is shown for each row and column, along with the spin number in parentheses.

For example, the value for J5,3 is entered into the highlighted field, which is column labeled 5(1) and the row labeled 3(2). As with chemical shifts, it is only possible to enter coupling constants for the previously defined number of spins.

From the View menu, the user can choose whether or not to display the experimental spectrum and the spin simulation parameters. The spin simulation parameters can be saved to a text file for later retrieval. These commands are available from the File menu. The simulation (in red) for the parameters entered above is shown below.


Manually fine-tuning shifts and couplings for several spins can be a tedious process. The Optimization function does a Simplex fit of the calculated spectrum to match the experimental spectrum. Note that you must manually adjust parameters to be reasonably close first, to allow the fit process to converge. The optimization makes fairly small adjustments to shifts and couplings (as well as linewidth and amplitude for the entire spectrum), and prints the resulting standard deviation in the upper right corner. Repeating the optimization several times should result in improvement in the fit. This step-wise approach allows the user to observe progress, and make manual adjustments in parameters during the optimization process. Note that only the displayed region is used to evaluate goodness of fit. This could result in a solution that fits the displayed region well, but is a worse match for regions of the spectrum that are not currently displayed. As noted above, be sure to force a refresh of the convolution if the zoom region is changed.

One problem with performing a fit is that often the experimental spectrum contains many more peaks than the spin system being simulated. As a result, the difference between calculated and experimental spectra can be very insensitive to changes in the simulation parameters. There are 2 ways to minimize this problem. If the peaks being fit are in the same region of the spectrum, zoom in to display just the region of interest and then initiate the fit with subcommand O. Only the displayed region will be used to evaluate goodness of fit.

However, sometimes the peaks being calculated are widely separated in the spectrum, and there may be many other peaks in the spectrum not included in the simulation. It is possible to define multiple small regions of the spectrum to be used in evaluating goodness of fit, while ignoring the rest of the spectrum. The regions must be defined using zoom, outside of the NS routine. All defined zoom regions will be used. Caution is required here – be sure to clear all zoom regions, then define the regions you want to use in the fit process. Failure to do this can result in performing the fit using unintended parts of the spectrum to evaluate goodness of fit, with poor results. Description of how to define and clear zoom regions can be found in the Help section on Zoom. The command to execute the optimization using regions is X, rather than O.

It is possible to prevent selected parameters from being varied during the fit process. The ability to “lock” a chemical shift or coupling constant is accomplished by “locking” a chemical shift or coupling constant to itself. A chemical shift can be locked from the chemical shift data entry dialog box, displayed with subcommand C. If the “Locked To” field is zero, the chemical shift is not locked. If a spin’s own number is entered, that chemical shift will not be adjusted at all during the fit. If the number of a different spin is entered, the chemical shift will be locked to that spin, ensuring that the values remain the same throughout the fitting process, as is the situation for symmetry-related spins. At the moment, coupling constants can only be locked by editing the simulation file, then reading it back in. See sample simulation files.

Subcommands: (also available from the menus)

E – Edit the spin system parameters
C – Enter chemical shifts
J – Enter coupling constants
R – Recalculate the spectrum from the parameters
O – optimize; performs a simplex fit to the experimental spectrum
H – Hide or show spin simulation parameters on the screen (toggle command)
F – Set the font for the spin simulation parameters
U – Move display of the calculated spectrum higher Up on the screen
L – Move display of the calculated spectrum Lower on the screen
0 (zero) – Move display of the calculated spectrum to zero offset (bottom of screen)
I – Increase amplitude of the calculated spectrum
D – Decrease amplitude of the calculated spectrum
N – Make linewidth of the calculated spectrum Narrower
W – Make linewidth of the calculated spectrum Wider
(minus sign) – Display difference between experimental and calculated spectrum (toggle command)
S – Save the spin simulation parameters to a text file (see example below)
G – Read spin simulation parameters from a previously saved file
V – Toggle on/off display of the standard deviation in the upper right corner of the screen
X – optimize using only selected regions of the spectrum

See example of a spin simulation file.

Allowed command line arguments are as follows. Note that all of these commands are executed outside the NS subroutine. These can be included in a macro to set default starting parameters.

ns spins n – set the number of spins for the calculation, where n is an integer

ns spin n i ppm – set the ppm value for spin n; the parameter i sets the number of equivalent spins (eg, i=3 for a methyl)

ns J n m hz – set the coupling constant between spins n and m to the value in hz

ns save [filename]- Save the spin simulation parameters to a text file. If no filename is supplied, a dialog box will be displayed to enter a file name.

ns open [filename] or ns read [filename]– Open a previously saved file and load spin simulation parameters. If no filename is supplied, a dialog box will be displayed to enter a file name.

ns new – sets all shifts and couplings to zero

ns showdata – enable display of the experimental spectrum along with the calculated spectrum while in the NS routine (helpful for comparing experimental and calculated spectra)

ns nowshowdata – disable display of the experimental spectrum along with the calculated spectrum while in the NS routine

ns width x – set the linewidth for the calculated spectrum to x

ns amp x – set the amplitude for the calculated spectrum to x

ns offset x – set the vertical offset for the calculated spectrum, where x is a percentage of the screen. Allowed values for x are -10 to 95.

ns jacobi – uses a jacobi method for matrix diagonalization

ns ql – default method for matrix diagonalization; usually faster, but does not always converge


Last updated: 1/30/09