/* Copyright 2000 Charles G. Wright
* This software may be distributed under the terms of the
* GNU General Public License.
*
* $Id: SOLwindow.java,v 1.1 2000-06-15 10:15:06-05 chuckles Exp chuckles $
*/
import java.math.*;
import java.awt.*;
import java.awt.event.*;
/** This class represents a surface of specific area exposed to the sun.
* The SOLorientation object required by the constructor specifies
* the surface's orientation and location on Earth's surface.
* It contains methods to calculate solar radiation falling on the surface.
*/
// values calculated in this class:
// diffuse irradiance
// diffuse radiation
// diffuse irradiance simple
// diffuse radiation simple
// ground reflected irradiance
// ground reflected radiation
// direct irradiance
// direct radiation
// total radiation
public class SOLwindow extends SOLsurface{
// Class variables:
public static final int DIFFUSE_RADIATION = 0;
public static final int GROUND_REFLECTED_RADIATION = 1;
public static final int DIRECT_RADIATION = 2;
public static final int TOTAL_RADIATION = 3;
public static final int DIFFUSE_GAIN = 4;
public static final int GROUND_REFLECTED_GAIN = 5;
public static final int DIRECT_GAIN = 6;
public static final int TOTAL_RADIANT_GAIN = 7;
public static final int CONDUCTIVE_GAIN = 8;
public static final int TOTAL_GAIN = 9;
public static final int DIFFUSE_RADIATION_COST = 10;
public static final int GROUND_REFLECTED_RADIATION_COST = 11;
public static final int DIRECT_RADIATION_COST = 12;
public static final int TOTAL_RADIATION_COST = 13;
public static final int CONDUCTIVE_COST = 14;
public static final int TOTAL_COST = 15;
public static String[] fields = {"Diffuse Radiation",
"Ground Reflected Radiation",
"Direct Radiation",
"Total Radiation",
"Diffuse Gain",
"Ground Reflected Gain",
"Direct Gain",
"Total Radiant Gain",
"Conductive Gain",
"Total Gain",
"Diffuse Radiation Cost",
"Ground Radiation Cost",
"Direct Radiation Cost",
"Total Radiation Cost",
"Conduction Cost",
"Total Cost"};
public static int[] field_types = {UnitConverter.POWER,
UnitConverter.POWER,
UnitConverter.POWER,
UnitConverter.POWER,
UnitConverter.POWER,
UnitConverter.POWER,
UnitConverter.POWER,
UnitConverter.POWER,
UnitConverter.POWER,
UnitConverter.POWER,
UnitConverter.NOTHING,
UnitConverter.NOTHING,
UnitConverter.NOTHING,
UnitConverter.NOTHING,
UnitConverter.NOTHING,
UnitConverter.NOTHING};
// Solar Heat Gain Coefficient
protected double shgc;
// Indoor Temperature
//protected double indoor_temp;
// Window U value (W/m**2 C)
protected double uvalue;
private hvac hvc;
// Inherited from SOLsurface:
// double area;
// String name;
// Ground Reflectance.
// public double rho;
// SOLorientation orientation;
// SOLlocation location;
// TMYdata tmystuff;
/** Create a SOLwindow object, given
*
- A SOLorientation object,
*
- The area of the surface (m2),
*
- The ground reflectance.
*
- The window's U value,
*
- The window's Solar Heat Gain Coefficient
*
- The indoor temperatue,
*
- and a name string.
*/
public SOLwindow(TMYdata tmystuff,
SOLorientation orientation,
double area,
double rho,
double uvalue,
double shgc,
hvac hvc,
String name){
super(tmystuff, orientation, area, rho, name, fields);
this.orientation = orientation;
this.location = orientation.location;
this.uvalue = uvalue;
this.shgc = shgc;
this.hvc = hvc;
this.rho = rho;
this.name = name;
}
//----------------------- methods inherited from SOLsurface ----------------------------
// public double getDiffuseIrradiance(double Dh, double I, int daynum, int solar_time){
// public double getDiffuseIrradiance(int month, int day, int hour){
// public double getDiffuseRadiation(double Dh, double I, int daynum, int solar_time){
// public double getDiffuseRadiation(int month, int day, int hour){
// public double getDiffuseIrradianceSimple(double Dh){
// public double getDiffuseIrradianceSimple(int month, int day, int hour){
// public double getDiffuseRadiationSimple(double Dh){
// public double getDiffuseRadiationSimple(int month, int day, int hour){
// public double getGroundReflectedIrradiance(double Ih){
// public double getGroundReflectedIrradiance(int month, int day, int hour){
// public double getGroundReflectedRadiation(double Ih){
// public double getGroundReflectedRadiation(int month, int day, int hour){
// public double getDirectIrradiance(double I, int daynum, int solar_time){
// public double getDirectIrradiance(int month, int day, int hour){
// public double getDirectRadiation(double I, int daynum, int solar_time){
// public double getDirectRadiation(int month, int day, int hour){
// public double getGroundReflectedRadiation(double Ih){
// public double getTotalIncidentRadiation(double Dh, double I, double Ih, int daynum, int solar_time){
// public double getTotalIncidentRadiation(int month, int day, int hour){
//---- public methods ------
/** Calculate the heat gain through the window (in Watts) due to
* direct solar radiation. */
public double getDirectRadiantGain(int month, int day, int hour){
return(getDirectRadiation(month, day, hour) * shgc);
}
/** Calculate the heat gain through the window (in Watts) due to
* diffuse solar radiation. */
public double getDiffuseRadiantGain(int month, int day, int hour){
return(getDiffuseRadiation(month, day, hour) * shgc);
}
/** Calculate the heat gain through the window (in Watts) due to
* ground reflected solar radiation. */
public double getGroundReflectedRadiantGain(int month, int day, int hour){
return(getGroundReflectedRadiation(month, day, hour) * shgc);
}
/** Calculate the heat gain through the window (in Watts) due to
* thermal conduction. */
public double getConductiveGain(int month, int day, int hour){
double outdoor_temp = tmystuff.getValue(month,
day,
hour,
TMYdata.DRY_BULB_TEMP);
double val = 0.0;
double cooling_temp = hvc.getCoolingTemp();
double heating_temp = hvc.getHeatingTemp();
// if th < toutdoor < tc, no gain at all.
if (outdoor_temp > cooling_temp){
// cooling: these numbers are positive ...heat coming in
val = (outdoor_temp - cooling_temp) * uvalue * area;
} else if (outdoor_temp < hvc.getHeatingTemp()){
// heating: these numbers are negative ... heat going out
val = (outdoor_temp - heating_temp) * uvalue * area;
}
return (val);
}
/** Calculate the heat gain through the window (in Watts per
* square meter) from radiant sources (direct, diffuse, and ground
* reflected solar radiation). */
public double getTotalRadiantGain(int month, int day, int hour){
return(getTotalIncidentRadiation(month, day, hour) * shgc);
}
/** Calculate the heat gain through the window (in Watts per
* square meter) due all sources (direct, diffuse, and ground
* reflected solar radiation, plus thermal conduction). */
public double getTotalGain(int month, int day, int hour){
double total_rad = getTotalIncidentRadiation(month, day, hour) * shgc;
double conduct_gain = getConductiveGain(month, day, hour);
return(conduct_gain + total_rad);
}
/** Calculate the cost of energy to deal with heat gain through
* the window due to diffuse radiation. If outdoor temperature
* is less than the heating temperature setpoint, we assume that
* we are heating, and the radiant gain is beneficial, hence
* this function returns a negative cost. */
public double getDiffuseRadiationCost(int month, int day, int hour){
double val = 0.0;
double outdoor_temp = tmystuff.getValue(month,
day,
hour,
TMYdata.DRY_BULB_TEMP);
if (outdoor_temp > hvc.getCoolingTemp()){
val = hvc.getCoolingCost(getDiffuseRadiantGain(month, day, hour) /
1000.0);
} else if (outdoor_temp < hvc.getHeatingTemp()){
val = -1.0 * hvc.getHeatingCost(getDiffuseRadiantGain(month, day, hour)
/ 1000.0);
}
return(val);
}
/** Calculate the cost of energy to deal with heat gain through
* the window due to direct radiation. If outdoor temperature
* is less than the heating temperature setpoint, we assume that
* we are heating, and the radiant gain is beneficial, hence
* this function returns a negative cost. */
public double getDirectRadiationCost(int month, int day, int hour){
double val = 0.0;
double outdoor_temp = tmystuff.getValue(month,
day,
hour,
TMYdata.DRY_BULB_TEMP);
if (outdoor_temp > hvc.getCoolingTemp()){
val = hvc.getCoolingCost(getDirectRadiantGain(month, day, hour)
/ 1000.0);
} else if (outdoor_temp < hvc.getHeatingTemp()){
val = -1.0 * hvc.getHeatingCost(getDirectRadiantGain(month, day, hour)
/ 1000.0);
}
return(val);
}
/** Calculate the cost of energy to deal with heat gain through
* the window due to ground reflected radiation. If outdoor temperature
* is less than the heating temperature setpoint, we assume that
* we are heating, and the radiant gain is beneficial, hence
* this function returns a negative cost. */
public double getGroundRadiationCost(int month, int day, int hour){
double val = 0.0;
double outdoor_temp = tmystuff.getValue(month,
day,
hour,
TMYdata.DRY_BULB_TEMP);
if (outdoor_temp > hvc.getCoolingTemp()){
val = hvc.getCoolingCost(getGroundReflectedRadiantGain(month, day, hour)
/ 1000.0);
} else if (outdoor_temp < hvc.getHeatingTemp()){
val = -1.0 * hvc.getHeatingCost(getGroundReflectedRadiantGain(month, day, hour)/1000.0);
}
return(val);
}
/** Calculate the cost of energy to deal with heat gain through
* the window due to total solar radiation. If outdoor temperature
* is less than the heating temperature setpoint, we assume that
* we are heating, and the radiant gain is beneficial, hence
* this function returns a negative cost. */
public double getTotalRadiationCost(int month, int day, int hour){
double val = 0.0;
double outdoor_temp = tmystuff.getValue(month,
day,
hour,
TMYdata.DRY_BULB_TEMP);
// radiant gain is always positive. In figuring cost, the
// question is whether it is working in our favor. We make
// the simple assumption that if we are heating (based on
// outdoor temperature and the heating thermostat setpoint),
// radiant is good, so has a negative cost. For outdoor
// temps above the cooling setpoint, we assume that all
// radiant gain is bad, and calculate a positive cost.
if (outdoor_temp > hvc.getCoolingTemp()){
val = hvc.getCoolingCost(getTotalRadiantGain(month, day, hour)
/ 1000.0);
} else if (outdoor_temp < hvc.getHeatingTemp()){
val = -1.0 * hvc.getHeatingCost(getTotalRadiantGain(month, day, hour)
/ 1000.0);
}
return(val);
}
/** Calculate the cost of energy to deal with heat gain through
* the window due to thermal conduction. If outdoor temperature
* is less than the heating temperature setpoint, we assume that
* we are heating. If it is greater than the cooling temperature
* setpoint, we assume cooling. */
public double getConductiveCost(int month, int day, int hour){
double val = 0.0;
double outdoor_temp = tmystuff.getValue(month,
day,
hour,
TMYdata.DRY_BULB_TEMP);
if (outdoor_temp > hvc.getCoolingTemp()){
val = hvc.getCoolingCost(getConductiveGain(month, day, hour) / 1000.0);
} else if (outdoor_temp < hvc.getHeatingTemp()){
// conductive gain is always negative under heating conditions,
// so we need to multiply by -1.
val = -1 * hvc.getHeatingCost(getConductiveGain(month, day, hour)
/ 1000.0);
}
return(val);
}
public double getTotalCost(int month, int day, int hour){
return(getTotalRadiationCost(month, day, hour) +
getConductiveCost(month, day, hour));
}
public double getValue(int month, int day, int hour, int fieldnum){
double result = 0.0;
switch (fieldnum) {
case 0: result = getDiffuseRadiation(month, day, hour); break;
case 1: result = getGroundReflectedRadiation(month, day, hour); break;
case 2: result = getDirectRadiation(month, day, hour); break;
case 3: result = getTotalIncidentRadiation(month, day, hour); break;
case 4: result = getDiffuseRadiantGain(month, day, hour); break;
case 5: result = getGroundReflectedRadiantGain(month, day, hour); break;
case 6: result = getDirectRadiantGain(month, day, hour); break;
case 7: result = getTotalRadiantGain(month, day, hour); break;
case 8: result = getConductiveGain(month, day, hour); break;
case 9: result = getTotalGain(month, day, hour); break;
case 10: result = getDiffuseRadiationCost(month, day, hour); break;
case 11: result = getGroundRadiationCost(month, day, hour); break;
case 12: result = getDirectRadiationCost(month, day, hour); break;
case 13: result = getTotalRadiationCost(month, day, hour); break;
case 14: result = getConductiveCost(month, day, hour); break;
case 15: result = getTotalCost(month, day, hour); break;
}
return(result);
}
/** Part of the CWmonitorable interface. */
public String[] getFields(){
return fields;
}
/** Returns the list of types of the monitorable fields.
* Part of the CWmonitorable
* interface. Used for unit conversions. Types are defined in class UnitConverter.*/
public int[] getFieldTypes(){
return(field_types);
}
} /* End of class SOLsurface */