iat-cener / tonatiuh

A Monte Carlo ray tracer for the optical simulation of solar concentrating systems
http://iat-cener.github.io/tonatiuh/
GNU General Public License v3.0
55 stars 15 forks source link

Bug Report tonatiuh 2.2 #82

Open pokinoi opened 7 years ago

pokinoi commented 7 years ago

i have a serious issue trying to post process my results on mathematica. the simulation seems to run fine and when i use the sun flux analysis tool, they results look perfect. however, when i export the model and try to post process the same result on mathematica, i get a completely wrong result. i have used the same script before and it worked for other models developed on tonatiuh 2.0.1 but not this one in particular, it didn't work. i intend to extract the csv or polynomial equation in order to use it as a heat source boundary on openFOAM. hence the reason i am trying to post process the result on mathematica. i have my complete case CFD case ready and this is the last bit of the puzzle.

I am guessing ASCII is better quality than Binary so, if i export the ASCII results how do i modify this particular code, shown bellow to read ASCII output?

For[i = 1, i <= numberOfFiles, ++i, fileRawData = BinaryReadList[file[[i]], "Real64", ByteOrdering -> +1]];

i would appreciate some help on this. please have a look at my results. and the mathematica script.

receiverphotonmap.zip screenshot 2016-10-26 09 56 39 screenshot 2016-10-26 09 58 18 screenshot 2016-10-26 10 05 12 screenshot 2016-10-26 10 14 08

ilescener commented 7 years ago

Dear user,

The incident flux distribution calculated through the inside tool seems fine, I guess the issue is in the mathematica file. I don't know the geometry of the receiver, and probably this is the reason why the mathematica file isn't working properly. But before trying to search along the mathematica file I propose you other solution.

As we know, Tonatiuh can export the results according to two ways: SQL_Database or Binary_file. The Binary_file is the best option if we want to post-process the results fast and easy, the data of the specific photons (according to the selected surface and additional information: surfaceSide, etc.) can be read by mathematica with the few lines you mentioned. ASCII is not an available option because the files would be too heavy. However, since you only want the flux distribution in order to calculate some kind of approximated equation, you don't need to post-process the whole photon map. Hence, you can get it exporting it through the flux distribution tool , which has the export option (ASCII format) and then, analyse it with mathematica.

I show you an example, imagine there is a square flat receiver with dimensions 5x5m with the following flux distribution.

prueba

I export the values of flux and the coordinates of the grid, after that, I read the values with mathematica and plot them.

mathematica1

Taking into account the symmetry of the flux, the most suitable seems to be to follow that symmetry. Then, I approximate the values with an exponential function as a function of the radius.

mathematica2

Probably is not the best function for approximating, but this is just an example.

I hope this helps you. The mathematica file and the txt file with the flux exported from Tonatiuh are also attached. Prueba.zip

Regards Iñigo

pokinoi commented 7 years ago

Hello Inigo,

thank you very much for your prompt response, i really appreciate it. however, i have a little fundamental issue i don't know if you have been able to fit a paraboloid on mathematica. i intend the convert the fluxData output into a polynomial equation as a function of the flux with respect to x and y axis as such (hyperbolic paraboloid:

http://mathematica.stackexchange.com/questions/108917/how-can-i-plot-a-paraboloid

http://math.stackexchange.com/questions/1249308/what-is-the-difference-between-an-elliptical-and-circular-paraboloid-3d

please find my script attached.

it works well. i really appreciate your support.

kind regards

10kw.nb.zip

ilescener commented 7 years ago

It's possible to fit any kind of function with Mathematica, if you really need to fit all data respect to x and y, I suggest you to use a kind of two-dimension exponential, in fact, it's similar to a Gaussian. Take a look of the result. two-dimensionexp Attached is the mathematica file. TwoDimensionalExp.zip Regards Iñigo

pokinoi commented 7 years ago

Hello Inigo,

wow graph looks amazing. i needed something much simpler actually but couldn't figure out how to do it on mathematica yet but i was able to do it on excel.

please have a look at the attached picture to see the example. a polynomial as such:

y = 8E+13x6 - 3E+13x5 + 3E+12x4 - 2E+11x3 + 3E+09x2 - 5E+07x + 3E+06

where y represents the heat flux.

kind regards

nas

~$flux-3.xlsx

ilescener commented 7 years ago

I can't open the excel file but yes, you are right. Excel allows to do this kind of things and according to the flux shape I guess that a polynomial as that can fit quite well.

Regards Iñigo

pokinoi commented 7 years ago

Hello Inigo,

Apologies for the delayed response, i now have the result in pdf format flux-3 Sheet2.pdf

kind regards