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

Photon Mapping for CAD surface #91

Open george-94 opened 7 years ago

george-94 commented 7 years ago

I have been running a script with no errors on a model created on tonatiuh. However, when I recreated the model and imported it as a CAD surface, the script continues to work fine but the selected surfaces do not save/export the photon map (no .dat file is created). Is there a different way to export CAD surfaces for photon mapping ?

This is the script I am running:

tonatiuh.Open("C:/Users/george/Desktop/solarus simulations/Model.tnh" );

for( var a= 0; a<=180; a=a+10 ){

aa = 90 + a;

for( var e= 0; e<=180; e=e+10){ ee = -90 + e;

var Flat_RectangleB = "//SunNode/Ynode/Xnode/Absorber/Top/TShapeKit1" tonatiuh.AddExportSurfaceURL(Flat_RectangleB);

var Flat_RectangleF = "//SunNode/Ynode/Xnode/Absorber/Bottom/TShapeKit1" tonatiuh.AddExportSurfaceURL(Flat_RectangleF);

//First define latitude and then longitude tonatiuh.ChangeSunPosition ( aa, ee);

/Define ray tracing options/ //Number of rays to trace into each iteration tonatiuh.SetRaysPerIteration( 10000); //Sun divisions. tonatiuh.SetRayCastingGrid( 200, 200 ); //type of random tonatiuh.SetRandomDeviateType("Mersenne Twister"); //Draw options tonatiuh.SetRaysDrawingOptions( false,false ); //Buffer size //tonatiuh.SetPhotonMapBufferSize( 5000000 );

/Define export parameters/ //The simulation will be saved into a SQL_Database file tonatiuh.SetExportPhotonMapType("Binary_file"); //The coordinates will be saved into target local coordinates tonatiuh.SetExportCoordinates( true, false); //The intersection surface will not saved because only target photons will be saved. tonatiuh. SetExportIntersectionSurface(true); //The surface side will also be saved tonatiuh.SetExportIntersectionSurfaceSide( true ); //Previous and next data is needed tonatiuh.SetExportPreviousNextPhotonID( true ); //Flat_Rectangle photons will be saved. //You must define the URL path to Surface node

//Define the directory to SQLDatabase files, the files names and the size in photons for the files. //To define the export directory and file you have to use the function two times. //Use different le name to save the results of each simulation. var exportDir = "C:/Users/george/Desktop/solarus simulations/iam model"; tonatiuh.SetExportTypeParameterValue( "ExportDirectory", exportDir ); var fileName = "IAM1"; tonatiuh.SetExportTypeParameterValue( "ExportFile", fileName.concat("", aa,"_", ee.toString() ) ); //Increments the photon map for tuned iterations. tonatiuh.SetIncreasePhotonMap( false );

tonatiuh.Run();

}}

ilescener commented 7 years ago

Dear george-94

The script you are running looks fine and apparently it doesn't content any spelling errors or wrong use of functions.

Probably the Tonatiuh model may have some mistakes, such as, materials assignation, reflection values, etc. If you want you can send me (iles@cener.com) the Tonatiuh file and I will do a deeper check.

Kind regards

george-94 commented 7 years ago

Thank you, I will do that

ilescener commented 7 years ago

Dear George,

I found the issue. There was a silly mistake in the script, the paths to the surfaces were bad written.

var Flat_RectangleB = "//SunNode/Ynode/Xnode/Absorber/Top/cell2/TShapeKit1"
var Flat_RectangleF = "//SunNode/Ynode/Xnode/Absorber/Bottom/cell2/TShapeKit1" 

If you look at the node tree these paths must be like this:

//SunNode/Ynode/Xnode/Aborber/Top/TShapeKit1
//SunNode/Ynode/Xnode/Aborber/Bottom/TShapeKit1

Kind regards Iñigo

george-94 commented 7 years ago

Dear Iñigo,

Thank you for your response. I think I sent you the wrong script because the paths were correct originally, however I made the changes to paths in the current script as you mentioned. Even with the correct path, it produces .txt files in the export directory but not the .dat files containing the photon map. However, I found that if I create an sql file and choose the surfaces to be exported first (in the photon map export settings) and then run the script, for some reason it works properly. Do you know why this is the case ?

Best Regards,

George


From: ilescener notifications@github.com Sent: 29 June 2017 16:44 To: iat-cener/tonatiuh Cc: george-94; Author Subject: Re: [iat-cener/tonatiuh] Photon Mapping for CAD surface (#91)

Dear George,

I found the issue. There was a silly mistake in the script, the paths to the surfaces were bad written.

var Flat_RectangleB = "//SunNode/Ynode/Xnode/Absorber/Top/cell2/TShapeKit1" var Flat_RectangleF = "//SunNode/Ynode/Xnode/Absorber/Bottom/cell2/TShapeKit1"

If you look at the node tree these paths must be like this:

//SunNode/Ynode/Xnode/Aborber/Top/TShapeKit1 //SunNode/Ynode/Xnode/Aborber/Bottom/TShapeKit1

Kind regards Iñigo

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/iat-cener/tonatiuh/issues/91#issuecomment-311988814, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AcVtm1981SNjhlF2Is4GT3PeaLn6VrrLks5sI7g8gaJpZM4OFzGu.

ilescener commented 7 years ago

It sounds weird. But for example, if any ray achieves to these surfaces then there will not be a .dat file, because there's no information to store and this may happen depending on the sun position. Anyway, I will write what is happening down and will do a further inspection if it happens more frequently.

Kind regards Iñigo

george-94 commented 7 years ago

Thank you for your help.

Best Regards,

George


From: ilescener notifications@github.com Sent: 30 June 2017 08:36 To: iat-cener/tonatiuh Cc: george-94; Author Subject: Re: [iat-cener/tonatiuh] Photon Mapping for CAD surface (#91)

It sounds weird. But for example, if any ray achieves to these surfaces then there will not be a .dat file, because there's no information to store and this may happen depending on the sun position. Anyway, I will write what is happening down and will do a further inspection if it happens more frequently.

Kind regards Iñigo

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/iat-cener/tonatiuh/issues/91#issuecomment-312187620, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AcVtm8yKE_O4em_6BUdiN87XB27O0QB_ks5sJJdfgaJpZM4OFzGu.

ChileNeverDie commented 5 years ago

Sorry, I have some similar problem, when I created some .stl model to import into Tonatiuh, the software will not recognize it as a surface, would you please share how you make it happen that you exported the phantom file from the CAD surface?