aboutsummaryrefslogtreecommitdiff
path: root/Examples/Tests/ParticleDataPython
diff options
context:
space:
mode:
authorGravatar Edoardo Zoni <59625522+EZoni@users.noreply.github.com> 2022-12-02 20:20:17 -0800
committerGravatar GitHub <noreply@github.com> 2022-12-02 20:20:17 -0800
commit2857ca08a97b3a8f82d902480816acac0b9614d6 (patch)
tree5999a62464445e491eeb81a96444f48c0fa41125 /Examples/Tests/ParticleDataPython
parent3b6a467d1b7dd79ce90b02048dd1c6a0db7b138d (diff)
downloadWarpX-2857ca08a97b3a8f82d902480816acac0b9614d6.tar.gz
WarpX-2857ca08a97b3a8f82d902480816acac0b9614d6.tar.zst
WarpX-2857ca08a97b3a8f82d902480816acac0b9614d6.zip
Clean up examples folders (#3545)
* Clean up examples folders * Use `snake_case` names * Rename `nci_corrector` as `nci_fdtd_stability`
Diffstat (limited to 'Examples/Tests/ParticleDataPython')
-rwxr-xr-xExamples/Tests/ParticleDataPython/PICMI_inputs_2d.py160
-rwxr-xr-xExamples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py126
-rwxr-xr-xExamples/Tests/ParticleDataPython/analysis.py14
3 files changed, 0 insertions, 300 deletions
diff --git a/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py b/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py
deleted file mode 100755
index c93b84f1f..000000000
--- a/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env python3
-import argparse
-import sys
-
-import numpy as np
-
-from pywarpx import callbacks, picmi
-
-# Create the parser and add the argument
-parser = argparse.ArgumentParser()
-parser.add_argument(
- '-u', '--unique', action='store_true',
- help="Whether injected particles should be treated as unique"
-)
-
-# Parse the input
-args, left = parser.parse_known_args()
-sys.argv = sys.argv[:1] + left
-
-##########################
-# numerics parameters
-##########################
-
-dt = 7.5e-10
-
-# --- Nb time steps
-
-max_steps = 10
-
-# --- grid
-
-nx = 64
-ny = 64
-
-xmin = 0
-xmax = 0.03
-ymin = 0
-ymax = 0.03
-
-##########################
-# numerics components
-##########################
-
-grid = picmi.Cartesian2DGrid(
- number_of_cells = [nx, ny],
- lower_bound = [xmin, ymin],
- upper_bound = [xmax, ymax],
- lower_boundary_conditions = ['dirichlet', 'periodic'],
- upper_boundary_conditions = ['dirichlet', 'periodic'],
- lower_boundary_conditions_particles = ['absorbing', 'periodic'],
- upper_boundary_conditions_particles = ['absorbing', 'periodic'],
- moving_window_velocity = None,
- warpx_max_grid_size = 32
-)
-
-solver = picmi.ElectrostaticSolver(
- grid=grid, method='Multigrid', required_precision=1e-6,
- warpx_self_fields_verbosity=0
-)
-
-##########################
-# physics components
-##########################
-
-electrons = picmi.Species(
- particle_type='electron', name='electrons'
-)
-
-##########################
-# diagnostics
-##########################
-
-field_diag = picmi.FieldDiagnostic(
- name = 'diag1',
- grid = grid,
- period = 10,
- data_list = ['phi'],
- write_dir = '.',
- warpx_file_prefix = f"Python_particle_attr_access_{'unique_' if args.unique else ''}plt"
-)
-
-##########################
-# simulation setup
-##########################
-
-sim = picmi.Simulation(
- solver = solver,
- time_step_size = dt,
- max_steps = max_steps,
- verbose = 1
-)
-
-sim.add_species(
- electrons,
- layout = picmi.GriddedLayout(
- n_macroparticle_per_cell=[0, 0], grid=grid
- )
-)
-sim.add_diagnostic(field_diag)
-
-sim.initialize_inputs()
-sim.initialize_warpx()
-
-##########################
-# python particle data access
-##########################
-
-# set numpy random seed so that the particle properties generated
-# below will be reproducible from run to run
-np.random.seed(30025025)
-
-sim.extension.add_real_comp('electrons', 'newPid')
-
-my_id = sim.extension.getMyProc()
-
-def add_particles():
-
- nps = 10 * (my_id + 1)
- x = np.linspace(0.005, 0.025, nps)
- y = np.zeros(nps)
- z = np.linspace(0.005, 0.025, nps)
- ux = np.random.normal(loc=0, scale=1e3, size=nps)
- uy = np.random.normal(loc=0, scale=1e3, size=nps)
- uz = np.random.normal(loc=0, scale=1e3, size=nps)
- w = np.ones(nps) * 2.0
- newPid = 5.0
-
- sim.extension.add_particles(
- species_name='electrons', x=x, y=y, z=z, ux=ux, uy=uy, uz=uz,
- w=w, newPid=newPid, unique_particles=args.unique
- )
-
-callbacks.installbeforestep(add_particles)
-
-##########################
-# simulation run
-##########################
-
-sim.step(max_steps - 1)
-
-##########################
-# check that the new PIDs
-# are properly set
-##########################
-
-assert (sim.extension.get_particle_count('electrons') == 270 / (2 - args.unique))
-assert (sim.extension.get_particle_comp_index('electrons', 'w') == 0)
-assert (sim.extension.get_particle_comp_index('electrons', 'newPid') == 4)
-
-new_pid_vals = sim.extension.get_particle_arrays(
- 'electrons', 'newPid', 0
-)
-for vals in new_pid_vals:
- assert np.allclose(vals, 5)
-
-##########################
-# take the final sim step
-##########################
-
-sim.step(1)
diff --git a/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py b/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py
deleted file mode 100755
index 0e988f0fe..000000000
--- a/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py
+++ /dev/null
@@ -1,126 +0,0 @@
-#!/usr/bin/env python3
-#
-# --- Input file to test the saving of old particle positions
-
-import numpy as np
-
-from pywarpx import picmi
-
-constants = picmi.constants
-
-##########################
-# numerics parameters
-##########################
-
-dt = 7.5e-10
-
-# --- Nb time steps
-
-max_steps = 10
-
-# --- grid
-
-nx = 64
-nz = 64
-
-xmin = 0
-xmax = 0.03
-zmin = 0
-zmax = 0.03
-
-
-##########################
-# numerics components
-##########################
-
-grid = picmi.Cartesian2DGrid(
- number_of_cells = [nx, nz],
- lower_bound = [xmin, zmin],
- upper_bound = [xmax, zmax],
- lower_boundary_conditions = ['dirichlet', 'periodic'],
- upper_boundary_conditions = ['dirichlet', 'periodic'],
- lower_boundary_conditions_particles = ['absorbing', 'periodic'],
- upper_boundary_conditions_particles = ['absorbing', 'periodic'],
- moving_window_velocity = None,
- warpx_max_grid_size = 32
-)
-
-solver = picmi.ElectrostaticSolver(
- grid=grid, method='Multigrid', required_precision=1e-6,
- warpx_self_fields_verbosity=0
-)
-
-##########################
-# physics components
-##########################
-
-uniform_plasma_elec = picmi.UniformDistribution(
- density = 1e15,
- upper_bound = [None] * 3,
- rms_velocity = [np.sqrt(constants.kb * 1e3 / constants.m_e)] * 3,
- directed_velocity = [0.] * 3
-)
-
-electrons = picmi.Species(
- particle_type='electron', name='electrons',
- initial_distribution=uniform_plasma_elec,
- warpx_save_previous_position=True
-)
-
-##########################
-# diagnostics
-##########################
-
-field_diag = picmi.ParticleDiagnostic(
- species=electrons,
- name = 'diag1',
- data_list=['previous_positions'],
- period = 10,
- write_dir = '.',
- warpx_file_prefix = 'Python_prev_positions_plt'
-)
-
-##########################
-# simulation setup
-##########################
-
-sim = picmi.Simulation(
- solver = solver,
- time_step_size = dt,
- max_steps = max_steps,
- verbose = 1
-)
-
-sim.add_species(
- electrons,
- layout = picmi.GriddedLayout(
- n_macroparticle_per_cell=[1, 1], grid=grid
- )
-)
-sim.add_diagnostic(field_diag)
-
-##########################
-# simulation run
-##########################
-
-sim.step(max_steps - 1)
-
-##########################
-# check that the new PIDs
-# exist
-##########################
-
-assert (sim.extension.get_particle_comp_index('electrons', 'prev_x') > 0)
-assert (sim.extension.get_particle_comp_index('electrons', 'prev_z') > 0)
-
-prev_z_vals = sim.extension.get_particle_arrays(
- 'electrons', 'prev_z', 0
-)
-for z_vals in prev_z_vals:
- assert np.all(z_vals < zmax)
-
-##########################
-# take the final sim step
-##########################
-
-sim.step(1)
diff --git a/Examples/Tests/ParticleDataPython/analysis.py b/Examples/Tests/ParticleDataPython/analysis.py
deleted file mode 100755
index 0b0cce329..000000000
--- a/Examples/Tests/ParticleDataPython/analysis.py
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env python3
-
-# Copyright 2021 Modern Electron
-#
-# License: BSD-3-Clause-LBNL
-
-# This script just checks that the PICMI file executed successfully.
-# If it did there will be a plotfile for the final step.
-
-import sys
-
-step = int(sys.argv[1][-5:])
-
-assert step == 10