Search in sources :

Example 56 with SolarPanel

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

the class PvDailyAnalysis method updateGraph.

@Override
public void updateGraph() {
    for (int i = 0; i < 24; i++) {
        SolarRadiation.getInstance().computeEnergyAtHour(i);
        final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
        if (selectedPart != null) {
            if (selectedPart instanceof SolarPanel) {
                graph.addData("Solar", ((SolarPanel) selectedPart).getYieldNow());
            } else if (selectedPart instanceof Rack) {
                graph.addData("Solar", ((Rack) selectedPart).getYieldNow());
            } else if (selectedPart instanceof Foundation) {
                double output = 0;
                for (final HousePart p : Scene.getInstance().getParts()) {
                    if (p.getTopContainer() == selectedPart) {
                        if (p instanceof SolarPanel) {
                            output += ((SolarPanel) p).getYieldNow();
                        } else if (p instanceof Rack) {
                            output += ((Rack) p).getYieldNow();
                        }
                    }
                }
                graph.addData("Solar", output);
            } else if (selectedPart.getTopContainer() instanceof Foundation) {
                double output = 0;
                for (final HousePart p : Scene.getInstance().getParts()) {
                    if (p.getTopContainer() == selectedPart.getTopContainer()) {
                        if (p instanceof SolarPanel) {
                            output += ((SolarPanel) p).getYieldNow();
                        } else if (p instanceof Rack) {
                            output += ((Rack) p).getYieldNow();
                        }
                    }
                }
                graph.addData("Solar", output);
            }
        } else {
            double output = 0;
            for (final HousePart p : Scene.getInstance().getParts()) {
                if (p instanceof SolarPanel) {
                    output += ((SolarPanel) p).getYieldNow();
                } else if (p instanceof Rack) {
                    output += ((Rack) p).getYieldNow();
                }
            }
            graph.addData("Solar", output);
        }
    }
    graph.repaint();
}
Also used : Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Example 57 with SolarPanel

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

the class PvDailyAnalysis method toJson.

@Override
public String toJson() {
    String s = "{";
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart != null) {
        if (selectedPart instanceof SolarPanel) {
            s += "\"Panel\": \"" + selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1) + "\"";
        } else if (selectedPart instanceof Rack) {
            s += "\"Rack\": \"" + selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1) + "\"";
        } else if (selectedPart instanceof Foundation) {
            s += "\"Foundation\": \"" + selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1) + "\"";
        } else if (selectedPart.getTopContainer() instanceof Foundation) {
            s += "\"Foundation\": \"" + selectedPart.getTopContainer().toString().substring(0, selectedPart.getTopContainer().toString().indexOf(')') + 1) + "\"";
        }
    } else {
        s += "\"Panel\": \"All\"";
    }
    final String name = "Solar";
    final List<Double> data = graph.getData(name);
    s += ", \"" + name + "\": {";
    s += "\"Hourly\": [";
    if (data != null) {
        for (final Double x : data) {
            s += Graph.FIVE_DECIMALS.format(x) + ",";
        }
        s = s.substring(0, s.length() - 1);
    }
    s += "]\n";
    s += ", \"Total\": " + Graph.ENERGY_FORMAT.format(getResult(name));
    s += "}";
    s += "}";
    return s;
}
Also used : Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Example 58 with SolarPanel

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

the class PvProjectCost method showPieChart.

@Override
void showPieChart() {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    final Foundation selectedFoundation;
    if (selectedPart == null || selectedPart instanceof Tree || selectedPart instanceof Human) {
        selectedFoundation = null;
    } else if (selectedPart instanceof Foundation) {
        selectedFoundation = (Foundation) selectedPart;
    } else {
        selectedFoundation = selectedPart.getTopContainer();
        selectedPart.setEditPointsVisible(false);
        SceneManager.getInstance().setSelectedPart(selectedFoundation);
    }
    String details = "";
    int count = 0;
    for (final HousePart p : Scene.getInstance().getParts()) {
        if (p instanceof Foundation) {
            count++;
            if (selectedFoundation == null) {
                final Foundation foundation = (Foundation) p;
                details += "$" + (int) getCostByFoundation(foundation) + " (" + foundation.getId() + ") | ";
            }
        }
    }
    if (selectedFoundation == null) {
        if (count > 0) {
            details = details.substring(0, details.length() - 2);
        }
    }
    double landSum = 0;
    double solarPanelSum = 0;
    String info;
    if (selectedFoundation != null) {
        info = "Zone #" + selectedFoundation.getId();
        landSum = getPartCost(selectedFoundation);
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p.getTopContainer() == selectedFoundation) {
                if (p instanceof SolarPanel || p instanceof Rack) {
                    solarPanelSum += getPartCost(p);
                }
            }
        }
    } else {
        info = count + " zones";
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p instanceof Foundation) {
                landSum += getPartCost(p);
            } else if (p instanceof SolarPanel || p instanceof Rack) {
                solarPanelSum += getPartCost(p);
            }
        }
    }
    final double[] data = new double[] { landSum, solarPanelSum };
    final String[] legends = new String[] { "Land (" + Scene.getInstance().getPvCustomPrice().getLifespan() + " years)", "Solar Panels" };
    // show them in a popup window
    final PieChart pie = new PieChart(data, PvProjectCostGraph.colors, legends, "$", info, count > 1 ? details : null, true);
    pie.setBackground(Color.WHITE);
    pie.setBorder(BorderFactory.createEtchedBorder());
    final JDialog dialog = new JDialog(MainFrame.getInstance(), "Project Costs by Category", true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.getContentPane().add(pie, BorderLayout.CENTER);
    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final JButton buttonClose = new JButton("Close");
    buttonClose.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            dialog.dispose();
        }
    });
    buttonPanel.add(buttonClose);
    dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setLocationRelativeTo(MainFrame.getInstance());
    dialog.setVisible(true);
}
Also used : Human(org.concord.energy3d.model.Human) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Rack(org.concord.energy3d.model.Rack) ActionListener(java.awt.event.ActionListener) SolarPanel(org.concord.energy3d.model.SolarPanel) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog)

Example 59 with SolarPanel

use of org.concord.energy3d.model.SolarPanel 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 60 with SolarPanel

use of org.concord.energy3d.model.SolarPanel 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)

Aggregations

SolarPanel (org.concord.energy3d.model.SolarPanel)109 Rack (org.concord.energy3d.model.Rack)66 HousePart (org.concord.energy3d.model.HousePart)58 Foundation (org.concord.energy3d.model.Foundation)43 Window (org.concord.energy3d.model.Window)25 Roof (org.concord.energy3d.model.Roof)24 Wall (org.concord.energy3d.model.Wall)23 Mirror (org.concord.energy3d.model.Mirror)20 Door (org.concord.energy3d.model.Door)17 FresnelReflector (org.concord.energy3d.model.FresnelReflector)14 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)14 ActionEvent (java.awt.event.ActionEvent)13 ActionListener (java.awt.event.ActionListener)13 ParabolicDish (org.concord.energy3d.model.ParabolicDish)13 Vector3 (com.ardor3d.math.Vector3)11 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)11 JMenuItem (javax.swing.JMenuItem)10 JDialog (javax.swing.JDialog)9 JPanel (javax.swing.JPanel)9 Tree (org.concord.energy3d.model.Tree)9