@@ -133,17 +133,20 @@ def __init__(self, x_aper=None, y_aper=None, dx=None, dy=None, xg=None, yg=None,
133133
134134
135135 #@profile
136- def scatter (self , x_mp , y_mp , nel_mp , charge = - qe ):
136+ def scatter (self , x_mp , y_mp , nel_mp , charge = - qe , flag_add = False ):
137137
138138 if not (len (x_mp )== len (y_mp )== len (nel_mp )):
139139 raise ValueError ('x_mp, y_mp, nel_mp should have the same length!!!' )
140140
141141 if len (x_mp )> 0 :
142142 rho = rhocom .compute_sc_rho (x_mp ,y_mp ,nel_mp ,self .bias_x ,self .bias_y ,self .dx ,self .dy ,self .Nxg ,self .Nyg )
143+ else :
144+ rho = self .rho * 0.
143145
144- self .rho = charge * rho / (self .dx * self .dy );
146+ if flag_add :
147+ self .rho += charge * rho / (self .dx * self .dy );
145148 else :
146- self .rho = self .rho * 0.
149+ self .rho = charge * rho / ( self .dx * self . dy );
147150
148151
149152 def gather (self , x_mp , y_mp ):
@@ -200,8 +203,8 @@ def solve(self, *args, **kwargs):
200203 pass
201204
202205 #@profile
203- def scatter_and_solve (self , x_mp , y_mp , nel_mp , charge = - qe ):
204- self .scatter (x_mp , y_mp , nel_mp , charge )
206+ def scatter_and_solve (self , x_mp , y_mp , nel_mp , charge = - qe , flag_add = False ):
207+ self .scatter (x_mp , y_mp , nel_mp , charge , flag_add )
205208 self .solve ()
206209
207210
0 commit comments