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 Lattice Energy Calculator #1774

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions Calculators/Lattice-Energy-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# <p align="center">Lattice Energy Calculator</p>

## Description :-

The Lattice Energy Calculator helps you determine the lattice energy of ionic compounds based on the charges of the ions and the distance between them. Simply input the ion charges and their separation distance to calculate the lattice energy instantly.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Screenshots :-
30 changes: 30 additions & 0 deletions Calculators/Lattice-Energy-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lattice Energy Calculator</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">
<h1>Lattice Energy Calculator</h1>
<form id="latticeForm">
<label for="charge1">Charge of ion 1 (z<sub>1</sub>):</label>
<input type="number" id="charge1" name="charge1" required />

<label for="charge2">Charge of ion 2 (z<sub>2</sub>):</label>
<input type="number" id="charge2" name="charge2" required />

<label for="distance"
>Distance between ions (r<sub>0</sub>) in pm:</label
>
<input type="number" id="distance" name="distance" required />

<button type="submit">Calculate</button>
</form>
<div id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions Calculators/Lattice-Energy-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
document.getElementById("latticeForm").addEventListener("submit", function (e) {
e.preventDefault();

const charge1 = parseFloat(document.getElementById("charge1").value);
const charge2 = parseFloat(document.getElementById("charge2").value);
const distance = parseFloat(document.getElementById("distance").value);

// Constant (k) in the Lattice Energy formula (k = 8.99 x 10^9 Nm^2/C^2)
const k = 8.99e9;
// Convert distance from picometers (pm) to meters (m)
const distanceInMeters = distance * 1e-12;

// Calculate lattice energy using the formula: E = k * (z1 * z2) / r0
const latticeEnergy = (k * (charge1 * charge2)) / distanceInMeters;

// Display the result
document.getElementById(
"result"
).textContent = `Lattice Energy: ${latticeEnergy.toFixed(2)} J/mol`;
});
63 changes: 63 additions & 0 deletions Calculators/Lattice-Energy-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
background-image: url("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQGV5d7tcd_q6PKvynba4QFZW-tPjds6YUDzA&s");
Rakesh9100 marked this conversation as resolved.
Show resolved Hide resolved
background-size: cover;
background-position: center;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

.container {
background-color: rgba(219, 220, 238, 0.7);
padding: 40px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
text-align: center;
width: 300px;
}

h1 {
font-size: 26px;
margin-bottom: 25px;
}

label {
display: block;
margin-top: 15px;
font-size: 20px;
}

input {
width: 100%;
padding: 8px;
margin-top: 5px;
margin-bottom: 10px;
border: 2px solid #0a0d0e;
border-radius: 5px;
}

button {
background-color: #033f7e;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin-top: 10px;
transition: background-color 0.3s ease; /* Add transition for the button */
}

button:hover {
background-color: #aad0fa;
color: black;
border: 2px solid #0a0d0e;
}

#result {
margin-top: 20px;
font-size: 18px;
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2801,6 +2801,20 @@ <h3>Calculates the kinetic and potential energy.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Lattice Energy Calculator</h2>
<h3>The Lattice Energy Calculator computes the lattice energy of ionic compounds based on ion charges and their separation distance.</h3>
<div class="card-footer">
<a href="./Calculators/Lattice-Energy-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Lattice-Energy-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>LCM Calculator</h2>
Expand Down