/* Copyright 2000 Charles G. Wright
* This software may be distributed under the terms of the
* GNU General Public License.
*
* $Id: SOLsurface.java,v 1.1 2000-06-15 10:15:04-05 chuckles Exp chuckles $
*/
import java.math.*;
import java.awt.*;
import java.awt.event.*;
/**
This class extends the SOLsurfaceBase class, which defines
* basic operations for a surface. This class includes reference
* to a TMYdata class, and versions of the methods that use data
* from the TMYdata class.
*/
public class SOLsurface extends SOLsurfaceBase implements CWmonitorable{
public static final int DIFFUSE_IRRADIANCE = 0;
public static final int DIFFUSE_RADIATION = 1;
public static final int DIFFUSE_IRRADIANCE_SIMPLE = 2;
public static final int DIFFUSE_RADATION_SIMPLE = 3;
public static final int GROUND_REFLECTED_IRRADIANCE = 4;
public static final int GROUND_REFLECTED_RADIATION = 5;
public static final int DIRECT_IRRADIANCE = 6;
public static final int DIRECT_RADIATION = 7;
public static final int TOTAL_RADIATION = 8;
private static int instance_number = 1;
// Class variables:
public static String[] base_fields = {"Diffuse Irradiance",
"Diffuse Radiation",
"Diffuse Irradiance Simple",
"Diffuse Radiation Simple",
"Ground Reflected Irradiance",
"Ground Reflected Radiation",
"Direct Irradiance",
"Direct Radiation",
"Total Radiation"};
public static int[] field_types = {UnitConverter.POWER_PER_AREA,
UnitConverter.POWER,
UnitConverter.POWER_PER_AREA,
UnitConverter.POWER,
UnitConverter.POWER_PER_AREA,
UnitConverter.POWER,
UnitConverter.POWER_PER_AREA,
UnitConverter.POWER,
UnitConverter.POWER};
private String[] fields;
public TMYdata tmystuff;
/** Create a SOLsurface object, given
*
- A SOLorientation object,
*
- The area of the surface (m2),
*
- The ground reflectance.
*/
public SOLsurface(TMYdata tmystuff,
SOLorientation orientation,
double area,
double rho,
String name){
super(orientation, area, rho, name);
this.tmystuff = tmystuff;
// Add the outputs of this class that can be displayed to the
// master list.
fields = base_fields;
CWmonitoredElements.addElements(this);
instance_number++;
}
/** Create a SOLsurface object, given
*- A SOLorientation object,
*
- The area of the surface (m2),
*
- The ground reflectance.
*/
public SOLsurface(TMYdata tmystuff,
SOLorientation orientation,
double area,
double rho,
String name,
String[] fields){
super(orientation, area, rho, name);
this.tmystuff = tmystuff;
// Add the outputs of this class that can be displayed to the
// master list.
this.fields = fields;
CWmonitoredElements.addElements(this);
instance_number++;
}
// Inherited from SOLsurface:
// double area;
// String name;
// Ground Reflectance.
// public double rho;
// SOLorientation orientation;
// SOLlocation location;
//-------------------- Public methods -----------------------------------
//---------- methods inherited from SOLsurface ----------------
// public double getDiffuseIrradiance(double Dh, double I,
// int daynum, int solar_time){
// public double getDiffuseRadiation(double Dh, double I,
// int daynum, int solar_time){
// public double getDiffuseIrradianceSimple(double Dh){
// public double getDiffuseRadiationSimple(double Dh){
// public double getGroundReflectedIrradiance(double Ih){
// public double getGroundReflectedRadiation(double Ih){
// public double getDirectIrradiance(double I, int daynum, int solar_time){
// public double getDirectRadiation(double I, int daynum, int solar_time){
// public double getGroundReflectedRadiation(double Ih){
// public double getTotalIncidentRadiation(double Dh, double I,
// double Ih, int daynum, int solar_time){
public static int nextInstanceNumber(){
return(instance_number);
}
//--------------------------- diffuse, perez, from TMY ------------------
/** Return diffuse irradiance on the surface (Watts/m2),
* calculated according to Perez (1990), given
*
* - The Month number,
*
- The Day number,
*
- The Hour number.
*/
public double getDiffuseIrradiance(int month, int day, int hour){
double Dh;
double I;
int daynum;
int solar_time;
daynum = tmystuff.dayOfYear(month, day);
solar_time = tmystuff.location.getSolarTime(daynum, location.timeInSeconds(hour+1, 0, 0));
I = tmystuff.getValue(month, day, hour, tmystuff.DIRECT_NORMAL_RADIATION);
// Ih = tmystuff.getValue(month, day, hour, tmystuff.GLOBAL_HORIZONTAL_RADIATION);
Dh = tmystuff.getValue(month, day, hour, tmystuff.DIFFUSE_HORIZONTAL_RADIATION);
// Call basic method in parent class.
return getDiffuseIrradiance(Dh, I, daynum, solar_time);
}
/** Return diffuse radiation on the surface (in Watts), calculated according to Perez (1990),
* given
*
* - The Month number,
*
- The Day number,
*
- The Hour number.
*/
public double getDiffuseRadiation(int month, int day, int hour){
return getDiffuseIrradiance(month, day, hour) * area;
}
//------------------ simple diffuse, from TMY ----------------
/** Return diffuse irradiance (in Watts/m2) by the simple formula, given
*
* - The Month number,
*
- The Day number,
*
- The Hour number.
*/
public double getDiffuseIrradianceSimple(int month, int day, int hour){
double Dh;
Dh = tmystuff.getValue(month, day, hour, tmystuff.DIFFUSE_HORIZONTAL_RADIATION);
return getDiffuseIrradianceSimple(Dh);
}
/** Return diffuse radiation by the simple formula, given
* - A TMYdata object,
- The month number,
- The day number,
- The Hour number.
*/
public double getDiffuseRadiationSimple(int month, int day, int hour){
return getDiffuseIrradianceSimple(month, day, hour) * area;
}
//----------------- ground reflected -------------------------------
/** Return ground reflected irradiance on the surface (in Watts/m2), given
*- The global horizontal irradiance (W/m2)
*
- The ground reflectance.
*/
public double getGroundReflectedIrradiance(double Ih){
double beta = SOLlocation.toRadians(orientation.surface_tilt);
double sinterm = Math.sin(beta / 2);
return(rho * Ih * sinterm * sinterm);
}
/** Return ground reflected radiation on the surface, given
*- The global horizontal irradiance (in Watts)
*
- The ground reflectance.
*/
public double getGroundReflectedRadiation(double Ih){
return getGroundReflectedIrradiance(Ih) * area;
}
//------------------------------------------------------------------
//------------------ ground reflected from TMY ----------------------
/** Return ground reflected irradiance on the surface
* (in Watts/m2), given
*
* - The Month number,
*
- The Day number,
*
- The Hour number,
*
- The ground reflectance.
*/
public double getGroundReflectedIrradiance(int month, int day, int hour){
double Ih = tmystuff.getValue(month,
day,
hour,
tmystuff.GLOBAL_HORIZONTAL_RADIATION);
return(getGroundReflectedIrradiance(Ih));
}
/** Return ground reflected radiation on the surface (in Watts), given
* ,
* - The Month number,
*
- The Day number,
*
- The Hour number,
*
- The ground reflectance.
*/
public double getGroundReflectedRadiation(int month, int day, int hour){
return getGroundReflectedIrradiance(month, day, hour) * area;
}
//-----------------------------------------------------------------------
//--------------------- direct, from TMY ------------------------------
/** Return the direct irradiance on the surface (in W/m2), given
*- The month number,
*
- The day number,
*
- The hour number.
*/
public double getDirectIrradiance(int month, int day, int hour){
double I = tmystuff.getValue(month,
day,
hour,
tmystuff.DIRECT_NORMAL_RADIATION);
if (I > 0.0){
int daynum = tmystuff.dayOfYear(month, day);
int solar_time = location.getSolarTime(daynum, location.timeInSeconds(hour+1, 0, 0));
return (I * orientation.getCosTheta(daynum, solar_time));
} else {
return 0.0;
}
}
/** Return the direct radiation on the surface (in Watts), given
*- A TMYdata object,
*
- The month number,
*
- The day number,
*
- The hour number.
*/
public double getDirectRadiation(int month, int day, int hour){
double I = tmystuff.getValue(month,
day,
hour,
tmystuff.DIRECT_NORMAL_RADIATION);
if (I > 0.0){
return getDirectIrradiance(month, day, hour) * area;
} else {
return 0.0;
}
}
//---------------------------------------------------------
//----------------------- total, from TMY -------------
/** Return the total radiation on the surface (in Watts), given
*
* - Month number,
*
- Day number,
*
- Hour number.
*/
public double getTotalIncidentRadiation(int month, int day, int hour){
return (getDirectRadiation(month, day, hour) +
getGroundReflectedRadiation(month, day, hour) +
getDiffuseRadiation(month, day, hour));
}
//----- common method for accessing like TMY data -----------
/** Access to all of the methods using TMY data using same method name as
* for accessing values from the solar classes. */
public double getValue(int month, int day, int hour, int fieldnum){
double result = 0.0;
switch (fieldnum) {
case 0: result = getDiffuseIrradiance(month, day, hour); break;
case 1: result = getDiffuseRadiation(month, day, hour); break;
case 2: result = getDiffuseIrradianceSimple(month, day, hour); break;
case 3: result = getDiffuseRadiationSimple(month, day, hour); break;
case 4: result = getGroundReflectedIrradiance(month, day, hour); break;
case 5: result = getGroundReflectedRadiation(month, day, hour); break;
case 6: result = getDirectIrradiance(month, day, hour); break;
case 7: result = getDirectRadiation(month, day, hour); break;
case 8: result = getTotalIncidentRadiation(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 */