Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic update picmi to 0.0.22 #4364

Merged
38 changes: 25 additions & 13 deletions lib/python/picongpu/picmi/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,35 @@ def get_as_pypicongpu(self):
"periodic": grid.BoundaryCondition.PERIODIC,
}

assert self.bc_xmin in picongpu_boundary_condition_by_picmi_id, \
assert self.lower_boundary_conditions[0] in \
picongpu_boundary_condition_by_picmi_id, \
"X: boundary condition not supported"
assert self.bc_ymin in picongpu_boundary_condition_by_picmi_id, \
assert self.lower_boundary_conditions[1] in \
picongpu_boundary_condition_by_picmi_id, \
"Y: boundary condition not supported"
assert self.bc_zmin in picongpu_boundary_condition_by_picmi_id, \
assert self.lower_boundary_conditions[2] in \
picongpu_boundary_condition_by_picmi_id, \
PrometheusPi marked this conversation as resolved.
Show resolved Hide resolved
"Z: boundary condition not supported"

g = grid.Grid3D()
g.cell_size_x_si = (self.xmax - self.xmin) / self.nx
g.cell_size_y_si = (self.ymax - self.ymin) / self.ny
g.cell_size_z_si = (self.zmax - self.zmin) / self.nz
g.cell_cnt_x = self.nx
g.cell_cnt_y = self.ny
g.cell_cnt_z = self.nz
g.cell_size_x_si = (self.upper_bound[0] - self.lower_bound[0]) \
/ self.number_of_cells[0]
g.cell_size_y_si = (self.upper_bound[1] - self.lower_bound[1]) \
/ self.number_of_cells[1]
g.cell_size_z_si = (self.upper_bound[2] - self.lower_bound[2]) \
/ self.number_of_cells[2]
g.cell_cnt_x = self.number_of_cells[0]
g.cell_cnt_y = self.number_of_cells[1]
g.cell_cnt_z = self.number_of_cells[2]
g.boundary_condition_x = \
picongpu_boundary_condition_by_picmi_id[self.bc_xmin]
picongpu_boundary_condition_by_picmi_id[
self.lower_boundary_conditions[0]]
g.boundary_condition_y = \
picongpu_boundary_condition_by_picmi_id[self.bc_ymin]
picongpu_boundary_condition_by_picmi_id[
self.lower_boundary_conditions[1]]
g.boundary_condition_z = \
picongpu_boundary_condition_by_picmi_id[self.bc_zmin]
picongpu_boundary_condition_by_picmi_id[
self.lower_boundary_conditions[2]]

# gpu distribution
# convert input to 3 integer list
Expand All @@ -100,7 +109,10 @@ def get_as_pypicongpu(self):
# check if gpu distribution fits grid
# TODO: super_cell_size still hard coded
super_cell_size = [8, 8, 4]
cells = [self.nx, self.ny, self.nz]
cells = [
self.number_of_cells[0],
self.number_of_cells[1],
self.number_of_cells[2]]
dim_name = ["x", "y", "z"]
for dim in range(3):
assert (((cells[dim] // g.n_gpus[dim]) // super_cell_size[dim])
Expand Down
15 changes: 9 additions & 6 deletions lib/python/picongpu/picmi/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ def __yee_compute_cfl_or_delta_t(self) -> None:
assert "Yee" == self.solver.method
assert isinstance(self.solver.grid, Cartesian3DGrid)

delta_x = (self.solver.grid.xmax - self.solver.grid.xmin) \
/ self.solver.grid.nx
delta_y = (self.solver.grid.ymax - self.solver.grid.ymin) \
/ self.solver.grid.ny
delta_z = (self.solver.grid.zmax - self.solver.grid.zmin) \
/ self.solver.grid.nz
delta_x = ((self.solver.grid.upper_bound[0]
- self.solver.grid.lower_bound[0])
/ self.solver.grid.number_of_cells[0])
delta_y = ((self.solver.grid.upper_bound[1]
- self.solver.grid.lower_bound[1])
/ self.solver.grid.number_of_cells[1])
delta_z = ((self.solver.grid.upper_bound[2]
- self.solver.grid.lower_bound[2])
/ self.solver.grid.number_of_cells[2])

if self.time_step_size is not None and \
self.solver.cfl is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def get_generic_profile_rendering_context(self) -> dict:
retrieve a context valid for "any profile"

Problem: Every profile has its respective schema, and it is difficult
in JSON (particularly in a mustache-compatible way) the type of the
schema.
in JSON (particularly in a mustache-compatible way) to get the type
of the schema.

Solution: The normal rendering of profiles get_rendering_context()
provides **only their parameters**, i.e. there is **no meta
Expand Down
4 changes: 2 additions & 2 deletions lib/python/picongpu/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
typeguard >= 2.12
sympy >= 1.9
chevron >= 0.13.1
jsonschema >= 4.4.0
jsonschema >= 4.17.3
scipy >= 1.7.1
picmistandard >= 0.0.18
picmistandard >= 0.0.22

-r extra/requirements.txt
12 changes: 2 additions & 10 deletions test/python/picongpu/compiling/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,8 @@ def test_uniform(self):
uniform_dist = picmi.UniformDistribution(density=8e24)
self._compile_distribution(uniform_dist)

def test_analytic(self):
analytic_dist = picmi.AnalyticDistribution(
density_expression="a * sin(x) + z - sqrt(y)",
a=42)
self._compile_distribution(analytic_dist)

def test_gaussian_bunch(self):
gaussian_dist = picmi.GaussianBunchDistribution(
1283, 0.3e-7, centroid_position=[-1321, -4e-3, 0])
self._compile_distribution(gaussian_dist)
# tests for analytic distribution and gaussian-bunch distribution have been
# removed for now, see issue #4367 for the test cases

def test_temperature(self):
uniform_dist = picmi.UniformDistribution(
Expand Down
3 changes: 2 additions & 1 deletion test/python/picongpu/compiling/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ def test_minimal(self):
sim = pypicongpu.Simulation()
sim.delta_t_si = 1.39e-16
sim.time_steps = 1
sim.grid = pypicongpu.Grid3D()
sim.grid = pypicongpu.grid.Grid3D()
sim.grid.cell_size_x_si = 1.776e-07
sim.grid.cell_size_y_si = 4.43e-08
sim.grid.cell_size_z_si = 1.776e-07
sim.grid.cell_cnt_x = 1
sim.grid.cell_cnt_y = 1
sim.grid.cell_cnt_z = 1
sim.grid.n_gpus = (1, 1, 1)
sim.grid.boundary_condition_x = \
pypicongpu.grid.BoundaryCondition.PERIODIC
sim.grid.boundary_condition_y = \
Expand Down
1 change: 1 addition & 0 deletions test/python/picongpu/compiling/species.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def setUp(self):
laser = picmi.GaussianLaser(0.8e-6, 5.0e-6 / 1.17741, 5.0e-15,
a0=8,
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
centroid_position=[
0.5*grid.upper_bound[0],
0,
Expand Down
21 changes: 20 additions & 1 deletion test/python/picongpu/quick/picmi/gaussian_laser.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_values_focal_pos(self):
focal_position=[0, 7, .5],
centroid_position=[.5, 0, .5],
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
E0=1)
with self.assertRaisesRegex(Exception, ".*foc(us|al).*[xX].*"):
picmi_laser.get_as_pypicongpu()
Expand All @@ -65,6 +66,7 @@ def test_values_focal_pos(self):
focal_position=[.5, 2, 500],
centroid_position=[.5, 0, .5],
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
E0=1)
with self.assertRaisesRegex(Exception, ".*foc(us|al).*[zZ].*"):
picmi_laser.get_as_pypicongpu()
Expand All @@ -75,6 +77,7 @@ def test_values_focal_pos(self):
focal_position=[.5, -5, .5],
centroid_position=[.5, 0, .5],
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
E0=1)
self.assertEqual(-5, picmi_laser.get_as_pypicongpu().focus_pos)

Expand All @@ -83,6 +86,7 @@ def test_values_focal_pos(self):
focal_position=[.5, 0, .5],
centroid_position=[.5, 0, .5],
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
E0=1)
self.assertEqual(0, picmi_laser.get_as_pypicongpu().focus_pos)

Expand All @@ -103,6 +107,7 @@ def test_values_propagation_direction(self):
focal_position=[.5, 0, .5],
centroid_position=[.5, 0, .5],
propagation_direction=invalid_propagation_vector,
polarization_direction=[1, 0, 0],
E0=1)
with self.assertRaisesRegex(Exception, ".*propagation.*"):
picmi_laser.get_as_pypicongpu()
Expand All @@ -113,6 +118,7 @@ def test_values_propagation_direction(self):
focal_position=[.5, 0, .5],
centroid_position=[.5, 0, .5],
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
E0=1)

def test_values_polarization(self):
Expand All @@ -127,6 +133,8 @@ def test_values_polarization(self):
for invalid_polarization in invalid_polarizations:
picmi_laser = picmi.GaussianLaser(
1, 2, 3,
focal_position=[0, 0, 0],
centroid_position=[0, 0, 0],
propagation_direction=[0, 1, 0],
polarization_direction=invalid_polarization,
E0=1)
Expand All @@ -136,6 +144,8 @@ def test_values_polarization(self):
# valid examples:
picmi_laser = picmi.GaussianLaser(
1, 2, 3,
focal_position=[0, 0, 0],
centroid_position=[0, 0, 0],
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
E0=1)
Expand All @@ -146,6 +156,8 @@ def test_values_polarization(self):

picmi_laser = picmi.GaussianLaser(
1, 2, 3,
focal_position=[0, 0, 0],
centroid_position=[0, 0, 0],
propagation_direction=[0, 1, 0],
polarization_direction=[0, 0, 1],
E0=1)
Expand All @@ -158,7 +170,10 @@ def test_minimal(self):
"""mimimal possible initialization"""
# does not throw, normal usage process works
picmi_laser = picmi.GaussianLaser(1, 2, 3,
focal_position=[0, 0, 0],
centroid_position=[0, 0, 0],
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
E0=1)
pypic_laser = picmi_laser.get_as_pypicongpu()
self.assertNotEqual({}, pypic_laser.get_rendering_context())
Expand All @@ -171,6 +186,7 @@ def test_values_centroid_position_y_is_zero(self):
centroid_position=[1, 1, 1],
focal_position=[1, 1, 1],
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
E0=1).get_as_pypicongpu()

# valid example:
Expand All @@ -180,6 +196,7 @@ def test_values_centroid_position_y_is_zero(self):
centroid_position=[12, 0, 7],
focal_position=[12, 0, 7],
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
E0=1)
.get_as_pypicongpu().get_rendering_context())

Expand Down Expand Up @@ -213,7 +230,8 @@ def test_laguerre_modes_optional(self):
focal_position=[0, 0, 0],
centroid_position=[0, 0, 0],
E0=5,
propagation_direction=[0, 1, 0])
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0])
pypic_laser = picmi_laser.get_as_pypicongpu()
self.assertEqual([1.0], pypic_laser.laguerre_modes)
self.assertEqual([0.0], pypic_laser.laguerre_phases)
Expand All @@ -227,6 +245,7 @@ def test_laguerre_modes_optional(self):
centroid_position=[0, 0, 0],
E0=5,
propagation_direction=[0, 1, 0],
polarization_direction=[1, 0, 0],
picongpu_laguerre_modes=None,
picongpu_laguerre_phases=None)
pypic_laser = picmi_laser.get_as_pypicongpu()
Expand Down