CST-Modelling-Tools / TonatiuhPP

3 stars 3 forks source link

Flux computation in Script #2

Open giogio8427 opened 4 months ago

giogio8427 commented 4 months ago

Hi,

I am a researcher working on CSP technology and I am positively surprised by the fast computation that Tonatiuh++ allows .

In particular, I am interested in using Tonatiuh++ computation core in an optimization process (handled by Matlab or Python) that uses, as objective function, fluxes on different surfaces.

I was able to use the Tonatiuh++'s script functionalities but I was able to run "FindInterception" only that computes the number of rays on a surface (as far as I understood from example) and I did not find a way to compute fluxes.

So, I was trying to find a way using the script in order to run a flux analysis (or alternatively to save ray data in order to compute the flux outside Tonatiuh++).

Could you help me?

Thank you...

Andrea

andrevitoras commented 1 month ago

Hi,

I do not know if this would be still helpful, but I use the "RunFluxAnalysis" function in my scripts to write a file with the flux data. You can read more about such a function in (Line 1925): https://github.com/CST-Modelling-Tools/TonatiuhPP/blob/664250e8ef38e7d6dab3ed35d6fab7f732edec19/source/application/main/MainWindow.cpp#L1925

giogio8427 commented 1 month ago

Hi, Thanks...It works perfectly :-) Probably I am missing how to exploit the script capabilities with the procedure reported in the source code (I wasn't able to find in the the wiki some documentation about this and I tried to learn from the examples. Do you have some advice about this?). For example, now (thank to your help ;-)) I am able to export the flux from a surface but I am wondering if it is possible to export more surfaces at once (in order to avoid calling many times the FluxAnalysis function). Probably to overcome this issue, it would be sufficient to export the photon map (I am able to do this from the GUI) from the script and to manipulate data (i.e.Python or Matlab). I looked for a function that is able to do this but it seems to be absent.

Thanks again,

andrevitoras commented 1 month ago

Hi,

Glad it helped you.

Regarding to your new question, I usually have one absorber, so I never had to export the data for more than one surface.

One option is what you mentioned: call the RunFluxAnalysis function more than one time. However, I suspect that Tonatiuh++ trace rays each time you call this function, and two different simulations could yield different outputs due to the stochastic nature of these simulations -- differently from SolTrace, Tonatiuh++ does not have a Seed Value input so that one can control this process. In addition, it will take far more computation time.

I assume that by photo map you refer to what you can export by the GUI in the window Run --> Ray Tracing (CTRL + R), which has two settings options: Parameters and Format.

I found the RunFluxAnalysis function by looking up in the source code. I observed that all input data you need to insert in the GUI match with of this function. Maybe you can find something related for the photon map.

I only could find this for the photon map:

https://github.com/CST-Modelling-Tools/TonatiuhPP/blob/664250e8ef38e7d6dab3ed35d6fab7f732edec19/source/application/run/RayTracingDialog.cpp#L15

https://github.com/CST-Modelling-Tools/TonatiuhPP/blob/664250e8ef38e7d6dab3ed35d6fab7f732edec19/source/application/main/MainWindow.h#L121

Hope it help.

Kind regards, André.

mblancomuriel commented 1 month ago

Good morning!

Traditionally, both in Tonatiuh and Tonatiuh++ you compute fluxes on different surfaces be exporting the results of the raytracing simulation, i.e., the photons files, and processing them in an external program such as Mathematica or Matlab.

The structure of the raytracing information that can be exported is the same in Tonatiuh than in Tonatiuh++. You can find the information regarding the Output Files Formate and how to use them here.

giogio8427 commented 1 month ago

Thank you for your help :-)