예제 #1
0
def symmetric_4(radius):
    ions = []
    ions.append(ion(0, radius))
    ions.append(ion(radius, 0))
    ions.append(ion(0, -radius))
    ions.append(ion(-radius, 0))
    return ions
예제 #2
0
def symmetric_4(radius):
    ions = []
    ions.append(ion(0, radius))
    ions.append(ion(radius, 0))
    ions.append(ion(0, -radius))
    ions.append(ion(-radius, 0))
    return ions
예제 #3
0
def cross_5(radius):
    ions = []
    ions.append(ion(0, 0))
    ions.append(ion(0, radius))
    ions.append(ion(radius, 0))
    ions.append(ion(0, -radius))
    ions.append(ion(-radius, 0))
    return ions
예제 #4
0
def cross_5(radius):
    ions = []
    ions.append(ion(0, 0))
    ions.append(ion(0, radius))
    ions.append(ion(radius, 0))
    ions.append(ion(0, -radius))
    ions.append(ion(-radius, 0))
    return ions
예제 #5
0
def triangle_4(radius):
    ions = []
    theta = np.pi/6.0
    x = radius * np.cos(theta)
    y = radius * np.sin(theta)
    ions.append(ion(0, 0))
    ions.append(ion(0, radius))
    ions.append(ion(x, -y))
    ions.append(ion(-x, -y))
    return ions
예제 #6
0
def triangle_4(radius):
    ions = []
    theta = np.pi / 6.0
    x = radius * np.cos(theta)
    y = radius * np.sin(theta)
    ions.append(ion(0, 0))
    ions.append(ion(0, radius))
    ions.append(ion(x, -y))
    ions.append(ion(-x, -y))
    return ions
예제 #7
0
def symmetric_6(radius):
    ions = []
    ions.append(ion(0, radius))
    ions.append(ion(0, -radius))
    x = radius * np.cos(np.pi/6)
    y = radius * np.sin(np.pi/6)
    ions.append(ion(x, y))
    ions.append(ion(-x, -y))
    ions.append(ion(-x, y))
    ions.append(ion(x, -y))
    return ions
예제 #8
0
def symmetric_6(radius):
    ions = []
    ions.append(ion(0, radius))
    ions.append(ion(0, -radius))
    x = radius * np.cos(np.pi / 6)
    y = radius * np.sin(np.pi / 6)
    ions.append(ion(x, y))
    ions.append(ion(-x, -y))
    ions.append(ion(-x, y))
    ions.append(ion(x, -y))
    return ions
예제 #9
0
def make_crystal(N_ions=6, starting_ions=None, constant_ion=None,
                 progress=True, assymetry=None):
    '''
    This function iterates random steps in postion and recalculates the energy
    of the configuration of N ions, if the energy is decreased it accepts
    the move and repeats
    '''

    A = utility.get_potential_coefficient()
    tp = get_trap_parameters()
    sp = get_simulation_parameters()

    if assymetry:
        assy = assymetry
    else:
        assy = tp[4]
    pos_spread = sp[2]
    iterations = sp[1]
    step_size = sp[0]

    if progress:
        p = ProgressBar(iterations)
    N = N_ions
    ions = []
    if starting_ions is None:
        for _i in range(N):
            # initiate ions in random position
            x0 = (np.random.rand() - 0.5)*pos_spread
            y0 = (np.random.rand() - 0.5)*pos_spread
            ions.append(ion(x0, y0))
    else:
        # initiate ions in specified starting positions
        for starting_ion in starting_ions:
            ions.append(ion(starting_ion.x, starting_ion.y,
                            starting_ion.color))
    E0 = total_energy(ions, assy)

    iters = 0
    E = [E0]
    last_E = E0
    if constant_ion is not None:
        for fixed in constant_ion:
            ions[fixed].constant = True
    while iters < iterations:
        if progress:
            p.animate(iters)
        iters += 1
        for particle in ions:
            if not particle.constant:  # Checks if ion is movable
                particle.lastx = particle.x
                particle.x = particle.x + (np.random.rand() - 0.5)*step_size
                particle.lasty = particle.y
                particle.y = particle.y + (np.random.rand() - 0.5)*step_size
                tot_E = total_energy(ions, assy, A)
                if tot_E < last_E:  # Check to take the position step or not
                    E.append(tot_E)
                    last_E = tot_E
                else:
                    particle.x = particle.lastx
                    particle.y = particle.lasty
    return E[-1], ions
예제 #10
0
def three_line(radius):
    ions = []
    ions.append(ion(0, radius))
    ions.append(ion(0, 0))
    ions.append(ion(0, -radius))
    return ions
예제 #11
0
def two_ion(radius):
    ions = []
    ions.append(ion(0, radius))
    ions.append(ion(0, -radius))
    return ions
예제 #12
0
def one_ion(radius):
    ions = []
    ions.append(ion(0, radius))
    return ions
예제 #13
0
def three_line(radius):
    ions = []
    ions.append(ion(0, radius))
    ions.append(ion(0, 0))
    ions.append(ion(0, -radius))
    return ions
예제 #14
0
def two_ion(radius):
    ions = []
    ions.append(ion(0, radius))
    ions.append(ion(0, -radius))
    return ions
예제 #15
0
def one_ion(radius):
    ions = []
    ions.append(ion(0, radius))
    return ions
예제 #16
0
def make_crystal(N_ions=6,
                 starting_ions=None,
                 constant_ion=None,
                 progress=True,
                 assymetry=None):
    '''
    This function iterates random steps in postion and recalculates the energy
    of the configuration of N ions, if the energy is decreased it accepts
    the move and repeats
    '''

    A = utility.get_potential_coefficient()
    tp = get_trap_parameters()
    sp = get_simulation_parameters()

    if assymetry:
        assy = assymetry
    else:
        assy = tp[4]
    pos_spread = sp[2]
    iterations = sp[1]
    step_size = sp[0]

    if progress:
        p = ProgressBar(iterations)
    N = N_ions
    ions = []
    if starting_ions is None:
        for _i in range(N):
            # initiate ions in random position
            x0 = (np.random.rand() - 0.5) * pos_spread
            y0 = (np.random.rand() - 0.5) * pos_spread
            ions.append(ion(x0, y0))
    else:
        # initiate ions in specified starting positions
        for starting_ion in starting_ions:
            ions.append(ion(starting_ion.x, starting_ion.y,
                            starting_ion.color))
    E0 = total_energy(ions, assy)

    iters = 0
    E = [E0]
    last_E = E0
    if constant_ion is not None:
        for fixed in constant_ion:
            ions[fixed].constant = True
    while iters < iterations:
        if progress:
            p.animate(iters)
        iters += 1
        for particle in ions:
            if not particle.constant:  # Checks if ion is movable
                particle.lastx = particle.x
                particle.x = particle.x + (np.random.rand() - 0.5) * step_size
                particle.lasty = particle.y
                particle.y = particle.y + (np.random.rand() - 0.5) * step_size
                tot_E = total_energy(ions, assy, A)
                if tot_E < last_E:  # Check to take the position step or not
                    E.append(tot_E)
                    last_E = tot_E
                else:
                    particle.x = particle.lastx
                    particle.y = particle.lasty
    return E[-1], ions