Magnetization Observer for LMC

  1. Write a MagnetizationObserver class. It should have member variables mtot, m2tot, numMtot, numberSpins, and temperature and member functions Mbar(), Reset(), Susceptibility(), and Update(). Whenever the temperature or the number of spins are changed, Reset() should be called. The susceptibility at temperature T and external field H can be measured from the equilibrium fluctuations: chi(H,T) = <(m-< m >)^2> / T where m is the magnetization per spin (M/numM). Using the normal trick
    <(X-<X>)^2>=<X^2>-2<X><X> + <X>^2 = <X^2>-<X>^2,
    chi(H,T) = (m2tot - mtot*mtot/numMtot) /((numMtot-1) * numberSpins * temperature)
    Make sure the program compiles.
  2. Add a MagnetizationObserver to the CLMCDoc class. Attach it to the IsingSimulation sim in the constructor for CLMCDoc. Compile and run.
  3. Change OnDraw in CLMCView to print out Mbar and the susceptibility Chi. The TextOut function will look OK if it starts at location (0, lattice->GetHeight()*0.9 ...
  4. Whenever you change parameters, the system takes a while to reach equilibrium: you want to start measuring just AFTER that point. It's easy to add a button to call Reset():
    1. Under Resource View -> Toolbar -> IDR_MAINFRAME, click on the last empty grey button: fill in with your symbol
    2. Double-click on the button, or select View, Properties
    3. Give the button a recognizable ID (say, ID_MAG_RESET)
    4. Start the Class Wizard. Make the Class Name CLMCDoc (since magnetizationObserver is in that class). Select your new object ID, and the message COMMAND. Add Function, and Edit Code.
    5. Call magnetizationObserver.Reset() in your new function.
  5. Check that your magnetization is zero at high temperatures, and near one or minus one at low temperatures. Check that your susceptibility at high temperatures obeys the Curie law: chi(T) = 1/T as T->Infinity

Statistical Mechanics: Entropy, Order Parameters, and Complexity, now available at Oxford University Press (USA, Europe).