Search in sources :

Example 26 with FresnelReflector

use of org.concord.energy3d.model.FresnelReflector in project energy3d by concord-consortium.

the class SceneManager method update.

@Override
public void update(final ReadOnlyTimer timer) {
    final double tpf = timer.getTimePerFrame();
    passManager.updatePasses(tpf);
    taskManager.getQueue(GameTaskQueue.UPDATE).setExecuteMultiple(executeAllTask);
    taskManager.getQueue(GameTaskQueue.UPDATE).execute(canvas.getCanvasRenderer().getRenderer());
    if (operationFlag) {
        executeOperation();
    }
    if (mouseState != null) {
        mouseMoved();
    }
    if (Scene.isRedrawAll()) {
        Scene.getInstance().redrawAllNow();
    }
    if (rotAnim && viewMode == ViewMode.NORMAL && canvas.getCanvasRenderer() != null) {
        final Matrix3 rotate = new Matrix3();
        rotate.fromAngleNormalAxis(45 * tpf * MathUtils.DEG_TO_RAD, Vector3.UNIT_Z);
        final Camera camera = getCamera();
        camera.setLocation(rotate.applyPre(camera.getLocation(), null));
        camera.lookAt(0, 0, 1, Vector3.UNIT_Z);
        getCameraNode().updateFromCamera();
        Scene.getInstance().updateEditShapes();
    }
    final Heliodon heliodon = Heliodon.getInstance();
    if (heliodon != null) {
        if (sunAnim) {
            heliodon.setHourAngle(heliodon.getHourAngle() + tpf * 0.5, true, true, false);
            SceneManager.getInstance().changeSkyTexture();
            SceneManager.getInstance().setShading(heliodon.isNightTime());
            final boolean night = Heliodon.getInstance().isNightTime();
            for (final HousePart part : Scene.getInstance().getParts()) {
                if (part instanceof Mirror) {
                    final Mirror m = (Mirror) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        m.drawSunBeam();
                    } else {
                        if (m.getReceiver() != null) {
                            m.draw();
                        }
                    }
                } else if (part instanceof ParabolicTrough) {
                    final ParabolicTrough t = (ParabolicTrough) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        t.drawSunBeam();
                    } else {
                        t.draw();
                    }
                } else if (part instanceof ParabolicDish) {
                    final ParabolicDish d = (ParabolicDish) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        d.drawSunBeam();
                    } else {
                        d.draw();
                    }
                } else if (part instanceof FresnelReflector) {
                    final FresnelReflector f = (FresnelReflector) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        f.drawSunBeam();
                    } else {
                        f.draw();
                    }
                } else if (part instanceof SolarPanel) {
                    final SolarPanel sp = (SolarPanel) part;
                    if (!night && sp.getTracker() != Trackable.NO_TRACKER) {
                        sp.draw();
                    }
                    if (sp.isSunBeamVisible()) {
                        sp.drawSunBeam();
                    }
                } else if (part instanceof Rack) {
                    final Rack rack = (Rack) part;
                    if (!night && rack.getTracker() != Trackable.NO_TRACKER) {
                        rack.draw();
                    }
                    if (rack.isSunBeamVisible()) {
                        rack.drawSunBeam();
                    }
                }
            }
        }
        heliodon.update();
    }
    if (cameraControl != null && cameraControl.isAnimating()) {
        cameraControl.animate();
    }
    root.updateGeometricState(tpf);
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) Rack(org.concord.energy3d.model.Rack) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) SolarPanel(org.concord.energy3d.model.SolarPanel) Camera(com.ardor3d.renderer.Camera) Mirror(org.concord.energy3d.model.Mirror) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) Matrix3(com.ardor3d.math.Matrix3) Heliodon(org.concord.energy3d.shapes.Heliodon)

Example 27 with FresnelReflector

use of org.concord.energy3d.model.FresnelReflector in project energy3d by concord-consortium.

the class SolarRadiation method resetTrackables.

public void resetTrackables() {
    Heliodon.getInstance().getCalendar().set(Calendar.HOUR_OF_DAY, hourOfDay);
    Heliodon.getInstance().getCalendar().set(Calendar.MINUTE, minuteOfHour);
    for (final HousePart part : Scene.getInstance().getParts()) {
        if (part instanceof Mirror) {
            final Mirror m = (Mirror) part;
            if (m.getReceiver() != null) {
                m.draw();
            }
        } else if (part instanceof FresnelReflector) {
            final FresnelReflector fr = (FresnelReflector) part;
            if (fr.getReceiver() != null) {
                fr.draw();
            }
        } else if (part instanceof ParabolicTrough) {
            final ParabolicTrough pt = (ParabolicTrough) part;
            pt.draw();
        } else if (part instanceof ParabolicDish) {
            final ParabolicDish pd = (ParabolicDish) part;
            pd.draw();
        } else if (part instanceof SolarPanel) {
            final SolarPanel sp = (SolarPanel) part;
            if (sp.getTracker() != Trackable.NO_TRACKER) {
                sp.draw();
            }
        } else if (part instanceof Rack) {
            final Rack rack = (Rack) part;
            if (rack.getTracker() != Trackable.NO_TRACKER) {
                rack.draw();
            }
        }
    }
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) Rack(org.concord.energy3d.model.Rack) FresnelReflector(org.concord.energy3d.model.FresnelReflector) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) SolarPanel(org.concord.energy3d.model.SolarPanel) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 28 with FresnelReflector

use of org.concord.energy3d.model.FresnelReflector in project energy3d by concord-consortium.

the class SolarRadiation method computeToday.

private void computeToday() {
    // save current calendar for restoring at the end of this calculation
    final Calendar today = (Calendar) Heliodon.getInstance().getCalendar().clone();
    hourOfDay = today.get(Calendar.HOUR_OF_DAY);
    minuteOfHour = today.get(Calendar.MINUTE);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.HOUR_OF_DAY, 0);
    final String city = (String) EnergyPanel.getInstance().getCityComboBox().getSelectedItem();
    dailyAirTemperatures = Weather.computeOutsideTemperature(today, city);
    final int timeStep = Scene.getInstance().getTimeStep();
    final ReadOnlyVector3[] sunLocations = new ReadOnlyVector3[SolarRadiation.MINUTES_OF_DAY / timeStep];
    int totalSteps = 0;
    for (int minute = 0; minute < SolarRadiation.MINUTES_OF_DAY; minute += timeStep) {
        final ReadOnlyVector3 sunLocation = Heliodon.getInstance().computeSunLocation(today).normalizeLocal();
        sunLocations[minute / timeStep] = sunLocation;
        if (sunLocation.getZ() > 0) {
            totalSteps++;
        }
        today.add(Calendar.MINUTE, timeStep);
    }
    totalSteps -= 2;
    final double dayLength = totalSteps * timeStep / 60.0;
    int step = 1;
    setupImportedMeshes();
    // for (int minute = MINUTES_OF_DAY / 2; minute < MINUTES_OF_DAY / 2 + timeStep; minute += timeStep) { // test for 12 pm for comparison with shadow
    for (int minute = 0; minute < MINUTES_OF_DAY; minute += timeStep) {
        final ReadOnlyVector3 sunLocation = sunLocations[minute / timeStep];
        if (sunLocation.getZ() > 0) {
            final ReadOnlyVector3 directionTowardSun = sunLocation.normalize(null);
            calculatePeakRadiation(directionTowardSun, dayLength);
            for (final HousePart part : Scene.getInstance().getParts()) {
                if (part.isDrawCompleted()) {
                    if (part instanceof Window) {
                        computeOnMesh(minute, directionTowardSun, part, part.getRadiationMesh(), (Mesh) part.getRadiationCollisionSpatial(), part.getNormal());
                    } else if (part instanceof Wall) {
                        if (((Wall) part).getType() == Wall.SOLID_WALL) {
                            computeOnMesh(minute, directionTowardSun, part, part.getRadiationMesh(), (Mesh) part.getRadiationCollisionSpatial(), part.getNormal());
                        }
                    } else if (part instanceof Door || part instanceof Floor) {
                        computeOnMesh(minute, directionTowardSun, part, part.getRadiationMesh(), (Mesh) part.getRadiationCollisionSpatial(), part.getNormal());
                    } else if (part instanceof Foundation) {
                        final Foundation foundation = (Foundation) part;
                        for (int i = 0; i < 5; i++) {
                            final Mesh radiationMesh = foundation.getRadiationMesh(i);
                            final ReadOnlyVector3 normal = i == 0 ? part.getNormal() : ((UserData) radiationMesh.getUserData()).getNormal();
                            computeOnMesh(minute, directionTowardSun, part, radiationMesh, foundation.getRadiationCollisionSpatial(i), normal);
                        }
                        if (!Scene.getInstance().getOnlySolarComponentsInSolarMap()) {
                            final List<Node> importedNodes = foundation.getImportedNodes();
                            if (importedNodes != null) {
                                for (final Node node : importedNodes) {
                                    for (final Spatial s : node.getChildren()) {
                                        final Mesh m = (Mesh) s;
                                        computeOnImportedMesh(minute, directionTowardSun, foundation, m);
                                    }
                                }
                            }
                        }
                    } else if (part instanceof Roof) {
                        for (final Spatial roofPart : ((Roof) part).getRoofPartsRoot().getChildren()) {
                            if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
                                final ReadOnlyVector3 faceDirection = (ReadOnlyVector3) roofPart.getUserData();
                                final Mesh mesh = (Mesh) ((Node) roofPart).getChild(6);
                                computeOnMesh(minute, directionTowardSun, part, mesh, mesh, faceDirection);
                            }
                        }
                    } else if (part instanceof SolarPanel) {
                        computeOnSolarPanel(minute, directionTowardSun, (SolarPanel) part);
                    } else if (part instanceof Rack) {
                        computeOnRack(minute, directionTowardSun, (Rack) part);
                    } else if (part instanceof Mirror) {
                        computeOnMirror(minute, directionTowardSun, (Mirror) part);
                    } else if (part instanceof FresnelReflector) {
                        computeOnFresnelReflector(minute, directionTowardSun, (FresnelReflector) part);
                    } else if (part instanceof ParabolicTrough) {
                        computeOnParabolicTrough(minute, directionTowardSun, (ParabolicTrough) part);
                    } else if (part instanceof ParabolicDish) {
                        computeOnParabolicDish(minute, directionTowardSun, (ParabolicDish) part);
                    } else if (part instanceof Sensor) {
                        computeOnSensor(minute, directionTowardSun, (Sensor) part);
                    }
                }
            }
            computeOnLand(directionTowardSun);
            EnergyPanel.getInstance().progress((int) Math.round(100.0 * step / totalSteps));
            step++;
        }
    }
    maxValue = Math.round((MINUTES_OF_DAY / timeStep + 1.0) * (1 - 0.01 * Scene.getInstance().getSolarHeatMapColorContrast()));
    // If tracking the sun, the heliodon's calendar has been changed. Restore the time now.
    resetTrackables();
}
Also used : ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) Wall(org.concord.energy3d.model.Wall) UserData(org.concord.energy3d.model.UserData) Node(com.ardor3d.scenegraph.Node) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) Foundation(org.concord.energy3d.model.Foundation) List(java.util.List) ArrayList(java.util.ArrayList) HousePart(org.concord.energy3d.model.HousePart) Window(org.concord.energy3d.model.Window) Floor(org.concord.energy3d.model.Floor) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Calendar(java.util.Calendar) Mesh(com.ardor3d.scenegraph.Mesh) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) Door(org.concord.energy3d.model.Door) ParabolicDish(org.concord.energy3d.model.ParabolicDish) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Spatial(com.ardor3d.scenegraph.Spatial) SolarPanel(org.concord.energy3d.model.SolarPanel) Mirror(org.concord.energy3d.model.Mirror) Sensor(org.concord.energy3d.model.Sensor)

Example 29 with FresnelReflector

use of org.concord.energy3d.model.FresnelReflector in project energy3d by concord-consortium.

the class SolarRadiation method computeEnergyAtHour.

public void computeEnergyAtHour(final int hour) {
    final Calendar today = Heliodon.getInstance().getCalendar();
    final String city = (String) EnergyPanel.getInstance().getCityComboBox().getSelectedItem();
    final double[] outsideAirTemperatureRange = Weather.computeOutsideTemperature(today, city);
    final double outsideAirTemperature = Weather.getInstance().getOutsideTemperatureAtMinute(outsideAirTemperatureRange[1], outsideAirTemperatureRange[0], hour * 60);
    for (final HousePart part : Scene.getInstance().getParts()) {
        if (part instanceof Foundation) {
            final Foundation foundation = (Foundation) part;
            if (foundation.getHeatLoss() == null) {
                continue;
            }
            final int n = (int) Math.round(60.0 / Scene.getInstance().getTimeStep());
            final double[] heatLoss = new double[n];
            final double[] passiveSolar = new double[n];
            final double[] photovoltaic = new double[n];
            final double[] csp = new double[n];
            final int t0 = n * hour;
            for (int i = 0; i < n; i++) {
                final double groundHeatLoss = foundation.getHeatLoss()[t0 + i];
                if (groundHeatLoss > 0) {
                    final double thermostat = foundation.getThermostat().getTemperature(today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY, today.get(Calendar.HOUR_OF_DAY));
                    if (outsideAirTemperature >= thermostat) {
                        heatLoss[i] -= groundHeatLoss;
                    }
                } else {
                    heatLoss[i] += groundHeatLoss;
                }
            }
            double solarPotentialTotal = 0.0;
            for (final HousePart child : Scene.getInstance().getParts()) {
                if (child.getTopContainer() == foundation) {
                    child.setSolarPotentialNow(0);
                    if (child instanceof SolarCollector) {
                        ((SolarCollector) child).setYieldNow(0);
                    }
                    for (int i = 0; i < n; i++) {
                        solarPotentialTotal += child.getSolarPotential()[t0 + i];
                        child.setSolarPotentialNow(child.getSolarPotentialNow() + child.getSolarPotential()[t0 + i]);
                        if (child instanceof Wall || child instanceof Door || child instanceof Window || child instanceof Roof) {
                            heatLoss[i] += child.getHeatLoss()[t0 + i];
                        }
                        if (child instanceof Window) {
                            final Window window = (Window) child;
                            passiveSolar[i] += window.getSolarPotential()[t0 + i] * window.getSolarHeatGainCoefficient();
                        } else if (child instanceof Mirror) {
                            final Mirror mirror = (Mirror) child;
                            final double yield = mirror.getSolarPotential()[t0 + i] * mirror.getSystemEfficiency();
                            csp[i] += yield;
                            mirror.setYieldNow(mirror.getYieldNow() + yield);
                        } else if (child instanceof ParabolicTrough) {
                            final ParabolicTrough trough = (ParabolicTrough) child;
                            final double yield = trough.getSolarPotential()[t0 + i] * trough.getSystemEfficiency();
                            csp[i] += yield;
                            trough.setYieldNow(trough.getYieldNow() + yield);
                        } else if (child instanceof ParabolicDish) {
                            final ParabolicDish dish = (ParabolicDish) child;
                            final double yield = dish.getSolarPotential()[t0 + i] * dish.getSystemEfficiency();
                            csp[i] += yield;
                            dish.setYieldNow(dish.getYieldNow() + yield);
                        } else if (child instanceof FresnelReflector) {
                            final FresnelReflector reflector = (FresnelReflector) child;
                            final double yield = reflector.getSolarPotential()[t0 + i] * reflector.getSystemEfficiency();
                            csp[i] += yield;
                            reflector.setYieldNow(reflector.getYieldNow() + yield);
                        } else if (child instanceof SolarPanel) {
                            final SolarPanel sp = (SolarPanel) child;
                            // distributed efficiency must be handled for each individual cell
                            final double yield = sp.getSolarPotential()[t0 + i];
                            photovoltaic[i] += yield;
                            sp.setYieldNow(sp.getYieldNow() + yield);
                        } else if (child instanceof Rack) {
                            final Rack rack = (Rack) child;
                            if (rack.isMonolithic()) {
                                // distributed efficiency must be handled for each individual cell
                                final double yield = rack.getSolarPotential()[t0 + i];
                                photovoltaic[i] += yield;
                                rack.setYieldNow(rack.getYieldNow() + yield);
                            }
                        }
                    }
                }
            }
            double heatingTotal = 0.0;
            double coolingTotal = 0.0;
            double passiveSolarTotal = 0.0;
            double photovoltaicTotal = 0.0;
            double cspTotal = 0.0;
            for (int i = 0; i < n; i++) {
                if (heatLoss[i] < 0) {
                    heatLoss[i] -= passiveSolar[i];
                } else {
                    heatLoss[i] = Math.max(0, heatLoss[i] - passiveSolar[i]);
                }
                if (heatLoss[i] > 0) {
                    heatingTotal += heatLoss[i];
                } else {
                    coolingTotal -= heatLoss[i];
                }
                passiveSolarTotal += passiveSolar[i];
                photovoltaicTotal += photovoltaic[i];
                cspTotal += csp[i];
            }
            foundation.setSolarPotentialNow(solarPotentialTotal);
            foundation.setPassiveSolarNow(passiveSolarTotal);
            foundation.setPhotovoltaicNow(photovoltaicTotal);
            foundation.setCspNow(cspTotal);
            foundation.setHeatingNow(heatingTotal);
            foundation.setCoolingNow(coolingTotal);
            foundation.setTotalEnergyNow(heatingTotal + coolingTotal - photovoltaicTotal);
        }
    }
}
Also used : Window(org.concord.energy3d.model.Window) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Wall(org.concord.energy3d.model.Wall) Calendar(java.util.Calendar) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) Door(org.concord.energy3d.model.Door) ParabolicDish(org.concord.energy3d.model.ParabolicDish) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) SolarCollector(org.concord.energy3d.model.SolarCollector) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 30 with FresnelReflector

use of org.concord.energy3d.model.FresnelReflector in project energy3d by concord-consortium.

the class FresnelReflectorAnnualAnalysis method show.

public void show() {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    String s = null;
    int cost = -1;
    String title = "Annual Yield of All Fresnel Reflectors (" + Scene.getInstance().countParts(FresnelReflector.class) + " Fresnel Reflectors)";
    if (selectedPart != null) {
        if (selectedPart instanceof FresnelReflector) {
            cost = (int) CspProjectCost.getPartCost(selectedPart);
            s = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
            title = "Annual Yield";
        } else if (selectedPart instanceof Foundation) {
            title = "Annual Yield of Selected Foundation (" + ((Foundation) selectedPart).countParts(FresnelReflector.class) + " Fresnel Reflectors)";
        } else if (selectedPart.getTopContainer() instanceof Foundation) {
            title = "Annual Yield of Selected Foundation (" + selectedPart.getTopContainer().countParts(FresnelReflector.class) + " Fresnel Reflectors)";
        }
    }
    final JDialog dialog = createDialog(s == null ? title : title + ": " + s + " (Cost: $" + cost + ")");
    final JMenuBar menuBar = new JMenuBar();
    dialog.setJMenuBar(menuBar);
    menuBar.add(createOptionsMenu(dialog, null, true, true));
    menuBar.add(createRunsMenu());
    dialog.setVisible(true);
}
Also used : FresnelReflector(org.concord.energy3d.model.FresnelReflector) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar)

Aggregations

FresnelReflector (org.concord.energy3d.model.FresnelReflector)48 HousePart (org.concord.energy3d.model.HousePart)32 Foundation (org.concord.energy3d.model.Foundation)25 Mirror (org.concord.energy3d.model.Mirror)21 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)18 ParabolicDish (org.concord.energy3d.model.ParabolicDish)17 Rack (org.concord.energy3d.model.Rack)16 SolarPanel (org.concord.energy3d.model.SolarPanel)14 Window (org.concord.energy3d.model.Window)14 Wall (org.concord.energy3d.model.Wall)12 Door (org.concord.energy3d.model.Door)9 Roof (org.concord.energy3d.model.Roof)9 ArrayList (java.util.ArrayList)8 Calendar (java.util.Calendar)5 JDialog (javax.swing.JDialog)5 SolarCollector (org.concord.energy3d.model.SolarCollector)5 List (java.util.List)4 Human (org.concord.energy3d.model.Human)4 Tree (org.concord.energy3d.model.Tree)4 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)3