Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model EnergyCalc.java, NONE, 1.1
Status: Pre-Alpha
Brought to you by:
henryml
From: Nikolaj B. <nbr...@us...> - 2006-09-11 09:23:23
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10973/src/net/sourceforge/bprocessor/model Added Files: EnergyCalc.java Log Message: Contains the different methods used in energycalculations --- NEW FILE: EnergyCalc.java --- //--------------------------------------------------------------------------------- // $Id: EnergyCalc.java,v 1.1 2006/09/11 09:23:20 nbramsen Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.util.Iterator; /** * This class handles calculations about energy transmission loss */ public class EnergyCalc { /** * energyLoss calculates the total energy transmission loss * @return the total loss */ public static double energyLoss() { Iterator it = Project.getInstance().getSurfaces().iterator(); double totalloss = 0; while (it.hasNext()) { Surface current = (Surface) it.next(); if (current.getFrontDomain().getClassification().equalsIgnoreCase("Exteriør")) { totalloss = totalloss + calcloss(current.getBackDomain(), current); } if (current.getFrontDomain().getClassification().equalsIgnoreCase("Uopvarmet rum")) { totalloss = totalloss + calcloss(current.getBackDomain(), current); } if (current.getBackDomain().getClassification().equalsIgnoreCase("Exteriør")) { totalloss = totalloss + calcloss(current.getFrontDomain(), current); } if (current.getBackDomain().getClassification().equalsIgnoreCase("Uopvarmet rum")) { totalloss = totalloss + calcloss(current.getFrontDomain(), current); } } return totalloss; } /** * Calculates energyloss of a surface * @param classification The classifaction of the surface * @param current The current Surface * @return the loss */ private static double calcloss(Space classification, Surface current) { double loss = 0; boolean first = true; if (isrelevant(classification, current)) { Iterator it = classification.getElements().iterator(); while (it.hasNext()) { Space elemcheck = (Space) it.next(); if (elemcheck.getName().equalsIgnoreCase("Void") && first) { if (classification.getClassification().equalsIgnoreCase("Terrandæk")) { loss = 0.15 * current.getArea(); return loss; } if (classification.getClassification().equalsIgnoreCase("Tagkonstruktion")) { loss = 0.15 * current.getArea(); return loss; } if (classification.getClassification().equalsIgnoreCase("Loft")) { loss = 0.15 * current.getArea(); return loss; } if (classification.getClassification().equalsIgnoreCase("Ydervæg")) { loss = 0.25 * current.getArea(); return loss; } if (classification.getClassification().equalsIgnoreCase("Ældre termovindue")) { loss = 2.5 * current.getArea(); return loss; } if (classification.getClassification().equalsIgnoreCase("2-lags lavenergivindue")) { loss = 1.5 * current.getArea(); return loss; } if (classification.getClassification().equalsIgnoreCase("3-lags lavenergivindue")) { loss = 0.8 * current.getArea(); return loss; } if (classification.getClassification().equalsIgnoreCase("Dør")) { loss = 1.5 * current.getArea(); return loss; } System.out.println("void - no more element spaces"); } if (!elemcheck.getName().equalsIgnoreCase("Void")) { System.out.println(elemcheck.getName()); } first = false; } } return loss; } /** * Test if the surface is relevant for thermiccalculation * @param classification The classifaction of the surface * @param current The current Surface * @return true if the surface is relevant */ private static boolean isrelevant(Space classification, Surface current) { boolean relevant = false; Vertex normal = current.normal(); if (current.getBackDomain().isConstructionSpace()) { normal.scale(-1); } Vertex origin = current.center(); double distance = 0; Surface closest = null; Space spa = null; Iterator it = Project.getInstance().getSurfaces().iterator(); while (it.hasNext()) { Surface sur = (Surface) it.next(); Vertex interpoint = sur.plane().intersection(origin, normal, true); if (interpoint != null) { if (sur.surrounds(interpoint)) { if (sur.getFrontDomain().isFunctionalSpace() || sur.getBackDomain().isFunctionalSpace()) { if (origin.distance(interpoint) != 0 && (distance == 0 || distance > origin.distance(interpoint))) { distance = origin.distance(interpoint); closest = sur; } } } } } if (closest != null && closest.getFrontDomain().isFunctionalSpace()) { spa = closest.getFrontDomain(); } if (closest != null && closest.getBackDomain().isFunctionalSpace()) { spa = closest.getBackDomain(); } if (spa != null && (spa.getClassification().equalsIgnoreCase("Stue") || spa.getClassification().equalsIgnoreCase("Badeværelse") || spa.getClassification().equalsIgnoreCase("Opvarmet rum"))) { relevant = true; } return relevant; } /** * heatedArea calculates the total area that is heated in the building * @return the total heated area */ public static double heatedArea() { double tha = 0; Iterator it = Project.getInstance().getSurfaces().iterator(); while (it.hasNext()) { Surface current = (Surface) it.next(); Space spa = null; if (current.normal().getZ() >= 0.99) { spa = current.getFrontDomain(); if (spa.getClassification() != null && (spa.getClassification().equalsIgnoreCase("Stue") || spa.getClassification().equalsIgnoreCase("Badeværelse") || spa.getClassification().equalsIgnoreCase("Opvarmet rum"))) { tha = tha + current.getArea(); } } if (current.normal().getZ() <= -0.99) { spa = current.getBackDomain(); if (spa.getClassification() != null && (spa.getClassification().equalsIgnoreCase("Stue") || spa.getClassification().equalsIgnoreCase("Badeværelse") || spa.getClassification().equalsIgnoreCase("Opvarmet rum"))) { tha = tha + current.getArea(); } } } return tha; } } |