Пример #1
0
def get_potential_coefficient():
    tp = get_trap_parameters()
    omegaRF = 2 * np.pi * tp[2]
    A = constants.q ** 2 * tp[1] ** 2 / (tp[3] * omegaRF ** 2 * tp[0] ** 4)
    return A
Пример #2
0
def get_potential_coefficient():
    tp = get_trap_parameters()
    omegaRF = 2 * np.pi * tp[2]
    A = constants.q**2 * tp[1]**2 / (tp[3] * omegaRF**2 * tp[0]**4)
    return A
Пример #3
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
Пример #4
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