Skip to content

Commit 44c97e5

Browse files
committed
all CI tests ran successfullly with no failures
1 parent b68451b commit 44c97e5

File tree

82 files changed

+2650
-1184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2650
-1184
lines changed
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
from .auto import Auto
2-
from .bound_electron_density import BoundElectronDensity
3-
from .source_base import SourceBase
4-
5-
__all__ = [
6-
"Auto",
7-
"BoundElectronDensity",
8-
"SourceBase",
9-
]
10-
11-
"""
12-
131
from .auto import Auto
142
from .bound_electron_density import BoundElectronDensity
153
from .charge_density import ChargeDensity
4+
from .source_base import SourceBase
165
from .counter import Counter
176
from .density import Density
187
from .derived_attributes import DerivedAttributes
@@ -26,11 +15,11 @@
2615
from .momentum_density import MomentumDensity
2716
from .weighted_velocity import WeightedVelocity
2817

29-
3018
__all__ = [
3119
"Auto",
3220
"BoundElectronDensity",
3321
"ChargeDensity",
22+
"SourceBase",
3423
"Counter",
3524
"Density",
3625
"DerivedAttributes",
@@ -44,4 +33,3 @@
4433
"MomentumDensity",
4534
"WeightedVelocity",
4635
]
47-
"""
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
"""
22
This file is part of PIConGPU.
3-
Copyright 2025-2025 PIConGPU contributors
3+
Copyright 2025 PIConGPU contributors
44
Authors: Masoud Afshari
55
License: GPLv3+
66
"""
77

88
from .source_base import SourceBase
9-
from ....pypicongpu.output.openpmd_sources import Auto as PyPIConGPUAuto
9+
from picongpu.pypicongpu.output.openpmd_sources import Auto as PyPIConGPUAuto
1010
import typeguard
11+
import typing
1112

1213

1314
@typeguard.typechecked
1415
class Auto(SourceBase):
1516
"""
16-
Default data source for openPMD output
17+
Default data source for openPMD output in PIConGPU.
1718
18-
This class provides a convenient way to dump default simulation data (e.g., all
19-
particle species and fields) using the openPMD standard, with defaults determined
20-
by the PIC code in particle-in-cell simulations.
19+
Provides a convenient way to dump default simulation data (e.g., all particle species and fields)
20+
using the openPMD standard, with defaults determined by the PIC code.
2121
"""
2222

2323
def __init__(self, filter: str = "species_all"):
@@ -29,18 +29,18 @@ def filter(self) -> str:
2929
return self._filter
3030

3131
def check(self) -> None:
32-
"""
33-
Validate the filter parameter.
34-
"""
3532
valid_filters = ["species_all", "fields_all", "custom_filter"]
3633
if not isinstance(self._filter, str):
37-
raise ValueError(f"Filter must be a string, got {type(self._filter)}")
34+
raise TypeError(f"Filter must be a string, got {type(self._filter)}")
3835
if self._filter not in valid_filters:
3936
raise ValueError(f"Filter must be one of {valid_filters}, got {self._filter}")
4037

41-
def get_as_pypicongpu(self) -> PyPIConGPUAuto:
42-
"""
43-
Convert this Auto source to a PyPIConGPU Auto source.
44-
"""
38+
def get_as_pypicongpu(
39+
self,
40+
dict_species_picmi_to_pypicongpu: typing.Optional[typing.Dict] = None,
41+
time_step_size: float = 0.0,
42+
num_steps: int = 0,
43+
simulation_box=None,
44+
) -> PyPIConGPUAuto:
4545
self.check()
4646
return PyPIConGPUAuto(filter=self._filter)
Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""
22
This file is part of PIConGPU.
3-
Copyright 2025-2025 PIConGPU contributors
3+
Copyright 2025 PIConGPU contributors
44
Authors: Masoud Afshari
55
License: GPLv3+
66
"""
77

88
from .source_base import SourceBase
9-
from ....pypicongpu.output.openpmd_sources import ChargeDensity as PyPIConGPUChargeDensity
9+
from picongpu.pypicongpu.output.openpmd_sources import ChargeDensity as PyPIConGPUChargeDensity
1010
from ...species import Species as PICMISpecies
1111
import typeguard
1212
import typing
@@ -15,51 +15,38 @@
1515
@typeguard.typechecked
1616
class ChargeDensity(SourceBase):
1717
"""
18-
Charge density data source for openPMD output
18+
Charge density data source for openPMD output in PIConGPU.
1919
20-
This source calculates the charge density from a specified particle species, optionally
20+
Calculates the charge density from a specified particle species, optionally
2121
filtered by a selection criterion, for particle-in-cell simulations.
22-
23-
@param species Particle species contributing to the charge density (e.g., electrons, protons).
24-
@param filter Name of a filter to select particles contributing to the source.
25-
Default: "all" (includes all particles of the specified species).
2622
"""
2723

28-
def __init__(self, species: PICMISpecies, filter: str = "all"):
24+
def __init__(self, species: PICMISpecies, filter: str = "species_all"):
2925
self.species = species
30-
self.filter = filter
26+
self._filter = filter
3127
self.check()
3228

33-
def check(self) -> None:
34-
"""
35-
Validate the parameters.
29+
@property
30+
def filter(self) -> str:
31+
return self._filter
3632

37-
@throw ValueError If filter is not a string or species is not a PICMISpecies.
38-
"""
39-
if not isinstance(self.filter, str):
40-
raise ValueError(f"Filter must be a string, got {type(self.filter)}")
33+
def check(self) -> None:
34+
valid_filters = ["species_all", "fields_all", "custom_filter"]
4135
if not isinstance(self.species, PICMISpecies):
42-
raise ValueError(f"Species must be a PICMISpecies, got {type(self.species)}")
36+
raise TypeError(f"Species must be a PICMISpecies, got {type(self.species)}")
37+
if not isinstance(self._filter, str):
38+
raise TypeError(f"Filter must be a string, got {type(self._filter)}")
39+
if self._filter not in valid_filters:
40+
raise ValueError(f"Filter must be one of {valid_filters}, got {self._filter}")
4341

4442
def get_as_pypicongpu(
4543
self,
46-
dict_species_picmi_to_pypicongpu: dict[PICMISpecies, typing.Any],
44+
dict_species_picmi_to_pypicongpu: typing.Dict[PICMISpecies, typing.Any],
45+
time_step_size: float = 0.0,
46+
num_steps: int = 0,
47+
simulation_box=None,
4748
) -> PyPIConGPUChargeDensity:
48-
"""
49-
Convert this ChargeDensity source to a PyPIConGPU ChargeDensity source.
50-
51-
@param dict_species_picmi_to_pypicongpu Mapping of PICMI species to PyPIConGPU species.
52-
@return A PyPIConGPU ChargeDensity instance with the same filter and species.
53-
@throw ValueError If the species is not known to the simulation or not mapped to a PyPIConGPUSpecies.
54-
"""
5549
self.check()
56-
57-
if self.species not in dict_species_picmi_to_pypicongpu.keys():
58-
raise ValueError(f"Species {self.species} is not known to Simulation")
59-
60-
pypicongpu_species = dict_species_picmi_to_pypicongpu.get(self.species)
61-
62-
if pypicongpu_species is None:
63-
raise ValueError(f"Species {self.species} is not mapped to a PyPIConGPUSpecies.")
64-
65-
return PyPIConGPUChargeDensity(filter=self.filter, species=pypicongpu_species)
50+
if self.species not in dict_species_picmi_to_pypicongpu:
51+
raise ValueError(f"Species {self.species.name} is not known to Simulation")
52+
return PyPIConGPUChargeDensity(filter=self._filter, species=dict_species_picmi_to_pypicongpu[self.species])
Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""
22
This file is part of PIConGPU.
3-
Copyright 2025-2025 PIConGPU contributors
3+
Copyright 2025 PIConGPU contributors
44
Authors: Masoud Afshari
55
License: GPLv3+
66
"""
77

88
from .source_base import SourceBase
9-
from ....pypicongpu.output.openpmd_sources import Counter as PyPIConGPUCounter
9+
from picongpu.pypicongpu.output.openpmd_sources import Counter as PyPIConGPUCounter
1010
from ...species import Species as PICMISpecies
1111
import typeguard
1212
import typing
@@ -15,55 +15,41 @@
1515
@typeguard.typechecked
1616
class Counter(SourceBase):
1717
"""
18-
Particle counter data source for openPMD output
18+
Particle counter data source for openPMD output in PIConGPU.
1919
20-
This source derives a scalar field representing the number of real particles per cell
21-
for a specified species, optionally filtered by a selection criterion, in particle-in-cell
22-
simulations. The particle count is based on the species' weighting attribute and assigned
23-
directly to the cell containing each particle. Intended primarily for debugging due to
24-
its non-physical deposition shape, which differs from standard charge or momentum-conserving
25-
assignments.
26-
27-
@param species Particle species to count (e.g., electrons, ions). Must have a weighting attribute.
28-
@param filter Name of a filter to select particles contributing to the source.
29-
Default: "all" (includes all particles of the specified species).
20+
Derives a scalar field representing the number of real particles per cell
21+
for a specified species, optionally filtered by a selection criterion.
22+
The particle count is based on the species' weighting attribute and assigned
23+
directly to the cell containing each particle. Intended primarily for debugging
24+
due to its non-physical deposition shape.
3025
"""
3126

32-
def __init__(self, species: PICMISpecies, filter: str = "all"):
27+
def __init__(self, species: PICMISpecies, filter: str = "species_all"):
3328
self.species = species
34-
self.filter = filter
29+
self._filter = filter
3530
self.check()
3631

37-
def check(self) -> None:
38-
"""
39-
Validate the parameters.
32+
@property
33+
def filter(self) -> str:
34+
return self._filter
4035

41-
@throw ValueError If filter is not a string or species is not a PICMISpecies.
42-
"""
43-
if not isinstance(self.filter, str):
44-
raise ValueError(f"Filter must be a string, got {type(self.filter)}")
36+
def check(self) -> None:
37+
valid_filters = ["species_all", "fields_all", "custom_filter"]
4538
if not isinstance(self.species, PICMISpecies):
46-
raise ValueError(f"Species must be a PICMISpecies, got {type(self.species)}")
39+
raise TypeError(f"Species must be a PICMISpecies, got {type(self.species)}")
40+
if not isinstance(self._filter, str):
41+
raise TypeError(f"Filter must be a string, got {type(self._filter)}")
42+
if self._filter not in valid_filters:
43+
raise ValueError(f"Filter must be one of {valid_filters}, got {self._filter}")
4744

4845
def get_as_pypicongpu(
4946
self,
50-
dict_species_picmi_to_pypicongpu: dict[PICMISpecies, typing.Any],
47+
dict_species_picmi_to_pypicongpu: typing.Dict[PICMISpecies, typing.Any],
48+
time_step_size: float = 0.0,
49+
num_steps: int = 0,
50+
simulation_box=None,
5151
) -> PyPIConGPUCounter:
52-
"""
53-
Convert this Counter source to a PyPIConGPU Counter source.
54-
55-
@param dict_species_picmi_to_pypicongpu Mapping of PICMI species to PyPIConGPU species.
56-
@return A PyPIConGPU Counter instance with the same filter and species.
57-
@throw ValueError If the species is not known to the simulation or not mapped to a PyPIConGPUSpecies.
58-
"""
5952
self.check()
60-
61-
if self.species not in dict_species_picmi_to_pypicongpu.keys():
62-
raise ValueError(f"Species {self.species} is not known to Simulation")
63-
64-
pypicongpu_species = dict_species_picmi_to_pypicongpu.get(self.species)
65-
66-
if pypicongpu_species is None:
67-
raise ValueError(f"Species {self.species} is not mapped to a PyPIConGPUSpecies.")
68-
69-
return PyPIConGPUCounter(filter=self.filter, species=pypicongpu_species)
53+
if self.species not in dict_species_picmi_to_pypicongpu:
54+
raise ValueError(f"Species {self.species.name} is not known to Simulation")
55+
return PyPIConGPUCounter(filter=self._filter, species=dict_species_picmi_to_pypicongpu[self.species])
Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""
22
This file is part of PIConGPU.
3-
Copyright 2025-2025 PIConGPU contributors
3+
Copyright 2025 PIConGPU contributors
44
Authors: Masoud Afshari
55
License: GPLv3+
66
"""
77

88
from .source_base import SourceBase
9-
from ....pypicongpu.output.openpmd_sources import Density as PyPIConGPUDensity
9+
from picongpu.pypicongpu.output.openpmd_sources import Density as PyPIConGPUDensity
1010
from ...species import Species as PICMISpecies
1111
import typeguard
1212
import typing
@@ -15,54 +15,40 @@
1515
@typeguard.typechecked
1616
class Density(SourceBase):
1717
"""
18-
Particle density data source for openPMD output
18+
Particle density data source for openPMD output in PIConGPU.
1919
20-
This source derives a scalar field representing the number density (in m^-3) of a specified
21-
particle species, optionally filtered by a selection criterion, in particle-in-cell simulations.
22-
The density is calculated based on the species' weighting and position attributes and mapped to
23-
cells according to the PIC code's spatial shape assignment.
24-
25-
@param species Particle species to calculate density for (e.g., electrons, ions).
26-
Must have weighting and position attributes.
27-
@param filter Name of a filter to select particles contributing to the source.
28-
Default: "all" (includes all particles of the specified species).
20+
Derives a scalar field representing the number density (in m^-3) of a specified
21+
particle species, optionally filtered by a selection criterion.
22+
The density is calculated based on the species' weighting and position attributes
23+
and mapped to cells according to the PIC code's spatial shape assignment.
2924
"""
3025

31-
def __init__(self, species: PICMISpecies, filter: str = "all"):
26+
def __init__(self, species: PICMISpecies, filter: str = "species_all"):
3227
self.species = species
33-
self.filter = filter
28+
self._filter = filter
3429
self.check()
3530

36-
def check(self) -> None:
37-
"""
38-
Validate the parameters.
31+
@property
32+
def filter(self) -> str:
33+
return self._filter
3934

40-
@throw ValueError If filter is not a string or species is not a PICMISpecies.
41-
"""
42-
if not isinstance(self.filter, str):
43-
raise ValueError(f"Filter must be a string, got {type(self.filter)}")
35+
def check(self) -> None:
36+
valid_filters = ["species_all", "fields_all", "custom_filter"]
4437
if not isinstance(self.species, PICMISpecies):
45-
raise ValueError(f"Species must be a PICMISpecies, got {type(self.species)}")
38+
raise TypeError(f"Species must be a PICMISpecies, got {type(self.species)}")
39+
if not isinstance(self._filter, str):
40+
raise TypeError(f"Filter must be a string, got {type(self._filter)}")
41+
if self._filter not in valid_filters:
42+
raise ValueError(f"Filter must be one of {valid_filters}, got {self._filter}")
4643

4744
def get_as_pypicongpu(
4845
self,
49-
dict_species_picmi_to_pypicongpu: dict[PICMISpecies, typing.Any],
46+
dict_species_picmi_to_pypicongpu: typing.Dict[PICMISpecies, typing.Any],
47+
time_step_size: float = 0.0,
48+
num_steps: int = 0,
49+
simulation_box=None,
5050
) -> PyPIConGPUDensity:
51-
"""
52-
Convert this Density source to a PyPIConGPU Density source.
53-
54-
@param dict_species_picmi_to_pypicongpu Mapping of PICMI species to PyPIConGPU species.
55-
@return A PyPIConGPU Density instance with the same filter and species.
56-
@throw ValueError If the species is not known to the simulation or not mapped to a PyPIConGPUSpecies.
57-
"""
5851
self.check()
59-
60-
if self.species not in dict_species_picmi_to_pypicongpu.keys():
61-
raise ValueError(f"Species {self.species} is not known to Simulation")
62-
63-
pypicongpu_species = dict_species_picmi_to_pypicongpu.get(self.species)
64-
65-
if pypicongpu_species is None:
66-
raise ValueError(f"Species {self.species} is not mapped to a PyPIConGPUSpecies.")
67-
68-
return PyPIConGPUDensity(filter=self.filter, species=pypicongpu_species)
52+
if self.species not in dict_species_picmi_to_pypicongpu:
53+
raise ValueError(f"Species {self.species.name} is not known to Simulation")
54+
return PyPIConGPUDensity(filter=self._filter, species=dict_species_picmi_to_pypicongpu[self.species])

0 commit comments

Comments
 (0)