Example #1
0
freqs = bsrs_lw_envelope(lpse,cells_per_wvl=cells_per_wvl,dispfun=disp)
print(freqs)
print(k)
spectral_dt(lpse,freqs,dt_frac=0.99)

# %%
"""
# Run case and get LPSE SRS growth rate
"""

# %%
if lwc.lw.landauDamping.enable == 'true':
  ld = True
else:
  ld = False
t1 = stopwatch()
pfit = ihp.srs_growth_error(lpse,gamma,gamma0,ld=ld)
t2 = stopwatch()
print(f'Time taken: {t2-t1:0.3f} s')

# %%
# Check E field of waves
lpse.fields(kspace=True)
datt = lpse.fdat['E0_z']
plt.plot(datt['x'],np.real(datt['data'][0]))
plt.xlabel('k [1/um]')
plt.ylabel('E0')
plt.show()
print(datt['x'][np.argmax(np.real(datt['data'][0]))])
datt = lpse.fdat['E1_z']
xdat = datt['x']
names = []
name = ''

for char in file.read():
    if char == '"': pass
    elif char == ',':
        names.append(name)
        name = ''
    else:
        name += char
names.append(name)

file.close()

start = stopwatch()


def compare_alphebetically(name1, name2):
    ''' returns 1 if name1 < name2
returns 0 otherwise '''

    if name1 in name2:
        if name2[:len(name1)] == name1:
            return (0)
    if name2 in name1:
        if name1[:len(name2)] == name2:
            return (1)

    for i in range(0, len(name1)):
        if ord(name1[i]) < ord(name2[i]): return (0)
xdev1 = -50; xdev2 = 50
x = np.linspace(xdev1,xdev2,len(gains))
plt.plot(x,gains)
# plt.ylim(0,50)
plt.show()

# %%
xcut = int(len(gains)/10)
x = np.linspace(xdev1,xdev2,len(gains))
# plt.semilogy(x[xcut:-xcut],gains[xcut:-xcut])
plt.plot(x[xcut:-xcut],gains[xcut:-xcut])
plt.show()

# %%
# Ray trace solution
t0 = stopwatch()
x,n,I0,I1,gr,grres = rs.ray_trace(lpse,points=251,return_all=True,\
                                  noise=False,gpf='gp2.pickle')
t1 = stopwatch()
print(f'Time taken: {t1-t0} s')

# %%
xn = np.linspace(x[0],x[-1],100)
# plt.semilogy(x,I0,label='laser')
# plt.semilogy(x,I1,label='raman')
plt.plot(x*1e6,-I1,label='raman')
plt.xlabel(r'Position [$\mu m$]')
plt.ylabel(r'Intensity [$W/cm^2$]')
plt.legend()
plt.show()
print(I1[0],I1[0]/I1[-1])
            xbuff = i.laser.evolution.Labc + i.laser.evolution.Loff
        elif isinstance(i, wf.temporal_control):
            touts = int(tavg / i.simulation.samplePeriod)

    # Get central densities of density range splits
    xmin = xbuff - split
    xmax = split - xbuff
    dx = abs(xmin - xmax)
    xsep = dx / splits
    xcens = np.array([j * xsep + xmin + 0.5 * xsep for j in range(splits)])
    Ln = dx / np.log(nmax / nmin)
    ncens = nmax * np.exp(-abs(xcens - xmax) / Ln)

    # Run sim for each envelope density and sum Isrs
    isrstot = 0
    t0 = stopwatch()
    for j in range(splits):
        t2 = stopwatch()
        case.plasmaFrequencyDensity = ncens[j]
        freqs = ci.bsrs_lw_envelope(case, cpw, verbose)
        ci.spectral_dt(case, freqs, dt_frac=0.99, verbose=verbose)

        # Write lpse.parms and run case
        case.write()
        case.run()

        # Extract data
        case.fields(fname=fname)

        # Calculate <I_srs> and return
        xdat = case.fdat[ky]['x']