const STATES = [ { name: 'AGUASCALIENTES', ps: 1725.42063420168, GDMTH: 2.25768, GDMTO: 1.85748, PDBT: 4.78584, GDBT: 2.22732, DAC: 7.70868, F1: 2.24043 }, { name: 'BAJA CALIFORNIA', ps: 1536.74298160517, GDMTH: 1.00764, GDMTO: 0.762, PDBT: 2.7564, GDBT: 0.912, DAC: 6.516, F1: 1.9482 }, { name: 'BAJA CALIFORNIA SUR', ps: 1536.7429754582, GDMTH: 2.77728, GDMTO: 2.4408, PDBT: 4.2096, GDBT: 3.1536, DAC: 7.0992, F1: 1.9482 }, { name: 'CAMPECHE', ps: 1404.97851136051, GDMTH: 2.17404, GDMTO: 1.8192, PDBT: 4.3356, GDBT: 2.1828, DAC: 6.2148, F1: 1.9482 }, { name: 'CHIAPAS', ps: 1519.69053946396, GDMTH: 1.84008, GDMTO: 1.3464, PDBT: 4.1724, GDBT: 1.5684, DAC: 6.2148, F1: 1.9482 }, { name: 'CHIHUAHUA', ps: 1647.91071302165, GDMTH: 1.70556, GDMTO: 1.3092, PDBT: 4.0452, GDBT: 1.6692, DAC: 6.12, F1: 1.9482 }, { name: 'CIUDAD DE MEXICO', ps: 1557.4250005757, GDMTH: 1.91784, GDMTO: 1.674, PDBT: 3.9528, GDBT: 2.1048, DAC: 6.7032, F1: 1.9482 }, { name: 'COAHUILA', ps: 1649.58363747643, GDMTH: 1.70556, GDMTO: 1.3092, PDBT: 4.0452, GDBT: 1.6692, DAC: 6.12, F1: 1.9482 }, { name: 'COLIMA', ps: 1647.6548304293, GDMTH: 1.96596, GDMTO: 1.4676, PDBT: 4.1508, GDBT: 1.5252, DAC: 6.7032, F1: 1.9482 }, { name: 'DURANGO', ps: 1575.4730325138, GDMTH: 1.70556, GDMTO: 1.3092, PDBT: 4.0452, GDBT: 1.6692, DAC: 6.12, F1: 1.9482 }, { name: 'GUANAJUATO', ps: 1677.00439212182, GDMTH: 1.9632, GDMTO: 1.6152, PDBT: 4.0356, GDBT: 1.9368, DAC: 6.7032, F1: 1.9482 }, { name: 'GUERRERO', ps: 1586.73132909853, GDMTH: 1.78872, GDMTO: 1.3332, PDBT: 4.1616, GDBT: 1.62, DAC: 6.2148, F1: 1.9482 }, { name: 'HIDALGO', ps: 1678.68348757873, GDMTH: 1.9668, GDMTO: 1.5948, PDBT: 4.0416, GDBT: 1.7676, DAC: 6.7032, F1: 1.9482 }, { name: 'JALISCO', ps: 1647.65483701992, GDMTH: 1.89732, GDMTO: 1.488, PDBT: 4.8024, GDBT: 1.5732, DAC: 6.7032, F1: 1.9482 }, { name: 'MEXICO', ps: 1602.48095394995, GDMTH: 1.92876, GDMTO: 1.6884, PDBT: 4.0032, GDBT: 2.3412, DAC: 6.7032, F1: 1.9482 }, { name: 'MICHOACAN', ps: 1571.01905481714, GDMTH: 1.96596, GDMTO: 1.4676, PDBT: 4.1508, GDBT: 1.5252, DAC: 6.7032, F1: 1.9482 }, { name: 'MORELOS', ps: 1628.34256515637, GDMTH: 1.78872, GDMTO: 1.3332, PDBT: 4.122, GDBT: 1.62, DAC: 6.7032, F1: 1.9482 }, { name: 'NAYARIT', ps: 1575.4730325138, GDMTH: 1.89732, GDMTO: 1.488, PDBT: 4.8024, GDBT: 1.5732, DAC: 6.7032, F1: 1.9482 }, { name: 'NUEVO LEON', ps: 1445.61022810944, GDMTH: 1.665, GDMTO: 1.3344, PDBT: 3.8316, GDBT: 1.4568, DAC: 6.12, F1: 1.9482 }, { name: 'OAXACA', ps: 1651.46533110706, GDMTH: 1.84008, GDMTO: 1.3464, PDBT: 4.1724, GDBT: 1.5684, DAC: 6.2148, F1: 1.9482 }, { name: 'PUEBLA', ps: 1667.18376645454, GDMTH: 1.9668, GDMTO: 1.5948, PDBT: 4.0416, GDBT: 1.7676, DAC: 6.7032, F1: 1.9482 }, { name: 'QUERETARO', ps: 1682.900593622, GDMTH: 1.9632, GDMTO: 1.6152, PDBT: 4.1616, GDBT: 1.9368, DAC: 6.7032, F1: 1.9482 }, { name: 'QUINTANA ROO', ps: 1465.36896933307, GDMTH: 2.17404, GDMTO: 1.8192, PDBT: 4.3356, GDBT: 2.1828, DAC: 6.2148, F1: 1.9482 }, { name: 'SAN LUIS POTOSI', ps: 1669.24024534636, GDMTH: 1.77504, GDMTO: 1.4268, PDBT: 4.3224, GDBT: 1.7484, DAC: 6.7032, F1: 1.9482 }, { name: 'SINALOA', ps: 1565.77706412961, GDMTH: 1.63284, GDMTO: 1.3716, PDBT: 3.6348, GDBT: 1.602, DAC: 6.2796, F1: 1.9482 }, { name: 'SONORA', ps: 1594.86498818786, GDMTH: 1.63284, GDMTO: 1.3716, PDBT: 3.6348, GDBT: 1.602, DAC: 6.2796, F1: 1.9482 }, { name: 'TABASCO', ps: 1424.90730862583, GDMTH: 1.84008, GDMTO: 1.3464, PDBT: 4.1724, GDBT: 1.5684, DAC: 6.2148, F1: 1.9482 }, { name: 'TAMAULIPAS', ps: 1472.88634712537, GDMTH: 1.77504, GDMTO: 1.4268, PDBT: 4.3224, GDBT: 1.7484, DAC: 6.12, F1: 1.9482 }, { name: 'TLAXCALA', ps: 1671.0170001452, GDMTH: 1.9668, GDMTO: 1.5948, PDBT: 4.0416, GDBT: 1.7676, DAC: 6.7032, F1: 1.9482 }, { name: 'VERACRUZ', ps: 1459.75630875567, GDMTH: 1.71504, GDMTO: 1.3944, PDBT: 4.1832, GDBT: 1.4184, DAC: 6.2148, F1: 1.9482 }, { name: 'YUCATAN', ps: 1382.72992579033, GDMTH: 2.17404, GDMTO: 1.8192, PDBT: 4.3356, GDBT: 2.1828, DAC: 6.2148, F1: 1.9482 }, { name: 'ZACATECAS', ps: 1575.4730325138, GDMTH: 1.9632, GDMTO: 1.6152, PDBT: 4.1616, GDBT: 1.9368, DAC: 6.7032, F1: 1.9482 } ];
document.querySelector('#step-next').onclick = function calculate() { // datos que ingresa el usuario let CM, TA, ST;
CM = document.getElementById('consumption').value; TA = document.getElementById('rate').value; ST = document.getElementById('place').value;
console.log('Consumo menusal: '+ CM); console.log('Tarifa asignada: ' + TA); console.log('Estado: ' + ST);
let fieldCM = document.getElementById('monthly-cons'); let fieldPlace = document.getElementById('state'); let fieldRate = document.getElementById('rate-cfe'); fieldCM.innerText = CM; fieldPlace.innerText = ST; fieldRate.innerText = TA;
let PI, GEA, A1, AT, RI, TON, ARB, LTS, PSE, CAGW, IE; // PI --> Potencia a instalar // GEA --> Generación estimada anual // A1 --> Ahorro primer año // AT --> Ahorro total vida util // RI --> Retorno de la inversión (al año) // TON --> Ton CO2 // ARB --> Árboles // LTS --> Litros de agua // PSE --> Potencia solar estado // TE --> Tarifa del estado // CAGW --> Consumo anual en GW
function setInnerText (id, text) { document.getElementById(id).innerText = text; } function num(n) { return new Intl.NumberFormat('es-MX',{maximumFractionDigits: 1}).format(+n); }
let fieldPI = document.getElementById('power-install'); let state = STATES.find( state => state.name === ST ); let stateRate = state[TA]; console.log(state); console.log('Tarifa de estado: ' + stateRate);
PSE = state.ps; PI = (CM * 12) / (PSE); setInnerText('power-install', num(PI)); console.log('Potencia a instalar: ' + PI);
GEA = PI * PSE; setInnerText('annual-generation', num(GEA)); console.log('Generación anual: ' + GEA);
A1 = GEA * stateRate; setInnerText('first-year', num(A1)); console.log('Ahorro primer año: ' + A1);
AT = A1 * 25; setInnerText('total-saving', num(AT)); console.log('Ahorro total : ' + AT);
const USDMXN = 20; const CAPEX = [ { min: 250, max: 500, costKWMxn: 0.85 * 1000 * USDMXN, }, { min: 100, max: 249, costKWMxn: 0.90 * 1000 * USDMXN, }, { min: 40, max: 99, costKWMxn: 0.95 * 1000 * USDMXN, }, { min: 20, max: 39, costKWMxn: 1 * 1000 * USDMXN, }, { min: 10, max: 19, costKWMxn: 1.10 * 1000 * USDMXN, }, { min: 0, max: 9, costKWMxn: 1.20 * 1000 * USDMXN, } ];
let range = CAPEX.find( capex => PI >= capex.min );
IE = range.costKWMxn * PI; setInnerText('investment', num(IE)); console.log('Inversion estimada: ' + IE);
RI = IE / A1; setInnerText('return-inv', num(RI)); console.log('Retorno inversion: ' + RI);
CAGW = GEA / 1000; console.log('Consumo anual en GW: ' + CAGW); TON = 0.51 * CAGW; setInnerText('ton', num(TON)); console.log('Ton CO2: ' + TON);
ARB = 52 * CAGW; setInnerText('trees', num(ARB)); console.log('Arboles: ' + ARB);
LTS = 65000 * CAGW; setInnerText('liters', num(LTS)); console.log('Litros de agua: ' + LTS);
}