spin.py
def update(model, nodes, node_qty, T=1.0):
    """
    Updates state of system by randomly switching spin based on current energy of system.
    Args:
        model: an instance of a Model object.
        nodes: a dictionary of node objects.
        node_qty: an integer, quantity of nodes within model.
        T: a float, non zero temperature for the Boltzmann distribution probability formula.
    """
    for i in range(node_qty):
        n = random.randint(0, node_qty-1) # Randomly selects a node in the model.
        E = nodes[n].getE(nodes)
        if E > 0:
            nodes[n].switchSpin() # If energy is high, inverts node spin.
        elif E <= 0 and random.random() < math.exp(2*E/T): # If energy is low, randomly inverts node spin anyway as a function of Boltzmann distribution.
            nodes[n].switchSpin()

    Updates state of system by randomly switching spin based on current energy of system.
    Args:
        model: an instance of a Model object.
        nodes: a dictionary of node objects.
        node_qty: an integer, quantity of nodes within model.
        T: a float, non zero temperature for the Boltzmann distribution probability formula.
    
Updates state of system by randomly switching spin based on current energy of system.
Updates state of system by randomly switching spin based on current energy of system .
def update(model, nodes, node_qty, T=1.0):
    for i in range(node_qty):
        n = random.randint(0, node_qty-1) 
        E = nodes[n].getE(nodes)
        if E > 0:
            nodes[n].switchSpin() 
        elif E <= 0 and random.random() < math.exp(2*E/T): 
            nodes[n].switchSpin()
def update ( model , nodes , node_qty , T = 1.0 ) : for i in range ( node_qty ) : n = random . randint ( 0 , node_qty - 1 ) E = nodes [ n ] . getE ( nodes ) if E > 0 : nodes [ n ] . switchSpin ( ) elif E <= 0 and random . random ( ) < math . exp ( 2 * E / T ) : nodes [ n ] . switchSpin ( )
Updates state of system by randomly switching spin based on current energy of system.
Updates state of system by randomly switching spin based on current energy of system .
"""
    Updates state of system by randomly switching spin based on current energy of system.
    Args:
        model: an instance of a Model object.
        nodes: a dictionary of node objects.
        node_qty: an integer, quantity of nodes within model.
        T: a float, non zero temperature for the Boltzmann distribution probability formula.
    """ # Randomly selects a node in the model. # If energy is high, inverts node spin. # If energy is low, randomly inverts node spin anyway as a function of Boltzmann distribution.
model
an instance of a Model object.
an instance of a Model object .
nodes
a dictionary of node objects.
a dictionary of node objects .
node_qty
an integer, quantity of nodes within model.
an integer quantity of nodes within model .
T
a float, non zero temperature for the Boltzmann distribution probability formula.
a float non zero temperature for the Boltzmann distribution probability formula .