Search in sources :

Example 11 with SolarCollector

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

the class SolarRadiation method computeEnergyAtHour.

public void computeEnergyAtHour(final int hour) {
    final Calendar today = Heliodon.getInstance().getCalendar();
    final String city = (String) EnergyPanel.getInstance().getCityComboBox().getSelectedItem();
    final double[] outsideAirTemperatureRange = Weather.computeOutsideTemperature(today, city);
    final double outsideAirTemperature = Weather.getInstance().getOutsideTemperatureAtMinute(outsideAirTemperatureRange[1], outsideAirTemperatureRange[0], hour * 60);
    for (final HousePart part : Scene.getInstance().getParts()) {
        if (part instanceof Foundation) {
            final Foundation foundation = (Foundation) part;
            if (foundation.getHeatLoss() == null) {
                continue;
            }
            final int n = (int) Math.round(60.0 / Scene.getInstance().getTimeStep());
            final double[] heatLoss = new double[n];
            final double[] passiveSolar = new double[n];
            final double[] photovoltaic = new double[n];
            final double[] csp = new double[n];
            final int t0 = n * hour;
            for (int i = 0; i < n; i++) {
                final double groundHeatLoss = foundation.getHeatLoss()[t0 + i];
                if (groundHeatLoss > 0) {
                    final double thermostat = foundation.getThermostat().getTemperature(today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY, today.get(Calendar.HOUR_OF_DAY));
                    if (outsideAirTemperature >= thermostat) {
                        heatLoss[i] -= groundHeatLoss;
                    }
                } else {
                    heatLoss[i] += groundHeatLoss;
                }
            }
            double solarPotentialTotal = 0.0;
            for (final HousePart child : Scene.getInstance().getParts()) {
                if (child.getTopContainer() == foundation) {
                    child.setSolarPotentialNow(0);
                    if (child instanceof SolarCollector) {
                        ((SolarCollector) child).setYieldNow(0);
                    }
                    for (int i = 0; i < n; i++) {
                        solarPotentialTotal += child.getSolarPotential()[t0 + i];
                        child.setSolarPotentialNow(child.getSolarPotentialNow() + child.getSolarPotential()[t0 + i]);
                        if (child instanceof Wall || child instanceof Door || child instanceof Window || child instanceof Roof) {
                            heatLoss[i] += child.getHeatLoss()[t0 + i];
                        }
                        if (child instanceof Window) {
                            final Window window = (Window) child;
                            passiveSolar[i] += window.getSolarPotential()[t0 + i] * window.getSolarHeatGainCoefficient();
                        } else if (child instanceof Mirror) {
                            final Mirror mirror = (Mirror) child;
                            final double yield = mirror.getSolarPotential()[t0 + i] * mirror.getSystemEfficiency();
                            csp[i] += yield;
                            mirror.setYieldNow(mirror.getYieldNow() + yield);
                        } else if (child instanceof ParabolicTrough) {
                            final ParabolicTrough trough = (ParabolicTrough) child;
                            final double yield = trough.getSolarPotential()[t0 + i] * trough.getSystemEfficiency();
                            csp[i] += yield;
                            trough.setYieldNow(trough.getYieldNow() + yield);
                        } else if (child instanceof ParabolicDish) {
                            final ParabolicDish dish = (ParabolicDish) child;
                            final double yield = dish.getSolarPotential()[t0 + i] * dish.getSystemEfficiency();
                            csp[i] += yield;
                            dish.setYieldNow(dish.getYieldNow() + yield);
                        } else if (child instanceof FresnelReflector) {
                            final FresnelReflector reflector = (FresnelReflector) child;
                            final double yield = reflector.getSolarPotential()[t0 + i] * reflector.getSystemEfficiency();
                            csp[i] += yield;
                            reflector.setYieldNow(reflector.getYieldNow() + yield);
                        } else if (child instanceof SolarPanel) {
                            final SolarPanel sp = (SolarPanel) child;
                            // distributed efficiency must be handled for each individual cell
                            final double yield = sp.getSolarPotential()[t0 + i];
                            photovoltaic[i] += yield;
                            sp.setYieldNow(sp.getYieldNow() + yield);
                        } else if (child instanceof Rack) {
                            final Rack rack = (Rack) child;
                            if (rack.isMonolithic()) {
                                // distributed efficiency must be handled for each individual cell
                                final double yield = rack.getSolarPotential()[t0 + i];
                                photovoltaic[i] += yield;
                                rack.setYieldNow(rack.getYieldNow() + yield);
                            }
                        }
                    }
                }
            }
            double heatingTotal = 0.0;
            double coolingTotal = 0.0;
            double passiveSolarTotal = 0.0;
            double photovoltaicTotal = 0.0;
            double cspTotal = 0.0;
            for (int i = 0; i < n; i++) {
                if (heatLoss[i] < 0) {
                    heatLoss[i] -= passiveSolar[i];
                } else {
                    heatLoss[i] = Math.max(0, heatLoss[i] - passiveSolar[i]);
                }
                if (heatLoss[i] > 0) {
                    heatingTotal += heatLoss[i];
                } else {
                    coolingTotal -= heatLoss[i];
                }
                passiveSolarTotal += passiveSolar[i];
                photovoltaicTotal += photovoltaic[i];
                cspTotal += csp[i];
            }
            foundation.setSolarPotentialNow(solarPotentialTotal);
            foundation.setPassiveSolarNow(passiveSolarTotal);
            foundation.setPhotovoltaicNow(photovoltaicTotal);
            foundation.setCspNow(cspTotal);
            foundation.setHeatingNow(heatingTotal);
            foundation.setCoolingNow(coolingTotal);
            foundation.setTotalEnergyNow(heatingTotal + coolingTotal - photovoltaicTotal);
        }
    }
}
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) Calendar(java.util.Calendar) 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) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) SolarCollector(org.concord.energy3d.model.SolarCollector) 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 12 with SolarCollector

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

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

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

the class ChangeFoundationSolarCollectorBaseHeightCommand method undo.

@Override
public void undo() throws CannotUndoException {
    super.undo();
    final int n = collectors.size();
    newValues = new double[n];
    for (int i = 0; i < n; i++) {
        final SolarCollector c = collectors.get(i);
        newValues[i] = c.getBaseHeight();
        c.setBaseHeight(oldValues[i]);
        if (c instanceof HousePart) {
            ((HousePart) c).draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : SolarCollector(org.concord.energy3d.model.SolarCollector) HousePart(org.concord.energy3d.model.HousePart)

Example 15 with SolarCollector

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

the class ChangeFoundationSolarCollectorBaseHeightCommand method redo.

@Override
public void redo() throws CannotRedoException {
    super.redo();
    final int n = collectors.size();
    for (int i = 0; i < n; i++) {
        final SolarCollector c = collectors.get(i);
        c.setBaseHeight(newValues[i]);
        if (c instanceof HousePart) {
            ((HousePart) c).draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : SolarCollector(org.concord.energy3d.model.SolarCollector) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

HousePart (org.concord.energy3d.model.HousePart)18 SolarCollector (org.concord.energy3d.model.SolarCollector)18 Foundation (org.concord.energy3d.model.Foundation)12 Window (org.concord.energy3d.model.Window)9 Roof (org.concord.energy3d.model.Roof)8 ArrayList (java.util.ArrayList)7 Tree (org.concord.energy3d.model.Tree)7 Door (org.concord.energy3d.model.Door)6 Human (org.concord.energy3d.model.Human)6 Mirror (org.concord.energy3d.model.Mirror)6 Wall (org.concord.energy3d.model.Wall)6 CullHint (com.ardor3d.scenegraph.hint.CullHint)5 List (java.util.List)5 FresnelReflector (org.concord.energy3d.model.FresnelReflector)5 Rack (org.concord.energy3d.model.Rack)5 Calendar (java.util.Calendar)4 Floor (org.concord.energy3d.model.Floor)4 SolarPanel (org.concord.energy3d.model.SolarPanel)4 Vector3 (com.ardor3d.math.Vector3)3 Node (com.ardor3d.scenegraph.Node)3