def f_left(f, t, q1, q2, p1, p2, p3, params): k = params.boltzmann_constant E_upper = params.E_band T = params.initial_temperature mu = params.initial_mu t = params.current_time omega = 2. * np.pi * params.AC_freq if (params.source_type == 'AC'): vel_drift_x_in = params.vel_drift_x_in * np.sin(omega * t) elif (params.source_type == 'DC'): vel_drift_x_in = params.vel_drift_x_in else: raise NotImplementedError('Unsupported source_type') if (params.p_space_grid == 'cartesian'): p_x = p1 p_y = p2 elif (params.p_space_grid == 'polar2D'): p_x = p1 * af.cos(p2) p_y = p1 * af.sin(p2) else: raise NotImplementedError('Unsupported coordinate system in p_space') fermi_dirac_in = (1. / (af.exp( (E_upper - vel_drift_x_in * p_x - mu) / (k * T)) + 1.)) x, y = coords.get_cartesian_coords(q1, q2) y_contact_start = params.contact_start y_contact_end = params.contact_end cond = ((y >= y_contact_start) & \ (y <= y_contact_end) \ ) f_left = cond * fermi_dirac_in + (1 - cond) * f af.eval(f_left) return (f_left)
N_q2_2 = domain_2.N_q2 q1_2 = domain_2.q1_start + (0.5 + np.arange(N_q1_2)) * (domain_2.q1_end - \ domain_2.q1_start)/N_q1_2 q2_2 = domain_2.q2_start + (0.5 + np.arange(N_q2_2)) * (domain_2.q2_end - \ domain_2.q2_start)/N_q2_2 dq1_2 = (domain_2.q1_end - domain_1.q1_start) / N_q1_1 dq2_2 = (domain_2.q2_end - domain_1.q2_start) / N_q2_1 q2_meshgrid_2, q1_meshgrid_2 = np.meshgrid(q2_2, q1_2) q1_meshgrid_2 = af.from_ndarray(q1_meshgrid_2) q2_meshgrid_2 = af.from_ndarray(q2_meshgrid_2) x, y = coords_2.get_cartesian_coords(q1_meshgrid_2, q2_meshgrid_2) x_2 = x.to_ndarray() y_2 = y.to_ndarray() # Stich domains #N_q1 = N_q1_1 #N_q2 = N_q2_1 + N_q2_2 #q1_start = 0. #q1_end = domain_1.q1_end #q2_start = 0. #q2_end = domain_1.q2_end + domain_2.q2_end #dq1 = (q1_end - q1_start)/N_q1 #dq2 = (q2_end - q2_start)/N_q2
def initialize_f(q1, q2, p1, p2, p3, params): PETSc.Sys.Print("Initializing f") k = params.boltzmann_constant params.mu = 0. * q1 + params.initial_mu params.T = 0. * q1 + params.initial_temperature params.vel_drift_x = 0. * q1 params.vel_drift_y = 0. * q1 params.phi = 0. * q1 params.mu_ee = params.mu.copy() params.T_ee = params.T.copy() params.vel_drift_x = 0. * q1 + 0e-3 params.vel_drift_y = 0. * q1 + 0e-3 params.j_x = 0. * q1 params.j_y = 0. * q1 params.E_band = params.band_energy(p1, p2) params.vel_band = params.band_velocity(p1, p2) E_upper = params.E_band + params.charge[0] * params.phi if (params.p_space_grid == 'cartesian'): p_x = p1 p_y = p2 elif (params.p_space_grid == 'polar2D'): p_x = p1 * af.cos(p2) p_y = p1 * af.sin(p2) else: raise NotImplementedError('Unsupported coordinate system in p_space') # Initialize to zero f = 0 * q1 * p1 # Parameters to define a gaussian in space (representing a 2D ball) A = domain.N_p2 # Amplitude (required for normalization) sigma_x = 0.05 # Standard deviation in x sigma_y = 0.05 # Standard deviation in y x_0 = 0. # Center in x y_0 = 0. # Center in y # TODO: This will work with polar2D p-space only for the moment # Particles lying on the ball need to have the same velocity (direction) #theta_0_index = (5*N_p2/8) - 1 # Direction of initial velocity theta_0_index = int(5 * domain.N_p2 / 8) # Direction of initial velocity print("Initial angle : ") af.display(p2[theta_0_index]) # Load shift indices for all 4 boundaries into params. Required to perform # mirroring operations along boundaries at arbitrary angles. params.shift_indices_left, params.shift_indices_right, \ params.shift_indices_bottom, params.shift_indices_top = \ compute_shift_indices(q1, q2, p1, p2, p3, params) x, y = coords.get_cartesian_coords(q1, q2) # f[theta_0_index, :, :] = A + A*af.exp(-( (x-x_0)**2/(2*sigma_x**2) + \ # (y-y_0)**2/(2*sigma_y**2) # ) # ) f = (1. / (af.exp( (E_upper - params.vel_drift_x * p_x - params.vel_drift_y * p_y - params.mu) / (k * params.T)) + 1.)) af.eval(f) return (f)