Skip to content

Commit

Permalink
Delete parameter for numberSimulation #47
Browse files Browse the repository at this point in the history
We will fully focus on sky domes from now on.
NumberSimulations only makes sense if we neglect diffuse radiance,
which we cannot do anymore.
  • Loading branch information
FlorianK13 committed Oct 25, 2024
1 parent 74bf61a commit 965ce9d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 29 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ scene.addShadingGeometry(someShadingGeometry);
scene.addSimulationGeometry(someSimulationGeometry);

let mesh = await scene.calculate({
numberSimulations: 100,
diffuseIrradiance: "https://www.openpv.de/data/irradiance",
urlDirectIrrandianceTIF:
"https://www.openpv.de/data/irradiance/geotiff/average_direct_radiation.tif",
urlDiffuseIrrandianceTIF:
"https://www.openpv.de/data/irradiance/geotiff/average_diffuse_radiation.tif",
diffuseIrradiance: 'https://www.openpv.de/data/irradiance',
urlDirectIrrandianceTIF: 'https://www.openpv.de/data/irradiance/geotiff/average_direct_radiation.tif',
urlDiffuseIrrandianceTIF: 'https://www.openpv.de/data/irradiance/geotiff/average_diffuse_radiation.tif',
});

showThreeJS(mesh);
Expand Down
20 changes: 4 additions & 16 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export class ShadingScene {

async calculate(params: CalculateParams = {}) {
const {
numberSimulations = 80,
diffuseIrradianceURL,
pvCellEfficiency = 0.2,
maxYieldPerSquareMeter = 1400 * 0.2,
Expand Down Expand Up @@ -195,17 +194,12 @@ export class ShadingScene {
const doDiffuseIntensities = typeof diffuseIrradianceURL === 'string';
const simulationRounds = doDiffuseIntensities ? 2 : 1;

const directIntensities = await this.rayTrace(
midpointsArray,
normalsArray,
meshArray,
numberSimulations,
undefined,
(i, total) => progressCallback(i, total * simulationRounds),
const directIntensities = await this.rayTrace(midpointsArray, normalsArray, meshArray, undefined, (i, total) =>
progressCallback(i, total * simulationRounds),
);
let diffuseIntensities = new Float32Array();
if (doDiffuseIntensities) {
diffuseIntensities = await this.rayTrace(midpointsArray, normalsArray, meshArray, 0, diffuseIrradianceURL, (i, total) =>
diffuseIntensities = await this.rayTrace(midpointsArray, normalsArray, meshArray, diffuseIrradianceURL, (i, total) =>
progressCallback(i + total, total * simulationRounds),
);
}
Expand Down Expand Up @@ -259,7 +253,6 @@ export class ShadingScene {
* @param midpoints midpoints of triangles for which to calculate intensities
* @param normals normals for each midpoint
* @param meshArray array of vertices for the shading mesh
* @param numberSimulations number of random sun positions that are used for the simulation. Either numberSimulations or irradianceUrl need to be given.
* @param diffuseIrradianceUrl url where a 2D json of irradiance values lies. To generate such a json, visit https://github.com/open-pv/irradiance
* @return
* @memberof Scene
Expand All @@ -268,7 +261,6 @@ export class ShadingScene {
midpoints: Float32Array,
normals: TypedArray,
meshArray: Float32Array,
numberSimulations: number,
diffuseIrradianceUrl: string | undefined,
progressCallback: (progress: number, total: number) => void,
) {
Expand All @@ -281,12 +273,8 @@ export class ShadingScene {
irradiance = sun.convertSpericalToEuclidian(diffuseIrradianceSpherical);
} else if (typeof diffuseIrradianceUrl != 'undefined') {
throw new Error('The given url for diffuse Irradiance is not valid.');
} else if (numberSimulations > 0) {
irradiance = sun.getRandomSunVectors(numberSimulations, this.latitude, this.longitude);
} else {
throw new Error(
'No irradiance found for the simulation. Either give a valid URL for diffuse radiation or a numberSimulation > 0.',
);
throw new Error('No irradiance found for the simulation.');
}

if (this.elevationRaster.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/rayTracingWebGL.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TypedArray } from 'three';
import { Point, SunVector, timeoutForLoop } from './utils';
import { SunVector, timeoutForLoop } from './utils';

function addToArray(ar1: Float32Array, ar2: Float32Array) {
for (var i = 0; i < ar1.length; i++) {
Expand Down
6 changes: 0 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ export type ColorMap = (t: number) => Color;
* Interface for the parameter object for {@link index.ShadingScene.calculate}
*/
export interface CalculateParams {
/**
* Number of random sun positions that are used to calculate the PV yield.
* @defaultValue 80
*/
numberSimulations?: number;

/**
* URL where the files for the diffuse Irradiance can be retreived.
* The object at this URL needs to be of type {@link SolarIrradianceData}.
Expand Down

0 comments on commit 965ce9d

Please sign in to comment.