← Back to team overview

python-meep team mailing list archive

Re: [python-meep] Customized excitation sources

 

2011/7/14 Yu Zhang <zhamboo@xxxxxxxxx>:
> Your solution really works for me. A simplified code is given below.
>
> Yu
>
>
> class src_transient(Callback):
>    def __init__(self, src_value):
>        self.value = src_value
>        Callback.__init__(self)
>    def complex_time(self,t):
>        return complex(self.value, 0)
>
> src_data = src_transient(0)
> src = custom_src_time(SRC,src_data)
> wg_field.add_point_source(src_comp, src, vec(100,20))
>
> for time_index in arange(NUMBER_OF_TIMESTEPS):
>    print("Time Index %(#)06d"%{"#":time_index})
>    wg_field.step()
>    src_data.value = sin(2*pi*time_index/80) # update source value
>
>

Really glad that it works for you. A small tip here.
You can write your function in following manner:

class src_transient(Callback):
   def __init__(self):
       Callback.__init__(self)
   def complex_time(self,t):
       return complex(sin(2*pi*t/80), 0)

It is better because then you can call something like "simulate till
fields decay" without bothering to update source every time step.

Best regards,
Shavkat


References