Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
5cf59abe
Commit
5cf59abe
authored
4 years ago
by
Beerwerth, Randolf
Browse files
Options
Downloads
Patches
Plain Diff
update BasicPolarizedReflectometry example
parent
50c434fe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Examples/python/simulation/ex06_Reflectometry/BasicPolarizedReflectometry.py
+24
-15
24 additions, 15 deletions
...ulation/ex06_Reflectometry/BasicPolarizedReflectometry.py
with
24 additions
and
15 deletions
Examples/python/simulation/ex06_Reflectometry/BasicPolarizedReflectometry.py
+
24
−
15
View file @
5cf59abe
...
@@ -6,6 +6,7 @@ magnetized sample.
...
@@ -6,6 +6,7 @@ magnetized sample.
import
bornagain
as
ba
import
bornagain
as
ba
from
bornagain
import
deg
,
angstrom
from
bornagain
import
deg
,
angstrom
import
matplotlib.pyplot
as
plt
def
get_sample
():
def
get_sample
():
"""
"""
...
@@ -43,8 +44,8 @@ def get_simulation(scan_size=500):
...
@@ -43,8 +44,8 @@ def get_simulation(scan_size=500):
return
simulation
return
simulation
def
run_simulation
(
polarization
=
ba
.
kvector_t
(
0
.0
,
1
.0
,
0.
0
),
def
run_simulation
(
polarization
=
ba
.
kvector_t
(
0
,
1
,
0
),
analyzer
=
ba
.
kvector_t
(
0
.0
,
1
.0
,
0.
0
)):
analyzer
=
ba
.
kvector_t
(
0
,
1
,
0
)):
"""
"""
Runs simulation and returns its result.
Runs simulation and returns its result.
"""
"""
...
@@ -60,20 +61,28 @@ def run_simulation(polarization=ba.kvector_t(0.0, 1.0, 0.0),
...
@@ -60,20 +61,28 @@ def run_simulation(polarization=ba.kvector_t(0.0, 1.0, 0.0),
return
simulation
.
result
()
return
simulation
.
result
()
def
plot
(
pp
,
mm
):
def
plot
(
data
,
labels
):
from
matplotlib
import
pyplot
as
plt
plt
.
figure
()
ba
.
plot_simulation_result
(
pp
,
postpone_show
=
True
)
for
d
,
l
in
zip
(
data
,
labels
):
plt
.
semilogy
(
mm
.
axis
(),
mm
.
array
())
plt
.
semilogy
(
d
.
axis
(),
plt
.
legend
([
'
Up-Up
'
,
'
Down-Down
'
],
d
.
array
(),
loc
=
'
upper right
'
)
label
=
l
,
linewidth
=
1
)
plt
.
legend
(
loc
=
'
upper right
'
)
plt
.
gca
().
yaxis
.
set_ticks_position
(
'
both
'
)
plt
.
gca
().
xaxis
.
set_ticks_position
(
'
both
'
)
plt
.
xlabel
(
r
"
$\alpha_i$ [deg]
"
)
plt
.
ylabel
(
"
Reflectivity
"
)
plt
.
tight_layout
()
plt
.
show
()
plt
.
show
()
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
results_pp
=
run_simulation
(
ba
.
kvector_t
(
0
.0
,
1.0
,
0.
0
),
results_pp
=
run_simulation
(
ba
.
kvector_t
(
0
,
1
,
0
),
ba
.
kvector_t
(
0
.0
,
1.0
,
0.
0
))
ba
.
kvector_t
(
0
,
1
,
0
))
results_mm
=
run_simulation
(
ba
.
kvector_t
(
0
.0
,
-
1
.0
,
0.
0
),
results_mm
=
run_simulation
(
ba
.
kvector_t
(
0
,
-
1
,
0
),
ba
.
kvector_t
(
0
.0
,
-
1
.0
,
0.
0
))
ba
.
kvector_t
(
0
,
-
1
,
0
))
plot
(
results_pp
,
results_mm
)
plot
(
[
results_pp
,
results_mm
],
[
"
$++$
"
,
"
$--$
"
]
)
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