예제 #1
0
def plotCrossSection(paths):
    # Plot the expected and observed counts
    energies = np.array([])
    emits = np.array([])
    for path in paths:
        fn = glob.glob(path + "/xySlice/hdf5/*.h5")[-1]
        step = convertunits(readparticles(fn)['H2+'])
        energies = np.hstack((energies, 1e3*float(fn.split("keV")[0])))
        emits = np.hstack((emits, step.shape[0]))

    sigma = h2crosssections.h2_ioniz_crosssection
    I = h2crosssections.I
    bohr_radius = h2crosssections.bohr_radius
    ibeam = 0.1e-3  # in A
    sw = 100
    erate = ibeam/echarge  # 1/s
    beamarea = pi*(0.01)**2  # m^2

    target_pressure = 1  # Pa
    target_temp = 273  # K
    target_density = target_pressure / boltzmann / target_temp  # in 1/m^3
    target_length = 0.01875  # in m
    domain_length = 0.2  # in m

    N_gas = target_density * target_length * beamarea

    dist_to_target = 0.090625  # in m

    gammas = 1 + energies/511e3
    betas = np.sqrt(1-1/gammas**2)

    L = N_gas * erate / beamarea
    dT = 100e-9  # simulation time, in s
    dTioniz = dT - dist_to_target/(betas*clight)  # in s, adjusted for time spent traveling to target region

    fig = plt.figure(figsize=(12, 8))
    ax = plt.gca()

    try:
        # Try to plot alongside data from Rapp and Englander-Golden, http://dx.doi.org/10.1063/1.1696957
        h2_expdata = np.genfromtxt('rapp_data.csv', delimiter=' ', skiprows=1)
        plt.plot(h2_expdata[:, 0] - I, h2_expdata[:, 1], 'ko', label="Rapp and Englander-Golden", fillstyle='none', mew=1)
    except:
        pass

    plt.plot(energies - I, emits * sw / (L*dTioniz) / (np.pi*bohr_radius**2), 'k^', label="Warp simulation (100 ns)")

    contenergies = I + np.logspace(0, 5, num=50)
    contgammas = 1 + contenergies/511e3
    contbetas = np.sqrt(1-1/contgammas**2)
    plt.plot(contenergies - I, sigma(contbetas*clight) / (np.pi*bohr_radius**2), label="Rudd et al.")

    plt.xlim([0.1, 1e6])
    plt.xscale('log')
    plt.yscale('log')
    plt.xlabel("T - I (eV)")
    plt.legend(fontsize=12)
    plt.title("$H_2^+$ ionization cross-section ($\pi a_0^2$)", y=1.03)
    return fig
예제 #2
0
파일: warpvnd.py 프로젝트: cchall/sirepo
def _extract_current(data, data_file):
    grid = data['models']['simulationGrid']
    plate_spacing = _meters(grid['plate_spacing'])
    dz = plate_spacing / grid['num_z']
    zmesh = np.linspace(0, plate_spacing, grid['num_z'] + 1) #holds the z-axis grid points in an array
    report_data = readparticles(data_file.filename)
    data_time = report_data['time']
    with h5py.File(data_file.filename, 'r') as f:
        weights = np.array(f['data/{}/particles/beam/weighting'.format(data_file.iteration)])
    curr = get_zcurrent_new(report_data['beam'][:,4], report_data['beam'][:,5], zmesh, weights, dz)
    return _extract_current_results(data, curr, data_time)
예제 #3
0
파일: warpvnd.py 프로젝트: e-carlin/sirepo
def _extract_current(data, data_file):
    grid = data['models']['simulationGrid']
    plate_spacing = _meters(grid['plate_spacing'])
    dz = plate_spacing / grid['num_z']
    zmesh = np.linspace(0, plate_spacing, grid['num_z'] + 1) #holds the z-axis grid points in an array
    report_data = readparticles(data_file.filename)
    data_time = report_data['time']
    with h5py.File(data_file.filename, 'r') as f:
        weights = np.array(f['data/{}/particles/beam/weighting'.format(data_file.iteration)])
    curr = get_zcurrent_new(report_data['beam'][:,4], report_data['beam'][:,5], zmesh, weights, dz)
    return _extract_current_results(data, curr, data_time)
    Ex = data_efield['data/%s/meshes/E/x' % (step_number)]
    Ey = data_efield['data/%s/meshes/E/y' % (step_number)]
    Ez = data_efield['data/%s/meshes/E/z' % (step_number)]

    phi = data_efield['data/%s/meshes/phi' % (step_number)]

    particles_path = diagDir
    particles_files = [
        os.path.join(particles_path, fn) for fn in os.listdir(particles_path)
    ]
    particles_files.sort()

    particledata_file = particles_files[-1]

    # Read single particle diagnostic file in
    f0 = readparticles(particledata_file.format(num_steps))
    # Read all particles into directory. Structure: name[int stepnumber][str Species name]
    fall = loadparticlefiles(particles_path)

    def get_zcurrent_new(particle_array, momenta, mesh, particle_weight, dz):
        """
        Find z-directed current on a per cell basis
        particle_array: z positions at a given step
        momenta: particle momenta at a given step in SI units
        mesh: Array of Mesh spacings
        particle_weight: Weight from Warp
        dz: Cell Size
        """

        charge = 1.60217662e-19
        mass = 9.10938356e-31
    data_efield = h5py.File(fielddata_file, 'r')

    Ex = data_efield['data/%s/meshes/E/x' % (step_number)]
    Ey = data_efield['data/%s/meshes/E/y' % (step_number)]
    Ez = data_efield['data/%s/meshes/E/z' % (step_number)]

    phi = data_efield['data/%s/meshes/phi'% (step_number)]

    particles_path = diagDir
    particles_files = [os.path.join(particles_path,fn) for fn in os.listdir(particles_path)]
    particles_files.sort()

    particledata_file = particles_files[-1]

    # Read single particle diagnostic file in
    f0 = readparticles(particledata_file.format(num_steps))
    # Read all particles into directory. Structure: name[int stepnumber][str Species name]
    fall = loadparticlefiles(particles_path)


    def get_zcurrent_new(particle_array, momenta, mesh, particle_weight, dz):
        """
        Find z-directed current on a per cell basis
        particle_array: z positions at a given step
        momenta: particle momenta at a given step in SI units
        mesh: Array of Mesh spacings
        particle_weight: Weight from Warp
        dz: Cell Size
        """    

        charge = 1.60217662e-19