Search in sources :

Example 86 with Rack

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

the class GroupDailyAnalysis method toJson.

@Override
public String toJson() {
    String type = "Unknown";
    final ArrayList<String> names = new ArrayList<String>();
    for (final HousePart p : selectedParts) {
        if (p instanceof SolarPanel) {
            names.add("Solar " + p.getId());
            type = "Solar Panel";
        } else if (p instanceof Rack) {
            names.add("Solar " + p.getId());
            type = "Rack";
        } else if (p instanceof Mirror) {
            names.add("Solar " + p.getId());
            type = "Mirror";
        } else if (p instanceof ParabolicTrough) {
            names.add("Solar " + p.getId());
            type = "Parabolic Trough";
        } else if (p instanceof ParabolicDish) {
            names.add("Solar " + p.getId());
            type = "Parabolic Dish";
        } else if (p instanceof FresnelReflector) {
            names.add("Solar " + p.getId());
            type = "Fresnel Reflector";
        } else if (p instanceof Wall) {
            names.add("Heat Gain " + p.getId());
            type = "Wall";
        } else if (p instanceof Roof) {
            names.add("Heat Gain " + p.getId());
            type = "Roof";
        } else if (p instanceof Door) {
            names.add("Heat Gain " + p.getId());
            type = "Door";
        } else if (p instanceof Window) {
            names.add("Solar " + p.getId());
            names.add("Heat Gain " + p.getId());
            type = "Window";
        } else if (p instanceof Foundation) {
            final Foundation foundation = (Foundation) p;
            switch(foundation.getProjectType()) {
                case Foundation.TYPE_PV_PROJECT:
                    names.add("PV " + p.getId());
                    break;
                case Foundation.TYPE_CSP_PROJECT:
                    names.add("CSP " + p.getId());
                    break;
                case Foundation.TYPE_BUILDING:
                    names.add("Building " + p.getId());
                    break;
            }
            type = "Foundation";
        }
    }
    String s = "{\"Type\": \"" + type + "\"";
    for (final String name : names) {
        final List<Double> data = graph.getData(name);
        if (data == null) {
            continue;
        }
        s += ", \"" + name + "\": {";
        s += "\"Hourly\": [";
        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 : Window(org.concord.energy3d.model.Window) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Wall(org.concord.energy3d.model.Wall) ArrayList(java.util.ArrayList) Door(org.concord.energy3d.model.Door) 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 87 with Rack

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

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

the class PvAnnualAnalysis method show.

public void show() {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    String s = null;
    int cost = -1;
    String title = "Annual Yield of All Solar Panels (" + Scene.getInstance().countSolarPanels() + " Panels)";
    if (selectedPart != null) {
        if (selectedPart instanceof SolarPanel) {
            cost = (int) ProjectCost.getCost(selectedPart);
            s = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
            title = "Annual Yield";
        } else if (selectedPart instanceof Rack) {
            final Rack rack = (Rack) selectedPart;
            cost = (int) ProjectCost.getCost(rack);
            s = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
            title = "Annual Yield (" + rack.getNumberOfSolarPanels() + " Solar Panels)";
        } else if (selectedPart instanceof Foundation) {
            title = "Annual Yield on Selected Foundation (" + ((Foundation) selectedPart).getNumberOfSolarPanels() + " Solar Panels)";
        } else if (selectedPart.getTopContainer() != null) {
            title = "Annual Yield on Selected Foundation (" + selectedPart.getTopContainer().getNumberOfSolarPanels() + " Solar Panels)";
        }
    }
    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 : Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar)

Example 89 with Rack

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

the class PvAnnualAnalysis method toJson.

@Override
public String toJson() {
    String s = "{\"Months\": " + getNumberOfDataPoints();
    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 += "\"Monthly\": [";
    if (data != null) {
        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 : 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 90 with Rack

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

the class BuildingCost method showPieChart.

@Override
void showPieChart() {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    final Foundation selectedBuilding;
    if (selectedPart == null || selectedPart instanceof Tree || selectedPart instanceof Human) {
        selectedBuilding = null;
    } else if (selectedPart instanceof Foundation) {
        selectedBuilding = (Foundation) selectedPart;
    } else {
        selectedBuilding = selectedPart.getTopContainer();
        selectedPart.setEditPointsVisible(false);
        SceneManager.getInstance().setSelectedPart(selectedBuilding);
    }
    String details = "";
    int count = 0;
    for (final HousePart p : Scene.getInstance().getParts()) {
        if (p instanceof Foundation) {
            count++;
            if (selectedBuilding == null) {
                final Foundation foundation = (Foundation) p;
                details += "$" + (int) getCostByFoundation(foundation) + " (" + foundation.getId() + ") | ";
            }
        }
    }
    if (selectedBuilding == null) {
        if (count > 0) {
            details = details.substring(0, details.length() - 2);
        }
    }
    double wallSum = 0;
    double floorSum = 0;
    double windowSum = 0;
    double roofSum = 0;
    double foundationSum = 0;
    double doorSum = 0;
    double solarPanelSum = 0;
    double treeSum = 0;
    String info;
    if (selectedBuilding != null) {
        info = "Building #" + selectedBuilding.getId();
        foundationSum = getPartCost(selectedBuilding);
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p.getTopContainer() == selectedBuilding) {
                if (p instanceof Wall) {
                    wallSum += getPartCost(p);
                } else if (p instanceof Floor) {
                    floorSum += getPartCost(p);
                } else if (p instanceof Window) {
                    windowSum += getPartCost(p);
                } else if (p instanceof Roof) {
                    roofSum += getPartCost(p);
                } else if (p instanceof Door) {
                    doorSum += getPartCost(p);
                } else if (p instanceof SolarPanel || p instanceof Rack) {
                    solarPanelSum += getPartCost(p);
                }
            }
            if (count <= 1) {
                if (p instanceof Tree && !p.getLockEdit()) {
                    treeSum += getPartCost(p);
                }
            }
        }
    } else {
        info = count + " buildings";
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p instanceof Wall) {
                wallSum += getPartCost(p);
            } else if (p instanceof Floor) {
                floorSum += getPartCost(p);
            } else if (p instanceof Window) {
                windowSum += getPartCost(p);
            } else if (p instanceof Roof) {
                roofSum += getPartCost(p);
            } else if (p instanceof Foundation) {
                foundationSum += getPartCost(p);
            } else if (p instanceof Door) {
                doorSum += getPartCost(p);
            } else if (p instanceof SolarPanel || p instanceof Rack) {
                solarPanelSum += getPartCost(p);
            } else if (p instanceof Tree && !p.getLockEdit()) {
                treeSum += getPartCost(p);
            }
        }
    }
    final double[] data = new double[] { wallSum, windowSum, roofSum, foundationSum, floorSum, doorSum, solarPanelSum, treeSum };
    // show them in a popup window
    final PieChart pie = new PieChart(data, BuildingCostGraph.colors, BuildingCostGraph.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 buttonItemize = new JButton("Itemize");
    buttonItemize.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            showItemizedCost();
        }
    });
    buttonPanel.add(buttonItemize);
    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) Window(org.concord.energy3d.model.Window) Floor(org.concord.energy3d.model.Floor) JPanel(javax.swing.JPanel) Wall(org.concord.energy3d.model.Wall) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Door(org.concord.energy3d.model.Door) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) 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)

Aggregations

Rack (org.concord.energy3d.model.Rack)126 HousePart (org.concord.energy3d.model.HousePart)67 SolarPanel (org.concord.energy3d.model.SolarPanel)66 Foundation (org.concord.energy3d.model.Foundation)45 Window (org.concord.energy3d.model.Window)27 Roof (org.concord.energy3d.model.Roof)25 Wall (org.concord.energy3d.model.Wall)23 Mirror (org.concord.energy3d.model.Mirror)22 Door (org.concord.energy3d.model.Door)20 FresnelReflector (org.concord.energy3d.model.FresnelReflector)16 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)16 ParabolicDish (org.concord.energy3d.model.ParabolicDish)15 ActionEvent (java.awt.event.ActionEvent)12 ActionListener (java.awt.event.ActionListener)12 Vector3 (com.ardor3d.math.Vector3)10 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)10 JMenuItem (javax.swing.JMenuItem)10 Tree (org.concord.energy3d.model.Tree)10 Floor (org.concord.energy3d.model.Floor)9 ArrayList (java.util.ArrayList)8