Skip to content

Conversation

@m51vortice
Copy link

@m51vortice m51vortice commented Sep 17, 2025

Example code to run simulations on a custom angle grid and integrate hemispherical forward and backward scattering cross sections.
It is a sort of stand-alone compiler to be put in the ADDA directory, as it both launches the simulations and then reads the outputs. The main advantages are:

• User-friendly GUI and ready-to-use environment.
• Separation of the scattering cross section into two hemispherical domains (forward and backward components), also in surface mode (eq. 66 of the manual).
• user-dependent theta and phi angle grid.
• Built-in parallel simulations of wavelength spectra and custom shapes, with clear folder and output files names, and of Mie efficiencies for comparison.
• Script, guide and complementary files also available at https://drive.google.com/drive/folders/1NCNRca60HqnRZOXDdlva6jbG9POnmfpJ?usp=sharing.

Example code to run simulations on a custom angle grid and integrate forward and backward scattering efficiencies.
@myurkin myurkin self-assigned this Sep 19, 2025
@myurkin myurkin added pri-Medium Worth assigning to a milestone comp-Example Related to scripts in examples/ labels Sep 19, 2025
@myurkin myurkin added this to the 1.5 milestone Sep 19, 2025
@myurkin
Copy link
Member

myurkin commented Sep 19, 2025

Mattia, thanks a lot for your contribution!

Right now, it seems that two files were merged together, so replacement of the files is required. I guess, the main idea of the script is to compute hemispherical (forward and backward) scattering cross sections (in addition to other more standard properties), so I propose to to name the whole folder hsph_Csca. This will lead to the following structure (see https://github.com/adda-team/adda/tree/master/examples/bessel for example):

/examples/hsph_Csca/...

  • hsph_Csca.py (or any other name), this is the main script which you already have (and is present on Google drive),
  • README.md - short description of the example and all files in the folder,
  • Guide.pdf - you may also include .docx source, but most users will prefer to just read the pdf.
  • lambda_nk_test.txt - short file, so that some minimal examples can be executed out of the box.

Here are a few other comments after looking at the files:

  • please spellcheck the python file (specifically, comments), there are a few typos
  • I guess, your script is designed to be used on Windows. Please mention it explicitly in the documentation. Or maybe you can think of a way to run it on other systems?
  • you mention in the guide that definition of theta angle changes between free-space and surface mode. However, the figure seems to depict the substrate together with free-space definition. This maybe the intended meaning to indicate that definition in the guide is different from that of ADDA (to have unambiguous definitions of forward and backward cross sections), but it is not clear from the discussion.
  • the guide describes well the whole functionality of the code, but it would be great if you can provide some minimal example (a few lines using your python functions), that can be executed as is. This can be included as a separate file in the folder, or make the main script runnable to execute such minimal example by default.
  • if you have any paper, which describes (or uses) this script, do not hesitate to mention it in the guide and comments in the script ("if you use this script, please cite this paper"). You may also add one later, if an appropriate paper is not yet published.

Please remove the previously added file, add new files (in proper path), address the above comments, and push your changes to github (to your fork). It will then automatically appear in this pull request.

@myurkin
Copy link
Member

myurkin commented Sep 19, 2025

And please add your name and contact info to the guide as well.

@m51vortice m51vortice changed the title Create Integration on angle grid hsph_Csca Sep 20, 2025
@m51vortice
Copy link
Author

Thank you very much for having revised the code. I will work to solve these issues, and I will push the changes with a new, and more user-friendly, version of the code and of the guide (with also a Linux version) in the next days.

@myurkin
Copy link
Member

myurkin commented Sep 23, 2025

And a small note (for future references) - this is related to issues #195, #301.

Copy link
Author

@m51vortice m51vortice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Added updated version of the hsph_Csca_ADDA (named V2).py, now featuring a user friendly GUI.
-added alldir_params.dat file to be used with the .py script.
-added updated version of the guide in .pdf format.
-added example input file "lambda_nk_test.txt.
-added external python module "miepython.py".

- adds mention of new folder in examples/README.md
- fixes a lot of typos
- removes duplicate file papers/hsph_Csca/README.md
@myurkin
Copy link
Member

myurkin commented Oct 15, 2025

I've made some cosmetic changes, but there are a few more important issues. First, to facilitate further discussion, here is the working configuration that I managed to create (all paths except one are relative to adda/examples/hsph_Csca/):

  • create folder win64, copy alldir_params.dat there
  • copy default scat_params.dat (from .../adda/input) to win64/, change lines 19 and 33 there to N=361 and N=181, respectively.
  • copy adda.exe (from somewhere) to win64/
  • create folder SimulationResults
  • change folders in the script to:
Mainfolder="win64\\" #set name of the working folder
SimResfolder = r"SimulationResults" #specify where to save the scattering results

Next, the problems:

  • proper scat_params.dat is missing.
    • At minimum, you should provide the one corresponding to the default parameters (for theta-phi grid) in the script.
    • A better solution would be to generate the file from the script, according to the given parameters.
  • the script is not runnable out of the box, due to necessity to set the folders (and some copying) as mentioned above.
    • At minimum, please make it working as explained in README, i.e. when all files and adda.exe are in the same folder. Then the minimum effort would be, e.g., to copy adda.exe to the script folder.
    • A better solution would be to set the relative path to adda.exe in the script. Then, you can set the default value to something like here - see the commented-out line. This may run out of the box for anyone, who downloads the full ADDA package.
  • Related to the above, I recommend to make the script to be able to create folder SimResfolder if it doesn't exist. The same applies to Mainfolder, if adda.exe could be located in other places and accessible by a path. Please also avoid using hardwired absolute paths, so that the whole ADDA folder (including, among many others, this script and ADDA binaries) can be freely moved.

Finally, a note about different OS. You mention Windows in the description, so it's fine to keep it as such. However, it seems that the factor limiting portability to other OS is not GUI (tkinter package is portable), but use of .bat files. So, if you can avoid the latter, the script can be used anywhere. For instance, you may run ADDA directly from Python - see the above link. But that can be kept as an idea for future version.

As previously, once you commit all the changes, please write a comment here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-Example Related to scripts in examples/ pri-Medium Worth assigning to a milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants