----Package contents---- This is the source code to carry out an inverse design of a structure producing helicity lattice, as explained in the accompany paper.It contains several files: readme.txt helicity_library.py id_helicity.py id_module.py load_structure.py module_3d_wave.py --parallel computation scripts p_id_helicity.py p_id_helicity_continue.py and three directories: images monitor_progress_plots sim_details ----System requirements---- The system requirements are a working installation of Python 3, as well as the package/s Meep and/or parallel Meep (https://meep.readthedocs.io/en/latest/Installation/). All simulations in the paper were performed using: Python 3.9 Rocky Linux 8.5 -----Modules ---- This program generates 2D helicity density patterns in 3D simulation space. It comprises of several modules and their description is as follows: ***helicity_by_id*** This is the main program that runs the simulations without parallelization. It can be thought of as a test module, as it plots the status of simulation at evrey iteration. It operates in three modes: “OSS” – One Source Simulation. This generates a crystal-like structure (a list with positions of the dielectric blocks) which refracts the single beam in such a way that a user chosen helicity lattice emerges. This requires specifying the direction and polarization of the input beam. For best results keep the propagation direction and polarization direction along the axes. The module_3d_wave can handle producing plane waves in arbitrary direction only in large simulation boxes (the larger the gap between the computational area and an observational one, the closer the result resembles a plane wave). Large sim boxes for this mode make the computational load very heavy and slow, a gap of 1-2 wavelengths between computational and observation area is recommended. “MSS”- Multiple Source Simulation. Recreates the preselected helicity lattice with multiple beams. Only a single simulation is run. In this mode it is recommended to enlarge the sim box and the difference between computational and observational volumes. “IMG” – This is a variation of the “OSS” mode; instead of a lattice, the program tries to recreate a user provided image. The image has to have nxn dimensions. This mode is still under construction. ***id_module*** Contains all the functions dealing with the simulation and 2D/3D plotting ***helicity_library*** Is a collection of analytical expressions for various helicity lattices. It also contains constituent propagation and polarization vectors forming the multi-beam lattices; this is used when a user chooses to recreate an original lattice without building the dielectric structure. ***load_structure*** Simulates (fast) a field with a structure previously built by the user and produces several 2D/3D plots. This allows for rotating of the 3D crystal and saving results manually. It recreates structures discovered in both single and parallel mode. ***module_3d_wave*** A module simulating plane wave propagation. Used in both, single- and multiple-source simulations. In "OSS" and "IMG" modes, an input with propagation direction and polarization should have them be defined parallel to axes e.g. no [1,1,0]. For the "MSS" mode however, the module is capable of producing plane waves in arbitrary directions with arbitrary polarizations. In such case,they are superpositions of plane waves in orthogonal, parallel-to-axes directions, therefore large simulation boxes are needed to mitigate the interference of elements that are not 'truly a plane wave' due to the finite width of the source. ***p_id_helicity*** A parallel simulation script, similar to the id_helicity but without the plotting modules. Needs to be run from the shell. ***p_id_helicity_continue*** A parallel simulation script allowing to run a simulation with previously calculated geometry, hence continuing (extending) the previous script ************************************************************************************************************************ ---Instructions--- Sets of known helicity patterns are prepared in helicity_library.py-these can be recreated using multiple beams or by using the single source simulation via inverse design. If an image is to be recreated, only a single source inverse design is applicable. A user would first choose the simulation type, the desired pattern or an image to be recreated (desired image must be square and needs to be copied to the images folder), set the size of the sim box, resolution, and the nr of iterations (if applicable) and run the id_helicity script (this is a test module that outputs useful plots in real time). At every iteration 4 plots are printed to monitor_progress_plots directory to allow for checking the status of the session; they are: helicity density, intensity, merit function decrease, intensity max - intensity min. They are being overwritten at every iteration so only last one is kept until the next session. User can choose whether to tell the program to save the sim data and the 2d plot automatically at the end of the sim by setting SAVE_ALL=True. The data saved in sim_details allows for reconstruction of the previously simulated lattices, i.e the program remembers the geometry of the crystal and runs only one simulation to achieve it. Previous simulations can be quickly recreated by using the load_structure module. Once the user is happy with the parameters of the test simulation, p_id_helicity module can be edited to input the sim parameters and the script can be run in parallel from the command line: *Illustration of an example where the user has 8 physical cores* once the parallel meep has been installed in its own environment (i.e. pmp), $conda activate pmp$ navigate to the source code folder $mpirun -np 8 python3 p_id_helicity.py$ After the simulation has finished, load_structure.py can be run specifying the particular file to be opened and plotted. (folder sim_details contains all the relevant data, the desired simulations can be accessed by specifying type(IMG or e.g. sc_3) and number of iterations and resolution. All modules and functions are annotated.