def main(): argparser = argparse.ArgumentParser() argparser.add_argument("input", help="File with cross-sections in BOLSIG+ format") argparser.add_argument("bolsigdata", help="File with BOLSIG+ rates") argparser.add_argument( "--debug", help="If set, produce a lot of output for debugging", action='store_true', default=False) args = argparser.parse_args() if args.debug: logging.basicConfig(format='[%(asctime)s] %(module)s.%(funcName)s: ' '%(message)s', datefmt='%a, %d %b %Y %H:%M:%S', level=logging.DEBUG) # Use a linear grid from 0 to 60 eV with 100 intervals. gr = grid.LinearGrid(0.001, 80., 400) # Initiate the solver instance bsolver = solver.BoltzmannSolver(gr) # Parse the cross-section file in BOSIG+ format and load it into the # solver. with open(args.input) as fp: processes = parser.parse(fp) processes = bsolver.load_collisions(processes) # Set the conditions. And initialize the solver bsolver.target['N2'].density = 0.8 bsolver.target['O2'].density = 0.2 # Calculate rates only for N2 and O2 processes = [p for p in processes if p.target.density > 0] bolsig = np.loadtxt(args.bolsigdata) # Electric fields in the BOLSIG+ file en = bolsig[:, 1] # Create an array to store our results bolos = np.empty((len(en), len(processes))) # Start with Maxwell EEDF as initial guess. Here we are starting with # with an electron temperature of 2 eV f0 = bsolver.maxwell(2.0) # Solve for each E/n for i, ien in enumerate(en): bsolver.grid = gr logging.info("E/n = %f Td" % ien) bsolver.EN = ien * solver.TOWNSEND bsolver.kT = 300 * co.k / co.eV bsolver.init() # Note that for each E/n we start with the previous E/n as # a reasonable first guess. f1 = bsolver.converge(f0, maxn=200, rtol=1e-4) # Second pass: with an automatic grid and a lower tolerance. mean_energy = bsolver.mean_energy(f1) newgrid = grid.QuadraticGrid(0, 15 * mean_energy, 200) bsolver.grid = newgrid bsolver.init() f2 = bsolver.grid.interpolate(f1, gr) f2 = bsolver.converge(f2, maxn=200, rtol=1e-5) bolos[i, :] = [bsolver.rate(f2, p) for p in processes] for k, p in enumerate(processes): print "%.3d: %-40s %s eV" % (k, p, p.threshold or 0.0) plt.clf() plt.figure(figsize=(8, 8)) plt.subplot(2, 1, 1) plt.plot(en, bolos[:, k], lw=2.0, c='r', label="BOLOS") plt.plot(en, bolsig[:, k + 3], lw=2.0, ls='--', c='k', label="Bolsig+") plt.ylabel("k (cm$^\mathdefault{3}$/s)") plt.grid() plt.semilogy() plt.legend(loc='lower right') plt.gca().xaxis.set_ticklabels([]) plt.subplot(2, 1, 2) plt.plot(en, abs(bolos[:, k] - bolsig[:, k + 3]) / bolsig[:, k + 3], lw=2.0, c='b') plt.xlabel("E/n (Td)") plt.ylabel("$|k_{BOLOS}-k_{Bolsig}|/k_{Bolsig}$") plt.grid() plt.semilogy() plt.text(0.025, 0.05, str(p) + " %s eV" % p.threshold, color='b', horizontalalignment='left', verticalalignment='bottom', size=18, transform=plt.gca().transAxes) plt.savefig("%.3d.pdf" % k) plt.close()
def main(): # fig, ax = plt.subplots() args = parse_args() print(args.temp) if args.debug: logging.basicConfig(format='[%(asctime)s] %(module)s.%(funcName)s: ' '%(message)s', datefmt='%a, %d %b %Y %H:%M:%S', level=logging.DEBUG) temp = 300 E_N = 10 list_ion_degree = [0, 1e-6, 1e-5, 1e-4, 1e-3] for ion_degree in list_ion_degree: print("Ion degree = %.1e" % ion_degree) # fichier_out.write('R%d\n' % (index+1)) # fichier_out.write('------------------------------------------------------------\n') # fichier_out.write('Electric field / N (Td) %.1f \n'% reduced_e ) # fichier_out.write('Gas temperature (K) %.1f \n'% temp ) # Use a linear grid from 0 to 60 eV with 500 intervals. gr = grid.LinearGrid(0, 60, 200) # gr = grid.QuadraticGrid(0, maxgrid[index], 400) # Initiate the solver instance bsolver = solver.BoltzmannSolver(gr) # Parse the cross-section file in BOSIG+ format and load it into the # solver. with open(args.input) as fp: bsolver.load_collisions(parser.parse(fp)) # Set the conditions. And initialize the solver bsolver.target['Ar'].density = 1.0 bsolver.kT = temp * co.k / co.eV bsolver.EN = E_N * solver.TOWNSEND bsolver.coulomb = True bsolver.electron_density = 1e18 bsolver.ion_degree = ion_degree bsolver.growth_model = 1 bsolver.init() # Start with Maxwell EEDF as initial guess. Here we are starting with # with an electron temperature of 2 eV f0 = bsolver.maxwell(4) # ax.plot(bsolver.grid.c, f0, label='Init') # Solve the Boltzmann equation with a tolerance rtol and maxn iterations. f0 = bsolver.converge(f0, maxn=200, rtol=1e-4) # plt.plot(bsolver.grid.c, f0, label='f0 n/N = %.1e' % ion_degree) # ax.plot(bsolver.grid.c, f0, label='First convergence') # Second pass: with an automatic grid and a lower tolerance. mean_energy = bsolver.mean_energy(f0) print(mean_energy) # newgrid = grid.QuadraticGrid(0, 10 * mean_energy, 400) newgrid = grid.QuadraticGrid(0, 15 * mean_energy, 300) bsolver.grid = newgrid bsolver.init() f1 = bsolver.grid.interpolate(f0, gr) f1 = bsolver.converge(f1, maxn=200, rtol=1e-6) plt.plot(bsolver.grid.c, f1, label='n/N = %.1e' % ion_degree) # Search for a particular process in the solver and print its rate. #k = bsolver.search('N2 -> N2^+') #print "THE REACTION RATE OF %s IS %g\n" % (k, bsolver.rate(f1, k)) # You can also iterate over all processes or over processes of a certain # type. # # Calculate the mobility and diffusion. # fichier_out.write('------------------------------------------------------------\n') # fichier_out.write("TRANSPORT PARAMETERS:\n") # fichier_out.write("Mean energy (eV) %.4e \n" % bsolver.mean_energy(f1)) # fichier_out.write("Mobility *N (1/m/V/s) %.4e \n" % bsolver.mobility(f1)) # fichier_out.write("Diffusion coefficient *N (1/m/s) %.4e \n" % bsolver.diffusion(f1)) # fichier_out.write('------------------------------------------------------------\n') # fichier_out.write("Rate coefficients (m3/s)\n") # for t, p in bsolver.iter_all(): # fichier_out.write("%-40s %.4e\n" % (str(p), bsolver.rate(f1, p))) # fichier_out.write('------------------------------------------------------------\n') # fichier_out.write("Energy (eV) EEDF (eV-3/2)\n") # for i in range(len(bsolver.grid.c)): # fichier_out.write("%.4e %.4e\n" % (bsolver.grid.c[i],f1[i])) # fichier_out.write('\n\n\n') # ax.plot(bsolver.grid.c, f1, label='Final Solution') plt.xlim([0, 35]) plt.yscale('log') plt.ylim([1e-9, 1]) plt.legend() plt.xlabel(r'$\epsilon$ (eV)') plt.ylabel(r'$F_0$ (eV$^{-3/2}$)') plt.savefig('FIGURES/Ar_10Td_coulomb_2it.png', bbox_inches='tight')
def main(): args = parse_args() if args.debug: logging.basicConfig(format='[%(asctime)s] %(module)s.%(funcName)s: ' '%(message)s', datefmt='%a, %d %b %Y %H:%M:%S', level=logging.DEBUG) # Use a linear grid from 0 to 60 eV with 500 intervals. gr = grid.LinearGrid(0, 60., 500) # Initiate the solver instance bsolver = solver.BoltzmannSolver(gr) # Parse the cross-section file in BOSIG+ format and load it into the # solver. with open(args.input) as fp: bsolver.load_collisions(parser.parse(fp)) # Set the conditions. And initialize the solver bsolver.target['N2'].density = 0.8 bsolver.target['O2'].density = 0.2 bsolver.kT = args.temp * co.k / co.eV bsolver.EN = args.en * solver.TOWNSEND bsolver.init() # Start with Maxwell EEDF as initial guess. Here we are starting with # with an electron temperature of 2 eV f0 = bsolver.maxwell(2.0) # Solve the Boltzmann equation with a tolerance rtol and maxn iterations. f0 = bsolver.converge(f0, maxn=200, rtol=1e-4) # Second pass: with an automatic grid and a lower tolerance. mean_energy = bsolver.mean_energy(f0) newgrid = grid.QuadraticGrid(0, 150 * mean_energy, 200) bsolver.grid = newgrid bsolver.init() f1 = bsolver.grid.interpolate(f0, gr) f1 = bsolver.converge(f1, maxn=200, rtol=1e-5) # Search for a particular process in the solver and print its rate. #k = bsolver.search('N2 -> N2^+') #print "THE REACTION RATE OF %s IS %g\n" % (k, bsolver.rate(f1, k)) # You can also iterate over all processes or over processes of a certain # type. print "\nREACTION RATES:\n" for t, p in bsolver.iter_all(): print "%-40s %.3e m^3/s" % (str(p), bsolver.rate(f1, p)) # Calculate the mobility and diffusion. print "\nTRANSPORT PARAMETERS:\n" print "mobility * N = %.3e 1/m/V/s" % bsolver.mobility(f1) print "diffusion * N = %.3e 1/m/s" % bsolver.diffusion(f1) print "average energy = %.3e eV" % bsolver.mean_energy(f1) import pylab pylab.plot(bsolver.grid.c, f1) pylab.show()
eta = np.zeros(nEf) k2BodyAttach = np.zeros(nEf) k3BodyAttach = np.zeros(nEf) mean_energy = np.zeros(nEf) elastic = np.zeros(nEf) EArray[0] = EStart for i in range(0, nEf - 1): EArray[i + 1] = EArray[i] * mult # Set-up the electron energy grid we want to compute the electron # energy distribution on en_start = 0.0 en_fin = 60.0 en_bins = 200 gr = grid.QuadraticGrid(en_start, en_fin, en_bins) boltzmann = solver.BoltzmannSolver(gr) with open('/home/alexlindsay/bolos/LXCat-June2013.txt') as fp: processes = parser.parse(fp) boltzmann.load_collisions(processes) boltzmann.target['N2'].density = xN2 boltzmann.target['O2'].density = xO2 boltzmann.kT = T * co.k / solver.ELECTRONVOLT for i in range(0, nEf): EField = EArray[i] En = EField / N boltzmann.EN = En boltzmann.init() fMaxwell = boltzmann.maxwell(2.0) f1 = boltzmann.converge(fMaxwell, maxn=100, rtol=1e-5) mean_energy[i] = boltzmann.mean_energy(f1)
def main(): args = parse_args() print(args.temp) if args.debug: logging.basicConfig(format='[%(asctime)s] %(module)s.%(funcName)s: ' '%(message)s', datefmt='%a, %d %b %Y %H:%M:%S', level=logging.DEBUG) temp = 300 E_N = [0.1, 20, 100] maxgrid = [20, 60, 60] inital_energy = [0.1, 1, 2] fichier_out = open("IST_Lisbon_air_bolos.dat", "w") for index, reduced_e in enumerate(E_N): fichier_out.write('R%d\n' % (index + 1)) fichier_out.write( '------------------------------------------------------------\n') fichier_out.write( 'Electric field / N (Td) %.1f \n' % reduced_e) fichier_out.write( 'Gas temperature (K) %.1f \n' % temp) # Use a linear grid from 0 to 60 eV with 500 intervals. gr = grid.LinearGrid(0.001, maxgrid[index], 200) # Initiate the solver instance bsolver = solver.BoltzmannSolver(gr) # Parse the cross-section file in BOSIG+ format and load it into the # solver. with open(args.input) as fp: bsolver.load_collisions(parser.parse(fp)) # Set the conditions. And initialize the solver bsolver.target['N2'].density = 0.8 bsolver.target['O2'].density = 0.2 bsolver.kT = temp * co.k / co.eV bsolver.EN = reduced_e * solver.TOWNSEND bsolver.init() # Start with Maxwell EEDF as initial guess. Here we are starting with # with an electron temperature of 2 eV f0 = bsolver.maxwell(2.0) # plt.plot(bsolver.grid.c, bsolver.grid.c**(1/2)*f0, label='Init') # Solve the Boltzmann equation with a tolerance rtol and maxn iterations. f0 = bsolver.converge(f0, maxn=200, rtol=1e-4) # plt.plot(bsolver.grid.c, bsolver.grid.c**(1/2)*f0, label='First iteration') # Second pass: with an automatic grid and a lower tolerance. mean_energy = bsolver.mean_energy(f0) newgrid = grid.QuadraticGrid(0, 12 * mean_energy, 200) bsolver.grid = newgrid bsolver.init() f1 = bsolver.grid.interpolate(f0, gr) f1 = bsolver.converge(f1, maxn=200, rtol=1e-5) # plt.plot(bsolver.grid.c, bsolver.grid.c**(1/2)*f1, label='Second iteration') # plt.legend() # plt.show() # Search for a particular process in the solver and print its rate. #k = bsolver.search('N2 -> N2^+') #print "THE REACTION RATE OF %s IS %g\n" % (k, bsolver.rate(f1, k)) # You can also iterate over all processes or over processes of a certain # type. # Calculate the mobility and diffusion. fichier_out.write( '------------------------------------------------------------\n') fichier_out.write("TRANSPORT PARAMETERS:\n") fichier_out.write( "Mean energy (eV) %.4e \n" % bsolver.mean_energy(f1)) fichier_out.write( "Mobility *N (1/m/V/s) %.4e \n" % bsolver.mobility(f1)) fichier_out.write( "Diffusion coefficient *N (1/m/s) %.4e \n" % bsolver.diffusion(f1)) fichier_out.write( '------------------------------------------------------------\n') fichier_out.write("Rate coefficients (m3/s)\n") for t, p in bsolver.iter_all(): fichier_out.write("%-40s %.4e\n" % (str(p), bsolver.rate(f1, p))) fichier_out.write( '------------------------------------------------------------\n') fichier_out.write("Energy (eV) EEDF (eV-3/2)\n") for i in range(len(bsolver.grid.c)): fichier_out.write("%.4e %.4e\n" % (bsolver.grid.c[i], f1[i])) fichier_out.write('\n\n\n')
def main(): # fig, ax = plt.subplots() args = parse_args() if args.debug: logging.basicConfig(format='[%(asctime)s] %(module)s.%(funcName)s: ' '%(message)s', datefmt='%a, %d %b %Y %H:%M:%S', level=logging.DEBUG) temp = 300 growth_model_string = ['None', 'Temporal', 'Spatial'] list_growth_model = [0, 1, 2] list_EN = np.linspace(30, 600, 30) color = ['k', 'b', 'g'] #search for the mean of the elastic cross sections in log energy space # gr = grid.LinearGrid(0, 120, 200) # bsolver = solver.BoltzmannSolver(gr) # with open(args.input) as fp: # bsolver.load_collisions(parser.parse(fp)) # bsolver.target['Ar'].density = 1.0 # list_kT = np.linspace(1, 15, 15) # list_mean_cs = [] # for t, p in bsolver.iter_all(): # if p.kind[:3] == 'ELA': # mean_en_cs = np.max(p.y) # for kT in list_kT: # maxwell = (2 * np.sqrt(1 / np.pi) * kT**(-3./2.) * np.exp(-p.x / kT)) # mean_en_cs = integrate.simps(maxwell * p.y * np.sqrt(p.x), x=p.x) # list_mean_cs.append(mean_en_cs) # mean_en_cs = np.max(np.array(list_mean_cs)) # print(mean_en_cs) # # print('kT = %.1f, mean_cs = %.2e' % (kT, mean_en_cs)) # print(temp * co.k / co.e * 1.5) # plt.plot(list_EN, 2 / 3 * list_EN * np.sqrt(np.pi / 12 / 1e-3) / mean_en_cs * 1e-21 + temp * co.k / co.e * 1.5) # plt.show() # list_initial_energy = 2 / 3 * list_EN * np.sqrt(np.pi / 12 / 1e-3) / mean_en_cs * 1e-21 + temp * co.k / co.e * 1.5 # print('EN = %.2f, epsilon = %.2f' % (EN, mean_energy)) # intial energy at 5eV for all list_initial_energy = 5 * np.ones(len(list_EN)) for growth_model in list_growth_model: mean_epsilon = [] ion_rate = [] for i, EN in enumerate(list_EN): print("Growth model = %s \nE/N = %.2f Td\nInitial energy = %.2f" % (growth_model_string[growth_model], EN, list_initial_energy[i])) # fichier_out.write('R%d\n' % (index+1)) # fichier_out.write('------------------------------------------------------------\n') # fichier_out.write('Electric field / N (Td) %.1f \n'% reduced_e ) # fichier_out.write('Gas temperature (K) %.1f \n'% temp ) # Use a linear grid from 0 to 60 eV with 500 intervals. # gr = grid.LinearGrid(0, 120, 200) # gr = grid.QuadraticGrid(0, maxgrid[index], 400) mean_energy = list_initial_energy[i] gr = grid.LinearGrid(0, 12 * mean_energy, 200) # Initiate the solver instance bsolver = solver.BoltzmannSolver(gr) # Parse the cross-section file in BOSIG+ format and load it into the # solver. with open(args.input) as fp: bsolver.load_collisions(parser.parse(fp)) # Set the conditions. And initialize the solver bsolver.target['Ar'].density = 1.0 bsolver.kT = temp * co.k / co.eV bsolver.EN = EN * solver.TOWNSEND bsolver.coulomb = False bsolver.growth_model = growth_model bsolver.init() # plot_cross_sections(bsolver, 'cross_sections_Ar_Phelps') # Start with Maxwell EEDF as initial guess. Here we are starting with # with an electron temperature of 2 eV f0 = bsolver.maxwell(mean_energy) # ax.plot(bsolver.grid.c, f0, label='Init') # Solve the Boltzmann equation with a tolerance rtol and maxn iterations. f0 = bsolver.converge(f0, maxn=200, rtol=1e-4) # plt.plot(bsolver.grid.c, f0, label='f0 growth_model = %d' % growth_model) # ax.plot(bsolver.grid.c, f0, label='First convergence') # Second pass: with an automatic grid and a lower tolerance. mean_energy = bsolver.mean_energy(f0) print('Mean Energy = %.2e' % mean_energy) # newgrid = grid.QuadraticGrid(0, 10 * mean_energy, 400) newgrid = grid.QuadraticGrid(0, 12 * mean_energy, 800) bsolver.grid = newgrid bsolver.init() f1 = bsolver.grid.interpolate(f0, gr) f1 = bsolver.converge(f1, maxn=200, rtol=1e-6) # plt.plot(bsolver.grid.c, f1, color=color[growth_model], label='Growth model = %s' % growth_model_string[growth_model]) mean_energy = bsolver.mean_energy(f1) mean_epsilon.append(mean_energy) for t, p in bsolver.iter_inelastic(): if p.kind[:3] == 'ION': ion_rate.append(bsolver.rate(f1, p)) #update for the spatial pass list_initial_energy[i] = 0.4 * mean_energy # print(mean_epsilon) # print(ion_rate) plt.plot(mean_epsilon, ion_rate, color=color[growth_model], label='Growth model = %s' % growth_model_string[growth_model]) # Search for a particular process in the solver and print its rate. #k = bsolver.search('N2 -> N2^+') #print "THE REACTION RATE OF %s IS %g\n" % (k, bsolver.rate(f1, k)) # You can also iterate over all processes or over processes of a certain # type. # # Calculate the mobility and diffusion. # fichier_out.write('------------------------------------------------------------\n') # fichier_out.write("TRANSPORT PARAMETERS:\n") # fichier_out.write("Mean energy (eV) %.4e \n" % bsolver.mean_energy(f1)) # fichier_out.write("Mobility *N (1/m/V/s) %.4e \n" % bsolver.mobility(f1)) # fichier_out.write("Diffusion coefficient *N (1/m/s) %.4e \n" % bsolver.diffusion(f1)) # fichier_out.write('------------------------------------------------------------\n') # fichier_out.write("Rate coefficients (m3/s)\n") # for t, p in bsolver.iter_all(): # fichier_out.write("%-40s %.4e\n" % (str(p), bsolver.rate(f1, p))) # fichier_out.write('------------------------------------------------------------\n') # fichier_out.write("Energy (eV) EEDF (eV-3/2)\n") # for i in range(len(bsolver.grid.c)): # fichier_out.write("%.4e %.4e\n" % (bsolver.grid.c[i],f1[i])) # fichier_out.write('\n\n\n') # ax.plot(bsolver.grid.c, f1, label='Final Solution') plt.legend() plt.xlim([5, 10]) plt.ylim([1e-18, 1e-14]) plt.yscale('log') plt.xlabel(r'$\epsilon$ (eV)') plt.ylabel(r'Ionization rate coefficient (m$^3$/s)') plt.savefig('FIGURES/Ar_growth_rates', bbox_inches='tight')