VR-Vantage 3.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
thermal_solvers.h
Go to the documentation of this file.
1 
2 /* © 1998 JRM Technologies, Inc.*/
3 
4 
5 
6 
7 /***********************************
8 Copyright JRM Enterprises, Inc. 1998
9 All rights reserved.
10 
11 This code is the intellectual property of JRM Enterprises, Inc.
12 It may not be used or released as source or compiled binary form
13 without the prior written consent of JRM Enterprises, Inc.
14 ***********************************/
15 
16 #ifndef _THERMAL_SOLVERS_H_
17 #define _THERMAL_SOLVERS_H_
18 
19 #include "JRMDefines.h"
20 #include "JRMlibrary.h"
21 #include "Ellipsoid.h"
22 #include "SigSimDefines.h"
23 #include "sigsim.h"
24 #include "sigsimDLLstub.h"
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
31 #define TIMESHIFT_MODE2 FALSE
32 #define SIMPLE 0 // 1 = What is likely to happen in the GPU. 0 = (better) CPU approximation.
33 
34 
35 
36 // APPLYSPINTIME=TRUE is the default, and looks at the thermal_spin_up_time to decide a start time for last_update. FALSE leaves last_update alone.
37 // ORDER2FLAG is relevant to solver mode 2 and indicates whether or not 2nd order contributions are to be added in.
38 // absorbratio is relevant to solver mode 2 and if >=0 gives the ratio of aS to eL to be used in calculating the GPU factor.
39 // twosidedflag is relevant to solver mode 2 and if >=0 gives the ability of the surface to accept backside irradiance.
40 SIGSIM_API int ThermalSpinUp(long nmatls, MATL_PROP_TABLE *mp_table, METIN *metin, jrmbool APPLYSPINTIME, jrmbool ORDER2FLAG, double absorbratio, double twosidedflag);
41 SIGSIM_API void SmoothSpinup(long nmatls, MATL_PROP_TABLE *mp_table);
42 int RunThermalSolvers(MATL_PROP_TABLE *mp_table, METIN *metin, jrmbool CURRENT);
43 SIGSIM_API double Tsteady_state(METIN *metin, MATL_PROP_TABLE *mp_table);
44 SIGSIM_API double T1Dimplicit(METIN *metin, MATL_PROP_TABLE *mp_table);
45 SIGSIM_API double T1DYellow(METIN *metin, MATL_PROP_TABLE *mp_table);
46 SIGSIM_API double T1DYellowRT(METIN *metin, MATL_PROP_TABLE *mp_table, int normswitch);
47 SIGSIM_API int AdvanceThermalTime(MATL_PROP_TABLE *mp_table, int nmatls, METIN *metin, jrmbool BOUNCE);
48 
49 int Create1DHorizontalSurfaceTable(MATL_PROP_TABLE *mp1, double dist1_m, MATL_PROP_TABLE *mp2, double dist2_m, MATL_PROP_TABLE *mph, double env_update_interval, long *nodes);
50 double T1DSurfaceNodes(METIN *metin, MATL_PROP_TABLE *mp_table, jrmbool SURFACENODES, jrmbool ADVANCETIME);
51 int InterpolateNodeGradient(MATL_PROP_TABLE *mp_table, double *gradient, long npix, jrmbool FRACTION);
52 int PrintNodeGradient(char *filespec, MATL_PROP_TABLE *mp_table);
53 SIGSIM_API int Run1DSurfaceSolution(METIN *metin, MATL_PROP_TABLE *mpHI, double distHI_m, MATL_PROP_TABLE *mpLO, double distLO_m, jrmbool SURFACENODES, double *gradient, long npix, jrmbool FRACTION);
54 
57 
58 double peakloadtime(VECTOR N, EPHEMERIS fm);
59 double endloadtime(VECTOR N, EPHEMERIS fm);
60 double startloadtime(VECTOR N, EPHEMERIS fm);
61 double peakresponsetime(VECTOR N, EPHEMERIS fm);
62 double lagtime(VECTOR N, EPHEMERIS fm);
63 SIGSIM_API int lagindex(VECTOR N, EPHEMERIS fm, int nonlagindex, int nsteps, double dthrs); // Provides appropriate index into dtCosCache[] array for GPU TIMESHIFT_MODE2 equation Tsurf = Tbase + dtCosCache[index]*DTAttenuationRatio(norm).
65 SIGSIM_API double DTAttenuationRatio(VECTOR N, EPHEMERIS fm); // Provides appropriate attenuation ratio for GPU TIMESHIFT_MODE2 equation Tsurf = Tbase + dtCosCache[index]*DTAttenuationRatio(norm).
66 SIGSIM_API void RecalcSunVec(EPHEMERIS *fm); // In case sun direction needs to be recalculated from fm.current.tod.
67 SIGSIM_API double CalculateTwoSidedFlag(MATL_PROP_TABLE mp_table); // calculates what gpu.d should be set at, but doesn't set it in the mp_table.
68 SIGSIM_API double CalculateAverageTwoSidedFlag(MATL_PROP_TABLE *mp_table, int nmatls); // calculates average over set of mp_tables.
69 SIGSIM_API double CalculateAverageAbsorbRatio(MATL_PROP_TABLE *mp_table, int nmatls); // calculates average over set of mp_tables.
70 SIGSIM_API double CalculateAverageConductionFactor(MATL_PROP_TABLE *mp_table, int nmatls, double tod); // calculates average over set of mp_tables. Assumes d=0.
71 SIGSIM_API double SkyHorizonFactor(double Esky, double TaC);
72 SIGSIM_API THERMAL_CACHE GetEnvironmentalCacheForTOD(METIN *metin, double tod, jrmbool INTERPOLATE, jrmbool ALONGPATHCONVERT);
73 SIGSIM_API int GetTemperatureCacheForTOD(MATL_PROP_TABLE *mp_table, double tod, jrmbool INTERPOLATE, jrmbool USECACHEIFPRESENT, double *Tncos, double *dTcos, double *dTcos2);
74 SIGSIM_API VECTOR GetModeNorm(int normswitch, VECTOR msfilenorm, VECTOR sunmax, double diffusenormkmin, THERMAL_CACHE tc, double d, double absorbratio);
75 double Qdiff1(THERMAL_CACHE tc, double Etot, double c, double d, double s, MATL_PROP_TABLE *mp_table, VECTOR N, VECTOR sunplane);
76 GPUCOEFF2 Qdiff2(THERMAL_CACHE tc, double Etot, double d, ATM_DEFAULT atm_default, MATL_PROP_TABLE *mp_table);
77 SIGSIM_API double Qdiff(THERMAL_CACHE tc, double Etot, ATM_DEFAULT atm_default, EPHEMERIS fm, MATL_PROP_TABLE *mp_table, VECTOR N, double shadowflag);
79 SIGSIM_API double SurfaceTemperature(METIN *metin, VECTOR N, MATL_PROP_TABLE *mp_table, jrmbool USECACHEIFPRESENT);
80 //SIGSIM_API double ViewableSkyFactor(VECTOR N, double altkm, ATMINFO inf); //, ATMCOEF *atm, double TaC);
81 SIGSIM_API double ViewableSkyFactor(double normk, double diffusenormkmin, double TairC, double Esky);
82 SIGSIM_API double ViewableSkyDifference(double d, double normk, double diffusenormkmin, double TairC, double Esky);
83 SIGSIM_API double ViewableEarthFactor(double normk, double diffusenormkmin);
84 SIGSIM_API double ViewableEarthDifference(double d, double normk, double diffusenormkmin);
85 SIGSIM_API double ViewableSunDiffuseFactor(double normk, double diffusenormkmin);
86 SIGSIM_API double ViewableSunDiffuseDifference(double d, double normk, double diffusenormkmin);
87 SIGSIM_API double ViewableSunDirectFactor(VECTOR norm, VECTOR sun, double shadowflag, int normswitch);
88 SIGSIM_API double ViewableSunDirectDifference(double d, VECTOR norm, VECTOR sun, double shadowflag, int normswitch);
89 SIGSIM_API double DiurnalConductionConstant(METIN *metin, MATL_PROP_TABLE *mp_table, int normswitch);
90 
91 
92 //double AmbientAngleFactor(double normk, jrmbool HEATIN, jrmbool TOPSURF, double *dAdnormk);
93 double AmbientAngleFactor(double normk, double signTminusTair, double *dAdnormk);
94 //double TCMAmbientConvectionCoefficient(double Csurf, double Cair, double normk, double L, jrmbool TOPSURF, double *dhdCsurf, double *dhdCair, double *dhcdnormk);
95 double TCMAmbientConvectionCoefficient(double Csurf, double Cair, double normk, double L, double *dhdCsurf, double *dhdCair, double *dhcdnormk);
96 double TCMWindConvectionCoefficient(double airspeed, double L);
97 double TCMForcedConvectionCoefficient(double airspeed, double L);
98 //double TCMConvectionCoefficient(double airspeed, double normk, double L, double Csurf, double Cair, jrmbool TOPSURF, jrmbool WIND, double *dhdCsurf, double *dhdCair, double *dhcdnormk);
99 SIGSIM_API double TCMConvectionCoefficient(double airspeed, double normk, double L, double Csurf, double Cair, jrmbool WIND, double *dhdCsurf, double *dhdCair, double *dhcdnormk);
100 //double JRMConvectionCoefficient(double airspeed, double normk, double Csurf, double Cair, jrmbool TOPSURF, double *dhdCsurf, double *dhdCair, double *dhcdnormk);
101 SIGSIM_API double JRMConvectionCoefficient(double airspeed, double normk, double Csurf, double Cair, double *dhdCsurf, double *dhdCair, double *dhcdnormk);
102 
103 
104 double SaturatedVaporPressure(double degC);
105 double SpecificHumidity(double Pa_mb, double degC);
106 //double GetEvapRate(METIN *metin, double Ta, double *waterloss, double hc, double Tsurf);
107 double GetEvapRate(double relative_humidity, double Ta, double *waterloss, double hc, double Tsurf);
108 double GetEvapRateTCM2(METIN *metin, double Ta, double *waterloss, double hc, double Tsurf);
109 
110 
111 typedef struct
112 {
113  int bc; // [cardinal] Boundary condition type specifier
114  double T; // [degC] Constant user-defined temperature
115  double V; // [m/s] Constant user-defined fluid velocity
116  double Q; // [W/m2] Constant user-defined heat flux
117  double Qf; // [W/m2] Frictional heat flux (if bcn==8)
118  double hrad; // [W/m2/degC] Radiative heat transfer per unit time
119  double hr; // [W/m2/degC] Thermal mass of rain per unit time
120  double hc; // [W/m2/degC] Coefficient of convection
121  double ha; // [W/m2/degC] Coefficient of aerodynamic heat transfer
122  double hk; // [W/m2/degC] Coefficient of conduction
123  double aS; // [unitless] Solar absorptivity
124  double eL; // [unitless] Lambertian Emissivity
125  double evaparea; // [unitless] Area fraction exposed to evapotranspiration
126  double Ta; // [degC] Air Temperature
127  double Tc; // [degC] Temperature of convective gas
128  double Train; // [degC] Temperature of rain
129  double Trec; // [degC] Temperature for aerodynamic skin heating calculation
130  double Tosurf; // [degC] Temperature of other surface
131  double Esun_dir; // [W/m2] Solar Direct irradiance
132  double Esun_dif; // [W/m2] Solar Diffuse irradiance
133  double Esky; // [W/m2] Sky irradiance
134  double Earthshine; // [W/m2] Earthshine irradiance
135  double qevap; // [W/m2] Evaporative heat loss
136  double waterloss; // [kg/s/m2] Evaporative water loss
137  double dSunDirectdt; // [W/m2/s] Derivative of solar direct irradiance w.r.t. time
138  double dSunDiffusedt; // [W/m2/s] Derivative of solar diffuse irradiance w.r.t time
139  double dSkydt; // [W/m2/s] Derivative of sky irradiance w.r.t. time
140  double dEarthdt; // [W/m2/s] Derivative of earthshine irradiance w.r.t. time
141  double dhrdt; // [W/m2/degC/s] Derivative of hr w.r.t. time
142  double dhcdt; // [W/m2/degC/s] Derivative of hc w.r.t. time
143  double dhadt; // [W/m2/degC/s] Derivative of ha w.r.t. time
144  double dqevapdt; // [W/m2/s] Derivative of qevap w.r.t. time
145  double devapareadt; // [degK/s] Derivative of evapotranspiration area fraction w.r.t. time
146  double dTdt; // [degK/s] Derivative of surface temperature w.r.t. time
147  double dhraddT; // [W/m2/degC2] Derivative of hrad w.r.t. temperature
148  double dhrdT; // [W/m2/degC2] Derivative of hr w.r.t. temperature
149  double dhcdT; // [W/m2/degC2] Derivative of hc w.r.t. temperature
150  double dhadT; // [W/m2/degC2] Derivative of ha w.r.t. temperature
151  double dqevapdT; // [W/m2/degC] Derivative of qevap w.r.t. temperature
152  double F; // [W/m2] Sum of energy balance contributions
153  double dFdt; // [W/m2/s] Derivative of energy balance equation for surface w.r.t. time
154  double dFdT; // [W/m2/degC] Derivative of energy balance equation for surface w.r.t. temperature
155  double D; // [m] Thickness for SurfaceNode solution
156  double hsum; // [W/m2/degC] Sum of environmental convection coefficients for SurfaceNode solution
157  double Qsum; // [W/m2] Sum of environmental Q-loading terms for SurfaceNode solution
159 
160 typedef struct
161 {
162  int normswitch; // [enum]
163  int month; // [enum 1-12]
164  long julian; // [days]
165  double tod; // [hrs]
166  double dt; // [s]
167  double D; // [m] Total MS Thickness
168  double lostab; // [unitless] Lower bound to stability measure below which model is Steady-State
169  int bc1; // [cardinal] Boundary condition type specifier
170  int bc2; // [cardinal] Boundary condition type specifier
171  double aS0; // [unitless] Solar absorptivity
172  double eL0; // [unitless] Lambertian Emissivity
173  double Tsurf0; // [degC] Current top node temp
174  double TsurfN_1; // [degC] Current bottom node temp
175  double T0; // [degC] Temperature Boundary Condition
176  double V0; // [m/s] Air Velocity Boundary Condition
177  double TN_1; // [degC] Temperature Boundary Condition
178  double VN_1; // [m/s] Air Velocity Boundary Condition
179  double M0; // [?] Friction heating parameter
180  double MN_1; // [?] Friction heating parameter
181  double Q0; // [W/m2] Constant user-defined irradiance
182  double QN_1; // [W/m2] Constant user-defined irradiance
183  double Train; // [degC] Temperature of rain
184  double alt; // [m] Material System current altitude
185  double lat; // [deg] Material System current latitude
186  VECTOR norm; // [unitless] Material System normal
187  VECTOR sun; // [unitless] Sun direction
188  double shadow; // [unitless] Material System shadowflag
189  double stype; // [unitless] Material System Soil Type
190  double L; // [m] Characteristic Length [m] over which convection occurs.
191  double gpud; // [unitless] Two-Sided flag for material
192  jrmbool TCM; // [bool] TRUE=Use TCM convection model, FALSE=Use JRM model.
193  double hr; // [W/m2/degC] Thermal mass of rain per unit time
194  double hk; // [W/m2/degC] Coefficient of conduction
195  double Ta; // [degC] Air Temperature
196  double Va; // [m/s] Air Velocity
197  double stan; // [unitless] Stanton Number
198  double rtype; // [unitless] Surface Normal Dependence of Aero Heating
199  double relative_humidity;// [unitless] Humidity ratio from METIN
200  double Esun_dir; // [W/m2] Solar Direct Irradiance max for this time, for any normal or face.
201  double Esun_max; // [W/m2] Maximum Solar Direct Irradiance for evapotranspiration.
202  double Esun_dif; // [W/m2] Solar Diffuse Irradiance max for this time, for any normal or face.
203  double Esky; // [W/m2] Sky Diffuse Irradiance max for this time, for any normal or face.
204  double Earthshine; // [W/m2] Earthshine Irradiance max for this time, for any normal or face.
205  double sun_dot_product; // [unitless] Sun/surface dot product
206  double evaparea; // [unitless] Area fraction exposed to evapotranspiration
207  double evapareamin; // [unitless] Minimum Area fraction exposed to evapotranspiration
208  double evapareamax; // [unitless] Maximum Area fraction exposed to evapotranspiration
209  double diffusenormkmin; // [unitless] norm.k value corresponding to horizon for this altitude.
210  double sundirfactor0; // [unitless] Scaling factor for direct solar irradiance normal dependence.
211  double sundiffactor0; // [unitless] Scaling factor for diffuse solar irradiance normal dependence.
212  double skyfactor0; // [unitless] Scaling factor for sky irradiance normal dependence.
213  double earthfactor0; // [unitless] Scaling factor for earthshine irradiance normal dependence.
214  double sundirfactorN_1; // [unitless] Scaling factor for direct solar irradiance normal dependence.
215  double sundiffactorN_1; // [unitless] Scaling factor for diffuse solar irradiance normal dependence.
216  double skyfactorN_1; // [unitless] Scaling factor for sky irradiance normal dependence.
217  double earthfactorN_1; // [unitless] Scaling factor for earthshine irradiance normal dependence.
218  double dsundpdt; // [Hz] Derivative of sun_dot_product w.r.t. time
219  double dSunDirectdt; // [W/m2/s] Derivative of solar direct irradiance w.r.t. time
220  double dSunDiffusedt; // [W/m2/s] Derivative of solar diffuse irradiance w.r.t time
221  double dSkydt; // [W/m2/s] Derivative of sky irradiance w.r.t. time
222  double dEarthdt; // [W/m2/s] Derivative of earthshine irradiance w.r.t. time
223  double dTadt; // [degK/s] Derivative of air temperature w.r.t. time
224  double dTrecdt; // [degK/s] Derivative of aerodynamic skin heating temperature w.r.t. time
225  double dTraindt; // [degK/s] Derivative of rain temperature w.r.t. time
226  double devapareadt; // [degK/s] Derivative of evapotranspiration area fraction w.r.t. time
228 
229 int PrintNodalTemps(MATL_PROP_TABLE *mp_table, double *T, THERMAL_INFLUENCES *E0, THERMAL_INFLUENCES *EN, JRMTIME current, double ptime);
230 
231 
232 #ifdef __cplusplus
233 }
234 #endif
235 
236 #endif // _THERMAL_SOLVERS_H_


Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)