def buneman_deck_maker(iname='buneman.txt', oname='case1.txt', vx0=3.0, rmass=100, tend=200): with open(iname) as osdata: data = osdata.readlines() for i in range(len(data)): if 'VX0 =' in data[i]: data[i] = ' VX0 = ' + str(vx0) + ',\n' if 'WAVEW' in data[i]: data[i] = ' RMASS = ' + str(rmass) + ',\n' if 'TEND' in data[i]: data[i] = ' TEND = ' + str(tend) + ',\n' with open(oname, 'w') as f: for line in data: f.write(line) print('New file ' + oname + ' is written.') dirname = oname.strip('.txt') print('Running UPIC in directory ' + dirname + '...') osiris.run_upic_es(rundir=dirname, inputfile=oname) outdirname = oname.split(".")[0] print(outdirname) phasespace_movie(output_directory=dirname) plot_t_vs_k(output_directory=dirname, v0=vx0, mass_ratio=1 / rmass) print('Done')
def twostream_deck_maker(iname='twostream.txt', oname='case1.txt', n1=1, vx0=-3.0, vdx=3.0, n2n1=1.0, tend=200, indx=8): with open(iname) as osdata: data = osdata.readlines() STREAM2_ELECTRONS = int(n2n1*262144) for i in range(len(data)): if 'VX0 =' in data[i]: data[i] = ' VX0 = '+str(vx0)+',\n' if 'VDX =' in data[i]: data[i] = ' VDX = '+str(vdx)+',\n' if 'NPXB' in data[i]: data[i] = 'NPXB = '+str(STREAM2_ELECTRONS)+'\n' if 'TEND' in data[i]: data[i] = ' TEND = '+str(tend)+',\n' if 'INDX' in data[i]: data[i] = ' INDX = '+str(indx)+',\n' with open(oname,'w') as f: for line in data: f.write(line) print('New file '+oname+' is written.') dirname = oname.strip('.txt') print('Running UPIC in directory '+dirname+'...') osiris.run_upic_es(rundir=dirname,inputfile=oname) outdirname=oname.split(".")[0] print(outdirname) phasespace_movie(output_directory=dirname) print('Done')
def wcb_deck_maker(iname='wcb.txt', oname='case1.txt', vdx=3.0, rden=0.01, vth0=1, vthb=0.01, tend=200): with open(iname) as osdata: data = osdata.readlines() BEAM_ELECTRONS = int(rden * 262144) for i in range(len(data)): if 'VX0 =' in data[i]: data[i] = ' VDX = ' + str(vdx) + ',\n' if 'VTX' in data[i]: data[i] = ' VTX = ' + str(vth0) + ',\n' if 'VTDX' in data[i]: data[i] = ' VTDX = ' + str(vthb) + '\n' if 'NPXB' in data[i]: data[i] = 'NPXB = ' + str(BEAM_ELECTRONS) + '\n' if 'TEND' in data[i]: data[i] = ' TEND = ' + str(tend) + ',\n' with open(oname, 'w') as f: for line in data: f.write(line) print('New file ' + oname + ' is written.') dirname = oname.strip('.txt') print('Running UPIC in directory ' + dirname + '...') osiris.run_upic_es(rundir=dirname, inputfile=oname) outdirname = oname.split(".")[0] print(outdirname) # e_history=energy_history(dirname=outdirname) # taxis=np.arange(len(e_history))*0.2 # plt.plot(taxis,e_history) # plt.title('Energy Deviation vs Time (in %)') # plt.xlabel('Time ($\omega_p^{-1}$)') # plt.show() # phasespace_movie(output_directory=dirname) print('Done')
def run_upic(output_directory, inputfile): osiris.run_upic_es(rundir=output_directory, inputfile=inputfile)