Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Capacitance Calculator #1773

Merged
merged 8 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Calculators/Capacitance-In-A-Parallel-Plate-capacitor/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Capacitance Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="calculator">
<h1>Parallel Plate Capacitor Calculator</h1>
<label for="area">A (plate area):</label>
<input type="number" id="area" placeholder="Enter area in mm²">
<span>(mm²)</span>
<br>
<label for="distance">d (distance):</label>
<input type="number" id="distance" placeholder="Enter distance in mm">
<span>(mm)</span>
<br>
<label for="dielectric">K (dielectric constant):</label>
<input type="number" id="dielectric" value="1">
<br>
<button onclick="computeCapacitance()">Compute</button>
<br>
<label for="capacitanceUF">Capacitance:</label>
<input type="text" id="capacitanceUF" readonly>
<span>(uF)</span>
<br>
<label for="capacitancePF">Capacitance:</label>
<input type="text" id="capacitancePF" readonly>
<span>(pF)</span>
</div>
<script src="script.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions Calculators/Capacitance-In-A-Parallel-Plate-capacitor/readme.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# <p align="center">Capacitance in a parallel plate capacitor calculator</p>

## Description :-

This calculator will help to find the capacitance in a parallel plate capaacitor.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-

![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/fe335fb9-7659-4b40-a08e-7ca4d64e63d0)
23 changes: 23 additions & 0 deletions Calculators/Capacitance-In-A-Parallel-Plate-capacitor/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function computeCapacitance() {
const epsilon0 = 8.854187817e-12; // Vacuum permittivity in F/m
const area = document.getElementById("area").value;
const distance = document.getElementById("distance").value;
const dielectric = document.getElementById("dielectric").value;

if (area && distance && dielectric) {
const areaMeters = area * 1e-6; // convert mm² to m²
const distanceMeters = distance * 1e-3; // convert mm to m
const capacitanceFarads =
(dielectric * epsilon0 * areaMeters) / distanceMeters;

const capacitanceMicroFarads = capacitanceFarads * 1e6;
const capacitancePicoFarads = capacitanceFarads * 1e12;

document.getElementById("capacitanceUF").value =
capacitanceMicroFarads.toFixed(6);
document.getElementById("capacitancePF").value =
capacitancePicoFarads.toFixed(6);
} else {
alert("Please fill in all fields.");
}
}
83 changes: 83 additions & 0 deletions Calculators/Capacitance-In-A-Parallel-Plate-capacitor/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* styles.css */

body {
font-family: Arial, sans-serif;
background: linear-gradient(to right, #4facfe, #00f2fe);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

.calculator {
background: #ffffff;
padding: 20px;
border-radius: 15px;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
max-width: 400px;
width: 100%;
text-align: center;
animation: fadeIn 1.5s ease-in-out;
}

h1 {
font-size: 1.5em;
margin-bottom: 20px;
color: #333;
}

label {
display: block;
margin: 10px 0 5px;
color: #555;
font-weight: bold;
}

input[type="number"],
input[type="text"] {
width: calc(100% - 30px);
padding: 10px;
margin-bottom: 10px;
border: 2px solid #ddd;
border-radius: 10px;
transition: border-color 0.3s;
}

input[type="number"]:focus,
input[type="text"]:focus {
border-color: #00f2fe;
outline: none;
}

button {
background: linear-gradient(to right, #ff416c, #ff4b2b);
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 25px;
cursor: pointer;
font-size: 1em;
transition: background 0.3s;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

button:hover {
background: linear-gradient(to right, #ff4b2b, #ff416c);
}

span {
color: #555;
font-weight: bold;
}

@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,20 @@ <h3>Converts capacitor values between different units.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Capacitance in a parallel plate capacitor calculator</h2>
<h3>Converts capacitor values between different units.</h3>
<div class="card-footer">
<a href="./Calculators/Capacitance-In-A-Parallel-Plate-capacitor/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Capacitance-In-A-Parallel-Plate-capacitor/" 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>Carbon Footprint Calculator</h2>
Expand Down