spinsphotonics / fdtdz

Fast, scalable, accessible photonic simulation
MIT License
111 stars 13 forks source link

Calculating source_waveform length (tt) manually? #28

Open PhysMa opened 3 months ago

PhysMa commented 3 months ago

In fdtdz there is:

  out_start, out_stop, out_interval = output_steps
  out_num = len(range(out_start, out_stop, out_interval))
  tt = out_start + out_interval * (out_num - 1) + 1

  if not (source_waveform.ndim == 2 and source_waveform.shape == (tt, 2)):
    raise ValueError(
        f"source_waveform must be of shape (tt, 2) = ({tt}, 2), but got "
        f"{source_waveform.shape} instead.") 

Since tt is calculated internally, one would need to do the same calculation outside to figure out the length of the input param source_waveform -- is this intended? One consequence is that whenever one changes output_steps, even just the interval value, this ValueError is often raised. Maybe allow source_waveform to be longer and only use the first tt elements?