Search in sources :

Example 41 with Window

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

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

the class HeatLoad method computeEnergyToday.

public void computeEnergyToday(final Calendar today) {
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.HOUR_OF_DAY, 0);
    if (EnergyPanel.getInstance().getCityComboBox().getSelectedItem().equals("")) {
        return;
    }
    final int timeStep = Scene.getInstance().getTimeStep();
    final double[] outsideTemperatureRange = Weather.computeOutsideTemperature(today, (String) EnergyPanel.getInstance().getCityComboBox().getSelectedItem());
    // System.out.println(today.get(Calendar.DAY_OF_YEAR) + ", " + outsideTemperatureRange[0] + ", " + outsideTemperatureRange[1]);
    int iMinute = 0;
    for (int minute = 0; minute < SolarRadiation.MINUTES_OF_DAY; minute += timeStep) {
        iMinute = minute / timeStep;
        final double outsideTemperature = Weather.getInstance().getOutsideTemperatureAtMinute(outsideTemperatureRange[1], outsideTemperatureRange[0], minute);
        final double groundTemperature = Scene.getInstance().getGround().getTemperatureMinuteOfDay(today.get(Calendar.DAY_OF_YEAR), minute, 0.5 * (outsideTemperatureRange[1] - outsideTemperatureRange[0]));
        for (final HousePart part : Scene.getInstance().getParts()) {
            if (part instanceof Human || part instanceof Tree || part instanceof Floor || (part instanceof SolarCollector && !(part instanceof Sensor))) {
                continue;
            }
            final double insideTemperature = (part instanceof Foundation ? (Foundation) part : part.getTopContainer()).getThermostat().getTemperature(today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY, minute / 60);
            final float absorption = part instanceof Window ? 0 : 1 - part.getAlbedo();
            if (part instanceof Roof) {
                // need to compute piece by piece for a roof because sun affects outside temperature of roof part
                final Roof roof = (Roof) part;
                for (final Spatial child : roof.getRoofPartsRoot().getChildren()) {
                    if (child.getSceneHints().getCullHint() != CullHint.Always) {
                        final Mesh mesh = (Mesh) ((Node) child).getChild(6);
                        final double[] solarPotential = SolarRadiation.getInstance().getSolarPotential(mesh);
                        final double solarHeat = solarPotential != null ? solarPotential[iMinute] * absorption / roof.getVolumetricHeatCapacity() : 0;
                        final double deltaT = insideTemperature - (outsideTemperature + solarHeat);
                        if (part.isDrawCompleted()) {
                            final double uValue = getUValue(part);
                            if (Util.isZero(uValue)) {
                                continue;
                            }
                            double heatloss = roof.getAreaWithoutOverhang(mesh) * uValue * deltaT / 1000.0 / 60 * timeStep;
                            // if the lowest outside temperature is high enough, there is no need to turn on the heater hence no heat loss
                            if (heatloss > 0 && outsideTemperatureRange[0] >= LOWEST_TEMPERATURE_OF_WARM_DAY) {
                                heatloss = 0;
                            }
                            roof.getHeatLoss()[iMinute] += heatloss;
                            final double[] heatLossArray = SolarRadiation.getInstance().getHeatLoss(mesh);
                            if (heatLossArray != null) {
                                heatLossArray[iMinute] += heatloss;
                            }
                        }
                    }
                }
            } else if (part instanceof Foundation) {
                final Foundation foundation = (Foundation) part;
                final double deltaT = insideTemperature - groundTemperature;
                if (foundation.isDrawCompleted()) {
                    final double uValue = getUValue(part);
                    if (Util.isZero(uValue)) {
                        continue;
                    }
                    final Building building = new Building(foundation);
                    double area;
                    if (building.isWallComplete()) {
                        building.calculate();
                        area = building.getArea();
                    } else {
                        area = foundation.getArea();
                    }
                    final double heatloss = area * uValue * deltaT / 1000.0 / 60 * timeStep;
                    // if (iMinute % 4 == 0) System.out.println((int) (iMinute / 4) + "=" + outsideTemperature + ", " + groundTemperature + ", " + deltaT + ", " + heatloss);
                    foundation.getHeatLoss()[iMinute] += heatloss;
                }
            } else {
                double deltaT = insideTemperature - outsideTemperature;
                if (part instanceof Thermal) {
                    // direct solar heating raises the outside temperature
                    deltaT -= part.getSolarPotential()[iMinute] * absorption / ((Thermal) part).getVolumetricHeatCapacity();
                }
                if (part.isDrawCompleted()) {
                    final double uValue = getUValue(part);
                    if (Util.isZero(uValue)) {
                        continue;
                    }
                    double heatloss = part.getArea() * uValue * deltaT / 1000.0 / 60 * timeStep;
                    // if outside is warm enough, there is no need to turn on the heater hence no heat loss
                    if (heatloss > 0 && outsideTemperatureRange[0] >= LOWEST_TEMPERATURE_OF_WARM_DAY) {
                        heatloss = 0;
                    }
                    part.getHeatLoss()[iMinute] += heatloss;
                }
            }
        }
    }
}
Also used : Human(org.concord.energy3d.model.Human) Window(org.concord.energy3d.model.Window) Building(org.concord.energy3d.model.Building) Floor(org.concord.energy3d.model.Floor) Mesh(com.ardor3d.scenegraph.Mesh) CullHint(com.ardor3d.scenegraph.hint.CullHint) Roof(org.concord.energy3d.model.Roof) Spatial(com.ardor3d.scenegraph.Spatial) SolarCollector(org.concord.energy3d.model.SolarCollector) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) Sensor(org.concord.energy3d.model.Sensor) Thermal(org.concord.energy3d.model.Thermal)

Example 43 with Window

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

Example 44 with Window

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

the class ChangeBuildingShutterColorCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    final int n = parts.size();
    newColors = new ReadOnlyColorRGBA[n];
    for (int i = 0; i < n; i++) {
        final Window w = (Window) parts.get(i);
        newColors[i] = w.getShutterColor();
        w.setShutterColor(oldColors[i]);
        w.draw();
    }
}
Also used : Window(org.concord.energy3d.model.Window)

Example 45 with Window

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

the class ChangeContainerShutterColorCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    final int n = windows.size();
    newColors = new ColorRGBA[n];
    for (int i = 0; i < n; i++) {
        final Window w = windows.get(i);
        newColors[i] = windows.get(i).getShutterColor();
        w.setShutterColor(oldColors[i]);
        w.draw();
    }
}
Also used : Window(org.concord.energy3d.model.Window)

Aggregations

Window (org.concord.energy3d.model.Window)57 HousePart (org.concord.energy3d.model.HousePart)43 Foundation (org.concord.energy3d.model.Foundation)39 Roof (org.concord.energy3d.model.Roof)28 Wall (org.concord.energy3d.model.Wall)28 Rack (org.concord.energy3d.model.Rack)27 Door (org.concord.energy3d.model.Door)25 SolarPanel (org.concord.energy3d.model.SolarPanel)25 Mirror (org.concord.energy3d.model.Mirror)16 ArrayList (java.util.ArrayList)15 FresnelReflector (org.concord.energy3d.model.FresnelReflector)14 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)14 ParabolicDish (org.concord.energy3d.model.ParabolicDish)13 Tree (org.concord.energy3d.model.Tree)12 List (java.util.List)10 Floor (org.concord.energy3d.model.Floor)10 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)9 SolarCollector (org.concord.energy3d.model.SolarCollector)9 Human (org.concord.energy3d.model.Human)8 Vector3 (com.ardor3d.math.Vector3)7