Skip to content

Commit

Permalink
Added Solar Power Saving Calculator (#1195)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archiesachin authored Jun 10, 2024
1 parent d6baa2d commit 05f77a6
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Calculators/Solar-Power-Saving-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# <p align="center">Solar Power Saving Calculator</p>

## Description :-

A Solar Power Savings Calculator helps users estimate the potential savings from installing solar panels on their property. This tool considers various factors such as local solar insolation (sunlight exposure), electricity consumption, current electricity rates, and the cost of solar installation to provide an estimate of both short-term and long-term financial benefits.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-

![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/46452036-92d7-4a72-aa96-6c44936b14da)

![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/6476cf0f-0666-4dc9-b0b5-2b6d28bbcb95)
66 changes: 66 additions & 0 deletions Calculators/Solar-Power-Saving-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Solar Power Saving Calculator</title>
</head>
<body>
<h1>Solar Power Saving Calculator</h1>
<form id="solarForm">
<div class="form-group">
<label for="state">State:</label>
<select id="state" onchange="updateStateData()" required>
<option value="">Select a state</option>
<option value="maharashtra">Maharashtra</option>
<option value="karnataka">Karnataka</option>
<option value="rajasthan">Rajasthan</option>
<option value="tamilnadu">Tamil Nadu</option>
<option value="gujarat">Gujarat</option>
<!-- Add more states as needed -->
</select>
</div>
<div class="form-group">
<label for="roofArea">Roof Area (sq ft):</label>
<input type="number" id="roofArea" required>
</div>
<div class="form-group">
<label for="roofOrientation">Roof Orientation:</label>
<input type="text" id="roofOrientation" placeholder="e.g., south-facing, 30-degree tilt" required>
</div>
<div class="form-group">
<label for="electricityConsumption">Electricity Consumption (kWh per month):</label>
<input type="number" id="electricityConsumption" required>
</div>
<div class="form-group">
<label for="systemSize">Solar System Size (kW):</label>
<input type="number" id="systemSize" required>
</div>
<div class="form-group">
<label for="installationCost">Installation Cost (₹):</label>
<input type="number" id="installationCost" required>
</div>
<div class="form-group">
<label for="incentives">Incentives and Rebates (₹):</label>
<input type="number" id="incentives" required>
</div>
<div class="form-group">
<label for="financingOptions">Financing Options:</label>
<input type="text" id="financingOptions" placeholder="e.g., Loan with 5% interest rate" required>
</div>
<button type="button" onclick="calculateSavings()">Calculate</button>
</form>

<div class="results" id="results">
<h2>Results</h2>
<p id="annualEnergyProduction"></p>
<p id="annualSavings"></p>
<p id="paybackPeriod"></p>
<p id="lifetimeSavings"></p>
<p id="environmentalImpact"></p>
</div>

<script src="script.js"></script>
</body>
</html>
89 changes: 89 additions & 0 deletions Calculators/Solar-Power-Saving-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const stateData = {
maharashtra: {
avgSunHours: 5.5,
electricityRate: 8,
co2Reduction: 0.85,
installationCost: 100000,
incentives: 20000
},
karnataka: {
avgSunHours: 5.8,
electricityRate: 7.5,
co2Reduction: 0.82,
installationCost: 95000,
incentives: 15000
},
rajasthan: {
avgSunHours: 6.0,
electricityRate: 7,
co2Reduction: 0.88,
installationCost: 90000,
incentives: 18000
},
tamilnadu: {
avgSunHours: 5.6,
electricityRate: 8.2,
co2Reduction: 0.83,
installationCost: 110000,
incentives: 22000
},
gujarat: {
avgSunHours: 5.9,
electricityRate: 7.8,
co2Reduction: 0.86,
installationCost: 105000,
incentives: 21000
},
// Add more states as needed
};

function updateStateData() {
const state = document.getElementById('state').value;
if (stateData[state]) {
document.getElementById('installationCost').value = stateData[state].installationCost;
document.getElementById('incentives').value = stateData[state].incentives;
} else {
document.getElementById('installationCost').value = '';
document.getElementById('incentives').value = '';
}
}

function calculateSavings() {
const state = document.getElementById('state').value;
const roofArea = parseFloat(document.getElementById('roofArea').value);
const roofOrientation = document.getElementById('roofOrientation').value;
const electricityConsumption = parseFloat(document.getElementById('electricityConsumption').value);
const systemSize = parseFloat(document.getElementById('systemSize').value);
const installationCost = parseFloat(document.getElementById('installationCost').value);
const incentives = parseFloat(document.getElementById('incentives').value);
const financingOptions = document.getElementById('financingOptions').value;

const avgSunHoursPerDay = stateData[state].avgSunHours;
const electricityRate = stateData[state].electricityRate;
const co2ReductionPerKWh = stateData[state].co2Reduction;

const systemEfficiency = 0.75; // Efficiency of the solar system

// Annual energy production calculation
const annualEnergyProduction = systemSize * avgSunHoursPerDay * 365 * systemEfficiency;

// Annual savings calculation
const annualSavings = annualEnergyProduction * electricityRate;

// Payback period calculation
const netInstallationCost = installationCost - incentives;
const paybackPeriod = netInstallationCost / annualSavings;

// Lifetime savings calculation
const lifetimeSavings = annualSavings * 25; // Assuming a 25-year lifespan

// Environmental impact calculation
const annualCo2Reduction = annualEnergyProduction * co2ReductionPerKWh;

// Display results
document.getElementById('annualEnergyProduction').innerText = `Annual Energy Production: ${annualEnergyProduction.toFixed(2)} kWh`;
document.getElementById('annualSavings').innerText = `Annual Savings: ₹${annualSavings.toFixed(2)}`;
document.getElementById('paybackPeriod').innerText = `Payback Period: ${paybackPeriod.toFixed(2)} years`;
document.getElementById('lifetimeSavings').innerText = `Total Lifetime Savings: ₹${lifetimeSavings.toFixed(2)}`;
document.getElementById('environmentalImpact').innerText = `Environmental Impact: ${annualCo2Reduction.toFixed(2)} kg CO2 avoided annually`;
}
56 changes: 56 additions & 0 deletions Calculators/Solar-Power-Saving-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
body {
font-family: Arial, sans-serif;
margin: 20px;
background: slateblue;
}

h1 {
text-align: center;
}

form {
max-width: 600px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
background-color: #f9f9f9;
}

.form-group {
margin-bottom: 15px;
}

label {
display: block;
margin-bottom: 5px;
}

input[type="text"],
input[type="number"],
select {
width: 100%;
padding: 8px;
box-sizing: border-box;
}

button {
padding: 10px 20px;
background-color: slateblue;
color: white;
border: none;
cursor: pointer;
}

.results {
max-width: 600px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
background-color: #f9f9f9;
}

.results p {
margin: 5px 0;
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2570,6 +2570,20 @@ <h3>Calculator that determines whether a given number is a Smith number or not.<
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Solar Power Saving Calculator</h2>
<h3>Calculates the amount one can save on electricity by installing solar panels.</h3>
<div class="card-footer">
<a href="./Calculators/Solar-Power-Saving-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Solar-Power-Saving-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Speed Calculator</h2>
Expand Down

0 comments on commit 05f77a6

Please sign in to comment.