Skip to content

Commit

Permalink
Added Thermal Expansion Calculator (Rakesh9100#1558)
Browse files Browse the repository at this point in the history
  • Loading branch information
aadium authored Jul 11, 2024
1 parent 473ae68 commit b245d33
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Calculators/Thermal-Expansion-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# <p align="center">Thermal Expansion Calculator</p>

## Description :-

Any material undergoes thermal expansion according to the formula ΔL = αLΔT, where ΔL is the change in length, α is the thermal expansion coefficient, L is the initial length, and ΔT is the temperature change.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-

![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/9efa5d08-f9d9-418e-84e0-7052ac43690c)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions Calculators/Thermal-Expansion-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Thermal Expansion Calculator</title>
</head>
<body>
<h1>Thermal Expansion Calculator</h1>
<div class="calculator-container">
<div class="input-container">
<label for="initialLength">Initial Length (metres):</label>
<input type="number" id="initialLength" placeholder="Enter initial length">
</div>
<div class="input-container">
<label for="expansionCoefficient">Thermal Expansion Coefficient (α):</label>
<input type="number" id="expansionCoefficient" placeholder="Enter coefficient" step="any">
</div>
<div class="input-container">
<label for="temperatureChange">Temperature Change (Kelvin):</label>
<input type="number" id="temperatureChange" placeholder="Enter temperature change">
</div>
<button onclick="calculateExpansion()">Calculate ΔL</button>
<div class="result-container">
<p id="result">Result will appear here.</p>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions Calculators/Thermal-Expansion-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function calculateExpansion() {
const initialLength = document.getElementById('initialLength').value;
const expansionCoefficient = document.getElementById('expansionCoefficient').value;
const temperatureChange = document.getElementById('temperatureChange').value;

if (initialLength && expansionCoefficient && temperatureChange) {
const deltaL = expansionCoefficient * initialLength * temperatureChange;
document.getElementById('result').innerText = `The change in length (ΔL) is: ${deltaL}m.\n\nThe final length is: ${parseFloat(initialLength) + deltaL}m.`;
} else {
document.getElementById('result').innerText = 'Please fill in all fields.';
}
}
70 changes: 70 additions & 0 deletions Calculators/Thermal-Expansion-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
body {
font-family: Arial, sans-serif;
background-image: url(./assets/background.jpg);
background-size: cover;
color: #333;
margin: 5px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
min-height: 0vh;
}

h1,
h2 {
color: #fff;
background-color: #3498db;
padding: 10px;
border: 2px solid #2980b9;
text-align: center;
width: 100%;
box-sizing: border-box;
}

.calculator-container {
background-color: #fff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
padding: 20px;
max-width: 400px;
margin: 20px auto;
}

.input-container {
margin-bottom: 15px;
}

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

input {
width: 100%;
padding: 10px;
box-sizing: border-box;
}

button {
background-color: #3498db;
color: #fff;
padding: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s ease;
}

button:hover {
background-color: #2980b9;
}

.calculation-container,
.result-container {
background-color: #f1f1f1;
padding: 15px;
border-radius: 5px;
margin-bottom: 15px;
}
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4051,6 +4051,19 @@ <h3>Whatever number you give it will return 7.</h3>
</a>
</div>
</div>
</div><div class="box">
<div class="content">
<h2>Thermal Expansion Calculator</h2>
<h3>Calculates the thermal expansion based on the expansion coefficient and change in temperature</h3>
<div class="card-footer">
<a href="./Calculators/Thermal-Expansion-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Thermal-Expansion-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">
Expand Down

0 comments on commit b245d33

Please sign in to comment.