qpv-research-group / rayflare

Open-source, integrated optical modelling of complex stacks
Other
31 stars 11 forks source link

Dealing with changing parameters between simulations using the angular redistribution matrix method #36

Open phoebe-p opened 2 years ago

phoebe-p commented 2 years ago

Is your feature request related to a problem? Please describe. As in #28, when using the angular redistribution matrix method, if an interface is changed between simulations, or options which affect the calculation of the matrices for a surface are changed, RayFlare does not currently recognize/'know' about this. This means that if you for example change the surface layers on an interface, or change the polarization or number of rays in options, but do not change the name of the interface or the name of the project (options.project_name), the previously-calculated matrices will just be loaded and used. This is confusing and can clearly lead to errors.

Describe the solution you'd like There should be a way for RayFlare to check, per surface, if that surface and options relevant to its matrix calculation have changed between runs. Perhaps this information can be stored in a text file alongside the results, and that information can be compared with the new options/surface information at the start of the next run. Note that the check should be per surface because if only one surface has changed, it isn't necessary to recalculate matrices for both surfaces. Similarly, only changing the options which actually affect the method used for a surface should trigger re-calculation; if you are using ray-tracing for one of the surfaces and change the number of RCWA orders, that will not affect the matrices for the ray-traced surface.

Describe alternatives you've considered The above would be quite involved -- perhaps an interim solution is to give a warning or yes/no text prompt saying that matrices already exist and asking the user if they want to recalculate, with the option of setting a 'force_recalculate' option or similar.

michelgaglioni commented 3 months ago

I have been doing that manually simply by checking if the directory in which the simulation is saved is existent and deleting it after every iteration of the loop (os/shutil).