Group Abstract Group Abstract

Message Boards Message Boards

Problem with graphics rendering from data file Mathematica Code

Posted 10 years ago

Hello good afternoon. I am representing a 3D graphic impact on the amount of photons on a surface and I have found that the flow distribution has a shape that does not correspond to the 3D graph. I attached pictures of the obtained and used Mathematica code Thanks you very much for your attention.

side[{photonID_, x_, y_, z_, sideID_}, refSide_] := sideID == refSide
file = FileNames["Receiver_*.dat"];
numberOfFiles = Length[file]
rReceiver = 0.045(*m*);
powerPerPhoton = 0.000348468 (*W/m2*);
nElements = 100;
ds = (2 rReceiver)/nElements (*m*);
dx = (2 rReceiver)/(nElements - 1) (*m*);
elementArea = ds*ds (*m^2*);
totalPhotonsCounts = ConstantArray[0, {nElements, nElements}];
totalNumberOfPhotons = 0;
totalNumberOfPhotonsX = 0;
totalPhotonsCountsX = ConstantArray[0, {nElements}];
rMin = 0.;
conversionFactor = powerPerPhoton/(elementArea*1000) (*MW/m2*);
For[i = 1, i <= numberOfFiles, ++i,
fileRawData = BinaryReadList[file[[i]], "Real64", ByteOrdering -> +1];
filePhotonSet = Partition[fileRawData[[1 ;; Length[fileRawData]]], 5];

Clear[fileRawData];
fileValidPhoton =Select[filePhotonSet, side[#, 0] &] /. {photonID_, x_, y_, z_, sideID_} -> {x, z};
fileValidPhotonX = Select[filePhotonSet,side[#, 0] &] /. {photonID_, x_, y_, z_, sideID_} -> {x};
Clear[filePhotonSet];
Print["Iteration # ", i, ". Processing file: ", file[[i]]] ;
     fileNumberOfValidPhotons = Length[fileValidPhoton];
     totalNumberOfPhotons = totalNumberOfPhotons + Length[fileValidPhoton];
     totalNumberOfPhotonsX = totalNumberOfPhotonsX + Length[fileValidPhotonX];

     filePhotonCounts =BinCounts[ fileValidPhoton, {-rReceiver, rReceiver, ds}, {-rReceiver, 
        rReceiver, ds}];
     filePhotonCountsX =  BinCounts[fileValidPhotonX, {-rReceiver, rReceiver, ds}];
     Clear[fileValidPhoton];
     totalPhotonsCounts = totalPhotonsCounts + filePhotonCounts;
     totalPhotonsCountsX = totalPhotonsCountsX + filePhotonCountsX;
     Clear[fileValidPhotonX];
     Clear[filePhotonCounts]
     Clear[filePhotonCountsX]]


    estimatedPowerAtReceiver =  powerPerPhoton totalNumberOfPhotons/1000 (*kW*)
fluxDistribution = conversionFactor*totalPhotonsCounts;
f2 = conversionFactor*totalPhotonsCountsX;
X = Range[-rReceiver, rReceiver, dx];

Grafico = Thread[{X, f2}];
ListPlot[Grafico, Axes -> False]
ListContourPlot[fluxDistribution, Contours -> 10,  DataRange -> {{-0.04, 0.04}, {-0.04, 0.04}}]
ListDensityPlot[fluxDistribution, PlotTheme -> "Business", Mesh -> 20, MeshFunctions -> Automatic,  DataRange -> {{-0.04, 0.04}, {-0.04, 0.04}}]
ListPlot3D[fluxDistribution, InterpolationOrder -> 10, Mesh -> None, DataRange -> {{-0.04, 0.04}, {-0.04, 0.04}}]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use