-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Laser Linewidth And Bandwidth Calculator (#1884)
- Loading branch information
1 parent
bdf60e4
commit d5077f9
Showing
6 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Calculators/Laser-Linewidth-And-Bandwidth-Calculator/README.md
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 @@ | ||
# <p align="center">Laser Linewidth And Bandwidth Calculator</p> | ||
|
||
## Description :- | ||
|
||
A simple web-based calculator to compute the **linewidth** and **bandwidth** of a laser. These parameters are critical in determining the performance and applications of a laser system, such as in fiber optics. | ||
|
||
## Tech Stacks :- | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
|
||
## Features :- | ||
|
||
- Accepts **Frequency (Hz)** and **Quality Factor (Q)** as inputs. | ||
- Calculates: | ||
- **Linewidth** = Frequency / Quality Factor | ||
- **Bandwidth** = GainBandwidth × (1 - DampingFactor) | ||
- Provides real-time results with an interactive UI. | ||
|
||
## Screenshots :- | ||
|
||
![image](https://github.com/user-attachments/assets/c5bddc25-f389-429c-9a29-8f0bbedef54f) |
Binary file added
BIN
+63.2 KB
Calculators/Laser-Linewidth-And-Bandwidth-Calculator/assets/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
Calculators/Laser-Linewidth-And-Bandwidth-Calculator/index.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,34 @@ | ||
<!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>Laser Linewidth And Bandwidth Calculator</title> | ||
</head> | ||
<body> | ||
<div class="calculator"> | ||
<h1>Laser Linewidth & Bandwidth Calculator</h1> | ||
<p>Calculate the linewidth and bandwidth of a laser.</p> | ||
<div class="input-group"> | ||
<label for="frequency">Frequency (Hz):</label> | ||
<input type="number" id="frequency" placeholder="Enter frequency in Hz"> | ||
</div> | ||
<div class="input-group"> | ||
<label for="quality-factor">Quality Factor (Q):</label> | ||
<input type="number" id="quality-factor" placeholder="Enter quality factor (Q)"> | ||
</div> | ||
<div class="input-group"> | ||
<label for="gain-bandwidth">Gain Bandwidth (Hz):</label> | ||
<input type="number" id="gain-bandwidth" placeholder="Enter gain bandwidth in Hz"> | ||
</div> | ||
<div class="input-group"> | ||
<label for="damping-factor">Damping Factor (0-1):</label> | ||
<input type="number" step="0.01" id="damping-factor" placeholder="Enter damping factor (0-1)"> | ||
</div> | ||
<button id="calculate-btn">Calculate</button> | ||
<div id="result" class="result"></div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
34 changes: 34 additions & 0 deletions
34
Calculators/Laser-Linewidth-And-Bandwidth-Calculator/script.js
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,34 @@ | ||
document.getElementById("calculate-btn").addEventListener("click", () => { | ||
const frequency = parseFloat(document.getElementById("frequency").value); | ||
const qualityFactor = parseFloat(document.getElementById("quality-factor").value); | ||
const gainBandwidth = parseFloat(document.getElementById("gain-bandwidth").value); | ||
const dampingFactor = parseFloat(document.getElementById("damping-factor").value); | ||
const resultDiv = document.getElementById("result"); | ||
|
||
// Validate inputs | ||
if ( | ||
isNaN(frequency) || isNaN(qualityFactor) || | ||
isNaN(gainBandwidth) || isNaN(dampingFactor) || | ||
frequency <= 0 || qualityFactor <= 0 || gainBandwidth <= 0 | ||
) { | ||
resultDiv.innerHTML = `<p style="color: red;">Please enter valid positive numbers for all fields.</p>`; | ||
return; | ||
} | ||
|
||
// Validate damping factor range | ||
if (dampingFactor < 0 || dampingFactor >= 1) { | ||
resultDiv.innerHTML = `<p style="color: red;">Damping Factor must be between 0 and 1 (exclusive).</p>`; | ||
return; | ||
} | ||
|
||
// Linewidth calculation | ||
const linewidth = frequency / qualityFactor; | ||
|
||
// Bandwidth calculation | ||
const bandwidth = gainBandwidth * (1 - dampingFactor); | ||
|
||
resultDiv.innerHTML = ` | ||
<p>Linewidth: <strong>${linewidth.toFixed(2)} Hz</strong></p> | ||
<p>Bandwidth: <strong>${bandwidth.toFixed(2)} Hz</strong></p> | ||
`; | ||
}); |
73 changes: 73 additions & 0 deletions
73
Calculators/Laser-Linewidth-And-Bandwidth-Calculator/style.css
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,73 @@ | ||
body { | ||
font-family: 'Poppins', sans-serif; | ||
background: linear-gradient(135deg, #2196f3, #21cbf3); | ||
margin: 0; | ||
padding: 0; | ||
min-height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
color: #fff; | ||
} | ||
|
||
.calculator { | ||
background: #fff; | ||
padding: 30px 40px; | ||
border-radius: 15px; | ||
text-align: center; | ||
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3); | ||
width: 450px; | ||
max-width: 90%; | ||
box-sizing: border-box; | ||
} | ||
|
||
h1 { | ||
font-size: 24px; | ||
color: #333; | ||
} | ||
|
||
p { | ||
color: #555; | ||
font-size: 14px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.input-group { | ||
margin-bottom: 15px; | ||
} | ||
|
||
label { | ||
display: block; | ||
font-size: 14px; | ||
color: #333; | ||
margin-bottom: 5px; | ||
} | ||
|
||
input { | ||
width: 100%; | ||
padding: 8px; | ||
font-size: 14px; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
} | ||
|
||
button { | ||
background: #4caf50; | ||
color: #fff; | ||
padding: 10px 15px; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
font-size: 14px; | ||
transition: background 0.3s; | ||
} | ||
|
||
button:hover { | ||
background: #388e3c; | ||
} | ||
|
||
.result { | ||
margin-top: 20px; | ||
font-size: 16px; | ||
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