Closed momchilmm closed 6 years ago
Ok I realized that to reset you can just set simulation.src to np.zeros(eps_r.shape). I think this is good enough.
Related: @momchilmm @ianwilliamson ideally we should set simulation.src
and simulation.eps_r
each as a @property
of the simulation class. Then we can do setting and getting more cleanly than we do now. (for example, if we make eps_r
a property, we can automatically have it create A
whenever simulation.eps_r = new_array
.
I just assigned myself to this. but if anyone else has time go for it.
Technically this pertains to fdfdpy
but yes, Momchil's approach will work as a temporary solution. Agreed that its better to have as a @property
.
Regarding momchil's first point, what's the problem with just reassigning simulation.src?
simulation.src = new_src
Maybe I don't understand the use case
Oh it's just that when we set modal sources up we use simulation.add_mode
and simulation.setup_src
, we don't assign simulation.src
directly. So there is a method to add a modal source but no method to remove existing modal sources, that was my concern initially.
A function that clears the list of sources in the simulation object is probably the best option. It could also be redesigned to store sources in a dict. This would allow you to reference sources by name to edit.
why not just pop them off the simulation.modes
list? or make simulation.modes
a dict would be fine too. We could also add @property to simulation.modes
as well
Ah yes good point. I also realized that instead of doing simulation.src *= scale_fact
to rescale the source, we can also do for example
simulation.modes[0].scale *= scale_fact
simulation.setup_modes()
This has the advantage for example that simulation.W_in
will be re-computed with the new scale.
It would be nice to be able to change or remove a simulation source once it is added. If I want to run the same simulation but with a different input power, right now I don't see any other way but to initialize the simulation object anew. We can add sources, but we cannot remove or edit them. Editing might be too much to ask at this point, but a simple method that removes all sources will suffice.