function calculateInstalledCapacity(area, panelEfficiency) { return area * panelEfficiency; } function getPanelEfficiency() { var panelType = prompt("Select the type of panel:\n1. Mono-Si\n2. Poly-Si\n3. Other\nEnter your choice:"); if (panelType === '1') { return 0.18; } else if (panelType === '2') { return 0.16; } else if (panelType === '3') { return parseFloat(prompt("Enter panel efficiency:")); } else { alert("Invalid choice. Using default panel efficiency of 0.18."); return 0.18; } } function getInverterEfficiency() { var inverterType = prompt("Select the type of inverter:\n1. String Inverter\n2. Micro Inverter\n3. Other\nEnter your choice:"); if (inverterType === '1') { return 0.95; } else if (inverterType === '2') { return 0.97; } else if (inverterType === '3') { return parseFloat(prompt("Enter inverter efficiency:")); } else { alert("Invalid choice. Using default inverter efficiency of 0.95."); return 0.95; } } var area = parseFloat(prompt("Enter the area of the system (in m²):")); var panelEfficiency = getPanelEfficiency(); var inverterEfficiency = getInverterEfficiency(); var roofAngle = parseFloat(prompt("Enter the angle of the roof (in degrees):")); var roofDirection = prompt("Enter the direction of the roof (N/S/E/W):"); var pricePerKwh = parseFloat(prompt("Enter the price per kWh (in your local currency):")); var userCurrency = prompt("Enter your currency:"); var latitude = parseFloat(prompt("Enter the latitude of the location:")); var longitude = parseFloat(prompt("Enter the longitude of the location:")); var installedCapacity = calculateInstalledCapacity(area, panelEfficiency); // Since we can't use pvlib, we'll simulate clear sky data and calculations var monthlyOutputPower = []; var monthlyOutputEnergy = []; var totalIrradiance = 1000; // Simulated value for total irradiance for simplicity for (var month = 0; month < 12; month++) { monthlyOutputPower.push(installedCapacity * totalIrradiance / 1000); // kW monthlyOutputEnergy.push((installedCapacity * totalIrradiance / 1000)); // kWh } var expectedYearlyOutputPower = monthlyOutputPower.reduce((a, b) => a + b, 0); var expectedYearlyOutputEnergy = monthlyOutputEnergy.reduce((a, b) => a + b, 0); var solarPanels = installedCapacity / panelEfficiency; var solarInverters = installedCapacity / inverterEfficiency; var specificYield = expectedYearlyOutputEnergy / area; var systemEfficiency = expectedYearlyOutputEnergy / (installedCapacity * totalIrradiance); console.log("Here are the results and graphs for planning your solar system:"); console.log("Installed Capacity: " + installedCapacity.toFixed(3) + " kW"); console.log("Total Global Solar Energy: " + expectedYearlyOutputEnergy.toFixed(3) + " kWh"); // As we cannot display graphs in the console, this is a placeholder console.log("Graphs would be displayed here if this were a full web application.");