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
51789fec
Commit
51789fec
authored
2 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
repair test
parent
e0d2c4de
No related branches found
No related tags found
1 merge request
!773
new mechanism to steer simulation size in examples and tests, based on command-line argument sim_n
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Examples/specular/BeamAngularDivergence.py
+9
-4
9 additions, 4 deletions
Examples/specular/BeamAngularDivergence.py
Tests/Examples/CMakeLists.txt
+2
-1
2 additions, 1 deletion
Tests/Examples/CMakeLists.txt
with
11 additions
and
5 deletions
Examples/specular/BeamAngularDivergence.py
+
9
−
4
View file @
51789fec
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
An example of taking into account beam angular divergence
An example of taking into account beam angular divergence
and beam footprint correction in reflectometry calculations.
and beam footprint correction in reflectometry calculations.
"""
"""
import
os
,
numpy
as
np
import
numpy
as
np
,
os
,
sys
from
matplotlib
import
pyplot
as
plt
from
matplotlib
import
pyplot
as
plt
import
bornagain
as
ba
import
bornagain
as
ba
from
bornagain
import
angstrom
,
ba_plot
as
bp
,
deg
,
std_samples
from
bornagain
import
angstrom
,
ba_plot
as
bp
,
deg
,
std_samples
...
@@ -39,14 +39,15 @@ def get_sample():
...
@@ -39,14 +39,15 @@ def get_sample():
return
std_samples
.
alternating_layers
()
return
std_samples
.
alternating_layers
()
def
get_simulation
(
sample
,
scan_size
=
500
):
def
get_simulation
(
sample
,
**
kwargs
):
"""
"""
Returns a specular simulation with beam and detector defined.
Returns a specular simulation with beam and detector defined.
"""
"""
n
=
simargs
[
'
n
'
]
footprint
=
ba
.
FootprintSquare
(
beam_sample_ratio
)
footprint
=
ba
.
FootprintSquare
(
beam_sample_ratio
)
alpha_distr
=
ba
.
RangedDistributionGaussian
(
n_points
,
n_sig
)
alpha_distr
=
ba
.
RangedDistributionGaussian
(
n_points
,
n_sig
)
scan
=
ba
.
AlphaScan
(
wavelength
,
scan_size
,
alpha_i_min
,
alpha_i_max
)
scan
=
ba
.
AlphaScan
(
wavelength
,
n
,
alpha_i_min
,
alpha_i_max
)
scan
.
setFootprintFactor
(
footprint
)
scan
.
setFootprintFactor
(
footprint
)
scan
.
setAbsoluteAngularResolution
(
alpha_distr
,
d_ang
)
scan
.
setAbsoluteAngularResolution
(
alpha_distr
,
d_ang
)
...
@@ -58,14 +59,18 @@ def get_simulation(sample, scan_size=500):
...
@@ -58,14 +59,18 @@ def get_simulation(sample, scan_size=500):
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
plotargs
,
simargs
=
bp
.
kwargs_from_cmdline
(
sim_n
=
0
)
plotargs
,
simargs
=
bp
.
kwargs_from_cmdline
(
sim_n
=
500
)
datadir
=
os
.
getenv
(
'
BA_EXAMPLE_DATA_DIR
'
,
''
)
datadir
=
os
.
getenv
(
'
BA_EXAMPLE_DATA_DIR
'
,
''
)
data_fname
=
os
.
path
.
join
(
datadir
,
"
genx_angular_divergence.dat.gz
"
)
data_fname
=
os
.
path
.
join
(
datadir
,
"
genx_angular_divergence.dat.gz
"
)
print
(
f
"
DIR=
{
datadir
}
NAM=
{
data_fname
}
"
)
sample
=
get_sample
()
sample
=
get_sample
()
simulation
=
get_simulation
(
sample
,
**
simargs
)
simulation
=
get_simulation
(
sample
,
**
simargs
)
result
=
simulation
.
simulate
()
result
=
simulation
.
simulate
()
bp
.
plot_simulation_result
(
result
,
**
plotargs
)
bp
.
plot_simulation_result
(
result
,
**
plotargs
)
if
not
plotargs
.
pop
(
'
plot
'
,
'
on
'
)
in
[
'
on
'
]:
sys
.
exit
(
0
)
genx_axis
,
genx_values
=
reference_data
(
data_fname
)
genx_axis
,
genx_values
=
reference_data
(
data_fname
)
plt
.
semilogy
(
genx_axis
,
genx_values
,
'
ko
'
,
markevery
=
300
)
plt
.
semilogy
(
genx_axis
,
genx_values
,
'
ko
'
,
markevery
=
300
)
plt
.
legend
([
'
BornAgain
'
,
'
GenX
'
],
loc
=
'
upper right
'
)
plt
.
legend
([
'
BornAgain
'
,
'
GenX
'
],
loc
=
'
upper right
'
)
...
...
This diff is collapsed.
Click to expand it.
Tests/Examples/CMakeLists.txt
+
2
−
1
View file @
51789fec
...
@@ -47,6 +47,7 @@ function(test_equality example reference tolerance)
...
@@ -47,6 +47,7 @@ function(test_equality example reference tolerance)
set
(
test_name Example.persist.
${
EXAMPLE_NAME
}
)
set
(
test_name Example.persist.
${
EXAMPLE_NAME
}
)
add_test
(
NAME
${
test_name
}
add_test
(
NAME
${
test_name
}
COMMAND
${
CMAKE_COMMAND
}
-E env
"PYTHONPATH=
${
CMAKE_LIBRARY_OUTPUT_DIRECTORY
}
"
COMMAND
${
CMAKE_COMMAND
}
-E env
"PYTHONPATH=
${
CMAKE_LIBRARY_OUTPUT_DIRECTORY
}
"
"BA_EXAMPLE_DATA_DIR=
${
EXAMPLES_DIR
}
/data"
${
Python3_EXECUTABLE
}
-B
${
CMAKE_CURRENT_SOURCE_DIR
}
/RunPersistenceTest.py
${
Python3_EXECUTABLE
}
-B
${
CMAKE_CURRENT_SOURCE_DIR
}
/RunPersistenceTest.py
${
script_path
}
${
reference
}
${
script_path
}
${
reference
}
${
TEST_REFERENCE_DIR_EXAMPLES_MINI
}
${
TEST_OUTPUT_DIR_PY_PERSIST
}
11
${
tolerance
}
)
${
TEST_REFERENCE_DIR_EXAMPLES_MINI
}
${
TEST_OUTPUT_DIR_PY_PERSIST
}
11
${
tolerance
}
)
...
@@ -80,7 +81,7 @@ test_example(scatter2d/CylindersInAverageLayer 2e-10)
...
@@ -80,7 +81,7 @@ test_example(scatter2d/CylindersInAverageLayer 2e-10)
test_example
(
scatter2d/CylindersInBA 2e-10
)
test_example
(
scatter2d/CylindersInBA 2e-10
)
# test_example(scatter2d/CylindersWithSizeDistribution 2e-10)
# test_example(scatter2d/CylindersWithSizeDistribution 2e-10)
test_example
(
scatter2d/DetectorResolutionFunction 2e-10
)
test_example
(
scatter2d/DetectorResolutionFunction 2e-10
)
test_example
(
scatter2d/DodecahedraSAS
.py
2e-10
)
test_example
(
scatter2d/DodecahedraSAS 2e-10
)
test_example
(
scatter2d/HalfSpheresInAverageTopLayer 2e-10
)
test_example
(
scatter2d/HalfSpheresInAverageTopLayer 2e-10
)
test_example
(
scatter2d/HexagonalLatticesWithBasis 2e-10
)
test_example
(
scatter2d/HexagonalLatticesWithBasis 2e-10
)
test_example
(
scatter2d/Interference1DRadialParaCrystal 2e-10
)
test_example
(
scatter2d/Interference1DRadialParaCrystal 2e-10
)
...
...
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