-
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 Critical Point Calculator (#1826)
- Loading branch information
1 parent
9c10f22
commit 7feface
Showing
5 changed files
with
169 additions
and
1 deletion.
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,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 |
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,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> |
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,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); | ||
} |
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: '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; | ||
} |
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