use of org.concord.energy3d.model.SolarCollector in project energy3d by concord-consortium.
the class SolarRadiation method computeEnergyOfToday.
public void computeEnergyOfToday() {
updateTextures();
if (Scene.getInstance().getAlwaysComputeHeatFluxVectors()) {
for (final HousePart part : Scene.getInstance().getParts()) {
part.drawHeatFlux();
}
}
final Calendar today = Heliodon.getInstance().getCalendar();
final String city = (String) EnergyPanel.getInstance().getCityComboBox().getSelectedItem();
final double[] outsideTemperatureRange = Weather.computeOutsideTemperature(today, city);
for (final HousePart part : Scene.getInstance().getParts()) {
if (part instanceof Foundation) {
final Foundation foundation = (Foundation) part;
final int n = foundation.getHeatLoss().length;
final double[] heatLoss = new double[n];
final double[] passiveSolar = new double[n];
final double[] photovoltaic = new double[n];
final double[] csp = new double[n];
for (int i = 0; i < n; i++) {
final double groundHeatLoss = foundation.getHeatLoss()[i];
// In other words, geothermal energy is good in hot conditions. This is similar to passive solar energy, which is good in the winter but bad in the summer.
if (groundHeatLoss > 0) {
final double outsideTemperature = Weather.getInstance().getOutsideTemperatureAtMinute(outsideTemperatureRange[1], outsideTemperatureRange[0], i * Scene.getInstance().getTimeStep());
if (outsideTemperature >= foundation.getThermostat().getTemperature(today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY, today.get(Calendar.HOUR_OF_DAY))) {
heatLoss[i] -= groundHeatLoss;
}
} else {
heatLoss[i] += groundHeatLoss;
}
}
double solarPotentialTotal = 0;
for (final HousePart child : Scene.getInstance().getParts()) {
if (child.getTopContainer() == foundation) {
child.setSolarPotentialToday(0);
if (child instanceof SolarCollector) {
((SolarCollector) child).setYieldToday(0);
}
for (int i = 0; i < n; i++) {
solarPotentialTotal += child.getSolarPotential()[i];
child.setSolarPotentialToday(child.getSolarPotentialToday() + child.getSolarPotential()[i]);
if (child instanceof Wall || child instanceof Door || child instanceof Window || child instanceof Roof) {
heatLoss[i] += child.getHeatLoss()[i];
}
if (child instanceof Window) {
final Window window = (Window) child;
passiveSolar[i] += child.getSolarPotential()[i] * window.getSolarHeatGainCoefficient();
} else if (child instanceof SolarPanel) {
final SolarPanel sp = (SolarPanel) child;
// distributed efficiency must be handled for each individual cell
final double yield = sp.getSolarPotential()[i];
sp.setYieldToday(sp.getYieldToday() + yield);
photovoltaic[i] += yield;
} else if (child instanceof Rack) {
final Rack rack = (Rack) child;
// distributed efficiency must be handled for each individual cell
final double yield = rack.getSolarPotential()[i];
rack.setYieldToday(rack.getYieldToday() + yield);
photovoltaic[i] += yield;
} else if (child instanceof Mirror) {
final Mirror mirror = (Mirror) child;
final double yield = mirror.getSolarPotential()[i] * mirror.getSystemEfficiency();
mirror.setYieldToday(mirror.getYieldToday() + yield);
csp[i] += yield;
} else if (child instanceof ParabolicTrough) {
final ParabolicTrough trough = (ParabolicTrough) child;
final double yield = trough.getSolarPotential()[i] * trough.getSystemEfficiency();
trough.setYieldToday(trough.getYieldToday() + yield);
csp[i] += yield;
} else if (child instanceof ParabolicDish) {
final ParabolicDish dish = (ParabolicDish) child;
final double yield = dish.getSolarPotential()[i] * dish.getSystemEfficiency();
dish.setYieldToday(dish.getYieldToday() + yield);
csp[i] += yield;
} else if (child instanceof FresnelReflector) {
final FresnelReflector reflector = (FresnelReflector) child;
final double yield = reflector.getSolarPotential()[i] * reflector.getSystemEfficiency();
reflector.setYieldToday(reflector.getYieldToday() + yield);
csp[i] += yield;
}
}
}
}
if (foundation.getImportedNodes() != null) {
for (int i = 0; i < n; i++) {
solarPotentialTotal += foundation.getSolarPotential()[i];
foundation.setSolarPotentialToday(foundation.getSolarPotentialToday() + foundation.getSolarPotential()[i]);
}
}
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.setSolarPotentialToday(solarPotentialTotal);
foundation.setPassiveSolarToday(passiveSolarTotal);
foundation.setPhotovoltaicToday(photovoltaicTotal);
foundation.setCspToday(cspTotal);
foundation.setHeatingToday(heatingTotal);
foundation.setCoolingToday(coolingTotal);
foundation.setTotalEnergyToday(heatingTotal + coolingTotal - photovoltaicTotal);
}
}
}
use of org.concord.energy3d.model.SolarCollector in project energy3d by concord-consortium.
the class ChangeBaseHeightForAllSolarCollectorsCommand method redo.
@Override
public void redo() throws CannotRedoException {
super.redo();
final int n = collectors.size();
for (int i = 0; i < n; i++) {
final SolarCollector t = collectors.get(i);
t.setBaseHeight(newValues[i]);
if (t instanceof HousePart) {
((HousePart) t).draw();
}
}
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.model.SolarCollector in project energy3d by concord-consortium.
the class CspProjectCostGraph method calculateCost.
private void calculateCost() {
landSum = 0;
collectorSum = 0;
receiverSum = 0;
if (foundation.hasSolarReceiver()) {
receiverSum = CspProjectCost.getPartCost(foundation);
} else {
landSum = CspProjectCost.getPartCost(foundation);
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 += CspProjectCost.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 += CspProjectCost.getPartCost(absorber);
}
}
}
}
}
for (final HousePart p : Scene.getInstance().getParts()) {
if (p.getTopContainer() == foundation) {
if (p instanceof SolarCollector) {
// assuming that sensor doesn't cost anything
collectorSum += CspProjectCost.getPartCost(p);
}
}
}
totalCost = landSum + collectorSum + receiverSum;
}
use of org.concord.energy3d.model.SolarCollector in project energy3d by concord-consortium.
the class Scene method cleanup.
private void cleanup() {
// fix if roof and wall are not linked from each other
for (final HousePart p : parts) {
if (p instanceof Roof) {
final Roof r = (Roof) p;
final HousePart c = r.getContainer();
if (c != null && !c.getChildren().contains(r)) {
c.getChildren().add(r);
}
}
}
final ArrayList<HousePart> toBeRemoved = new ArrayList<HousePart>();
for (final HousePart p : parts) {
if (!p.isValid()) {
// remove invalid parts
toBeRemoved.add(p);
} else if (p.getContainer() == null) {
// remove orphan parts without a container
if (p instanceof Wall || p instanceof Roof || p instanceof Window || p instanceof Door || p instanceof SolarCollector || p instanceof Floor) {
toBeRemoved.add(p);
}
} else if (!parts.contains(p.getContainer())) {
// remove parts whose container doesn't exist in the scene
toBeRemoved.add(p);
}
}
for (final HousePart p : toBeRemoved) {
remove(p, false);
}
// remove walls that are at the same position
toBeRemoved.clear();
for (final HousePart p : parts) {
if (p instanceof Wall) {
// remove walls that are at the same position
if (((Wall) p).isAtSamePlaceAsAnotherPart()) {
toBeRemoved.add(p);
}
}
}
for (final HousePart p : toBeRemoved) {
remove(p, false);
}
// remove children with multiple parents
toBeRemoved.clear();
for (final HousePart p : parts) {
for (final HousePart child : p.getChildren()) {
if (child.getContainer() != p && !toBeRemoved.contains(child)) {
toBeRemoved.add(child);
}
}
}
for (final HousePart p : toBeRemoved) {
remove(p, false);
}
// remove from remaining parents
for (final HousePart p : parts) {
for (final HousePart r : toBeRemoved) {
p.getChildren().remove(r);
}
}
// remove all the children that are not in parts
toBeRemoved.clear();
for (final HousePart p : parts) {
for (final HousePart child : p.getChildren()) {
if (!parts.contains(child) && !toBeRemoved.contains(child)) {
toBeRemoved.add(child);
}
}
}
for (final HousePart p : toBeRemoved) {
remove(p, false);
}
// complete all non-completed parts
for (final HousePart p : parts) {
if (!p.isDrawCompleted()) {
p.complete();
}
}
}
use of org.concord.energy3d.model.SolarCollector in project energy3d by concord-consortium.
the class SolarRadiation method updateTextures.
public void updateTextures() {
EnergyPanel.getInstance().setComputingStartMillis(System.currentTimeMillis());
maxValue = Math.round((MINUTES_OF_DAY / Scene.getInstance().getTimeStep() + 1.0) * (1 - 0.01 * Scene.getInstance().getSolarHeatMapColorContrast()));
applyTexture(SceneManager.getInstance().getSolarLand());
final int totalMeshes = Scene.getInstance().getParts().size() + Scene.getInstance().countMeshes();
int countMesh = 0;
for (final HousePart part : Scene.getInstance().getParts()) {
if (part instanceof SolarCollector) {
applyTexture(part.getRadiationMesh());
} else {
if (!Scene.getInstance().getOnlySolarComponentsInSolarMap()) {
if (part instanceof Wall || part instanceof Door || part instanceof Floor) {
applyTexture(part.getRadiationMesh());
} else if (part instanceof Foundation) {
final Foundation foundation = (Foundation) part;
for (int i = 0; i < 5; i++) {
applyTexture(foundation.getRadiationMesh(i));
}
final List<Node> importedNodes = foundation.getImportedNodes();
if (importedNodes != null) {
for (final Node node : importedNodes) {
for (final Spatial s : node.getChildren()) {
applyTexture((Mesh) s);
EnergyPanel.getInstance().progress((int) Math.round(100.0 * (countMesh++) / totalMeshes));
}
}
}
} else if (part instanceof Roof) {
for (final Spatial roofPart : ((Roof) part).getRoofPartsRoot().getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
final Mesh mesh = (Mesh) ((Node) roofPart).getChild(6);
applyTexture(mesh);
}
}
}
}
}
countMesh++;
}
EnergyPanel.getInstance().progress(0);
}
Aggregations