Пример #1
0
def get_a0(res_dir, snapshot):
    header = res_dir + '/Header'
    print(snapshot)
    allrd, info = read_raw_data.read_lab_snapshot(snapshot, header)
    F = allrd[fieldname]
    return info['z'][-1], np.max(
        np.abs(F)) * scc.e / (scc.m_e * omega0 * scc.c)
the theory (with a 5% error allowed).

The simulation runs in a boosted frame, and the analysis is done in the lab
frame, i.e., on the back-transformed diagnostics.
'''

import numpy as np
import read_raw_data
import yt

yt.funcs.mylog.setLevel(0)

# Read data from back-transformed diagnostics
snapshot = './lab_frame_data/snapshots/snapshot00001'
header = './lab_frame_data/snapshots/Header'
allrd, info = read_raw_data.read_lab_snapshot(snapshot, header)
z = np.mean(read_raw_data.get_particle_field(snapshot, 'beam', 'z'))
w = np.std(read_raw_data.get_particle_field(snapshot, 'beam', 'x'))

# initial parameters
z0 = 20.e-6
w0 = 1.e-6
theta0 = np.arcsin(0.1)

# Theoretical beam width after propagation if rigid ON
wth = np.sqrt(w0**2 + (z - z0)**2 * theta0**2)
error_rel = np.abs((w - wth) / wth)
tolerance_rel = 0.03

# Print error and assert small error
print("Beam position: " + str(z))
'''
Analysis script of a WarpX simulation in a boosted frame.

The simulation runs in a boosted frame, and the analysis is done in the lab
frame, i.e., on the back-transformed diagnostics for the full 3D simulation and
an x-z slice at y=y_center. The field-data, Ez, along z, at (x_center,y_center,:) is compared
between the full back-transformed diagnostic and the reduced diagnostic (i.e., x-z slice) .
'''

import numpy as np
import read_raw_data

# Read data from back-transformed diagnostics of entire domain
snapshot = './lab_frame_data/snapshots/snapshot00002'
header = './lab_frame_data/snapshots/Header'
allrd, info = read_raw_data.read_lab_snapshot(snapshot, header)
F = allrd['Ez']
print("F.shape ", F.shape)
F_1D = np.squeeze(F[F.shape[0] // 2, F.shape[1] // 2, :])

# Read data from reduced back-transformed diagnostics (i.e. slice)
snapshot_slice = './lab_frame_data/slices/slice00002'
header_slice = './lab_frame_data/slices/Header'
allrd, info = read_raw_data.read_lab_snapshot(snapshot_slice, header_slice)
Fs = allrd['Ez']
print("Fs.shape", Fs.shape)
Fs_1D = np.squeeze(Fs[Fs.shape[0] // 2, 1, :])

error_rel = np.max(np.abs(Fs_1D - F_1D)) / np.max(np.abs(F_1D))
tolerance_rel = 1E-15