def metal_gen(trans_ind): # Set constants a1 = np.complex64(1e16) gamma = np.complex64(1e12) freq = np.complex64(0) inf_perm = np.complex64(1e0) # Calculate beta ang_gamma = np.complex64(gamma * 2 * np.pi) omega = np.complex64(freq * 2 * np.pi) beta = np.sqrt(np.add(np.square(ang_gamma), -np.square(omega)), dtype=np.complex64) a2 = -a1 # Create matrices m = np.ones((1, mlen), dtype=np.complex64) mgamma = m * ang_gamma mbeta = m * beta ma1 = m * a1 ma2 = m * a2 # Create opacity vector using a transition width of 200 fs an offset of mat_trans_ind width = int(200/0.1) # 200 fs / (0.1 fs/step) = 2000 steps opacity = normalized_error_func_gen(width, trans_ind) # Create metal object return Mat(dn, ilen, nlen, m_s_ind, inf_perm, ma1, ma2, mgamma, mbeta, opacity=opacity, storelocs=[1])
a1 = np.complex64(a / (2 * beta)) a2 = np.complex64(-a / (2 * beta)) # Determine matrix length m_len_ind = m_e_ind - m_s_ind # Create matrices m = np.ones((1, m_len_ind), dtype=np.complex64) mgamma = m * ang_gamma mbeta = m * beta ma1 = m * a1 ma2 = m * a2 # Create material object material = Mat(dn, ilen, nlen, m_s_ind, inf_perm, ma1, ma2, mgamma, mbeta, storelocs=[1]) # Display constants print('gamma=%i, beta=%i, a1=%i, a2=%i' % (gamma, beta, a1, a2)) # ============== # RUN SIMULATION # ============== # Create Sim object s = Sim(i0, i1, di, n0,
e_ma1_scaled = e_frac * e_ma1 e_ma2_scaled = e_frac * e_ma2 g_ma1_scaled = g_frac * g_ma1 g_ma2_scaled = g_frac * g_ma2 # Combine oscillators ma1 = np.vstack((e_ma1_scaled, g_ma1_scaled)) ma2 = np.vstack((e_ma2_scaled, g_ma2_scaled)) mgamma = np.vstack((e_mgamma, g_mgamma)) mbeta = np.vstack((e_mbeta, g_mbeta)) # Create material inf_perm = np.complex64(1e0) two_state_mat = Mat(dn, ilen, nlen, m_s_ind, inf_perm, ma1, ma2, mgamma, mbeta, storelocs=[1]) # Create and run simulation s = Sim(i0, i1, di, n0, n1, dn, epsilon0, mu0, 'absorbing', current,
if sim_file.is_file(): # Load results dat = np.load('drude_model_numeric.npz') t = dat['t'] els = dat['els'] erls = dat['erls'] hls = dat['hls'] hrls = dat['hrls'] chi = dat['chi'] else: # Create the material drude_material = Mat(di, dn, ilen, nlen, material_ind_start, material_ind_end, chi, inf_perm, tqdmarg={'desc': 'Calculating chi^m'}) # Create Sim object tqdmarg = {'desc': 'Executing simulation'} s = Sim(i0, i1, di, n0, n1, dn, epsilon0, mu0, 'absorbing',
for i in range(len(t_diffs)): # Wrap chi function def chi_wrapped(t): return chi(t, t_diffs[i]) # Create the material tqdmarg = { 'desc': ('Calculating chi^m ' + str(i + 1) + '/' + str(len(t_diffs))), 'leave': False } overlap_mat = Mat(di, dn, ilen, nlen, m_z_start_ind, m_z_end_ind, chi_wrapped, inf_perm, tqdmarg=tqdmarg) # Create Sim object s = Sim(i0, i1, di, n0, n1, dn, epsilon0, mu0, 'absorbing', thzpulse,