-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Capacitance Calculator (#1773)
- Loading branch information
1 parent
32e3480
commit b58521b
Showing
5 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# <p align="center">Capacitance Calculator</p> | ||
|
||
## Description :- | ||
|
||
This calculator will help to find the capacitance in a parallel plate capacitor. | ||
|
||
## Tech Stacks :- | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
|
||
## Screenshots :- | ||
|
||
![image](https://github.com/user-attachments/assets/f9692a50-1dc2-4a22-89e8-33a2431b66a1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Capacitance Calculator</title> | ||
</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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters