def cet_plasma(cet_param): bubble_r = 2 * np.sqrt(cet_param.a0) / cet_param.kp return Plasma( n_pe=cet_param.npe, laser=Laser.from_a0(a0=cet_param.a0, ɛL=cet_param.ɛL, beam=GaussianBeam(w0=cet_param.w0)), bubble_radius=bubble_r, )
def test_plasma_with_laser(cet_plasma, cet_param): """Check Plasma class when given a Laser.""" # test constructor with no bubble_radius and given propagation_distance _ = Plasma( n_pe=cet_param.npe, laser=cet_plasma.laser, propagation_distance=13.56555928 * u.mm, ) assert_allclose_units(cet_plasma.Pc, 19.7422087 * u.terawatt) assert_allclose_units(cet_plasma.depletion, 13.92603593 * u.mm) assert_allclose_units(cet_plasma.dephasing, 13.56555928 * u.mm)
def test_simulation(cet_plasma, cet_param): """Check Simulation class.""" with pytest.raises(TypeError): _ = Simulation( Plasma(n_pe=cet_param.npe, propagation_distance=13.56555928 * u.mm) ) sim = Simulation(cet_plasma) assert_allclose_units(sim.L, 109.04942675 * u.micrometer) assert_allclose_units(sim.Δx, 0.43389388 * u.micrometer) assert_allclose_units(sim.Δz, 0.04 * u.micrometer) assert_allclose_units(sim.nx, 251 * u.dimensionless) assert_allclose_units(sim.nz, 2726 * u.dimensionless) assert_allclose_units(sim.npart, 1373925808 * u.dimensionless) assert_allclose_units(sim.nstep, 341865 * u.dimensionless) sim2 = Simulation(cet_plasma, box_length=4 * cet_plasma.λp, ppc=8) assert sim2 == sim
STYLE = defaultdict(lambda: next(loop_cy_iter)) fig = Figure(figsize=(6.4, 6.4)) canvas = FigureCanvas(fig) ax = fig.add_subplot(111) beam = GaussianBeam(w0=15.0 * u.micrometer, λL=0.8 * u.micrometer) electron_densities = np.logspace(-2, 2, 20) * 1e18 / (u.cm**3) for a0 in np.linspace(2.0, 8.0, 7) * u.dimensionless: laser = Laser.from_a0(a0=a0, τL=30.0 * u.femtosecond, beam=beam) x_data = [] y_data = [] for npe in electron_densities: plasma = Plasma(n_pe=npe, laser=laser) x_data.append(plasma.npe) y_data.append(plasma.ΔE) h_axis = u.unyt_array(x_data) v_axis = u.unyt_array(y_data) a0_val = a0.to_value("dimensionless") ax.plot( h_axis.value, v_axis.value, color=STYLE[str(a0_val)]["color"], linestyle=STYLE[str(a0_val)]["linestyle"], label=f"$a_0$={a0_val}", )
ax.set_ylim(ymin=0, ymax=ne * 1.618) ax.set_xlim(xmin=-500) fig = plt.gcf() fig.set_size_inches(fig_width, fig_width * 0.40) plt.tight_layout() fig.savefig("density.eps", dpi=100, bbox_inches="tight") # Estimate laser-plasma parameters param = E4Params( npe=ne / u.cm**3, w0=18.7 * u.micrometer, ɛL=1.8 * u.joule, τL=25 * u.femtosecond, prop_dist=flat_top_dist * u.micrometer, ) e4_beam = GaussianBeam(w0=param.w0) e4_laser = Laser(ɛL=param.ɛL, τL=param.τL, beam=e4_beam) e4_plasma = Plasma(n_pe=param.npe, laser=e4_laser, propagation_distance=param.prop_dist) sim_e4 = Simulation(e4_plasma, box_length=97 * u.micrometer, ppc=2) print(e4_beam) print(e4_laser) print(f"critical density for this laser is {e4_laser.ncrit:.1e}") print(e4_plasma) print(sim_e4)
def test_radiator_without_laser(cet_param): """Check Radiator class constructor without passing a Laser.""" plasma = Plasma(n_pe=cet_param.npe, bubble_radius=cet_param.w0) with pytest.raises(TypeError): _ = Radiator(plasma)
ɛL=1.2 * u.joule, τL=28.0 * u.femtosecond, prop_dist=5.0 * u.mm, f_dist=1.0 * u.meter, diam=100 * u.mm, ) beam = GaussianBeam.from_focal_distance(focal_distance=param.f_dist, beam_diameter=param.diam) print(( f"The diffraction-limited beam waist for an OAP with focal lenght of {param.f_dist:.1f} " f"and a laser beam diameter of {param.diam:.1f} is w0={beam.w0:.1f} at 1/e^2 intensity.\n" )) laser = Laser(ɛL=param.ɛL, τL=param.τL, beam=GaussianBeam(w0=param.w0)) plasma = Plasma( n_pe=param.npe, laser=laser, bubble_radius=param.w0, propagation_distance=param.prop_dist, ) print( (f"For a plasma with a density of {plasma.npe:.1e} we get an " f"electron energy gain of {plasma.ΔE:.1f} and a total accelerated charge " f"of {plasma.Q:.1f} over an acceleration distance of {plasma.Lacc:.1f}.")) print("\nFurther details: ") print(f"{plasma}")