[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Space.java, 1.166, 1.167 Entity.java
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-08-13 11:36:34
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25175/src/net/sourceforge/bprocessor/model Modified Files: Space.java Entity.java Edge.java EnergyCalc.java Log Message: fixed energy calc Index: EnergyCalc.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/EnergyCalc.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EnergyCalc.java 26 Jun 2007 10:56:54 -0000 1.9 --- EnergyCalc.java 13 Aug 2007 11:36:21 -0000 1.10 *************** *** 7,33 **** 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().world().getSurfaces().iterator(); double totalloss = 0; ! ! while (it.hasNext()) { ! Surface current = (Surface) it.next(); if (current.getFrontDomain().getClassification() != null) { if (current.getFrontDomain().getClassification().getId().equalsIgnoreCase("-80")) { totalloss = totalloss + calcloss(current.getBackDomain(), current); ! } ! if (current.getFrontDomain().getClassification().getId(). ! equalsIgnoreCase("-100")) { totalloss = totalloss + calcloss(current.getBackDomain(), current); } --- 7,41 ---- package net.sourceforge.bprocessor.model; + import java.util.HashSet; import java.util.Iterator; + import org.apache.log4j.Logger; + /** * This class handles calculations about energy transmission loss */ public class EnergyCalc { + private static Logger log = Logger.getLogger(EnergyCalc.class); /** * energyLoss calculates the total energy transmission loss + * E.i. for every (Space)surface assigned to a functional space that is heated, + * calculate its energy loss * @return the total loss */ public static double energyLoss() { double totalloss = 0; ! HashSet<Surface> functionalAssigned = new HashSet<Surface>(); ! for (Space space : Project.getInstance().world().getElements()) { ! if (space.getType() == Space.FUNCTIONAL) { ! functionalAssigned.addAll(space.getEnvelope()); ! } ! } ! for (Surface current : functionalAssigned) { if (current.getFrontDomain().getClassification() != null) { if (current.getFrontDomain().getClassification().getId().equalsIgnoreCase("-80")) { totalloss = totalloss + calcloss(current.getBackDomain(), current); ! } else ! if (current.getFrontDomain().getClassification().getId().equalsIgnoreCase("-100")) { totalloss = totalloss + calcloss(current.getBackDomain(), current); } *************** *** 36,42 **** if (current.getBackDomain().getClassification().getId().equalsIgnoreCase("-80")) { totalloss = totalloss + calcloss(current.getFrontDomain(), current); ! } ! if (current.getBackDomain().getClassification().getId() ! .equalsIgnoreCase("-100")) { totalloss = totalloss + calcloss(current.getFrontDomain(), current); } --- 44,49 ---- if (current.getBackDomain().getClassification().getId().equalsIgnoreCase("-80")) { totalloss = totalloss + calcloss(current.getFrontDomain(), current); ! } else ! if (current.getBackDomain().getClassification().getId().equalsIgnoreCase("-100")) { totalloss = totalloss + calcloss(current.getFrontDomain(), current); } *************** *** 51,121 **** /** * 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().getFullId(null).equalsIgnoreCase("-210.01")) { ! loss = (Double)classification.getParameter("uvalue").getValue() * current.getArea(); ! //loss = 0.15 * current.getArea(); ! return loss; ! } ! if (classification.getClassification().getFullId(null).equalsIgnoreCase("-215.01") || ! classification.getClassification().getFullId(null).equalsIgnoreCase("-215")) { ! loss = (Double)classification.getParameter("uvalue").getValue() * current.getArea(); ! //loss = 0.15 * current.getArea(); ! return loss; ! } ! if (classification.getClassification().getFullId(null).equalsIgnoreCase("-215.04")) { ! loss = (Double)classification.getParameter("uvalue").getValue() * current.getArea(); ! //loss = 0.15 * current.getArea(); ! return loss; ! } ! if (classification.getClassification().getFullId(null).equalsIgnoreCase("-205")) { ! loss = (Double)classification.getParameter("uvalue").getValue() * current.getArea(); ! //loss = 0.25 * current.getArea(); ! return loss; ! } ! if (classification.getClassification().getFullId(null).equalsIgnoreCase("-205.01")) { ! loss = (Double)classification.getParameter("uvalue").getValue() * current.getArea(); ! return loss; ! } ! if (classification.getClassification().getName().equalsIgnoreCase("termovindue")) { ! loss = 2.5 * current.getArea(); ! return loss; ! } ! if (classification.getClassification(). ! getName().equalsIgnoreCase("2-lags lavenergivindue")) { ! loss = 1.5 * current.getArea(); ! return loss; ! } ! ! if (classification.getClassification(). ! getFullId(null).equalsIgnoreCase("-205.02")) { ! loss = (Double)classification.getParameter("uvalue").getValue() * current.getArea(); ! //loss = 0.8 * current.getArea(); ! return loss; ! } ! ! if (classification.getClassification().getFullId(null).equalsIgnoreCase("-205.03")) { ! 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; --- 58,81 ---- /** * Calculates energyloss of a surface ! * @param classification The space assigned to current that is opposite the heated functional ! * space that have to be assigned to current * @param current The current Surface ! * @return the enegyloss */ private static double calcloss(Space classification, Surface current) { double loss = 0; ! if (isrelevant(classification, current)) { ! for (Space elemcheck : classification.getElements()) { if (!elemcheck.getName().equalsIgnoreCase("Void")) { ! log.warn("The space " + classification + " had elements"); } } ! Attribute a = classification.getParameter("uvalue"); ! if (a != null && a.getValue() != null) { ! loss = (Double)classification.getParameter("uvalue").getValue() * current.getArea(); ! } else { ! log.warn("uvalue for " + classification + " through " + current + " were't there"); ! } ! return loss; } return loss; *************** *** 124,127 **** --- 84,88 ---- /** * Test if the surface is relevant for thermiccalculation + * E.i. current have a * @param classification The classifaction of the surface * @param current The current Surface *************** *** 139,150 **** Space spa = null; ! Iterator it = Project.getInstance().world().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))) { --- 100,111 ---- Space spa = null; ! //Find closest surface that have a functional space as either front or back domain ! for (Surface sur : classification.getEnvelope()) { Vertex interpoint = sur.plane().intersection(origin, normal, true); if (interpoint != null) { if (sur.surrounds(interpoint)) { ! if ((sur.getFrontDomain().isFunctionalSpace() || sur.getBackDomain().isFunctionalSpace()) ! && !(sur.getFrontDomain().isFunctionalSpace() & ! sur.getBackDomain().isFunctionalSpace())) { if (origin.distance(interpoint) != 0 && (distance == 0 || distance > origin.distance(interpoint))) { *************** *** 157,163 **** } ! ! ! if (closest != null && closest.getFrontDomain().isFunctionalSpace()) { spa = closest.getFrontDomain(); --- 118,122 ---- } ! //Choose the resulting functional space from the closest surface if (closest != null && closest.getFrontDomain().isFunctionalSpace()) { spa = closest.getFrontDomain(); *************** *** 167,180 **** } - - if (spa != null) { if (spa.getClassification() != null) { if (spa.getClassification().getParent() != null && ! spa.getClassification().getFullId(null).equalsIgnoreCase("-10")) { relevant = true; } if (spa.getClassification().getParent() != null && ! spa.getClassification().getParent().getFullId(null) .equalsIgnoreCase("-10")) { relevant = true; --- 126,137 ---- } if (spa != null) { if (spa.getClassification() != null) { if (spa.getClassification().getParent() != null && ! spa.getClassification().getId().equalsIgnoreCase("-10")) { relevant = true; } if (spa.getClassification().getParent() != null && ! spa.getClassification().getParent().getId() .equalsIgnoreCase("-10")) { relevant = true; *************** *** 200,221 **** spa = current.getFrontDomain(); if (spa.getClassification() != null) { ! if (spa.getClassification().getFullId(null).equalsIgnoreCase("-10")) { tha = tha + current.getArea(); } if (spa.getClassification().getParent() != null && ! spa.getClassification().getParent().getFullId(null) .equalsIgnoreCase("-10")) { tha = tha + current.getArea(); } } ! } ! if (current.normal().getZ() <= -0.99) { spa = current.getBackDomain(); if (spa.getClassification() != null) { ! if (spa.getClassification().getFullId(null).equalsIgnoreCase("-10")) { tha = tha + current.getArea(); } if (spa.getClassification().getParent() != null && ! spa.getClassification().getParent().getFullId(null) .equalsIgnoreCase("-10")) { tha = tha + current.getArea(); --- 157,177 ---- spa = current.getFrontDomain(); if (spa.getClassification() != null) { ! if (spa.getClassification().getId().equalsIgnoreCase("-10")) { tha = tha + current.getArea(); } if (spa.getClassification().getParent() != null && ! spa.getClassification().getParent().getId() .equalsIgnoreCase("-10")) { tha = tha + current.getArea(); } } ! } else if (current.normal().getZ() <= -0.99) { spa = current.getBackDomain(); if (spa.getClassification() != null) { ! if (spa.getClassification().getId().equalsIgnoreCase("-10")) { tha = tha + current.getArea(); } if (spa.getClassification().getParent() != null && ! spa.getClassification().getParent().getId() .equalsIgnoreCase("-10")) { tha = tha + current.getArea(); Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.166 retrieving revision 1.167 diff -C2 -d -r1.166 -r1.167 *** Space.java 9 Aug 2007 16:07:53 -0000 1.166 --- Space.java 13 Aug 2007 11:36:21 -0000 1.167 *************** *** 2840,2844 **** */ public Attribute getParameter(String string) { ! Attribute a = new Attribute(string, ownParameters.get(string)); if (a == null && getClassificationType() != null) { a = getClassificationType().getParameter(string); --- 2840,2848 ---- */ public Attribute getParameter(String string) { ! Object param = ownParameters.get(string); ! Attribute a = null; ! if (param != null) { ! a = new Attribute(string, param); ! } if (a == null && getClassificationType() != null) { a = getClassificationType().getParameter(string); Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** Edge.java 20 Jul 2007 13:33:26 -0000 1.94 --- Edge.java 13 Aug 2007 11:36:21 -0000 1.95 *************** *** 55,58 **** --- 55,59 ---- public static Vertex first(List edges) { if (edges.size() == 0) { + log.warn("The list were empty"); return null; } else if (edges.size() == 1) { *************** *** 308,311 **** --- 309,313 ---- return getFrom(); } + log.warn(this + " did not contain " + v); return null; } Index: Entity.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Entity.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Entity.java 18 Jul 2007 12:24:04 -0000 1.19 --- Entity.java 13 Aug 2007 11:36:21 -0000 1.20 *************** *** 70,73 **** --- 70,78 ---- final Comparator<Entity> comparator = new Comparator<Entity>() { public int compare(Entity ent1, Entity ent2) { + if (ent1 == null) { + return 1; + } else if (ent2 == null) { + return -1; + } Long id1 = ent1.getId(); Long id2 = ent2.getId(); |