Radio Buttons for Lattice Monte Carlo

To add radio buttons to switch from one dynamics to another:
  1. Add frame to RHS of dialog box under Resource View, call it Algorithm. Add three radio buttons (circle with dot), call them Heat Bath, Wolff, and BKL. Under Properties for the buttons, make the Heat Bath button ID IDC_ALG0, visible, group, and tab stop. Make the Wolff button IDC_ALG1, Visible, and Tab stop (not group), and the BKL button IDC_ALG2, Visible, and Tab stop. (Only the first button in a group of radio buttons is made "group").
  2. Using the Class Wizard, add a variable m_algorithm to the message IDC_ALG0. It should be a vlaue, and an int.
  3. Add member function to IsingSimulation:

    SpinDynamics * IsingSimulation::SwitchDynamics(SpinDynamics * spinDynamics)
    {

    SpinDynamics * oldDynamics = this->spinDynamics;
    this->spinDynamics = spinDynamics;
    spinDynamics->SetTemperature(temperature);
    spinDynamics->SetMagneticField(magneticField);
    spinDynamics->ResetLattice(S);
    return oldDynamics;
    }
  4. Add a protected integer variable oldAlgorithm to CLMCDoc. Set oldAlgorithm to two in the constructor CLMCDoc. (Presuming that you're running BKL by default in IsingSimulation, the corresponding algorithm number is two: third in the list.)
  5. Add to LMCDoc::OnParamChange: dialog_box.m_algorithm = oldAlgorithm;
    ...
    if (dialogBox.m_algorithm!=oldAlgorithm) {
    SpinDynamics* oldDynamics;
    switch(dialogBox.m_algorithm) {
    case 0:
    oldDynamics = sim->SwitchDynamics(new SpinDynamics(sim->GetLattice()));
    break;
    case 1:
    oldDynamics = sim->SwitchDynamics(new WolffDynamics(sim->GetLattice()));
    break;
    case 2:
    oldDynamics = sim->SwitchDynamics(new ContinuousTime(sim->GetLattice()));
    }
    delete oldDynamics;
    oldAlgorithm=dialogBox.m_algorithm;
    }

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