Search in sources :

Example 36 with FresnelReflector

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

the class GroupDailyAnalysis method updateGraph.

@Override
public void updateGraph() {
    final int n = (int) Math.round(60.0 / Scene.getInstance().getTimeStep());
    for (int i = 0; i < 24; i++) {
        SolarRadiation.getInstance().computeEnergyAtHour(i);
        for (final HousePart p : selectedParts) {
            final String customText = p.getLabelCustomText();
            if (p instanceof Window) {
                final Window window = (Window) p;
                final double solar = p.getSolarPotentialNow() * window.getSolarHeatGainCoefficient();
                graph.addData("Solar " + p.getId(), solar);
                final double[] loss = p.getHeatLoss();
                final int t0 = n * i;
                double sum = 0;
                for (int k = t0; k < t0 + n; k++) {
                    sum += loss[k];
                }
                graph.addData("Heat Gain " + p.getId(), -sum);
            } else if (p instanceof Wall || p instanceof Roof) {
                final double[] loss = p.getHeatLoss();
                final int t0 = n * i;
                double sum = 0;
                for (int k = t0; k < t0 + n; k++) {
                    sum += loss[k];
                }
                graph.addData("Heat Gain " + p.getId(), -sum);
            } else if (p instanceof SolarPanel) {
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, ((SolarPanel) p).getYieldNow());
                } else {
                    graph.addData("Solar " + p.getId(), ((SolarPanel) p).getYieldNow());
                }
            } else if (p instanceof Rack) {
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, ((Rack) p).getYieldNow());
                } else {
                    graph.addData("Solar " + p.getId(), ((Rack) p).getYieldNow());
                }
            } else if (p instanceof Mirror) {
                final Mirror mirror = (Mirror) p;
                final double solar = mirror.getSolarPotentialNow() * mirror.getSystemEfficiency();
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, solar);
                } else {
                    graph.addData("Solar " + p.getId(), solar);
                }
            } else if (p instanceof ParabolicTrough) {
                final ParabolicTrough trough = (ParabolicTrough) p;
                final double solar = trough.getSolarPotentialNow() * trough.getSystemEfficiency();
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, solar);
                } else {
                    graph.addData("Solar " + p.getId(), solar);
                }
            } else if (p instanceof ParabolicDish) {
                final ParabolicDish dish = (ParabolicDish) p;
                final double solar = dish.getSolarPotentialNow() * dish.getSystemEfficiency();
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, solar);
                } else {
                    graph.addData("Solar " + p.getId(), solar);
                }
            } else if (p instanceof FresnelReflector) {
                final FresnelReflector reflector = (FresnelReflector) p;
                final double solar = reflector.getSolarPotentialNow() * reflector.getSystemEfficiency();
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, solar);
                } else {
                    graph.addData("Solar " + p.getId(), solar);
                }
            } else if (p instanceof Foundation) {
                final boolean mean = group.getType().endsWith("(Mean)");
                final Foundation foundation = (Foundation) p;
                switch(foundation.getProjectType()) {
                    case Foundation.TYPE_PV_PROJECT:
                        double pv = foundation.getPhotovoltaicNow();
                        if (mean) {
                            pv /= foundation.getNumberOfSolarPanels();
                            if (customText != null) {
                                graph.addData("PV " + p.getId() + graph.getDataNameDelimiter() + customText + " mean", pv);
                            } else {
                                graph.addData("PV " + p.getId() + " mean", pv);
                            }
                        } else {
                            if (customText != null) {
                                graph.addData("PV " + p.getId() + graph.getDataNameDelimiter() + customText, pv);
                            } else {
                                graph.addData("PV " + p.getId(), pv);
                            }
                        }
                        break;
                    case Foundation.TYPE_CSP_PROJECT:
                        double csp = foundation.getCspNow();
                        if (mean) {
                            csp /= foundation.countParts(new Class[] { Mirror.class, ParabolicTrough.class, ParabolicDish.class });
                            if (customText != null) {
                                graph.addData("CSP " + p.getId() + graph.getDataNameDelimiter() + customText + " mean", csp);
                            } else {
                                graph.addData("CSP " + p.getId() + " mean", csp);
                            }
                        } else {
                            if (customText != null) {
                                graph.addData("CSP " + p.getId() + graph.getDataNameDelimiter() + customText, csp);
                            } else {
                                graph.addData("CSP " + p.getId(), csp);
                            }
                        }
                        break;
                    case Foundation.TYPE_BUILDING:
                        final double totalEnergy = foundation.getTotalEnergyNow();
                        graph.addData("Building " + p.getId(), totalEnergy);
                        break;
                }
            }
        }
    }
    graph.repaint();
}
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) ParabolicDish(org.concord.energy3d.model.ParabolicDish) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) 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 37 with FresnelReflector

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

the class CspProjectCost 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) {
            final Foundation foundation = (Foundation) p;
            if (!foundation.hasSolarReceiver()) {
                count++;
                if (selectedFoundation == null) {
                    double receiverSum = 0;
                    final List<Mirror> mirrors = foundation.getHeliostats();
                    if (!mirrors.isEmpty()) {
                        final ArrayList<Foundation> towers = new ArrayList<Foundation>();
                        for (final Mirror m : mirrors) {
                            if (m.getReceiver() != null) {
                                if (!towers.contains(m.getReceiver())) {
                                    towers.add(m.getReceiver());
                                }
                            }
                        }
                        if (!towers.isEmpty()) {
                            for (final Foundation tower : towers) {
                                receiverSum += getPartCost(tower);
                            }
                        }
                    } else {
                        final List<FresnelReflector> reflectors = foundation.getFresnelReflectors();
                        if (!reflectors.isEmpty()) {
                            final ArrayList<Foundation> absorbers = new ArrayList<Foundation>();
                            for (final FresnelReflector r : reflectors) {
                                if (r.getReceiver() != null) {
                                    if (!absorbers.contains(r.getReceiver())) {
                                        absorbers.add(r.getReceiver());
                                    }
                                }
                            }
                            if (!absorbers.isEmpty()) {
                                for (final Foundation absorber : absorbers) {
                                    receiverSum += getPartCost(absorber);
                                }
                            }
                        }
                    }
                    details += "$" + (int) (getCostByFoundation(foundation) + receiverSum) + " (" + foundation.getId() + ") | ";
                }
            }
        }
    }
    if (selectedFoundation == null) {
        if (count > 0) {
            details = details.substring(0, details.length() - 2);
        }
    }
    double landSum = 0;
    double collectorSum = 0;
    double receiverSum = 0;
    String info;
    if (selectedFoundation != null) {
        info = "Zone #" + selectedFoundation.getId();
        if (selectedFoundation.hasSolarReceiver()) {
            receiverSum = getPartCost(selectedFoundation);
        } else {
            landSum = getPartCost(selectedFoundation);
            final List<Mirror> mirrors = selectedFoundation.getHeliostats();
            if (!mirrors.isEmpty()) {
                final ArrayList<Foundation> towers = new ArrayList<Foundation>();
                for (final Mirror m : mirrors) {
                    if (m.getReceiver() != null) {
                        if (!towers.contains(m.getReceiver())) {
                            towers.add(m.getReceiver());
                        }
                    }
                }
                if (!towers.isEmpty()) {
                    for (final Foundation tower : towers) {
                        receiverSum += getPartCost(tower);
                    }
                }
            } else {
                final List<FresnelReflector> reflectors = selectedFoundation.getFresnelReflectors();
                if (!reflectors.isEmpty()) {
                    final ArrayList<Foundation> absorbers = new ArrayList<Foundation>();
                    for (final FresnelReflector r : reflectors) {
                        if (r.getReceiver() != null) {
                            if (!absorbers.contains(r.getReceiver())) {
                                absorbers.add(r.getReceiver());
                            }
                        }
                    }
                    if (!absorbers.isEmpty()) {
                        for (final Foundation absorber : absorbers) {
                            receiverSum += getPartCost(absorber);
                        }
                    }
                }
            }
        }
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p.getTopContainer() == selectedFoundation) {
                if (p instanceof SolarCollector) {
                    // assuming that sensor doesn't cost anything
                    collectorSum += getPartCost(p);
                }
            }
        }
    } else {
        info = count + " zones";
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p instanceof Foundation) {
                final Foundation f = (Foundation) p;
                if (f.hasSolarReceiver()) {
                    receiverSum += getPartCost(p);
                } else {
                    landSum += getPartCost(p);
                }
            } else if (p instanceof SolarCollector) {
                collectorSum += getPartCost(p);
            }
        }
    }
    double[] data;
    String[] legends;
    if (Util.isZero(receiverSum)) {
        data = new double[] { landSum, collectorSum };
        legends = new String[] { "Land (" + Scene.getInstance().getCspCustomPrice().getLifespan() + " years)", "Collectors" };
    } else {
        data = new double[] { landSum, collectorSum, receiverSum };
        legends = new String[] { "Land (" + Scene.getInstance().getCspCustomPrice().getLifespan() + " years)", "Collectors", "Receivers" };
    }
    // show them in a popup window
    final PieChart pie = new PieChart(data, CspProjectCostGraph.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) FresnelReflector(org.concord.energy3d.model.FresnelReflector) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) ActionListener(java.awt.event.ActionListener) SolarCollector(org.concord.energy3d.model.SolarCollector) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog)

Example 38 with FresnelReflector

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

the class ChangeAbsorberForAllFresnelReflectorsCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    final int n = reflectors.size();
    newValues = new Foundation[n];
    for (int i = 0; i < n; i++) {
        final FresnelReflector r = reflectors.get(i);
        newValues[i] = r.getReceiver();
        r.setReceiver(oldValues[i]);
        r.draw();
        if (oldValues[i] != null) {
            oldValues[i].drawSolarReceiver();
        }
        if (newValues[i] != null) {
            newValues[i].drawSolarReceiver();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : FresnelReflector(org.concord.energy3d.model.FresnelReflector)

Example 39 with FresnelReflector

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

the class ChangeFoundationFresnelReflectorAbsorberCommand method redo.

@Override
public void redo() throws CannotRedoException {
    super.redo();
    final int n = reflectors.size();
    for (int i = 0; i < n; i++) {
        final FresnelReflector r = reflectors.get(i);
        r.setReceiver(newValues[i]);
        r.draw();
        if (oldValues[i] != null) {
            oldValues[i].drawSolarReceiver();
        }
        if (newValues[i] != null) {
            newValues[i].drawSolarReceiver();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : FresnelReflector(org.concord.energy3d.model.FresnelReflector)

Example 40 with FresnelReflector

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

the class ChangeFoundationFresnelReflectorAzimuthCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    final int n = reflectors.size();
    newValues = new double[n];
    for (int i = 0; i < n; i++) {
        final FresnelReflector r = reflectors.get(i);
        newValues[i] = r.getRelativeAzimuth();
        r.setRelativeAzimuth(oldValues[i]);
        r.draw();
    }
    SceneManager.getInstance().refresh();
}
Also used : FresnelReflector(org.concord.energy3d.model.FresnelReflector)

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