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 Critical Point Calculator #1826

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 19 additions & 0 deletions Calculators/Critical-Point-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<p align="center">Critical Point Calculator</p>

## Description :-
Creating a critical point calculator for ideal gases involves calculating the critical temperature, critical pressure, and critical volume based on the Van der Waals equation of state.

The critical point of an ideal gas is a set of specific thermodynamic conditions where the distinction between the gas and liquid phases disappears. At this point:

Critical Temperature (Tc): This is the highest temperature at which the gas can be liquefied by applying pressure. Above this temperature, no amount of pressure can cause condensation into a liquid phase.

Critical Pressure (Pc): The critical pressure is the pressure required to liquefy the gas at its critical temperature. Below this pressure, the gas cannot be liquefied by any means.

Critical Volume (Vc): This is the molar volume of the gas at the critical point, where the densities of the gas and liquid phases become equal.


## Tech Stacks :-

- HTML
- CSS
- JavaScript
31 changes: 31 additions & 0 deletions Calculators/Critical-Point-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Critical Point Calculator for Ideal Gases</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Critical Point Calculator for Ideal Gases</h1>
<div class="input-group">
<label for="a">Parameter a (L<sup>2</sup> atm/mol<sup>2</sup>):</label>
<input type="number" id="a" step="any" placeholder="Enter value for a">
</div>
<div class="input-group">
<label for="b">Parameter b (L/mol):</label>
<input type="number" id="b" step="any" placeholder="Enter value for b">
</div>
<button onclick="calculateCriticalPoint()">Calculate</button>
<div id="results">
<h2>Critical Point:</h2>
<p>Critical Temperature (K): <span id="criticalTemperature"></span></p>
<p>Critical Pressure (atm): <span id="criticalPressure"></span></p>
<p>Critical Volume (L/mol): <span id="criticalVolume"></span></p>
</div>
</div>

<script src="script.js"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions Calculators/Critical-Point-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function calculateCriticalPoint() {
const a = parseFloat(document.getElementById('a').value);
const b = parseFloat(document.getElementById('b').value);

if (isNaN(a) || isNaN(b)) {
alert('Please enter valid numbers for a and b.');
return;
}

if (a === 0 && b === 0) {
alert('a and b cannot both be zero. Please enter valid non-zero values.');
return;
}

// Calculate critical point
const criticalTemperature = (8 * a) / (27 * b);
const criticalPressure = (a / (27 * b * b));
const criticalVolume = (3 * b);

// Display results
document.getElementById('criticalTemperature').textContent = criticalTemperature.toFixed(2);
document.getElementById('criticalPressure').textContent = criticalPressure.toFixed(2);
document.getElementById('criticalVolume').textContent = criticalVolume.toFixed(2);
}
81 changes: 81 additions & 0 deletions Calculators/Critical-Point-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #2980b9;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.container {
max-width: 400px;
background-color: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
text-align: center;
}

h1 {
color: #2980b9;
margin-bottom: 20px;
}

.input-group {
margin-bottom: 20px;
}

.input-group label {
display: block;
margin-bottom: 10px;
color: #555;
}

.input-group input {
width: calc(100% - 20px);
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
outline: none;
}

button {
background-color: #2ecc71;
color: white;
padding: 12px 24px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}

button:hover {
background-color: #27ae60;
}

#results {
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid #ccc;
}

#results h2 {
color: #555;
border-bottom: 1px solid #ccc;
padding-bottom: 10px;
}

#results p {
margin-bottom: 10px;
color: #777;
}

#results span {
font-weight: bold;
color: #333;
}
15 changes: 14 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5392,7 +5392,20 @@ <h3>Provides the zodiac sign of the user by taking the date of birth as input.</
</div>
</div>
</div>

<div class="box">
<div class="content">
<h2>Critical Point Calculator</h2>
<h3>Calculates the Critical point of ideal gases based on a and b</h3>
<div class="card-footer">
<a href="./Calculators/Critical-Point-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Critical-Point-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>
<br><br><br><br><br>
<div id="noResults" style="color: white; font-weight: bold; font-size: 18px;">
<p>No results found 🙃</p>
Expand Down