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
a2b8b8e4
Commit
a2b8b8e4
authored
4 months ago
by
AlQuemist
Browse files
Options
Downloads
Patches
Plain Diff
scatter2d/CustomFormFactor.py: add explanatory comments; clean up
parent
f3fa3da3
No related branches found
Branches containing commit
No related tags found
1 merge request
!2756
Restore the functionality for accepting a custom Python formfactor
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rawEx/scatter2d/CustomFormFactor.py
+36
-12
36 additions, 12 deletions
rawEx/scatter2d/CustomFormFactor.py
with
36 additions
and
12 deletions
rawEx/scatter2d/CustomFormFactor.py
+
36
−
12
View file @
a2b8b8e4
...
...
@@ -11,7 +11,7 @@ import matplotlib.pyplot as plt
def
sinc
(
x
):
if
abs
(
x
)
==
0
:
return
1.
return
cmath
.
sin
(
x
)
/
x
return
cmath
.
sin
(
x
)
/
x
class
CustomFormfactor
:
...
...
@@ -22,27 +22,35 @@ class CustomFormfactor:
"""
def
__init__
(
self
,
L
,
H
):
"""
arguments and initialization for the formfactor
"""
# parameters describing the form factor
self
.
L
=
L
self
.
H
=
H
def
formfactor
(
self
,
q
):
qzhH
=
0.5
*
q
.
z
()
*
self
.
H
qxhL
=
0.5
*
q
.
x
()
*
self
.
L
qyhL
=
0.5
*
q
.
y
()
*
self
.
L
return
0.5
*
self
.
H
*
self
.
L
**
2
*
cmath
.
exp
(
complex
(
0.
,
1.
)
*
qzhH
)
*
\
sinc
(
qzhH
)
*
(
sinc
(
0.5
*
qyhL
)
*
(
sinc
(
qxhL
)
-
0.5
*
sinc
(
0.5
*
qxhL
))
+
\
sinc
(
0.5
*
qxhL
)
*
sinc
(
qyhL
))
def
formfactor
(
self
,
q
:
'
C3
'
):
"""
main scattering function
"""
qzhH
=
0.5
*
q
.
z
()
*
self
.
H
qxhL
=
0.5
*
q
.
x
()
*
self
.
L
qyhL
=
0.5
*
q
.
y
()
*
self
.
L
return
(
0.5
*
self
.
H
*
self
.
L
**
2
*
cmath
.
exp
(
complex
(
0.
,
1.
)
*
qzhH
)
*
sinc
(
qzhH
)
*
(
sinc
(
0.5
*
qyhL
)
*
(
sinc
(
qxhL
)
-
0.5
*
sinc
(
0.5
*
qxhL
))
+
sinc
(
0.5
*
qxhL
)
*
sinc
(
qyhL
)))
def
spanZ
(
self
,
rotation
):
"""
upper and lower z-positions of a custom shape
"""
return
ba
.
Span
(
0
,
self
.
H
)
def
get_sample
():
"""
A s
ample with particles, having a custom form
factor, on a substrate.
S
ample with particles, having a custom formfactor, on a substrate.
"""
# defining materials
# materials
vacuum
=
ba
.
RefractiveMaterial
(
"
Vacuum
"
,
0
,
0
)
material_substrate
=
ba
.
RefractiveMaterial
(
"
Substrate
"
,
6e-6
,
2e-8
)
material_particle
=
ba
.
RefractiveMaterial
(
"
Particle
"
,
6e-4
,
2e-8
)
...
...
@@ -56,6 +64,18 @@ def get_sample():
vacuum_layer
.
addLayout
(
particle_layout
)
substrate_layer
=
ba
.
Layer
(
material_substrate
)
"""
NOTE:
Slicing of custom formfactor is not possible.
all layers must have number of slices equal to 1.
It is a default situation; otherwise use
```
my_layer.setNumberOfSlices(1)
```
Furthermore, a custom particle should not cross layer boundaries;
that is, the z-span should be within a single layer
"""
# assemble sample
sample
=
ba
.
Sample
()
sample
.
addLayer
(
vacuum_layer
)
...
...
@@ -68,8 +88,12 @@ def get_simulation(sample):
n
=
<%=
test_mode
?
11
:
100
%>
det
=
ba
.
SphericalDetector
(
n
,
-
1
*
deg
,
1
*
deg
,
n
,
0
,
2
*
deg
)
simulation
=
ba
.
ScatteringSimulation
(
beam
,
sample
,
det
)
simulation
.
options
().
setNumberOfThreads
(
1
)
# deactivate multithreading (why?)
# Deactivate multithreading:
# Currently BornAgain cannot access the Python interpreter
# from a multi-threaded C++ function
simulation
.
options
().
setNumberOfThreads
(
1
)
return
simulation
...
...
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