API Documentation

MonteCarloAlgorithm.BitString(string)

Simple class to implement a string of bits

MonteCarloAlgorithm.IsingHamiltonian([...])

MonteCarloAlgorithm.Metropolis()

runs the monte carlo alg to find average energy levels of a hamiltonian

class MonteCarloAlgorithm.Metropolis[source]

runs the monte carlo alg to find average energy levels of a hamiltonian

__weakref__

list of weak references to the object (if defined)

static metropolis_montecarlo(hamiltonian, config, temperature=1, calc_sweep=1000, pre_calc_sweep=100)[source]

runs a full metropolis sweep on a hamiltonian :Parameters: * config bit string

  • temperature temperature

  • calc_sweep how many iterations it should run for

  • pre_calc_sweep how many iterations it should run before calculations begin

Return type:

aproximate energy, magnetization, energy squared, magnetization squared values

static metropolis_to_end_values(average_energy_samples, average_energy_samples_squared, average_magnetization_samples, average_magnetization_samples_squared, temperature=1.0)[source]

converts full metropolis sweep results into useful values :Parameters: * average_energy_samples average energy array

  • average_energy_samples_squared average energy squared array

  • average_magnetization_samples average magnetization array

  • average_magnetization_samples_squared average magnetization squared array

  • temperature temperature of system

Return type:

aproximate energy, magnitization, heat capacity, and magnetic suceptibility values

class MonteCarloAlgorithm.IsingHamiltonian(node_connections=[[()]], outside_affect=array([0.]))[source]
__init__(node_connections=[[()]], outside_affect=array([0.]))[source]

creates a hamiltonian :Parameters: * node_connections how the nodes connect to each other

  • outside_affect any influence outside the hamiltonian

__weakref__

list of weak references to the object (if defined)

compute_average_values(config, temperature=1.0)[source]

compute the average energy of a hamiltonian :Parameters: * config a bitstring does not really matter what is inputed

  • temperature temperature

Return type:

average energy, magnetization, heat capacity, and magnetic susceptibility values

energy(config)[source]

calculates the energy of the config :Parameters: config a bitstring

Return type:

the energy of the config

energy_change(config, flipped_index: int, old_energy=nan)[source]

calculates delta energy given a bit flip :Parameters: * config origin config

  • flipped_index index of proposed bit to flip

  • old_energy energy state of the current config (not required input)

  • Returns

  • delta energy

  • ——-

static make_change(energy_change, temperature)[source]

determines if a change to the bit string should be made :Parameters: * energy_change how much energy a flip would save/cost

  • temperature temperature

Return type:

bool whether or not it should be flipped

metropolis_sweep(config, temperature=1.0)[source]

runs a metropolis sweep on the bitstring :Parameters: * config input config

  • temperature temperature

Return type:

changed config