Search in sources :

Example 46 with Foundation

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

the class HeliostatDailyAnalysis method toJson.

@Override
public String toJson() {
    String s = "{";
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart != null) {
        if (selectedPart instanceof Mirror) {
            s += "\"Heliostat\": \"" + 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 += "\"Heliostat\": \"All\"";
    }
    final String name = "Solar";
    final List<Double> data = graph.getData(name);
    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 : Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 47 with Foundation

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

the class BuildingCost method getCostByFoundation.

@Override
public double getCostByFoundation(final Foundation foundation) {
    if (foundation == null || foundation.getProjectType() != Foundation.TYPE_BUILDING) {
        return 0;
    }
    double sum = 0;
    int buildingCount = 0;
    for (final HousePart p : Scene.getInstance().getParts()) {
        if (p instanceof Foundation) {
            buildingCount++;
        }
    }
    if (buildingCount == 1) {
        for (final HousePart p : Scene.getInstance().getParts()) {
            // if there is only one building, trees are included in its cost
            if (!p.getLockEdit() && !(p instanceof Human)) {
                sum += getPartCost(p);
            }
        }
    } else {
        sum = getPartCost(foundation);
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p.getTopContainer() == foundation) {
                sum += getPartCost(p);
            }
        }
    }
    return sum;
}
Also used : Human(org.concord.energy3d.model.Human) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Example 48 with Foundation

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

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

the class SolarRadiation method computeOnMirror.

// unlike PV solar panels, no indirect (ambient or diffuse) radiation should be included in reflection calculation
private void computeOnMirror(final int minute, final ReadOnlyVector3 directionTowardSun, final Mirror mirror) {
    final int nx = Scene.getInstance().getMirrorNx();
    final int ny = Scene.getInstance().getMirrorNy();
    final Foundation target = mirror.getReceiver();
    if (target != null) {
        final Calendar calendar = Heliodon.getInstance().getCalendar();
        calendar.set(Calendar.HOUR_OF_DAY, (int) ((double) minute / (double) SolarRadiation.MINUTES_OF_DAY * 24.0));
        calendar.set(Calendar.MINUTE, minute % 60);
        mirror.draw();
    }
    // nx*ny*60: nx*ny is to get the unit cell area of the nx*ny grid; 60 is to convert the unit of timeStep from minute to kWh
    final double a = mirror.getMirrorWidth() * mirror.getMirrorHeight() * Scene.getInstance().getTimeStep() / (nx * ny * 60.0);
    final ReadOnlyVector3 normal = mirror.getNormal();
    if (normal == null) {
        throw new RuntimeException("Normal is null");
    }
    final Mesh mesh = mirror.getRadiationMesh();
    MeshDataStore data = onMesh.get(mesh);
    if (data == null) {
        data = initMeshTextureDataOnRectangle(mesh, nx, ny);
    }
    final ReadOnlyVector3 offset = directionTowardSun.multiply(1, null);
    final double dot = normal.dot(directionTowardSun);
    double directRadiation = 0;
    if (dot > 0) {
        directRadiation += calculateDirectRadiation(directionTowardSun, normal);
    }
    final FloatBuffer vertexBuffer = mesh.getMeshData().getVertexBuffer();
    // (0, 0)
    final Vector3 p0 = new Vector3(vertexBuffer.get(3), vertexBuffer.get(4), vertexBuffer.get(5));
    // (1, 0)
    final Vector3 p1 = new Vector3(vertexBuffer.get(6), vertexBuffer.get(7), vertexBuffer.get(8));
    // (0, 1)
    final Vector3 p2 = new Vector3(vertexBuffer.get(0), vertexBuffer.get(1), vertexBuffer.get(2));
    // final Vector3 q0 = drawMesh.localToWorld(p0, null);
    // final Vector3 q1 = drawMesh.localToWorld(p1, null);
    // final Vector3 q2 = drawMesh.localToWorld(p2, null);
    // System.out.println("***" + q0.distance(q1) * Scene.getInstance().getAnnotationScale() + "," + q0.distance(q2) * Scene.getInstance().getAnnotationScale());
    // this is the longer side (supposed to be y)
    final Vector3 u = p1.subtract(p0, null).normalizeLocal();
    // this is the shorter side (supposed to be x)
    final Vector3 v = p2.subtract(p0, null).normalizeLocal();
    // x and y must be swapped to have correct heat map texture, because nx represents rows and ny columns as we call initMeshTextureDataOnRectangle(mesh, nx, ny)
    final double xSpacing = p1.distance(p0) / nx;
    final double ySpacing = p2.distance(p0) / ny;
    final Vector3 receiver = target != null ? target.getSolarReceiverCenter() : null;
    List<Mesh> towerCollisionMeshes = null;
    if (target != null) {
        towerCollisionMeshes = new ArrayList<Mesh>();
        for (final HousePart child : target.getChildren()) {
            towerCollisionMeshes.add((Mesh) child.getRadiationCollisionSpatial());
        }
        final List<Roof> roofs = target.getRoofs();
        if (!roofs.isEmpty()) {
            for (final Roof r : roofs) {
                for (final Spatial roofPart : r.getRoofPartsRoot().getChildren()) {
                    towerCollisionMeshes.add((Mesh) ((Node) roofPart).getChild(6));
                }
            }
        }
    }
    final int iMinute = minute / Scene.getInstance().getTimeStep();
    final boolean reflectionMapOnly = Scene.getInstance().getOnlyReflectedEnergyInMirrorSolarMap();
    for (int x = 0; x < nx; x++) {
        for (int y = 0; y < ny; y++) {
            if (EnergyPanel.getInstance().isCancelled()) {
                throw new CancellationException();
            }
            final Vector3 u2 = u.multiply(xSpacing * (x + 0.5), null);
            final Vector3 v2 = v.multiply(ySpacing * (y + 0.5), null);
            final ReadOnlyVector3 p = mesh.getWorldTransform().applyForward(p0.add(v2, null).addLocal(u2)).addLocal(offset);
            final Ray3 pickRay = new Ray3(p, directionTowardSun);
            if (dot > 0) {
                final PickResults pickResults = new PrimitivePickResults();
                for (final Spatial spatial : collidables) {
                    if (spatial != mesh) {
                        PickingUtil.findPick(spatial, pickRay, pickResults, false);
                        if (pickResults.getNumber() != 0) {
                            break;
                        }
                    }
                }
                if (pickResults.getNumber() == 0) {
                    // for heat map generation
                    if (!reflectionMapOnly) {
                        data.dailySolarIntensity[x][y] += directRadiation;
                    }
                    if (receiver != null) {
                        // for concentrated energy calculation
                        final Vector3 toReceiver = receiver.subtract(p, null);
                        final Ray3 rayToReceiver = new Ray3(p, toReceiver.normalize(null));
                        final PickResults pickResultsToReceiver = new PrimitivePickResults();
                        for (final Spatial spatial : collidables) {
                            if (spatial != mesh) {
                                if (towerCollisionMeshes == null || (towerCollisionMeshes != null && !towerCollisionMeshes.contains(spatial))) {
                                    PickingUtil.findPick(spatial, rayToReceiver, pickResultsToReceiver, false);
                                    if (pickResultsToReceiver.getNumber() != 0) {
                                        break;
                                    }
                                }
                            }
                        }
                        if (pickResultsToReceiver.getNumber() == 0) {
                            final double r = directRadiation * Atmosphere.getTransmittance(toReceiver.length() * Scene.getInstance().getAnnotationScale() * 0.001, false);
                            mirror.getSolarPotential()[iMinute] += r * a;
                            if (reflectionMapOnly) {
                                data.dailySolarIntensity[x][y] += r;
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Calendar(java.util.Calendar) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) Ray3(com.ardor3d.math.Ray3) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Roof(org.concord.energy3d.model.Roof) Spatial(com.ardor3d.scenegraph.Spatial) CancellationException(java.util.concurrent.CancellationException) Foundation(org.concord.energy3d.model.Foundation) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) PickResults(com.ardor3d.intersection.PickResults) HousePart(org.concord.energy3d.model.HousePart)

Example 50 with Foundation

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

the class SolarRadiation method initCollidables.

private void initCollidables() {
    collidables.clear();
    collidablesToParts.clear();
    for (final HousePart part : Scene.getInstance().getParts()) {
        if (part instanceof SolarCollector || part instanceof Tree || part instanceof Window) {
            if (part instanceof Rack) {
                final Rack rack = (Rack) part;
                if (rack.isMonolithic()) {
                    final Spatial s = part.getRadiationCollisionSpatial();
                    collidables.add(s);
                    collidablesToParts.put(s, rack);
                }
            } else {
                final Spatial s = part.getRadiationCollisionSpatial();
                collidables.add(s);
                collidablesToParts.put(s, part);
            }
        } else if (part instanceof Foundation) {
            final Foundation foundation = (Foundation) part;
            for (int i = 0; i < 4; i++) {
                final Spatial s = foundation.getRadiationCollisionSpatial(i);
                collidables.add(s);
                collidablesToParts.put(s, foundation);
            }
            final List<Node> importedNodes = foundation.getImportedNodes();
            if (importedNodes != null) {
                for (final Node node : importedNodes) {
                    for (final Spatial s : node.getChildren()) {
                        collidables.add(s);
                        collidablesToParts.put(s, foundation);
                    }
                }
            }
        } else if (part instanceof Wall) {
            final Wall wall = (Wall) part;
            if (wall.getType() == Wall.SOLID_WALL) {
                final Spatial s = part.getRadiationCollisionSpatial();
                collidables.add(s);
                collidablesToParts.put(s, wall);
            }
        } else if (part instanceof Door) {
            final Door door = (Door) part;
            final Spatial s = door.getRadiationCollisionSpatial();
            collidables.add(s);
            collidablesToParts.put(s, door);
        } else if (part instanceof Floor) {
            final Floor floor = (Floor) part;
            final Spatial s = floor.getRadiationCollisionSpatial();
            collidables.add(s);
            collidablesToParts.put(s, floor);
        } else if (part instanceof Roof) {
            final Roof roof = (Roof) part;
            for (final Spatial roofPart : roof.getRoofPartsRoot().getChildren()) {
                if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
                    final Spatial s = ((Node) roofPart).getChild(6);
                    collidables.add(s);
                    collidablesToParts.put(s, roof);
                }
            }
        }
    }
}
Also used : Window(org.concord.energy3d.model.Window) Floor(org.concord.energy3d.model.Floor) Wall(org.concord.energy3d.model.Wall) Node(com.ardor3d.scenegraph.Node) Door(org.concord.energy3d.model.Door) Rack(org.concord.energy3d.model.Rack) 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) List(java.util.List) ArrayList(java.util.ArrayList) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

Foundation (org.concord.energy3d.model.Foundation)174 HousePart (org.concord.energy3d.model.HousePart)153 Rack (org.concord.energy3d.model.Rack)47 SolarPanel (org.concord.energy3d.model.SolarPanel)45 Window (org.concord.energy3d.model.Window)39 ActionEvent (java.awt.event.ActionEvent)38 ActionListener (java.awt.event.ActionListener)38 Roof (org.concord.energy3d.model.Roof)38 Wall (org.concord.energy3d.model.Wall)37 ArrayList (java.util.ArrayList)35 JDialog (javax.swing.JDialog)35 JMenuItem (javax.swing.JMenuItem)33 Mirror (org.concord.energy3d.model.Mirror)32 FresnelReflector (org.concord.energy3d.model.FresnelReflector)27 Door (org.concord.energy3d.model.Door)24 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)24 Tree (org.concord.energy3d.model.Tree)24 Vector3 (com.ardor3d.math.Vector3)22 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)22 ParabolicDish (org.concord.energy3d.model.ParabolicDish)22