> --
> You received this message because you are subscribed to the Google Groups
> "Tonatiuh - Monte Carlo ray tracer for the optical simulation of CSP
> systems." group.
> To post to this group, send email to tonatiuh-...@googlegroups.com.
> To unsubscribe from this group, send email to
> tonatiuh-raytra...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/tonatiuh-raytracer?hl=en.
>
>
Best regards,
#Open binary data file.fileName<- file("filePath/fileName.dat", "rb")#Store the power per photon in poerPerPhoton variable.powerPerPhoton <- readBin(fileName, what="numeric", n=1, endian="big")#Create a vector with photons all the information.endOfFile<-FALSE
photonDataphotonData<-vector( mode="numeric")while( !endOfFile ){photon<-readBin(fileName, what="numeric", n=6, endian="big")if( length( photon ) < 6 ) endOfFile = TRUE else photonData<-append( photonData, photon )}#Close the data file.close(fileName)#Compute the number of photons in the vector. all the photon sextuples at a row per #sextuplenPhotons<-length( photonData ) / 6photonMap<-matrix( photonData , nrow= nPhotons, ncol=6, byrow=TRUE )
Best regards,--
#Open binary data file.fileName<- file("/home/mblanco/Documents/rawData_1000000.dat", "rb")#Read the power per photon (Watts per photon) and store its value in the varialbe named: "powerPerPhoton"
powerPerPhoton <- readBin(fileName, what="numeric", n=1, endian="big")
#Read all the photon records in the file and store the information in the vector variable named: "rawData"#As explained in Tonatiuh's website, every photon record is composed of six numbers whith the following structure:# PhotonID x-coordinate y-coordinate z-coordinate PrevPhotonID NextPhotonIDendOfFile<-FALSErawData<-vector( mode="numeric")#To speed up the reading process we read nDataBlock binary numbers per iteration.#Here we are setting nDataBlock = 6 * 10000, to read 10000 photo records per iteration,#You should adjust this value depending on your computer RAM and processing speednDataBlock = 6 * 10000while( !endOfFile ){dataBlock<-readBin(fileName, what="numeric", n=nDataBlock, endian="big")rawData<-append( rawData, dataBlock )if( length( dataBlock ) < nDataBlock ) endOfFile = TRUE
}#Close the data file.close(fileName)
#Transform rawData into a 6-columns photonMap matrix, where each column represents#a given photon data (PhotonID x-coordinate y-coordinate z-coordinate PrevPhotonID NextPhotonID)photonMap<-matrix( rawData, ncol=6, byrow=T )colnames( photonMap )<-c("PhotonID", "x", "y", "z", "PrevPhotonID", "NextPhotonID")#Once the photonMap matrix is constructed, rawData is eliminated to save RAMrawData<-c( )#In this example we are analyzing the set of photons that hit the target of an ideal parabolic dish#the information about those photons were exported from Tonatiuh in the local coordinates of the target#Thus, of the three photons' coordinates only two (x and z) are relevant, since coordinate y,#which is the height above the target plane is zero for all photons that hit the target.#We store the x and z coordinates of each photon in the two-columns matrix xzData, which is a subset of photonMapxzData<-subset( photonMap, select=c("x", "z") );#We define the minimum square that contains all the xzData points, i.e., photonsxzRange<-range(xzData);minTargetSize<-xzRange[2]-xzRange[1];#We divide the height and the width of this square in nBins parts, thus dividing the total area of the square#in nBins * nBins elements of area. Then, we count the number of photons which fall whithin each one of the#area elements by generating a 2D histogram (hist2d)nBins<-150library(gplots)h2d<-hist2d( xzData,same.scale=TRUE, nbins=c(nBins,nBins) )#We calculate the area of the area elements in which we have divided the targetelementSideLength<-minTargetSize/nBinselementArea<-elementSideLength*elementSideLength#We calculate the conversion factor for which we have to multiply the 2D-histogram to transform#its photon count per area element matrix into a flux matrix in units of kW/m2conversionFactor<-(powerPerPhoton/1000)/elementAreafluxMatrix<-h2d$counts*conversionFactor#Once the fluxMatrix is computed we can represent it graphically in several ways, for instance by a contour plotfilled.contour( h2d$x, h2d$y, fluxMatrix, levels=c(0, 0.1, 1000, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000 ), color= rich.colors )range(fluxMatrix)
Dear Mr Chaitanya,
I have created two scripts to analyze the flux at the target of the Parabolic Dish system defined in the tutorial https://code.google.com/p/tonatiuh/wiki/Tutorial_ParabolicDish_V201. After modelling the system, I have simulated it with 1000000 rays. I have only exported the photons related with receiver intersection using local coordinates. I hope these examples will help you to analyze the database created by Tonatiuh as results of your the simulation.
The first script is for analyze the database using Mathematica. Mathematica is not free and if you haven’t got a license you can use the next script, script for R.
The software environment related with the R programming language is open source and you can download it from http://www.r-project.org/, the official website. I have downloaded three libraries to use with the script:
library(RSQLite): to connect and execute SQL sentences using R functions.
library(ash): to create a photons grid with the receiver photons
library(gplots): to show results using plots.
If you open the attached files, you will realize that it is not necessary to use the SQL browser to analyze de simulation data. You can connect to the database from the scripts.
Please contact us if you have any problem with the scripts.