コード例 #1
0
    tdeb = MPI.Wtime()

em.step(N_step)

tend = MPI.Wtime()
if (me == 0):
    print("Final runtime (s): " + str(tend - tdeb))

# ------------------------------------------------------------------------------
# Test Diagnostics
# ------------------------------------------------------------------------------

print("=== Test waist, ctau and a0 ===")

# Load the diags OpenPMD
ts = LpaDiagnostics('./diags/hdf5/')

# Values of waist, ctau and a0 set in the script
laser_waist_simu = ts.get_laser_waist(iteration=ts.iterations[0], pol='x')
ctau_simu = ts.get_ctau(iteration=ts.iterations[0], pol='x')
a0_simu = ts.get_a0(iteration=ts.iterations[0], pol='x')

# Compare the values and crash the code if not equal

assert np.isclose(laser_waist, laser_waist_simu, 5.e-2), "waist error. "
print("waist checked. ")
assert np.isclose(ctau, ctau_simu, 5.e-2), "ctau error. "
print("ctau checked. ")
assert np.isclose(a0, a0_simu, 5.e-2), "a0 error. "
print("a0 checked. ")
    plt.savefig('%sEzLineout_%09i2.png' % (Path + '/EzLineout/', iter),
                bbox_inches='tight')
    plt.close()

    rho, info_rho = ts_particles.get_field(iteration=iter,
                                           field='rho',
                                           plot=True,
                                           **particles)
    plt.savefig('%s/rho_%09i.png' % (Path + '/rho', iter), bbox_inches='tight')
    plt.close()

    a0 = ts_laser.get_a0(iteration=iter, pol='x')
    #print(a0)
    a0PerSnapshot.append(a0)

    waist = ts_laser.get_laser_waist(iteration=iter, pol='x')
    #print(waist)
    PulsewaistPerSnapshot.append(waist)

    length = ts_laser.get_ctau(iteration=iter, pol='x')
    #print(length)
    PulselengthPerSnapshot.append(length)

    ts_particles.get_particle(['z', 'uz'], species='electrons', iteration=iter)
    z_selected, uz_selected = ts_particles.get_particle(
        ['z', 'uz'],
        species='electrons',
        iteration=iter,
        select={'uz': [1, None]})
    plt.plot(z_selected, uz_selected, 'b.', markersize=0.1)
    plt.savefig('%s/uz_%09i.png' % (Path + '/uz', iter), bbox_inches='tight')