Search in sources :

Example 1 with Building

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

the class BuildingCost method getPartCost.

/* The material and installation costs are partly based on http://www.homewyse.com, but should be considered as largely fictitious. */
public static double getPartCost(final HousePart part) {
    // The baseline cost for a wall is set to be $300/m^2, close to homewyse's estimates of masonry walls, interior framing, etc.
    if (part instanceof Wall) {
        final double uFactor = ((Wall) part).getUValue();
        final double unitPrice = 300.0 + 8.0 / uFactor;
        return part.getArea() * unitPrice;
    }
    // A storm window of about 1 m^2 costs about $500. A double-pane window of about 1 m^2 costs about $700.
    if (part instanceof Window) {
        final double uFactor = ((Window) part).getUValue();
        final double unitPrice = 500.0 + 800.0 / uFactor;
        return part.getArea() * unitPrice;
    }
    // The baseline (that is, the structure without insulation) cost for a roof is set to be $100/m^2.
    if (part instanceof Roof) {
        final double uFactor = ((Roof) part).getUValue();
        final double unitPrice = 100.0 + 10.0 / uFactor;
        return part.getArea() * unitPrice;
    }
    // The foundation cost is set to be $200/m^2.
    if (part instanceof Foundation) {
        final Foundation foundation = (Foundation) part;
        final Building b = new Building(foundation);
        if (b.isWallComplete()) {
            b.calculate();
            final double uFactor = foundation.getUValue();
            final double unitPrice = 300.0 + 8.0 / uFactor;
            return b.getArea() * unitPrice;
        }
        // the building is incomplete yet, so we can assume the floor insulation isn't there yet
        return -1;
    }
    if (part instanceof Floor) {
        final double area = part.getArea();
        if (area > 0) {
            return part.getArea() * 100.0;
        }
        return -1;
    }
    // According to http://www.homewyse.com/costs/cost_of_exterior_doors.html
    if (part instanceof Door) {
        final double uFactor = ((Door) part).getUValue();
        final double unitPrice = 500.0 + 100.0 / uFactor;
        return part.getArea() * unitPrice;
    }
    if (part instanceof SolarPanel) {
        return Scene.getInstance().getPvCustomPrice().getTotalCost((SolarPanel) part);
    }
    if (part instanceof Rack) {
        return Scene.getInstance().getPvCustomPrice().getTotalCost((Rack) part);
    }
    if (part instanceof Tree) {
        switch(((Tree) part).getTreeType()) {
            case Tree.LINDEN:
                return 3000;
            case Tree.COTTONWOOD:
                return 2500;
            case Tree.ELM:
                return 2000;
            case Tree.OAK:
                return 2000;
            case Tree.PINE:
                return 1500;
            case Tree.MAPLE:
                return 1000;
            default:
                return 500;
        }
    }
    return 0;
}
Also used : Window(org.concord.energy3d.model.Window) Building(org.concord.energy3d.model.Building) Floor(org.concord.energy3d.model.Floor) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) Wall(org.concord.energy3d.model.Wall) SolarPanel(org.concord.energy3d.model.SolarPanel) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) Door(org.concord.energy3d.model.Door)

Example 2 with Building

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

the class BuildingInfoPanel method update.

void update(final Foundation foundation) {
    final Building b = new Building(foundation);
    if (b.isWallComplete()) {
        b.calculate();
        switch(Scene.getInstance().getUnit()) {
            case InternationalSystemOfUnits:
                areaBar.setValue((float) b.getArea());
                break;
            case USCustomaryUnits:
                areaBar.setValue((float) (b.getArea() * 3.28084 * 3.28084));
                break;
        }
        windowToFloorBar.setValue((float) b.getWindowToFloorRatio());
    } else {
        areaBar.setValue(0);
        windowToFloorBar.setValue(0);
    }
    // relax the requirement of a building
    solarPanelCountBar.setValue(foundation.getNumberOfSolarPanels());
    windowCountBar.setValue(foundation.countParts(Window.class));
    wallCountBar.setValue(foundation.countParts(Wall.class));
    final double height = Scene.getInstance().getAnnotationScale() * foundation.getBoundingHeight();
    switch(Scene.getInstance().getUnit()) {
        case InternationalSystemOfUnits:
            heightBar.setValue((float) height);
            break;
        case USCustomaryUnits:
            heightBar.setValue((float) (height * 3.28084));
            break;
    }
}
Also used : Building(org.concord.energy3d.model.Building) Window(org.concord.energy3d.model.Window) Wall(org.concord.energy3d.model.Wall)

Example 3 with Building

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

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

the class LoggerUtil method getInfo.

static Object getInfo(final HousePart p) {
    if (p == null)
        return null;
    long bid = Building.getBuildingId(p);
    String s;
    if (p instanceof Human) {
        s = "{\"Name\": \"" + ((Human) p).getHumanName() + "\", ";
    } else if (p instanceof Tree) {
        s = "{\"Species\": \"" + ((Tree) p).getTreeName() + "\", ";
    } else {
        s = "{\"Type\": \"" + p.getClass().getSimpleName() + "\", ";
    }
    if (bid != -1)
        s += "\"Building\": " + bid + ", ";
    s += "\"ID\": " + p.getId();
    int n = p.getPoints().size();
    if (n > 0) {
        s += ", \"Coordinates\": [";
        boolean exist;
        for (int i = 0; i < n; i++) {
            exist = false;
            for (int j = 0; j < i; j++) {
                if (p.getPoints().get(j).equals(p.getPoints().get(i))) {
                    exist = true;
                    break;
                }
            }
            if (!exist) {
                Vector3 v = p.getAbsPoint(i);
                s += "{\"x\": " + FORMAT.format(v.getX()) + ", \"y\": " + FORMAT.format(v.getY()) + ", \"z\": " + FORMAT.format(v.getZ()) + "}";
                if (i < n - 1)
                    s += ", ";
            }
        }
        s = s.trim();
        if (s.endsWith(",")) {
            s = s.substring(0, s.length() - 1);
        }
        s += "]";
    }
    if (bid != -1 && bid == p.getId()) {
        if (p instanceof Foundation) {
            Building b = new Building((Foundation) p);
            if (b.isWallComplete()) {
                s += ", " + b.geometryToJson();
            }
        }
    }
    s += "}";
    return s;
}
Also used : Human(org.concord.energy3d.model.Human) Building(org.concord.energy3d.model.Building) Tree(org.concord.energy3d.model.Tree) Vector3(com.ardor3d.math.Vector3) Foundation(org.concord.energy3d.model.Foundation)

Example 5 with Building

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

the class PostProcessor method analyze.

public void analyze(final File[] files, final File output, final Runnable update) {
    new Thread("Energy3D Post-Processor") {

        @Override
        public void run() {
            active = true;
            Arrays.sort(files, new FileComparator());
            final int n = files.length;
            PrintWriter logWriter = null;
            try {
                logWriter = new PrintWriter(output);
            } catch (final Exception ex) {
                ex.printStackTrace();
            }
            final PrintWriter pw = logWriter;
            int i = -1;
            int total0 = -1;
            int wallCount0 = -1;
            int windowCount0 = -1;
            int foundationCount0 = -1;
            int roofCount0 = -1;
            int floorCount0 = -1;
            int doorCount0 = -1;
            long timestamp = -1;
            Date date0 = null;
            ArrayList<Building> buildings0 = null;
            while (i < n - 1) {
                if (replaying) {
                    i++;
                    final int slash = files[i].toString().lastIndexOf(System.getProperty("file.separator"));
                    final String fileName = files[i].toString().substring(slash + 1).trim();
                    // get time stamp
                    final String[] ss = fileName.substring(0, fileName.length() - 4).split("[\\s]+");
                    if (ss.length >= 2) {
                        final String[] day = ss[0].split("-");
                        final String[] time = ss[1].split("-");
                        final Calendar c = Calendar.getInstance();
                        try {
                            c.set(Integer.parseInt(day[0]), Integer.parseInt(day[1]) - 1, Integer.parseInt(day[2]), Integer.parseInt(time[0]), Integer.parseInt(time[1]), Integer.parseInt(time[2]));
                        } catch (final Exception e) {
                            e.printStackTrace();
                        }
                        if (date0 == null) {
                            date0 = c.getTime();
                        }
                        timestamp = Math.round((c.getTime().getTime() - date0.getTime()) * 0.001);
                    } else {
                        System.err.println("File timestamp error");
                        timestamp = 0;
                    }
                    System.out.println("Play back " + i + " of " + n + ": " + fileName);
                    try {
                        Scene.openNow(files[i].toURI().toURL());
                        // Scene.initSceneNow();
                        // Scene.initEnergy();
                        EnergyPanel.getInstance().computeNow();
                        SceneManager.getInstance().refresh();
                        update.run();
                        EventQueue.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                EnergyPanel.getInstance().update();
                            }
                        });
                        sleep(SLEEP);
                    } catch (final Exception e) {
                        e.printStackTrace();
                    }
                    final List<HousePart> parts = Scene.getInstance().getParts();
                    final ArrayList<Building> buildings = new ArrayList<Building>();
                    int wallCount = 0;
                    int windowCount = 0;
                    int foundationCount = 0;
                    int roofCount = 0;
                    int floorCount = 0;
                    int doorCount = 0;
                    if (buildings0 == null) {
                        buildings0 = new ArrayList<Building>();
                        for (final HousePart x : parts) {
                            final Building b = new Building(Building.getBuildingFoundation(x));
                            if (!buildings0.contains(b)) {
                                buildings0.add(b);
                            }
                        }
                    }
                    for (final HousePart x : parts) {
                        // count the pieces by categories
                        if (x instanceof Window) {
                            windowCount++;
                        } else if (x instanceof Foundation) {
                            foundationCount++;
                        } else if (x instanceof Roof) {
                            roofCount++;
                        } else if (x instanceof Floor) {
                            floorCount++;
                        } else if (x instanceof Door) {
                            doorCount++;
                        } else if (x instanceof Wall) {
                            wallCount++;
                            final Building b = new Building(Building.getBuildingFoundation(x));
                            if (!buildings.contains(b) && !buildings0.contains(b)) {
                                buildings.add(b);
                            }
                        }
                    }
                    // scan again to compute building properties
                    if (total0 == -1) {
                        total0 = parts.size();
                    }
                    if (wallCount0 == -1) {
                        wallCount0 = wallCount;
                    }
                    if (windowCount0 == -1) {
                        windowCount0 = windowCount;
                    }
                    if (foundationCount0 == -1) {
                        foundationCount0 = foundationCount;
                    }
                    if (roofCount0 == -1) {
                        roofCount0 = roofCount;
                    }
                    if (floorCount0 == -1) {
                        floorCount0 = floorCount;
                    }
                    if (doorCount0 == -1) {
                        doorCount0 = doorCount;
                    }
                    final Calendar heliodonCalendar = Heliodon.getInstance().getCalendar();
                    String heliodonTime = FORMAT_TWO_DIGITS.format(heliodonCalendar.get(Calendar.MONTH) + 1);
                    heliodonTime += "/" + FORMAT_TWO_DIGITS.format(heliodonCalendar.get(Calendar.DAY_OF_MONTH));
                    heliodonTime += ":" + FORMAT_TWO_DIGITS.format(heliodonCalendar.get(Calendar.HOUR_OF_DAY));
                    pw.print(fileName);
                    pw.print("  Timestamp=" + FORMAT_TIME_COUNT.format(timestamp));
                    pw.print("  Heliodon=" + heliodonTime);
                    pw.print("  Latitude=" + FORMAT_THREE_DIGITS.format(Math.round(180 * Heliodon.getInstance().getLatitude() / Math.PI)));
                    pw.print("  #Total=" + FORMAT_THREE_DIGITS.format(parts.size() - total0));
                    pw.print("  #Wall=" + FORMAT_THREE_DIGITS.format(wallCount - wallCount0));
                    pw.print("  #Window=" + FORMAT_THREE_DIGITS.format(windowCount - windowCount0));
                    pw.print("  #Foundation=" + FORMAT_THREE_DIGITS.format(foundationCount - foundationCount0));
                    pw.print("  #Roof=" + FORMAT_THREE_DIGITS.format(roofCount - roofCount0));
                    pw.print("  #Floor=" + FORMAT_THREE_DIGITS.format(floorCount - floorCount0));
                    pw.print("  #Door=" + FORMAT_THREE_DIGITS.format(doorCount - doorCount0));
                    pw.print("  " + buildings);
                    pw.println("");
                // if (i == n - 1) i = 0;
                } else {
                    if (backward) {
                        if (i > 0) {
                            i--;
                            System.out.println("Play back " + i + " of " + n);
                            try {
                                Scene.open(files[i].toURI().toURL());
                                update.run();
                            } catch (final Exception e) {
                                e.printStackTrace();
                            }
                        }
                        backward = false;
                    } else if (forward) {
                        if (i < n - 1) {
                            i++;
                            System.out.println("Play back " + i + " of " + n);
                            try {
                                Scene.open(files[i].toURI().toURL());
                                update.run();
                            } catch (final Exception e) {
                                e.printStackTrace();
                            }
                        }
                        forward = false;
                        if (i == n - 1) {
                            i = n - 2;
                        }
                    }
                }
            }
            pw.close();
            EnergyPanel.getInstance().setComputeEnabled(true);
            active = false;
        }
    }.start();
}
Also used : Building(org.concord.energy3d.model.Building) Window(org.concord.energy3d.model.Window) Floor(org.concord.energy3d.model.Floor) Wall(org.concord.energy3d.model.Wall) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) Date(java.util.Date) Door(org.concord.energy3d.model.Door) Roof(org.concord.energy3d.model.Roof) ArrayList(java.util.ArrayList) List(java.util.List) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) PrintWriter(java.io.PrintWriter)

Aggregations

Building (org.concord.energy3d.model.Building)5 Foundation (org.concord.energy3d.model.Foundation)4 Window (org.concord.energy3d.model.Window)4 Floor (org.concord.energy3d.model.Floor)3 Roof (org.concord.energy3d.model.Roof)3 Tree (org.concord.energy3d.model.Tree)3 Wall (org.concord.energy3d.model.Wall)3 Door (org.concord.energy3d.model.Door)2 HousePart (org.concord.energy3d.model.HousePart)2 Human (org.concord.energy3d.model.Human)2 Vector3 (com.ardor3d.math.Vector3)1 Mesh (com.ardor3d.scenegraph.Mesh)1 Spatial (com.ardor3d.scenegraph.Spatial)1 CullHint (com.ardor3d.scenegraph.hint.CullHint)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 List (java.util.List)1 Rack (org.concord.energy3d.model.Rack)1