function Log10(e){return Math.log(e)/Math.LN10}function PresionAtmStd(e){return PresionAtm=119745e-10*Math.pow(288.15-.0065*e,5.25588)/1e3,PresionAtm}function PresionSat(e){return e=parseFloat(e),e>0?Psat=Math.pow(10,7.605*e/(241+e)+2.7877):Psat=Math.pow(10,9.756*e/(272.7+e)+2.7877),Psat}function TemperaturaSat(e){var t,n;if(e>PresionSat(0)){t=25;do n=(Log10(e)-(7.605*t/(241+t)+2.7877))/(1832.805/Math.pow(241+t,2)),t+=n;while(Math.abs(n)>.01)}else{t=-25;var r=Log10(e);do n=(r-(9.756*t/(272.7+t)+2.7877))/(9.756*272.7/Math.pow(272.7+t,2)),t+=n;while(Math.abs(n)>.01)}return t}function HumedadAbs(e,t,n,r){var i;r==null&&(PresionAtm?r=PresionAtm:r=PresionAtm0);if(e!==null&&t!==null)return i=PresionSat(parseFloat(e)),.622*t/(r/i-t);if(e!==null&&n!==null)return(n-cp_air*e)/(cp_w*e+Qlat);if(t!==null&&n!==null){var s,o,u,a;o=n/Qlat/2*t;do u=o-.622*t/(r/PresionSat((n-Qlat*o)/(cp_air+cp_w*o))-t),a=(o+1e-5-.622*t/(r/PresionSat((n-Qlat*(o+1e-5))/(cp_air+cp_w*(o+1e-5)))-t)-u)/1e-5,s=-u/a,o+=s;while(Math.abs(s)>1e-5);return o}return null}function TemperaturaBulboHumedo(e,t,n,r){n==null&&(n=HumedadAbs(e,t,r));var i=EntalpiaAireHumedo(e,t,n,r),s=HumedadAbs(null,1,i,r),o=TemperaturaAireHumedo(1,null,i,r),o=TemperaturaAireHumedo(1,null,i+(s-n)*cp_w*o,r);return o}function HumedadRel(e,t,n,r){var i;r==null&&(PresionAtm?r=PresionAtm:r=PresionAtm0);if(e!==null&&t!==null)return i=PresionSat(e),t/(t+.622)*r/i;if(e!==null&&n!==null)return t=(n-cp_air*e)/(cp_w*e+Qlat),i=PresionSat(e),t/(t+.622)*r/i;if(t!==null&&n!==null)return e=(n-Qlat*t)/(cp_air+cp_w*t),i=PresionSat(e),t/(t+.622)*r/i}function th2hr(e,t){var n=HumedadAbs(t,1,null),r=EntalpiaAireHumedo(t,1,null),i=HumedadAbs(e,null,r),s=r-(n-i)*cp_w*t;return HumedadRel(e,null,s)}function TemperaturaRocio(e,t){return TemperaturaAireHumedo(1,HumedadAbs(e,t))}function TemperaturaAireHumedo(e,t,n,r){if(e!==null&&t!==null){r==null&&(PresionAtm?r=PresionAtm:r=PresionAtm0);var i=t*r/((.622+t)*e);return TemperaturaSat(i)}return e!==null&&n!==null?(t=HumedadAbs(null,e,n),(n-Qlat*t)/(cp_air+cp_w*t)):t!==null&&n!==null?(n-Qlat*t)/(cp_air+cp_w*t):null}function EntalpiaAireHumedo(e,t,n,r){if(e!==null&&t!==null)n=HumedadAbs(e,t);else if(t!==null&&n!==null){var i;r==null&&(PresionAtm?r=PresionAtm:r=PresionAtm0);var i=n*r/((.622+n)*t);return e=TemperaturaSat(i),(cp_air+cp_w*n)*e+Qlat*n}return(cp_air+cp_w*n)*e+Qlat*n}function DensidadAireHumedo(e,t,n){return n==null&&(PresionAtm?n=PresionAtm:n=PresionAtm0),1/(461.24*(.622+t)*(e+273.15)/n)}function ViscosidadAireHumedo(e,t){return(.40401+.07458199999999999*(e+273.15)-57171e-9*(e+273.15)^2+2.9928e-8*(e+273.15)^3-6.2524e-12*(e+273.15)^4)*(1+1.608*t)*1e-6}function CpAireHumedo(e,t){return cp_air+t*cp_w}function ConductividadAireHumedo(e,t){var n=(e+273.15)/132.52,r=.004358*(33.9729025/n-164.702679*Math.pow(n,-2/3)+262.108546*Math.pow(n,-1/3)-21.5346955-443.455815*Math.pow(n,1/3)+607.3395819999999*Math.pow(n,2/3)-368.790121*n+111.296674*Math.pow(n,4/3)-13.4122465*Math.pow(n,5/3));n=(e+273.15)/647.26;var i=Math.sqrt(n)*(.0102811+.0299621*n+.0156146*Math.pow(n,2)-.00422464*Math.pow(n,3)),s=1.065*Math.pow(1+Math.sqrt(r/i)*Math.pow(t,.25),2)/(Math.pow(2,1.5)*(1+1/t)^.5),o=1.065*Math.pow(1+i/r^.5/Math.pow(t,.25),2)/(Math.pow(2,1.5)*(1+t)^.5);return r}function CpAgua(e){return 5.36449-2.59001*273.15/(273.15+e)+1.43759*Math.pow(273.15/(273.15+e),2)}function EntalpiaAgua(e){var t=5.36449*e-2.59001*273.15*Math.log((273.15+e)/273.15)-1.43759*273.15*(273.15/(273.15+e)-1);return e>=100&&(t+=Qlat),t}function AireHumedo(e,t,n,r){this.t=e,typeof r=="undefined"?this.Patm=PresionAtm0:this.Patm=r,t?this.hr=t:this.w=HumedadRel(this.t,n,null,this.Patm),n?this.w=n:this.w=HumedadAbs(this.t,t,null,this.Patm),this.h=EntalpiaAireHumedo(this.t,null,this.w,this.Patm),this.d=DensidadAireHumedo(this.t,this.w,this.Patm),this.v=ViscosidadAireHumedo(this.t,this.w),this.cp=CpAireHumedo(this.t,this.w),this.k=ConductividadAireHumedo(this.t,this.w),this.Pr=1e3*this.cp*this.v/this.k}function hr2DT(e,t,n){var r=PresionAtmStd(n),i=HumedadAbs(e,t,null,r),s=TemperaturaAireHumedo(1,i,null,r),o=(2*((e-s)*2/.8+3)).toFixed(0)/2;return o>25?25:o}var PresionAtm;const PresionAtm0=101325,cp_air=1.004,cp_w=1.83,Qlat=2505,Qfusion=333.55,cp_ice=2.09,cp_agua=4.18