44import 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
118122if __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