edmundsj / rcwa

Rigorous Coupled Wave Analysis for the calculation of Photonic Crystal R/T spectra
MIT License
97 stars 30 forks source link

Add sweeping for arbitrary variables #36

Closed edmundsj closed 2 years ago

edmundsj commented 2 years ago

If we could somehow give the user an ability to point to a specific object in the simulation and one of its properties, through some type of ID or by accessing it as an object externally, that would allow for sweeps of arbitrary variables anywhere in the simulation.

Idea: Allow the user to pass in an object (i.e. a Source) along with the parameters and values of that object they want to sweep. (i.e. 'phi': [0.5, 0.6, 0.7]). As long as we can ensure none of these objects are internally copied, then changing a parameter of that object could be done relatively easily. It would look something like this:

source = Source()
layer_n = Layer()
...
solver.solve((source, {'phi': [0.5, 0.6, 0.7]}), (layer_n, {'thickness': [0.2, 0.25, 0.3]}) 

TODO: Ensure no objects are copied internally, and make sure they are all only referenced. I think this may be an issue with the setup of LayerStacks.

edmundsj commented 2 years ago

This is implemented with unit and integration tests with the syntax above as of 0b68b56.