@njit def initial_trap(x, t=0): """ Trapping potential to get the initial state :param x: :return: """ #return v_0 * (x + offset) ** 2 return v_0 * (x) ** 2 #Increase first step, and then tighten with intermediate step init_state, mu = imag_time_gpe1D( v=initial_trap, g=g, dt=7e-5, epsilon=1e-9, **params ) init_state, mu = imag_time_gpe1D( init_wavefunction=init_state, g=g, v=initial_trap, dt=1e-6, epsilon=1e-11, **params ) flipped_initial_trap = njit(lambda x, t: initial_trap(-x, t)) flipped_init_state, mu_flip = imag_time_gpe1D(
) plt.title('Trapping Potential') x = gpe_qsys.x * L_xmum plt.plot(x, initial_trap(x) * muK_calc) plt.xlabel('$x$ ($\mu$m) ') plt.ylabel('$V(x)$ ($\mu$K)') plt.xlim([-80 * L_xmum, 80 * L_xmum]) plt.savefig('Trapping Potential' + '.pdf') plt.show() #Increase first step, and then tighten with intermediate step init_state, mu = imag_time_gpe1D( v=initial_trap, g=g, dt=1e-3, epsilon=1e-8, **params ) #init_state, mu = imag_time_gpe1D( # v=initial_trap, # g=g, # dt=5e-4, # epsilon=5e-9, # **params #) init_state, mu = imag_time_gpe1D( init_wavefunction=init_state, g=g,
@njit def initial_trap(x, t=0): """ Trapping potential to get the initial state :param x: :return: """ # omega = 2 * Pi * 100Hz return 12.5 * (x + 20.)**2 init_state, mu = imag_time_gpe1D(v=initial_trap, g=g, dt=1e-3, epsilon=1e-8, **params) init_state, mu = imag_time_gpe1D(init_wavefunction=init_state, g=g, v=initial_trap, dt=1e-4, epsilon=1e-9, **params) flipped_initial_trap = njit(lambda x, t: initial_trap(-x, t)) flipped_init_state, mu = imag_time_gpe1D(v=flipped_initial_trap, g=g, dt=1e-3,
def run_single_case(params): """ Find the initial state and then propagate :param params: dict with parameters for propagation :return: dict containing results """ # get the initial state init_state, mu = imag_time_gpe1D(v=params['initial_trap'], g=g, dt=5e-5, epsilon=1e-9, **params) init_state, mu = imag_time_gpe1D(v=params['initial_trap'], g=g, init_wavefunction=init_state, dt=1e-6, epsilon=1e-11, **params) #################################################################################################################### # Propagate GPE equation #################################################################################################################### print("\nPropagate GPE equation") gpe_propagator = SplitOpGPE1D(v=v, g=g, dt=propagation_dt, **params) gpe_propagator.set_wavefunction( init_state * np.exp(1j * params['init_momentum_kick'] * gpe_propagator.x)) # propagate till time T and for each time step save a probability density gpe_wavefunctions = [ gpe_propagator.propagate(t).copy() for t in params['times'] ] #################################################################################################################### # Propagate Schrodinger equation #################################################################################################################### print("\nPropagate Schrodinger equation") schrodinger_propagator = SplitOpGPE1D(v=v, g=0., dt=propagation_dt, **params) schrodinger_propagator.set_wavefunction( init_state * np.exp(1j * params['init_momentum_kick'] * schrodinger_propagator.x)) # Propagate till time T and for each time step save a probability density schrodinger_wavefunctions = [ schrodinger_propagator.propagate(t).copy() for t in params['times'] ] # bundle results into a dictionary return { 'init_state': init_state, 'mu': mu, # bundle separately GPE data 'gpe': { 'wavefunctions': gpe_wavefunctions, 'extent': [ gpe_propagator.x.min(), gpe_propagator.x.max(), 0., max(gpe_propagator.times) ], 'times': gpe_propagator.times, 'x_average': gpe_propagator.x_average, 'x_average_rhs': gpe_propagator.x_average_rhs, 'p_average': gpe_propagator.p_average, 'p_average_rhs': gpe_propagator.p_average_rhs, 'hamiltonian_average': gpe_propagator.hamiltonian_average, 'time_increments': gpe_propagator.time_increments, 'dx': gpe_propagator.dx, 'x': gpe_propagator.x, }, # bundle separately Schrodinger data 'schrodinger': { 'wavefunctions': schrodinger_wavefunctions, 'extent': [ schrodinger_propagator.x.min(), schrodinger_propagator.x.max(), 0., max(schrodinger_propagator.times) ], 'times': schrodinger_propagator.times, 'x_average': schrodinger_propagator.x_average, 'x_average_rhs': schrodinger_propagator.x_average_rhs, 'p_average': schrodinger_propagator.p_average, 'p_average_rhs': schrodinger_propagator.p_average_rhs, 'hamiltonian_average': schrodinger_propagator.hamiltonian_average, 'time_increments': schrodinger_propagator.time_increments, }, # collect parameters for export 'parameters': params }
diff_k=diff_k, g=1000, # epsilon=1e-2, ) ################################################################################################## # create the harmonic oscillator with time-independent hamiltonian harmonic_osc = SplitOpGPE1D(dt=0.001, **harmonic_osc_params) # set the initial condition harmonic_osc.set_wavefunction( #lambda x: np.exp(-1 * (x - 0.2) ** 2) imag_time_gpe1D(dt=1e-5, **harmonic_osc_params) ) # get time duration of 6 periods T = 3 * 2. * np.pi / omega # propagate till time T and for each time step save a probability density wavefunctions = [harmonic_osc.propagate(t).copy() for t in np.arange(0, T, harmonic_osc.dt)] fig1 = plt.figure(1) plt.title( "Test 1: Time evolution of harmonic oscillator with $\\omega$ = {:.1f} (a.u.)".format(omega) ) # plot the time dependent density plt.imshow( np.abs(wavefunctions) ** 2,
def run_single_case(params): """ This function that will be run on different processors. First it will find the initial state and then it will propagate :param params: dict with parameters for propagation :return: dict contaning results """ # get the initial state init_state, mu = imag_time_gpe1D(v=params['initial_trap'], g=g, dt=1e-3, epsilon=1e-8, **params) init_state, mu = imag_time_gpe1D(v=params['initial_trap'], g=g, init_wavefunction=init_state, dt=1e-4, epsilon=1e-9, **params) ######################################################################################################################## # # Propagate GPE equation # ######################################################################################################################## print("\nPropagate GPE equation") gpe_propagator = SplitOpGPE1D(v=v, g=g, dt=propagation_dt, **params).set_wavefunction(init_state) # propagate till time T and for each time step save a probability density gpe_wavefunctions = [ gpe_propagator.propagate(t).copy() for t in params['times'] ] #################################################################################################################### # # Propagate Schrodinger equation # #################################################################################################################### print("\nPropagate Schrodinger equation") schrodinger_propagator = SplitOpGPE1D( v=v, g=0., dt=propagation_dt, **params).set_wavefunction(init_state) # propagate till time T and for each time step save a probability density schrodinger_wavefunctions = [ schrodinger_propagator.propagate(t).copy() for t in params['times'] ] # bundle results into a dictionary return { 'init_state': init_state, 'mu': mu, # bundle separately GPE data 'gpe': { 'wavefunctions': gpe_wavefunctions, 'extent': [ gpe_propagator.x.min(), gpe_propagator.x.max(), 0., max(gpe_propagator.times) ], 'times': gpe_propagator.times, 'x_average': gpe_propagator.x_average, 'x_average_rhs': gpe_propagator.x_average_rhs, 'p_average': gpe_propagator.p_average, 'p_average_rhs': gpe_propagator.p_average_rhs, 'hamiltonian_average': gpe_propagator.hamiltonian_average, 'time_increments': gpe_propagator.time_increments, 'dx': gpe_propagator.dx, 'x': gpe_propagator.x, }, # bundle separately Schrodinger data 'schrodinger': { 'wavefunctions': schrodinger_wavefunctions, 'extent': [ schrodinger_propagator.x.min(), schrodinger_propagator.x.max(), 0., max(schrodinger_propagator.times) ], 'times': schrodinger_propagator.times, 'x_average': schrodinger_propagator.x_average, 'x_average_rhs': schrodinger_propagator.x_average_rhs, 'p_average': schrodinger_propagator.p_average, 'p_average_rhs': schrodinger_propagator.p_average_rhs, 'hamiltonian_average': schrodinger_propagator.hamiltonian_average, 'time_increments': schrodinger_propagator.time_increments, }, }