-
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
- Loading branch information
1 parent
b40a238
commit 64e7954
Showing
5 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
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.
31 changes: 31 additions & 0 deletions
31
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,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Laser Linewidth and Bandwidth Calculator</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</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> | ||
|
||
<button id="calculate-btn">Calculate</button> | ||
|
||
<div id="result" class="result"></div> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
# Laser Linewidth and Bandwidth Calculator | ||
|
||
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. | ||
|
||
--- | ||
|
||
## Features | ||
- Accepts **Frequency (Hz)** and **Quality Factor (Q)** as inputs. | ||
- Calculates: | ||
- **Linewidth** = Frequency / Quality Factor | ||
- **Bandwidth** = Linewidth (assumed equal in this context). | ||
- Provides real-time results with an interactive UI. | ||
|
||
--- | ||
|
||
## Technologies Used | ||
- **HTML** | ||
- **CSS** | ||
- **JavaScript** | ||
|
||
--- | ||
|
||
## Setup Instructions | ||
|
||
1. Clone or download this repository to your local machine. | ||
2. Run the index.html file. | ||
|
||
## Screenshot: | ||
|
||
![image](/Calculators/Laser-Linewidth-And-Bandwidth-Calculator/assets/image.png) | ||
|
||
|
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
document.getElementById("calculate-btn").addEventListener("click", () => { | ||
const frequency = parseFloat(document.getElementById("frequency").value); | ||
const qualityFactor = parseFloat(document.getElementById("quality-factor").value); | ||
const resultDiv = document.getElementById("result"); | ||
|
||
// Validate input | ||
if (isNaN(frequency) || isNaN(qualityFactor) || frequency <= 0 || qualityFactor <= 0) { | ||
resultDiv.innerHTML = `<p style="color: red;">Please enter valid positive numbers for frequency and quality factor.</p>`; | ||
return; | ||
} | ||
|
||
// Linewidth formula: Linewidth = Frequency / Quality Factor | ||
const linewidth = frequency / qualityFactor; | ||
|
||
// Bandwidth is equivalent to linewidth in this context | ||
const bandwidth = linewidth; | ||
|
||
resultDiv.innerHTML = ` | ||
<p>Linewidth: <strong>${linewidth.toFixed(2)} Hz</strong></p> | ||
<p>Bandwidth: <strong>${bandwidth.toFixed(2)} Hz</strong></p> | ||
`; | ||
}); | ||
|
72 changes: 72 additions & 0 deletions
72
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,72 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
background: linear-gradient(to right, #4caf50, #8bc34a); | ||
margin: 0; | ||
padding: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
color: #fff; | ||
} | ||
|
||
.calculator { | ||
background: #fff; | ||
padding: 20px 30px; | ||
border-radius: 10px; | ||
text-align: center; | ||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); | ||
width: 400px; | ||
} | ||
|
||
h1 { | ||
font-size: 22px; | ||
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; | ||
} | ||
|