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
dfa12e74
Commit
dfa12e74
authored
5 years ago
by
Van Herck, Walter
Browse files
Options
Downloads
Patches
Plain Diff
Add example for Polarized SANS
parent
3a452630
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/ex07_Miscellaneous/PolarizedSANS.py
+80
-0
80 additions, 0 deletions
...les/python/simulation/ex07_Miscellaneous/PolarizedSANS.py
with
80 additions
and
0 deletions
Examples/python/simulation/ex07_Miscellaneous/PolarizedSANS.py
0 → 100644
+
80
−
0
View file @
dfa12e74
"""
Simple example demonstrating how polarized SANS experiments can be
simulated with BornAgain.
"""
import
bornagain
as
ba
from
bornagain
import
deg
,
nm
,
kvector_t
# Magnetization of the particle's core material (A/m)
magnetization_core
=
kvector_t
(
0.0
,
0.0
,
1e7
)
def
get_sample
():
"""
Returns a sample with a magnetic core-shell particle in a solvent.
"""
# Defining Materials
mat_solvent
=
ba
.
HomogeneousMaterial
(
"
Solvent
"
,
5e-6
,
0.0
)
mat_core
=
ba
.
HomogeneousMaterial
(
"
Core
"
,
6e-6
,
2e-8
,
magnetization_core
)
mat_shell
=
ba
.
HomogeneousMaterial
(
"
Shell
"
,
1e-7
,
2e-8
)
# Defining Layer
solvent_layer
=
ba
.
Layer
(
mat_solvent
)
# Defining particle layout with a core-shell particle
layout
=
ba
.
ParticleLayout
()
core_sphere_ff
=
ba
.
FormFactorFullSphere
(
10
*
nm
)
shell_sphere_ff
=
ba
.
FormFactorFullSphere
(
12
*
nm
)
core
=
ba
.
Particle
(
mat_core
,
core_sphere_ff
)
shell
=
ba
.
Particle
(
mat_shell
,
shell_sphere_ff
)
position
=
kvector_t
(
0.0
,
0.0
,
2.0
)
particleCoreShell
=
ba
.
ParticleCoreShell
(
shell
,
core
,
position
)
layout
.
addParticle
(
particleCoreShell
)
# Adding layout to layer
solvent_layer
.
addLayout
(
layout
)
# Defining Multilayer with single layer
multiLayer
=
ba
.
MultiLayer
()
multiLayer
.
addLayer
(
solvent_layer
)
return
multiLayer
def
get_simulation
():
"""
Returns a polarized SANS simulation
"""
simulation
=
ba
.
GISASSimulation
()
# Defining detector
simulation
.
setDetectorParameters
(
200
,
-
3.0
*
deg
,
3.0
*
deg
,
200
,
-
3.0
*
deg
,
3.0
*
deg
)
# Defining beam parameters
simulation
.
setBeamParameters
(
0.5
*
nm
,
0.0
*
deg
,
0.0
*
deg
)
simulation
.
setBeamIntensity
(
1e12
)
# Defining beam polarization and polarization analysis for spin-flip channel
analyzer_dir
=
kvector_t
(
0.0
,
0.0
,
-
1.0
)
beampol
=
kvector_t
(
0.0
,
0.0
,
1.0
)
simulation
.
setBeamPolarization
(
beampol
)
simulation
.
setAnalyzerProperties
(
analyzer_dir
,
1.0
,
0.5
)
return
simulation
def
run_simulation
():
"""
Runs simulation and returns intensity map.
"""
simulation
=
get_simulation
()
simulation
.
setSample
(
get_sample
())
simulation
.
runSimulation
()
return
simulation
.
result
()
if
__name__
==
'
__main__
'
:
result
=
run_simulation
()
ba
.
plot_simulation_result
(
result
,
cmap
=
'
jet
'
,
units
=
ba
.
AxesUnits
.
QSPACE
,
aspect
=
'
auto
'
)
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