Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Photonics tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Bernabeu Lou
Photonics tool
Commits
45f3f783
Commit
45f3f783
authored
4 years ago
by
Bernabeu Lou
Browse files
Options
Downloads
Patches
Plain Diff
removed __init__.py, corrected typos in elements.py
parent
330f2040
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
__init__.py
+0
-2
0 additions, 2 deletions
__init__.py
__main__.py
+30
-0
30 additions, 0 deletions
__main__.py
elements.py
+1
-1
1 addition, 1 deletion
elements.py
with
31 additions
and
3 deletions
__init__.py
deleted
100644 → 0
+
0
−
2
View file @
330f2040
import
numpy
as
np
import
cmath
This diff is collapsed.
Click to expand it.
__main__.py
+
30
−
0
View file @
45f3f783
import
numpy
as
np
import
elements
import
graphics
print
(
"
Hi World!
"
)
## Tests
H
=
(
1
/
np
.
sqrt
(
2
))
*
np
.
array
([[
1
,
1
],[
1
,
-
1
]],
dtype
=
'
complex
'
)
H_rev
=
(
1
/
np
.
sqrt
(
2
))
*
np
.
array
([[
-
1
,
1
],[
1
,
1
]],
dtype
=
'
complex
'
)
A
=
np
.
kron
(
H_rev
,
np
.
eye
(
2
,
dtype
=
'
complex
'
))
# first beam splitter matrix
B
=
np
.
kron
(
H
,
np
.
eye
(
2
,
dtype
=
'
complex
'
))
# second beam splitter matrix
X
=
np
.
array
([[
0
,
1
],
[
1
,
0
]],
dtype
=
'
complex
'
)
Z
=
np
.
array
([[
1
,
0
],
[
0
,
-
1
]],
dtype
=
'
complex
'
)
source
=
elements
.
Source
(
initial_vector
=
np
.
array
([
1.
+
0j
,
0.
]))
BS1
=
elements
.
BeamSplitter
(
previous
=
{
"
left
"
:
(
source
,
"
left
"
),
"
right
"
:
None
},
matrix
=
A
)
X_left_1
=
elements
.
Plate
(
previous
=
(
BS1
,
"
left
"
),
jones_matrix
=
X
)
Z_left_2
=
elements
.
Plate
(
previous
=
(
X_left_1
,
"
left
"
),
jones_matrix
=
Z
)
Z_right_1
=
elements
.
Plate
(
previous
=
(
BS1
,
"
right
"
),
jones_matrix
=
Z
)
X_right_2
=
elements
.
Plate
(
previous
=
(
Z_right_1
,
"
left
"
),
jones_matrix
=
X
)
BS2
=
elements
.
BeamSplitter
(
previous
=
{
"
left
"
:
(
Z_left_2
,
"
left
"
),
"
right
"
:
(
X_right_2
,
"
left
"
)},
matrix
=
B
)
screen
=
elements
.
Screen
(
previous
=
(
BS2
,
"
left
"
))
print
(
screen
.
out
())
This diff is collapsed.
Click to expand it.
elements.py
+
1
−
1
View file @
45f3f783
...
...
@@ -58,7 +58,7 @@ class BeamSplitter(Element):
left_input_state
=
left_input_element
.
out
(
left_input_element_output_side
)
if
self
.
previous
[
"
right
"
]
is
None
:
lef
t_input_state
=
np
.
zeros
((
2
,),
dtype
=
"
complex
"
)
# if no input on the right, then |\psi> = 0
righ
t_input_state
=
np
.
zeros
((
2
,),
dtype
=
"
complex
"
)
# if no input on the right, then |\psi> = 0
else
:
right_input_element
=
self
.
previous
[
"
right
"
][
0
]
right_input_element_output_side
=
self
.
previous
[
"
right
"
][
1
]
...
...
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