Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PyPIC3D/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .distributed import initialize_distributed
from .utilities.distributed import initialize_distributed

initialize_distributed()

Expand Down
301 changes: 35 additions & 266 deletions PyPIC3D/__main__.py

Large diffs are not rendered by default.

18 changes: 3 additions & 15 deletions PyPIC3D/boundary_conditions/supergaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,6 @@ def load_supergaussian_from_toml(raw_supergaussian, dynamic_parameters):
return bool(layers), sg_x, sg_y, sg_z, tuple(layers)


def _shape_from_static_parameters(static_parameters):
tile_nx, tile_ny, tile_nz = [int(width) for width in static_parameters.tile_shape]
g = int(static_parameters.guard_cells)
mesh_shape = tuple(int(static_parameters.field_mesh.shape[axis]) for axis in ghost_cells.MESH_AXES)
return (
mesh_shape[0],
mesh_shape[1],
mesh_shape[2],
tile_nx + 2 * g,
tile_ny + 2 * g,
tile_nz + 2 * g,
)


def _axis_envelope(shape, static_parameters, axis_index, side, width, order, sigma_max, step_dt):
tile_width = int(static_parameters.tile_shape[axis_index])
g = int(static_parameters.guard_cells)
Expand Down Expand Up @@ -135,7 +121,9 @@ def build_supergaussian_envelope(static_parameters, dynamic_parameters, step_dt,
del dynamic_parameters

if shape is None:
shape = _shape_from_static_parameters(static_parameters)
g = int(static_parameters.guard_cells)
mesh_shape = tuple(int(static_parameters.field_mesh.shape[axis]) for axis in ghost_cells.MESH_AXES)
shape = mesh_shape + tuple(int(width) + 2 * g for width in static_parameters.tile_shape)

envelope = jnp.ones(tuple(int(value) for value in shape))
for axis_index, side, width, order, sigma_max in static_parameters.supergaussian_layers:
Expand Down
18 changes: 18 additions & 0 deletions PyPIC3D/diagnostics/diagnostic_quantities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
import jax.numpy as jnp


def compute_energy_components(particles, E, B, external_fields, static_parameters,
dynamic_parameters, species_config, *, dark_fields=None, dark_pml=None):
"""Flat-space energy including prescribed fields and optional Proca fields.

Use the supplied particle time level: initial reporting precedes the
backward leapfrog seed, while runtime diagnostics use the evolved state.
"""
from PyPIC3D.utilities.field_helpers import add_external_fields

total_E, total_B = add_external_fields(E, B, external_fields)
electric, magnetic, kinetic = compute_energy(
particles, total_E, total_B, static_parameters, dynamic_parameters,
species_config=species_config)
dark = (compute_dark_energy(dark_fields, static_parameters, dynamic_parameters, dark_pml)
if dark_fields is not None else 0.0)
return electric, magnetic, kinetic, dark


def compute_dark_energy(dark_fields, static_parameters, dynamic_parameters, pml_state=None):
"""Physical Proca energy at integer time, using reconstructed A and B.

Expand Down
Loading
Loading