Search in sources :

Example 86 with HousePart

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

the class EnergyDailyAnalysis method show.

public void show(final String title) {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    String s = null;
    int cost = -1;
    if (selectedPart != null) {
        cost = (int) BuildingCost.getPartCost(selectedPart);
        if (graph.instrumentType == Graph.SENSOR) {
            SceneManager.getInstance().setSelectedPart(null);
        } else {
            s = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
            if (selectedPart instanceof Foundation) {
                cost = (int) BuildingCost.getInstance().getCostByFoundation((Foundation) selectedPart);
                s = s.replaceAll("Foundation", "Building");
                if (selectedPart.getChildren().isEmpty()) {
                    JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no building on this foundation.", "No Building", JOptionPane.WARNING_MESSAGE);
                    return;
                }
                if (!isBuildingComplete((Foundation) selectedPart)) {
                    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "The selected building has not been completed.\nAre you sure to continue?", "Incomplete Building", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                        return;
                    }
                }
            } else if (selectedPart instanceof Tree) {
                JOptionPane.showMessageDialog(MainFrame.getInstance(), "Energy analysis is not applicable to a tree.", "Not Applicable", JOptionPane.WARNING_MESSAGE);
                return;
            }
        }
    }
    final JDialog dialog = createDialog(s == null ? title : title + ": " + s + " (Construction cost: $" + cost + ")");
    final JMenuBar menuBar = new JMenuBar();
    dialog.setJMenuBar(menuBar);
    menuBar.add(createOptionsMenu(dialog, null, false));
    menuBar.add(createTypesMenu());
    menuBar.add(createRunsMenu());
    dialog.setVisible(true);
}
Also used : Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar)

Example 87 with HousePart

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

the class FresnelReflectorAnnualAnalysis method toJson.

@Override
public String toJson() {
    String s = "{\"Months\": " + getNumberOfDataPoints();
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart != null) {
        if (selectedPart instanceof FresnelReflector) {
            s += ", \"Fresnel Reflector\": \"" + 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 += ", \"Fresnel Reflector\": \"All\"";
    }
    final String name = "Solar";
    final List<Double> data = graph.getData(name);
    s += ", \"" + name + "\": {";
    s += "\"Monthly\": [";
    for (final Double x : data) {
        s += Graph.ENERGY_FORMAT.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 : FresnelReflector(org.concord.energy3d.model.FresnelReflector) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Example 88 with HousePart

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

the class FresnelReflectorDailyAnalysis 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 FresnelReflector) {
                final FresnelReflector r = (FresnelReflector) selectedPart;
                graph.addData("Solar", r.getSolarPotentialNow() * r.getSystemEfficiency());
            } else if (selectedPart instanceof Foundation) {
                double output = 0;
                for (final HousePart p : Scene.getInstance().getParts()) {
                    if (p instanceof FresnelReflector && p.getTopContainer() == selectedPart) {
                        final FresnelReflector r = (FresnelReflector) p;
                        output += r.getSolarPotentialNow() * r.getSystemEfficiency();
                    }
                }
                graph.addData("Solar", output);
            } else if (selectedPart.getTopContainer() instanceof Foundation) {
                double output = 0;
                for (final HousePart p : Scene.getInstance().getParts()) {
                    if (p instanceof FresnelReflector && p.getTopContainer() == selectedPart.getTopContainer()) {
                        final FresnelReflector r = (FresnelReflector) p;
                        output += r.getSolarPotentialNow() * r.getSystemEfficiency();
                    }
                }
                graph.addData("Solar", output);
            }
        } else {
            double output = 0;
            for (final HousePart p : Scene.getInstance().getParts()) {
                if (p instanceof FresnelReflector) {
                    final FresnelReflector r = (FresnelReflector) p;
                    output += r.getSolarPotentialNow() * r.getSystemEfficiency();
                }
            }
            graph.addData("Solar", output);
        }
    }
    graph.repaint();
}
Also used : FresnelReflector(org.concord.energy3d.model.FresnelReflector) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Example 89 with HousePart

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

the class GroupAnnualAnalysis method updateGraph.

@Override
public void updateGraph() {
    for (final HousePart p : selectedParts) {
        final String customText = p.getLabelCustomText();
        if (p instanceof Window) {
            final Window window = (Window) p;
            final double solar = p.getSolarPotentialToday() * window.getSolarHeatGainCoefficient();
            graph.addData("Solar " + p.getId(), solar);
            final double[] loss = p.getHeatLoss();
            double sum = 0;
            for (final double x : loss) {
                sum += x;
            }
            graph.addData("Heat Gain " + p.getId(), -sum);
        } else if (p instanceof Wall || p instanceof Roof) {
            final double[] loss = p.getHeatLoss();
            double sum = 0;
            for (final double x : loss) {
                sum += x;
            }
            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).getYieldToday());
            } else {
                graph.addData("Solar " + p.getId(), ((SolarPanel) p).getYieldToday());
            }
        } else if (p instanceof Rack) {
            if (customText != null) {
                graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, ((Rack) p).getYieldToday());
            } else {
                graph.addData("Solar " + p.getId(), ((Rack) p).getYieldToday());
            }
        } else if (p instanceof Mirror) {
            final Mirror mirror = (Mirror) p;
            final double solar = mirror.getSolarPotentialToday() * 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.getSolarPotentialToday() * 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.getSolarPotentialToday() * 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.getSolarPotentialToday() * 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.getPhotovoltaicToday();
                    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.getCspToday();
                    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.getTotalEnergyToday();
                    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 90 with HousePart

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

the class HeliostatAnnualAnalysis method updateGraph.

@Override
public void updateGraph() {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart != null) {
        if (selectedPart instanceof Mirror) {
            final Mirror m = (Mirror) selectedPart;
            graph.addData("Solar", m.getSolarPotentialToday() * m.getSystemEfficiency());
        } else if (selectedPart instanceof Foundation) {
            double output = 0;
            for (final HousePart p : Scene.getInstance().getParts()) {
                if (p instanceof Mirror && p.getTopContainer() == selectedPart) {
                    final Mirror m = (Mirror) p;
                    output += m.getSolarPotentialToday() * m.getSystemEfficiency();
                }
            }
            graph.addData("Solar", output);
        } else if (selectedPart.getTopContainer() instanceof Foundation) {
            double output = 0;
            for (final HousePart p : Scene.getInstance().getParts()) {
                if (p instanceof Mirror && p.getTopContainer() == selectedPart.getTopContainer()) {
                    final Mirror m = (Mirror) p;
                    output += m.getSolarPotentialToday() * m.getSystemEfficiency();
                }
            }
            graph.addData("Solar", output);
        }
    } else {
        double output = 0;
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p instanceof Mirror) {
                final Mirror m = (Mirror) p;
                output += m.getSolarPotentialToday() * m.getSystemEfficiency();
            }
        }
        graph.addData("Solar", output);
    }
    graph.repaint();
}
Also used : Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

HousePart (org.concord.energy3d.model.HousePart)277 Foundation (org.concord.energy3d.model.Foundation)153 Rack (org.concord.energy3d.model.Rack)69 SolarPanel (org.concord.energy3d.model.SolarPanel)60 Roof (org.concord.energy3d.model.Roof)47 Wall (org.concord.energy3d.model.Wall)45 Window (org.concord.energy3d.model.Window)43 ActionEvent (java.awt.event.ActionEvent)42 ActionListener (java.awt.event.ActionListener)42 ArrayList (java.util.ArrayList)41 Mirror (org.concord.energy3d.model.Mirror)38 JMenuItem (javax.swing.JMenuItem)36 JDialog (javax.swing.JDialog)35 FresnelReflector (org.concord.energy3d.model.FresnelReflector)34 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)32 ParabolicDish (org.concord.energy3d.model.ParabolicDish)28 Tree (org.concord.energy3d.model.Tree)26 Door (org.concord.energy3d.model.Door)25 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)21 JPanel (javax.swing.JPanel)21