use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class ParabolicDishDailyAnalysis method updateGraph.
@Override
public void updateGraph() {
for (int i = 0; i < 24; i++) {
SolarRadiation.getInstance().computeEnergyAtHour(i);
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart != null) {
if (selectedPart instanceof ParabolicDish) {
final ParabolicDish d = (ParabolicDish) selectedPart;
graph.addData("Solar", d.getSolarPotentialNow() * d.getSystemEfficiency());
} else if (selectedPart instanceof Foundation) {
double output = 0;
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof ParabolicDish && p.getTopContainer() == selectedPart) {
final ParabolicDish d = (ParabolicDish) p;
output += d.getSolarPotentialNow() * d.getSystemEfficiency();
}
}
graph.addData("Solar", output);
} else if (selectedPart.getTopContainer() instanceof Foundation) {
double output = 0;
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof ParabolicDish && p.getTopContainer() == selectedPart.getTopContainer()) {
final ParabolicDish d = (ParabolicDish) p;
output += d.getSolarPotentialNow() * d.getSystemEfficiency();
}
}
graph.addData("Solar", output);
}
} else {
double output = 0;
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof ParabolicDish) {
final ParabolicDish d = (ParabolicDish) p;
output += d.getSolarPotentialNow() * d.getSystemEfficiency();
}
}
graph.addData("Solar", output);
}
}
graph.repaint();
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class ParabolicDishDailyAnalysis method show.
public void show() {
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
String s = null;
int cost = -1;
String title = "Daily Yield of All Parabolic Dishes (" + Scene.getInstance().countParts(ParabolicDish.class) + " Dishes)";
if (selectedPart != null) {
if (selectedPart instanceof ParabolicDish) {
cost = (int) CspProjectCost.getPartCost(selectedPart);
s = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
title = "Daily Yield";
} else if (selectedPart instanceof Foundation) {
title = "Daily Yield of Selected Foundation (" + ((Foundation) selectedPart).countParts(ParabolicDish.class) + " Parabolic Dishes)";
} else if (selectedPart.getTopContainer() instanceof Foundation) {
title = "Daily Yield of Selected Foundation (" + selectedPart.getTopContainer().countParts(ParabolicDish.class) + " Parabolic Dishes)";
}
}
final JDialog dialog = createDialog(s == null ? title : title + ": " + s + " (Cost: $" + cost + ")");
final JMenuBar menuBar = new JMenuBar();
dialog.setJMenuBar(menuBar);
menuBar.add(createOptionsMenu(dialog, null, true));
menuBar.add(createRunsMenu());
dialog.setVisible(true);
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class ParabolicTroughAnnualAnalysis method show.
public void show() {
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
String s = null;
int cost = -1;
String title = "Annual Yield of All Parabolic Troughs (" + Scene.getInstance().countParts(ParabolicTrough.class) + " Troughs)";
if (selectedPart != null) {
if (selectedPart instanceof ParabolicTrough) {
cost = (int) CspProjectCost.getPartCost(selectedPart);
s = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
title = "Annual Yield";
} else if (selectedPart instanceof Foundation) {
title = "Annual Yield of Selected Foundation (" + ((Foundation) selectedPart).countParts(ParabolicTrough.class) + " Parabolic Troughs)";
} else if (selectedPart.getTopContainer() instanceof Foundation) {
title = "Annual Yield of Selected Foundation (" + selectedPart.getTopContainer().countParts(ParabolicTrough.class) + " Parabolic Troughs)";
}
}
final JDialog dialog = createDialog(s == null ? title : title + ": " + s + " (Cost: $" + cost + ")");
final JMenuBar menuBar = new JMenuBar();
dialog.setJMenuBar(menuBar);
menuBar.add(createOptionsMenu(dialog, null, true, true));
menuBar.add(createRunsMenu());
dialog.setVisible(true);
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class ParabolicTroughAnnualAnalysis method updateGraph.
@Override
public void updateGraph() {
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart != null) {
if (selectedPart instanceof ParabolicTrough) {
final ParabolicTrough t = (ParabolicTrough) selectedPart;
graph.addData("Solar", t.getSolarPotentialToday() * t.getSystemEfficiency());
} else if (selectedPart instanceof Foundation) {
double output = 0;
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof ParabolicTrough && p.getTopContainer() == selectedPart) {
final ParabolicTrough t = (ParabolicTrough) p;
output += t.getSolarPotentialToday() * t.getSystemEfficiency();
}
}
graph.addData("Solar", output);
} else if (selectedPart.getTopContainer() instanceof Foundation) {
double output = 0;
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof ParabolicTrough && p.getTopContainer() == selectedPart.getTopContainer()) {
final ParabolicTrough t = (ParabolicTrough) p;
output += t.getSolarPotentialToday() * t.getSystemEfficiency();
}
}
graph.addData("Solar", output);
}
} else {
double output = 0;
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof ParabolicTrough) {
final ParabolicTrough t = (ParabolicTrough) p;
output += t.getSolarPotentialToday() * t.getSystemEfficiency();
}
}
graph.addData("Solar", output);
}
graph.repaint();
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class ParabolicTroughAnnualAnalysis method runAnalysis.
@Override
void runAnalysis(final JDialog parent) {
graph.info = "Calculating...";
graph.repaint();
onStart();
final EnergyPanel e = EnergyPanel.getInstance();
for (final int m : MONTHS) {
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() {
if (!analysisStopped) {
final Calendar c = Heliodon.getInstance().getCalendar();
c.set(Calendar.MONTH, m);
final Calendar today = (Calendar) c.clone();
Scene.getInstance().updateTrackables();
final Throwable t = compute();
if (t != null) {
stopAnalysis();
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
BugReporter.report(t);
}
});
}
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart instanceof Foundation) {
// synchronize with daily graph
final CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
if (g.hasGraph()) {
g.setCalendar(today);
g.updateGraph();
}
}
final Calendar today2 = today;
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
e.getDateSpinner().setValue(c.getTime());
if (selectedPart instanceof Foundation) {
final CspProjectDailyEnergyGraph g = e.getCspProjectDailyEnergyGraph();
e.getCspProjectTabbedPane().setSelectedComponent(g);
if (!g.hasGraph()) {
g.setCalendar(today2);
g.addGraph((Foundation) selectedPart);
}
}
}
});
}
return null;
}
});
}
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
onCompletion();
if (Heliodon.getInstance().getCalendar().get(Calendar.MONTH) != Calendar.DECEMBER) {
// annual calculation aborted
return;
}
final String current = Graph.TWO_DECIMALS.format(getResult("Solar"));
final Map<String, Double> recordedResults = getRecordedResults("Solar");
final int n = recordedResults.size();
if (n > 0) {
String previousRuns = "";
final Object[] keys = recordedResults.keySet().toArray();
for (int i = n - 1; i >= 0; i--) {
previousRuns += keys[i] + " : " + Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + " kWh<br>";
}
final Object[] options = new Object[] { "OK", "Copy Data" };
final String msg = "<html>The calculated annual output is <b>" + current + " kWh</b>.<br><hr>Results from previously recorded tests:<br>" + previousRuns + "</html>";
final JOptionPane optionPane = new JOptionPane(msg, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Annual Output");
dialog.setVisible(true);
final Object choice = optionPane.getValue();
if (choice == options[1]) {
String output = "";
for (int i = 0; i < n; i++) {
output += Graph.TWO_DECIMALS.format(recordedResults.get(keys[i]) * 365.0 / 12.0) + "\n";
}
output += current;
final Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(new StringSelection(output), null);
JOptionPane.showMessageDialog(MainFrame.getInstance(), "<html>" + (n + 1) + " data points copied to system clipboard.<br><hr>" + output, "Confirmation", JOptionPane.INFORMATION_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(parent, "<html>The calculated annual output is <b>" + current + " kWh</b>.</html>", "Annual Output", JOptionPane.INFORMATION_MESSAGE);
}
}
});
return null;
}
});
}
Aggregations