Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
students
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KIT
ETP-Lehre
P2-Praktikum
students
Commits
6c30fb53
Commit
6c30fb53
authored
11 months ago
by
Roger Wolf
Browse files
Options
Downloads
Patches
Plain Diff
adding new directory tools
parent
92037c98
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Interferenz/tools/lattice.py
+52
-0
52 additions, 0 deletions
Interferenz/tools/lattice.py
with
52 additions
and
0 deletions
Interferenz/tools/lattice.py
0 → 100755
+
52
−
0
View file @
6c30fb53
#!/usr/bin/python3
"""
Diffraction and interference at single, double slit and lattice
Usage:
python3 sinc.py
"""
import
matplotlib.pyplot
as
plt
import
numpy
as
np
def
lattice
(
x
,
b
=
150.
,
l
=
200.
,
g
=
200.
,
N
=
2
):
"""
x: alpha (rad)
b: slit width (nm)
l: wavelength (nm)
g: lattice constant (nm)
N: number of illuminated slits
"""
arg
=
np
.
pi
/
l
*
x
## Spaltfunktion
fS
=
(
np
.
sin
(
b
*
arg
)
/
(
b
*
arg
))
**
2
## Gitterinterferenzfunktion
fG
=
1
/
N
/
N
*
(
np
.
sin
(
N
*
g
*
arg
)
/
np
.
sin
(
g
*
arg
))
**
2
return
fS
*
fG
# Creating a list of points in x from -10 to 10 to display the functions of
# choice
def
plot
(
b
=
250.
,
l
=
200
,
g
=
200
,
N
=
2
):
x
=
np
.
linspace
(
-
10.2
,
10.2
,
2000
)
plt
.
plot
(
x
,
lattice
(
x
=
x
,
b
=
b
,
g
=
g
,
N
=
N
),
color
=
"
black
"
,
linestyle
=
"
solid
"
,
linewidth
=
1.5
,
label
=
r
"
Intensität am Gitter
"
)
plt
.
plot
(
x
,
lattice
(
x
=
x
,
b
=
b
,
l
=
l
,
g
=
1.
,
N
=
1
),
color
=
"
black
"
,
linestyle
=
"
dashed
"
,
linewidth
=
1.
,
label
=
r
"
Beugung am Spalt
"
)
# Customize the figure
plt
.
xlabel
(
r
'
Position (cm)
'
)
plt
.
ylabel
(
r
'
Intensität
'
)
plt
.
legend
(
bbox_to_anchor
=
(
0.
,
1.
,
1.
,
0.1
),
loc
=
"
lower left
"
,
ncol
=
2
,
mode
=
"
expand
"
)
# Save to pdf
plt
.
savefig
(
"
lattice.png
"
)
# Show the plot with a rendering machine
#plt.show()
plot
(
b
=
1.
,
l
=
200.
,
g
=
120.
,
N
=
5
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment