Search in sources :

Example 1 with CspCustomPrice

use of org.concord.energy3d.simulation.CspCustomPrice in project energy3d by concord-consortium.

the class Scene method init.

private void init() {
    root.detachAllChildren();
    originalHouseRoot.detachAllChildren();
    notReceivingShadowRoot.detachAllChildren();
    root.attachChild(originalHouseRoot);
    root.attachChild(notReceivingShadowRoot);
    if (url != null) {
        for (final HousePart p : parts) {
            final boolean b = p instanceof Tree || p instanceof Human;
            (b ? notReceivingShadowRoot : originalHouseRoot).attachChild(p.getRoot());
        }
        System.out.println("initSceneNow done");
    }
    root.updateWorldBound(true);
    SceneManager.getInstance().updateHeliodonAndAnnotationSize();
    SceneManager.getInstance().setAxesVisible(!hideAxes);
    SceneManager.getInstance().getSolarLand().setVisible(solarMapForLand);
    setTheme(theme);
    SceneManager.getInstance().getLand().setDefaultColor(landColor != null ? landColor : new ColorRGBA(0, 1, 0, 0.5f));
    PvModulesData.getInstance();
    final EnergyPanel energyPanel = EnergyPanel.getInstance();
    if (calendar != null) {
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        if (url == null) {
            // if a new file is created, its default time is always set to noon so that the user does not get a dark night scene
            calendar.set(Calendar.HOUR_OF_DAY, 12);
            calendar.set(Calendar.MINUTE, 0);
        }
        final Date time = calendar.getTime();
        Heliodon.getInstance().setDate(time);
        Heliodon.getInstance().setTime(time);
        Util.setSilently(energyPanel.getDateSpinner(), time);
        Util.setSilently(energyPanel.getTimeSpinner(), time);
        if ("Boston".equals(city) || city == null || "".equals(city)) {
            city = "Boston, MA";
            latitude = 42;
        }
        // already silent
        energyPanel.setLatitude(latitude);
        Util.selectSilently(energyPanel.getCityComboBox(), city);
        final LocationData ld = LocationData.getInstance();
        if (ld.getLatitudes().get(city) != null) {
            energyPanel.getCityComboBox().setToolTipText("<html>(" + ld.getLatitudes().get(city) + "&deg;, " + ld.getLongitudes().get(city) + "&deg;), elevation " + ld.getAltitudes().get(city).intValue() + "m<br>Use Edit>Set Region... to select country and region.</html>");
        } else {
            JOptionPane.showMessageDialog(MainFrame.getInstance(), city + " not supported. Please upgrade your Energy3D to the latest.", "Missing City", JOptionPane.ERROR_MESSAGE);
        }
        Scene.getInstance().updateTreeLeaves();
        SceneManager.getInstance().changeSkyTexture();
        if (!first) {
            SceneManager.getInstance().setHeliodonVisible(isHeliodonVisible);
            Util.selectSilently(MainPanel.getInstance().getHeliodonButton(), isHeliodonVisible);
            EventQueue.invokeLater(new Runnable() {

                @Override
                public void run() {
                    MainPanel.getInstance().getSunAnimationButton().setEnabled(isHeliodonVisible);
                }
            });
        }
        Heliodon.getInstance().drawSun();
        SceneManager.getInstance().setShading(Heliodon.getInstance().isNightTime());
    }
    // previous versions do not have the following classes
    if (designSpecs == null) {
        designSpecs = new DesignSpecs();
    } else {
        designSpecs.setDefaultValues();
    }
    if (pvDesignSpecs == null) {
        pvDesignSpecs = new PvDesignSpecs();
    } else {
        pvDesignSpecs.setDefaultValues();
    }
    if (cspDesignSpecs == null) {
        cspDesignSpecs = new CspDesignSpecs();
    } else {
        cspDesignSpecs.setDefaultValues();
    }
    if (pvCustomPrice == null) {
        pvCustomPrice = new PvCustomPrice();
    } else {
        pvCustomPrice.setDefaultValues();
    }
    if (cspCustomPrice == null) {
        cspCustomPrice = new CspCustomPrice();
    } else {
        cspCustomPrice.setDefaultValues();
    }
    if (ground == null) {
        ground = new Ground();
    }
    if (atmosphere == null) {
        atmosphere = new Atmosphere();
    }
    if (unit == null) {
        unit = Unit.InternationalSystemOfUnits;
    }
    // restore the default values
    if (Util.isZero(heatVectorLength)) {
        heatVectorLength = 5000;
    }
    if (Util.isZero(heatFluxGridSize)) {
        heatFluxGridSize = 2;
    }
    if (Util.isZero(solarStep)) {
        solarStep = 2;
    }
    if (Util.isZero(timeStep)) {
        timeStep = 15;
    }
    if (Util.isZero(solarPanelNx)) {
        solarPanelNx = 4;
    }
    if (Util.isZero(solarPanelNy)) {
        solarPanelNy = 4;
    }
    if (Util.isZero(rackNx)) {
        rackNx = 8;
    }
    if (Util.isZero(rackNy)) {
        rackNy = 8;
    }
    if (Util.isZero(mirrorNx)) {
        mirrorNx = 4;
    }
    if (Util.isZero(mirrorNy)) {
        mirrorNy = 4;
    }
    if (Util.isZero(parabolicDishN)) {
        parabolicDishN = 4;
    }
    if (Util.isZero(rackCellSize)) {
        rackCellSize = 1;
    }
    if (Util.isZero(solarContrast)) {
        solarContrast = 50;
    }
    // in case we need to have more instruction sheets
    if (instructionSheetText != null) {
        if (instructionSheetText.length < INSTRUCTION_SHEET_NUMBER) {
            final String[] tmp = new String[INSTRUCTION_SHEET_NUMBER];
            System.arraycopy(instructionSheetText, 0, tmp, 0, instructionSheetText.length);
            instructionSheetText = tmp;
        }
    }
    if (instructionSheetTextType != null) {
        if (instructionSheetTextType.length < INSTRUCTION_SHEET_NUMBER) {
            final String[] tmp = new String[INSTRUCTION_SHEET_NUMBER];
            System.arraycopy(instructionSheetTextType, 0, tmp, 0, instructionSheetTextType.length);
            instructionSheetTextType = tmp;
        }
    }
    setEdited(false);
    setCopyBuffer(null);
    Util.setSilently(energyPanel.getColorMapSlider(), solarContrast);
    // need to do this to avoid logging
    Util.setSilently(MainPanel.getInstance().getNoteTextArea(), note == null ? "" : note);
    EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            energyPanel.updateThermostat();
            // necessary for the scroll bars to show up appropriately
            MainPanel.getInstance().setNoteVisible(MainPanel.getInstance().isNoteVisible());
            // moved from OpenNow to here to avoid triggering EnergyComputer -> RedrawAllNow before open is completed
            MainPanel.getInstance().getEnergyButton().setSelected(false);
            SceneManager.getInstance().getUndoManager().discardAllEdits();
            MainApplication.getEventLog().clear();
        }
    });
}
Also used : Human(org.concord.energy3d.model.Human) PvCustomPrice(org.concord.energy3d.simulation.PvCustomPrice) Ground(org.concord.energy3d.simulation.Ground) Date(java.util.Date) ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ColorRGBA(com.ardor3d.math.ColorRGBA) EnergyPanel(org.concord.energy3d.gui.EnergyPanel) LocationData(org.concord.energy3d.simulation.LocationData) DesignSpecs(org.concord.energy3d.simulation.DesignSpecs) CspDesignSpecs(org.concord.energy3d.simulation.CspDesignSpecs) PvDesignSpecs(org.concord.energy3d.simulation.PvDesignSpecs) CspDesignSpecs(org.concord.energy3d.simulation.CspDesignSpecs) Atmosphere(org.concord.energy3d.simulation.Atmosphere) PvDesignSpecs(org.concord.energy3d.simulation.PvDesignSpecs) Tree(org.concord.energy3d.model.Tree) CspCustomPrice(org.concord.energy3d.simulation.CspCustomPrice) HousePart(org.concord.energy3d.model.HousePart)

Example 2 with CspCustomPrice

use of org.concord.energy3d.simulation.CspCustomPrice in project energy3d by concord-consortium.

the class CspProjectInfoPanel method updateBudgetMaximum.

public void updateBudgetMaximum() {
    final CspCustomPrice price = Scene.getInstance().getCspCustomPrice();
    final CspDesignSpecs specs = Scene.getInstance().getCspDesignSpecs();
    String t = "Total cost over " + price.getLifespan() + " years";
    if (specs.isBudgetEnabled()) {
        t += " (" + "<$" + specs.getMaximumBudget() + ")";
    }
    costBar.setMaximum(specs.getMaximumBudget());
    costPanel.setBorder(EnergyPanel.createTitledBorder(t, true));
    costBar.setEnabled(specs.isBudgetEnabled());
    costBar.repaint();
}
Also used : CspDesignSpecs(org.concord.energy3d.simulation.CspDesignSpecs) CspCustomPrice(org.concord.energy3d.simulation.CspCustomPrice)

Example 3 with CspCustomPrice

use of org.concord.energy3d.simulation.CspCustomPrice in project energy3d by concord-consortium.

the class CspProjectInfoPanel method update.

void update(final Foundation foundation) {
    final List<ParabolicTrough> troughs = foundation.getParabolicTroughs();
    if (!troughs.isEmpty()) {
        countBar.setValue(troughs.size());
        int totalModules = 0;
        for (final ParabolicTrough t : troughs) {
            totalModules += t.getNumberOfModules();
        }
        moduleCountBar.setValue(totalModules);
        countPanel.setBorder(EnergyPanel.createTitledBorder("Number of parabolic troughs", true));
        double cost = 0;
        double reflectingArea = 0;
        double troughArea = 0;
        final CspCustomPrice price = Scene.getInstance().getCspCustomPrice();
        for (final ParabolicTrough t : troughs) {
            troughArea = t.getTroughLength() * t.getApertureWidth();
            cost += price.getParabolicTroughUnitPrice() * troughArea;
            reflectingArea += troughArea;
        }
        cost += foundation.getArea() * price.getLandUnitPrice() * price.getLifespan();
        costBar.setValue(Math.round(cost));
        final CspDesignSpecs specs = Scene.getInstance().getCspDesignSpecs();
        String t = "Total cost over " + price.getLifespan() + " years";
        if (specs.isBudgetEnabled()) {
            t += " (" + "<$" + specs.getMaximumBudget() + ")";
        }
        costPanel.setBorder(EnergyPanel.createTitledBorder(t, true));
        packingDensityBar.setValue((float) (reflectingArea / foundation.getArea()));
    } else {
        final List<ParabolicDish> dishes = foundation.getParabolicDishes();
        if (!dishes.isEmpty()) {
            countBar.setValue(dishes.size());
            moduleCountBar.setValue(dishes.size());
            countPanel.setBorder(EnergyPanel.createTitledBorder("Number of parabolic dishes", true));
            double cost = 0;
            double reflectingArea = 0;
            double rimArea = 0;
            final CspCustomPrice price = Scene.getInstance().getCspCustomPrice();
            for (final ParabolicDish d : dishes) {
                rimArea = d.getRimRadius() * d.getRimRadius() * Math.PI;
                cost += price.getHeliostatUnitPrice() * rimArea;
                reflectingArea += rimArea;
            }
            cost += foundation.getArea() * price.getLandUnitPrice() * price.getLifespan();
            costBar.setValue(Math.round(cost));
            final CspDesignSpecs specs = Scene.getInstance().getCspDesignSpecs();
            String t = "Total cost over " + price.getLifespan() + " years";
            if (specs.isBudgetEnabled()) {
                t += " (" + "<$" + specs.getMaximumBudget() + ")";
            }
            costPanel.setBorder(EnergyPanel.createTitledBorder(t, true));
            packingDensityBar.setValue((float) (reflectingArea / foundation.getArea()));
        } else {
            final List<FresnelReflector> fresnels = foundation.getFresnelReflectors();
            if (fresnels.isEmpty()) {
                final List<Mirror> mirrors = foundation.getHeliostats();
                countBar.setValue(mirrors.size());
                moduleCountBar.setValue(mirrors.size());
                countPanel.setBorder(EnergyPanel.createTitledBorder("Number of heliostats", true));
                double cost = 0;
                double reflectingArea = 0;
                double mirrorArea = 0;
                final CspCustomPrice price = Scene.getInstance().getCspCustomPrice();
                final ArrayList<Foundation> towers = new ArrayList<Foundation>();
                for (final Mirror m : mirrors) {
                    mirrorArea = m.getMirrorWidth() * m.getMirrorHeight();
                    cost += price.getHeliostatUnitPrice() * mirrorArea;
                    reflectingArea += mirrorArea;
                    if (m.getReceiver() != null) {
                        if (!towers.contains(m.getReceiver())) {
                            towers.add(m.getReceiver());
                        }
                    }
                }
                if (!mirrors.isEmpty()) {
                    cost += foundation.getArea() * price.getLandUnitPrice() * price.getLifespan();
                    if (!towers.isEmpty()) {
                        for (final Foundation tower : towers) {
                            cost += price.getTowerUnitPrice() * tower.getSolarReceiverHeight(0) * Scene.getInstance().getAnnotationScale();
                        }
                    }
                } else {
                    if (foundation.hasSolarReceiver()) {
                        cost += price.getTowerUnitPrice() * foundation.getSolarReceiverHeight(0) * Scene.getInstance().getAnnotationScale();
                    }
                }
                costBar.setValue(Math.round(cost));
                final CspDesignSpecs specs = Scene.getInstance().getCspDesignSpecs();
                String t = "Total cost over " + price.getLifespan() + " years";
                if (specs.isBudgetEnabled()) {
                    t += " (" + "<$" + specs.getMaximumBudget() + ")";
                }
                costPanel.setBorder(EnergyPanel.createTitledBorder(t, true));
                packingDensityBar.setValue((float) (reflectingArea / foundation.getArea()));
            } else {
                countBar.setValue(fresnels.size());
                int totalModules = 0;
                for (final FresnelReflector r : fresnels) {
                    totalModules += r.getNumberOfModules();
                }
                moduleCountBar.setValue(totalModules);
                countPanel.setBorder(EnergyPanel.createTitledBorder("Number of Fresnel reflectors", true));
                double cost = 0;
                double reflectingArea = 0;
                double unitArea = 0;
                final CspCustomPrice price = Scene.getInstance().getCspCustomPrice();
                for (final FresnelReflector r : fresnels) {
                    unitArea = r.getLength() * r.getModuleWidth();
                    cost += price.getFresnelReflectorUnitPrice() * unitArea;
                    reflectingArea += unitArea;
                }
                cost += foundation.getArea() * price.getLandUnitPrice() * price.getLifespan();
                costBar.setValue(Math.round(cost));
                final CspDesignSpecs specs = Scene.getInstance().getCspDesignSpecs();
                String t = "Total cost over " + price.getLifespan() + " years";
                if (specs.isBudgetEnabled()) {
                    t += " (" + "<$" + specs.getMaximumBudget() + ")";
                }
                costPanel.setBorder(EnergyPanel.createTitledBorder(t, true));
                packingDensityBar.setValue((float) (reflectingArea / foundation.getArea()));
            }
        }
    }
}
Also used : ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) ArrayList(java.util.ArrayList) ParabolicDish(org.concord.energy3d.model.ParabolicDish) CspDesignSpecs(org.concord.energy3d.simulation.CspDesignSpecs) CspCustomPrice(org.concord.energy3d.simulation.CspCustomPrice) Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror)

Aggregations

CspCustomPrice (org.concord.energy3d.simulation.CspCustomPrice)3 CspDesignSpecs (org.concord.energy3d.simulation.CspDesignSpecs)3 ColorRGBA (com.ardor3d.math.ColorRGBA)1 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 EnergyPanel (org.concord.energy3d.gui.EnergyPanel)1 Foundation (org.concord.energy3d.model.Foundation)1 FresnelReflector (org.concord.energy3d.model.FresnelReflector)1 HousePart (org.concord.energy3d.model.HousePart)1 Human (org.concord.energy3d.model.Human)1 Mirror (org.concord.energy3d.model.Mirror)1 ParabolicDish (org.concord.energy3d.model.ParabolicDish)1 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)1 Tree (org.concord.energy3d.model.Tree)1 Atmosphere (org.concord.energy3d.simulation.Atmosphere)1 DesignSpecs (org.concord.energy3d.simulation.DesignSpecs)1 Ground (org.concord.energy3d.simulation.Ground)1 LocationData (org.concord.energy3d.simulation.LocationData)1 PvCustomPrice (org.concord.energy3d.simulation.PvCustomPrice)1