@@ -61,6 +61,7 @@ def __init__(self, grid, wake=None, cfln=0.5, dt=None,
6161 bc_high: list, default ['Periodic', 'Periodic', 'Periodic']
6262 Domain box boundary conditions for X+, Y+, Z+
6363 use_conductors: bool, default False
64+ [LEGACY] Will be deprecated in future releases
6465 If true, enables geometry import based on elements from `conductors.py`
6566 use_stl: bool, default False
6667 If true, activates all the solids and materials passed to the `grid` object
@@ -149,8 +150,8 @@ def __init__(self, grid, wake=None, cfln=0.5, dt=None,
149150 # MPI init
150151 if self .use_mpi :
151152 if self .grid .use_mpi :
152- self .mpi_initialize ()
153- self .one_step = self .mpi_one_step
153+ self ._mpi_initialize ()
154+ self .one_step = self ._mpi_one_step
154155 else :
155156 print ('[!] Grid not subdivided for MPI, set `use_mpi`=True also in `GridFIT3D` to enable MPI' )
156157
@@ -183,7 +184,7 @@ def __init__(self, grid, wake=None, cfln=0.5, dt=None,
183184 self .bc_low = bc_low
184185 self .bc_high = bc_high
185186 self .update_logger (['bc_low' , 'bc_high' ])
186- self .apply_bc_to_C ()
187+ self ._apply_bc_to_C ()
187188
188189 # Materials
189190 if verbose :
@@ -202,7 +203,7 @@ def __init__(self, grid, wake=None, cfln=0.5, dt=None,
202203 self .sigma = Field (self .Nx , self .Ny , self .Nz , use_ones = True , dtype = self .dtype )* self .sigma_bg
203204
204205 if self .use_stl :
205- self .apply_stl ()
206+ self ._apply_stl_materials ()
206207
207208 # Fill PML BCs
208209 if self .activate_pml :
@@ -212,7 +213,7 @@ def __init__(self, grid, wake=None, cfln=0.5, dt=None,
212213 self .pml_lo = 5e-3
213214 self .pml_hi = 1.e-1
214215 self .pml_func = np .geomspace
215- self .fill_pml_sigmas ()
216+ self ._fill_pml_sigmas ()
216217 self .update_logger (['n_pml' ])
217218
218219 # Timestep calculation
@@ -252,7 +253,7 @@ def __init__(self, grid, wake=None, cfln=0.5, dt=None,
252253 print ('Using MKL backend for time-stepping...' )
253254 self .tDsiDmuiDaC = mkl_sparse_mat (self .tDsiDmuiDaC )
254255 self .itDaiDepsDstC = mkl_sparse_mat (self .itDaiDepsDstC )
255- self .one_step = self .one_step_mkl
256+ self .one_step = self ._one_step_mkl
256257
257258 # Move to GPU
258259 if use_gpu :
@@ -306,9 +307,9 @@ def update_tensors(self, tensor='all'):
306307
307308 def _one_step (self ):
308309 if self .step_0 :
309- self .set_ghosts_to_0 ()
310+ self ._set_ghosts_to_0 ()
310311 self .step_0 = False
311- self .attrcleanup ()
312+ self ._attrcleanup ()
312313
313314 self .H .fromarray (self .H .toarray () -
314315 self .dt * self .tDsiDmuiDaC * self .E .toarray ()
@@ -324,11 +325,11 @@ def _one_step(self):
324325 if self .use_conductivity :
325326 self .J .fromarray (self .sigma .toarray ()* self .E .toarray ())
326327
327- def one_step_mkl (self ):
328+ def _one_step_mkl (self ):
328329 if self .step_0 :
329- self .set_ghosts_to_0 ()
330+ self ._set_ghosts_to_0 ()
330331 self .step_0 = False
331- self .attrcleanup ()
332+ self ._attrcleanup ()
332333
333334 self .H .fromarray (self .H .toarray () -
334335 self .dt * dot_product_mkl (self .tDsiDmuiDaC ,self .E .toarray ())
@@ -344,7 +345,7 @@ def one_step_mkl(self):
344345 if self .use_conductivity :
345346 self .J .fromarray (self .sigma .toarray ()* self .E .toarray ())
346347
347- def mpi_initialize (self ):
348+ def _mpi_initialize (self ):
348349 self .comm = self .grid .comm
349350 self .rank = self .grid .rank
350351 self .size = self .grid .size
@@ -354,30 +355,30 @@ def mpi_initialize(self):
354355 self .ZMAX = self .grid .ZMAX
355356 self .Z = self .grid .Z
356357
357- def mpi_one_step (self ):
358+ def _mpi_one_step (self ):
358359 if self .step_0 :
359- self .set_ghosts_to_0 ()
360+ self ._set_ghosts_to_0 ()
360361 self .step_0 = False
361- self .attrcleanup ()
362+ self ._attrcleanup ()
362363
363364 self .H .fromarray (self .H .toarray () -
364365 self .dt * self .tDsiDmuiDaC * self .E .toarray ()
365366 )
366367
367- self .mpi_communicate (self .H )
368- self .mpi_communicate (self .J )
368+ self ._mpi_communicate (self .H )
369+ self ._mpi_communicate (self .J )
369370 self .E .fromarray (self .E .toarray () +
370371 self .dt * (self .itDaiDepsDstC * self .H .toarray ()
371372 - self .ieps .toarray ()* self .J .toarray ()
372373 )
373374 )
374375
375- self .mpi_communicate (self .E )
376+ self ._mpi_communicate (self .E )
376377 # include current computation
377378 if self .use_conductivity :
378379 self .J .fromarray (self .sigma .toarray ()* self .E .toarray ())
379380
380- def mpi_communicate (self , field ):
381+ def _mpi_communicate (self , field ):
381382 if self .use_gpu :
382383 field .from_gpu ()
383384
@@ -604,7 +605,7 @@ def mpi_gather_asField(self, field):
604605
605606 return _field
606607
607- def apply_bc_to_C (self ):
608+ def _apply_bc_to_C (self ):
608609 '''
609610 Modifies rows or columns of C and tDs and itDa matrices
610611 according to bc_low and bc_high
@@ -745,7 +746,7 @@ def apply_bc_to_C(self):
745746 self .activate_pml = True
746747 self .use_conductivity = True
747748
748- def fill_pml_sigmas (self ):
749+ def _fill_pml_sigmas (self ):
749750 '''
750751 Routine to calculate pml sigmas and apply them
751752 to the conductivity tensor sigma
@@ -901,7 +902,7 @@ def update_abc(self, E_abc, H_abc):
901902 self .E [:, :, - 1 , d ] = E_abc [2 ][d + 'hi' ]
902903 self .H [:, :, - 1 , d ] = H_abc [2 ][d + 'hi' ]
903904
904- def set_ghosts_to_0 (self ):
905+ def _set_ghosts_to_0 (self ):
905906 '''
906907 Cleanup for initial conditions if they are
907908 accidentally applied to the ghost cells
@@ -920,8 +921,9 @@ def set_ghosts_to_0(self):
920921 self .E [:, - 1 , :, 'y' ] = 0.
921922 self .E [:, :, - 1 , 'z' ] = 0.
922923
923- def apply_conductors (self ):
924+ def _apply_conductors (self ):
924925 '''
926+ [LEGACY] conductors support
925927 Set the 1/epsilon values inside the PEC conductors to zero
926928 '''
927929 self .flag_in_conductors = self .grid .flag_int_cell_yz [:- 1 ,:,:] \
@@ -930,8 +932,9 @@ def apply_conductors(self):
930932
931933 self .ieps *= self .flag_in_conductors
932934
933- def set_field_in_conductors_to_0 (self ):
935+ def _set_field_in_conductors_to_0 (self ):
934936 '''
937+ [LEGACY] conductors support
935938 Cleanup for initial conditions if they are
936939 accidentally applied to the conductors
937940 '''
@@ -942,7 +945,7 @@ def set_field_in_conductors_to_0(self):
942945 self .H *= self .flag_cleanup
943946 self .E *= self .flag_cleanup
944947
945- def apply_stl (self ):
948+ def _apply_stl_materials (self ):
946949 '''
947950 Mask the cells inside the stl and assing the material
948951 defined by the user
@@ -960,55 +963,28 @@ def apply_stl(self):
960963
961964 mask = np .reshape (grid [key ], (self .Nx , self .Ny , self .Nz )).astype (int )
962965
963- if type (self .stl_materials [key ]) is str :
964- # Retrieve from material library
965- mat_key = self .stl_materials [key ].lower ()
966+ eps = self .stl_materials [key ][0 ]* eps_0
967+ mu = self .stl_materials [key ][1 ]* mu_0
966968
967- eps = material_lib [mat_key ][0 ]* eps_0
968- mu = material_lib [mat_key ][1 ]* mu_0
969+ # Setting to zero
970+ self .ieps += self .ieps * (- 1.0 * mask )
971+ self .imu += self .imu * (- 1.0 * mask )
969972
970- # Setting to zero
971- self .ieps += self . ieps * ( - 1.0 * mask )
972- self .imu += self . imu * ( - 1.0 * mask )
973+ # Adding new values
974+ self .ieps += mask * 1. / eps
975+ self .imu += mask * 1. / mu
973976
974- # Adding new values
975- self .ieps += mask * 1. / eps
976- self .imu += mask * 1. / mu
977+ # Conductivity
978+ if len (self .stl_materials [key ]) == 3 :
979+ sigma = self .stl_materials [key ][2 ]
980+ self .sigma += self .sigma * (- 1.0 * mask )
981+ self .sigma += mask * sigma
982+ self .use_conductivity = True
977983
978- # Conductivity
979- if len (material_lib [mat_key ]) == 3 :
980- sigma = material_lib [mat_key ][2 ]
981- self .sigma += self .sigma * (- 1.0 * mask )
982- self .sigma += mask * sigma
983- self .use_conductivity = True
984+ elif self .sigma_bg > 0.0 : # assumed sigma = 0
985+ self .sigma += self .sigma * (- 1.0 * mask )
984986
985- elif self .sigma_bg > 0.0 : # assumed sigma = 0
986- self .sigma += self .sigma * (- 1.0 * mask )
987-
988- else :
989- # From input
990- eps = self .stl_materials [key ][0 ]* eps_0
991- mu = self .stl_materials [key ][1 ]* mu_0
992-
993- # Setting to zero
994- self .ieps += self .ieps * (- 1.0 * mask )
995- self .imu += self .imu * (- 1.0 * mask )
996-
997- # Adding new values
998- self .ieps += mask * 1. / eps
999- self .imu += mask * 1. / mu
1000-
1001- # Conductivity
1002- if len (self .stl_materials [key ]) == 3 :
1003- sigma = self .stl_materials [key ][2 ]
1004- self .sigma += self .sigma * (- 1.0 * mask )
1005- self .sigma += mask * sigma
1006- self .use_conductivity = True
1007-
1008- elif self .sigma_bg > 0.0 : # assumed sigma = 0
1009- self .sigma += self .sigma * (- 1.0 * mask )
1010-
1011- def attrcleanup (self ):
987+ def _attrcleanup (self ):
1012988 # Fields
1013989 del self .L , self .tL , self .iA , self .itA
1014990 if hasattr (self , 'BC' ):
0 commit comments