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
1010 """
@@ -55,7 +55,7 @@ def inner_evaluate(self, s, x, symbol):
5555 return res
5656
5757 def eval_cases (self , s , x , symbol ):
58- """handle c++ cases o form cond ? case1 ? case 2
58+ """handle c++ cases of form condition ? case1 : case 2
5959 s ... string code
6060 x ... float value to evalute
6161 symbol ... symbol to replace in string s
@@ -117,14 +117,15 @@ def clean_substring(self, s):
117117
118118if __name__ == "__main__" :
119119 # load pypicongpu.json, convert json to dict and extract equation for density
120+ # a pypicongpu.json is created for every PICMI call
120121 file = open ("pypicongpu.json" )
121122 sim_dict = json .load (file )
122123 density_fct_str = sim_dict ["species_initmanager" ]["operations" ]["simple_density" ][0 ]["profile" ]["data" ][
123124 "function_body"
124125 ]
125126
126127 # create cpp_fct_reader class for later evaluation
127- reader = cpp_fct_reader (density_fct_str )
128+ reader = CppFctReader (density_fct_str )
128129
129130 # define positions where to evaluate the density
130131 x_array = np .linspace (0.0 , 5.0e-3 , 1000 )
@@ -137,6 +138,6 @@ def clean_substring(self, s):
137138 # plot density
138139 plt .plot (x_array , n_array )
139140 plt .xlabel (r"$y \, \mathrm{[m]}$" )
140- plt .xlabel (r"$n \, \mathrm{[m^-3]}$" )
141+ plt .ylabel (r"$n \, \mathrm{[m^-3]}$" )
141142 plt .yscale ("log" )
142143 plt .show ()
0 commit comments