Skip to content

Commit 9242eaf

Browse files
committed
add fix for include and rename after review
1 parent e48404d commit 9242eaf

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/python/picongpu/extra/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
from .memory_calculator import MemoryCalculator
33
from .field_ionization import FieldIonization
44
from . import FLYonPICRateCalculationReference
5-
from picmi_density_reader import cpp_fct_reader
5+
from .picmi_density_reader import CppFctReader
66

7-
__all__ = ["FindTime", "MemoryCalculator", "FieldIonization", "FLYonPICRateCalculationReference", "cpp_fct_reader"]
7+
__all__ = ["FindTime", "MemoryCalculator", "FieldIonization", "FLYonPICRateCalculationReference", "CppFctReader"]

lib/python/picongpu/extra/utils/picmi_density_reader.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
import json
55

66

7-
class cpp_fct_reader:
7+
class CppFctReader:
88
"""class that alllows to evalute the PIConGPU free density
99
from a c++ code string
10+
11+
BE AWARE: the code assumes that:
12+
1.) a free formular density profile was used in PICMI
13+
2.) if sympy.Piecewise was used, that the c++ code first case, will not branch
1014
"""
1115

1216
def __init__(self, s, debug=False):
@@ -55,7 +59,7 @@ def inner_evaluate(self, s, x, symbol):
5559
return res
5660

5761
def eval_cases(self, s, x, symbol):
58-
"""handle c++ cases o form cond ? case1 ? case 2
62+
"""handle c++ cases of form condition ? case1 : case 2
5963
s ... string code
6064
x ... float value to evalute
6165
symbol ... symbol to replace in string s
@@ -117,14 +121,15 @@ def clean_substring(self, s):
117121

118122
if __name__ == "__main__":
119123
# load pypicongpu.json, convert json to dict and extract equation for density
124+
# a pypicongpu.json is created for every PICMI call
120125
file = open("pypicongpu.json")
121126
sim_dict = json.load(file)
122127
density_fct_str = sim_dict["species_initmanager"]["operations"]["simple_density"][0]["profile"]["data"][
123128
"function_body"
124129
]
125130

126131
# create cpp_fct_reader class for later evaluation
127-
reader = cpp_fct_reader(density_fct_str)
132+
reader = CppFctReader(density_fct_str)
128133

129134
# define positions where to evaluate the density
130135
x_array = np.linspace(0.0, 5.0e-3, 1000)
@@ -137,6 +142,6 @@ def clean_substring(self, s):
137142
# plot density
138143
plt.plot(x_array, n_array)
139144
plt.xlabel(r"$y \, \mathrm{[m]}$")
140-
plt.xlabel(r"$n \, \mathrm{[m^-3]}$")
145+
plt.ylabel(r"$n \, \mathrm{[m^-3]}$")
141146
plt.yscale("log")
142147
plt.show()

0 commit comments

Comments
 (0)