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
42545d1e
Commit
42545d1e
authored
2 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
rename slicing tests -> auto*, known*; merge two legacy tests
parent
6bd626b7
No related branches found
No related tags found
1 merge request
!1222
Py fu tests: merge -> known_slicing; start auto_slicing tests
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tests/Py/Functional/known_slicing.py
+96
-4
96 additions, 4 deletions
Tests/Py/Functional/known_slicing.py
Tests/Py/Functional/sliced_spheres.py
+0
-108
0 additions, 108 deletions
Tests/Py/Functional/sliced_spheres.py
with
96 additions
and
112 deletions
Tests/Py/Functional/
sliced_compounds
.py
→
Tests/Py/Functional/
known_slicing
.py
+
96
−
4
View file @
42545d1e
"""
Check slicing mechanism for compound particles crossing an interface.
Check slicing mechanism for spherical particles crossing an interface,
using known decomposition of particles (as opposed to automatic slicing, tested elsewhere)
"""
import
unittest
...
...
@@ -7,11 +8,102 @@ import PyFuTestInfrastructure as infrastruct
import
bornagain
as
ba
from
bornagain
import
deg
,
R3
matSubstrate
=
ba
.
RefractiveMaterial
(
"
Substrate
"
,
3e-6
,
3e-8
)
matSubstrate
=
ba
.
RefractiveMaterial
(
"
Substrate
"
,
3
.2
e-6
,
3
.2
e-8
)
matVacuum
=
ba
.
RefractiveMaterial
(
"
Vacuum
"
,
0
,
0
)
matParticle
=
ba
.
RefractiveMaterial
(
"
Ag
"
,
1e-5
,
5e-7
)
matParticle
=
ba
.
RefractiveMaterial
(
"
Ag
"
,
1.2e-5
,
5.4e-7
)
R
=
10.0
dz
=
4.0
dz
=
4.0
# shift beneath interface
class
SlicedSpheresTest
(
unittest
.
TestCase
):
def
get_sample
(
self
,
particle_to_air
=
None
,
particle_to_substrate
=
None
):
"""
Returns a sample, with given particles attached to substrate or vacuum layer.
"""
vacuum_layer
=
ba
.
Layer
(
matVacuum
)
if
particle_to_air
:
layout
=
ba
.
ParticleLayout
()
layout
.
addParticle
(
particle_to_air
)
vacuum_layer
.
addLayout
(
layout
)
substrate
=
ba
.
Layer
(
matSubstrate
)
if
particle_to_substrate
:
layout
=
ba
.
ParticleLayout
()
layout
.
addParticle
(
particle_to_substrate
)
substrate
.
addLayout
(
layout
)
sample
=
ba
.
MultiLayer
()
sample
.
addLayer
(
vacuum_layer
)
sample
.
addLayer
(
substrate
)
return
sample
def
get_result
(
self
,
particle_to_air
=
None
,
particle_to_substrate
=
None
):
sample
=
self
.
get_sample
(
particle_to_air
,
particle_to_substrate
)
simulation
=
infrastruct
.
get_simulation_MiniGISAS
(
sample
)
return
simulation
.
simulate
()
def
testSphericalCupOnTopOfSubstrate
(
self
):
"""
Simulation #1: truncated sphere on top of substrate.
Simulation #2: sphere crossing the interface.
Both particles are made of same material as substrate.
Same scattering expected from both sample models.
"""
# truncated sphere (dz removed from bottom) on top of substrate
truncatedSphere
=
ba
.
Particle
(
matSubstrate
,
ba
.
TruncatedSphere
(
R
,
R
*
2
-
dz
,
0
))
reference
=
self
.
get_result
(
truncatedSphere
)
# same without truncation, sphere penetrating into substrate layer
sphere
=
ba
.
Particle
(
matSubstrate
,
ba
.
Sphere
(
R
))
sphere
.
translate
(
0
,
0
,
-
dz
)
data
=
self
.
get_result
(
sphere
)
diff
=
ba
.
meanRelativeDifference
(
data
,
reference
)
self
.
assertLess
(
diff
,
1e-15
)
def
testSphericalLacuneInSubstrate
(
self
):
"""
Similar to previous. Truncated sphere and sphere are made of vacuum material.
From scattering point of view, both cases should look like an vacuum lacune in substrate.
"""
# Sphere truncated from top. Intended to go below interface.
truncatedSphere
=
ba
.
Particle
(
matVacuum
,
ba
.
TruncatedSphere
(
R
,
R
*
2
,
R
*
2
-
dz
))
truncatedSphere
.
translate
(
0
,
0
,
-
dz
)
reference
=
self
.
get_result
(
truncatedSphere
)
# sphere crossing interface to look like truncated sphere above
sphere
=
ba
.
Particle
(
matVacuum
,
ba
.
Sphere
(
R
))
sphere
.
translate
(
0
,
0
,
-
dz
)
data
=
self
.
get_result
(
sphere
)
diff
=
ba
.
meanRelativeDifference
(
data
,
reference
)
self
.
assertLess
(
diff
,
1e-15
)
def
testSpheresCrossingInterface
(
self
):
"""
Same particle in same position, but attached to two different layers.
Of course, results shall be identical.
"""
# Sphere intended for vacuum layer and crossing interface
sphere1
=
ba
.
Particle
(
matParticle
,
ba
.
Sphere
(
R
))
sphere1
.
translate
(
0
,
0
,
-
dz
)
reference
=
self
.
get_result
(
particle_to_air
=
sphere1
)
# Sphere intended for substrate layer and crossing interface
sphere2
=
ba
.
Particle
(
matParticle
,
ba
.
Sphere
(
R
))
sphere2
.
translate
(
0
,
0
,
-
dz
)
data
=
self
.
get_result
(
particle_to_substrate
=
sphere2
)
diff
=
ba
.
meanRelativeDifference
(
data
,
reference
)
self
.
assertLess
(
diff
,
1e-15
)
class
SlicedSpheresTest
(
unittest
.
TestCase
):
...
...
This diff is collapsed.
Click to expand it.
Tests/Py/Functional/sliced_spheres.py
deleted
100644 → 0
+
0
−
108
View file @
6bd626b7
"""
Check slicing mechanism for spherical particles crossing an interface.
"""
import
unittest
import
PyFuTestInfrastructure
as
infrastruct
import
bornagain
as
ba
matSubstrate
=
ba
.
RefractiveMaterial
(
"
Substrate
"
,
3.2e-6
,
3.2e-8
)
matVacuum
=
ba
.
RefractiveMaterial
(
"
Vacuum
"
,
0
,
0
)
matParticle
=
ba
.
RefractiveMaterial
(
"
Ag
"
,
1.2e-5
,
5.4e-7
)
R
=
10.0
dz
=
4.0
# shift beneath interface
class
SlicedSpheresTest
(
unittest
.
TestCase
):
def
get_sample
(
self
,
particle_to_air
=
None
,
particle_to_substrate
=
None
):
"""
Returns a sample, with given particles attached to substrate or vacuum layer.
"""
vacuum_layer
=
ba
.
Layer
(
matVacuum
)
if
particle_to_air
:
layout
=
ba
.
ParticleLayout
()
layout
.
addParticle
(
particle_to_air
)
vacuum_layer
.
addLayout
(
layout
)
substrate
=
ba
.
Layer
(
matSubstrate
)
if
particle_to_substrate
:
layout
=
ba
.
ParticleLayout
()
layout
.
addParticle
(
particle_to_substrate
)
substrate
.
addLayout
(
layout
)
sample
=
ba
.
MultiLayer
()
sample
.
addLayer
(
vacuum_layer
)
sample
.
addLayer
(
substrate
)
return
sample
def
get_result
(
self
,
particle_to_air
=
None
,
particle_to_substrate
=
None
):
sample
=
self
.
get_sample
(
particle_to_air
,
particle_to_substrate
)
simulation
=
infrastruct
.
get_simulation_MiniGISAS
(
sample
)
return
simulation
.
simulate
()
def
testSphericalCupOnTopOfSubstrate
(
self
):
"""
Simulation #1: truncated sphere on top of substrate.
Simulation #2: sphere crossing the interface.
Both particles are made of same material as substrate.
Same scattering expected from both sample models.
"""
# truncated sphere (dz removed from bottom) on top of substrate
truncatedSphere
=
ba
.
Particle
(
matSubstrate
,
ba
.
TruncatedSphere
(
R
,
R
*
2
-
dz
,
0
))
reference
=
self
.
get_result
(
truncatedSphere
)
# same without truncation, sphere penetrating into substrate layer
sphere
=
ba
.
Particle
(
matSubstrate
,
ba
.
Sphere
(
R
))
sphere
.
translate
(
0
,
0
,
-
dz
)
data
=
self
.
get_result
(
sphere
)
diff
=
ba
.
meanRelativeDifference
(
data
,
reference
)
self
.
assertLess
(
diff
,
1e-15
)
def
testSphericalLacuneInSubstrate
(
self
):
"""
Similar to previous. Truncated sphere and sphere are made of vacuum material.
From scattering point of view, both cases should look like an vacuum lacune in substrate.
"""
# Sphere truncated from top. Intended to go below interface.
truncatedSphere
=
ba
.
Particle
(
matVacuum
,
ba
.
TruncatedSphere
(
R
,
R
*
2
,
R
*
2
-
dz
))
truncatedSphere
.
translate
(
0
,
0
,
-
dz
)
reference
=
self
.
get_result
(
truncatedSphere
)
# sphere crossing interface to look like truncated sphere above
sphere
=
ba
.
Particle
(
matVacuum
,
ba
.
Sphere
(
R
))
sphere
.
translate
(
0
,
0
,
-
dz
)
data
=
self
.
get_result
(
sphere
)
diff
=
ba
.
meanRelativeDifference
(
data
,
reference
)
self
.
assertLess
(
diff
,
1e-15
)
def
testSpheresCrossingInterface
(
self
):
"""
Same particle in same position, but attached to two different layers.
Of course, results shall be identical.
"""
# Sphere intended for vacuum layer and crossing interface
sphere1
=
ba
.
Particle
(
matParticle
,
ba
.
Sphere
(
R
))
sphere1
.
translate
(
0
,
0
,
-
dz
)
reference
=
self
.
get_result
(
particle_to_air
=
sphere1
)
# Sphere intended for substrate layer and crossing interface
sphere2
=
ba
.
Particle
(
matParticle
,
ba
.
Sphere
(
R
))
sphere2
.
translate
(
0
,
0
,
-
dz
)
data
=
self
.
get_result
(
particle_to_substrate
=
sphere2
)
diff
=
ba
.
meanRelativeDifference
(
data
,
reference
)
self
.
assertLess
(
diff
,
1e-15
)
if
__name__
==
'
__main__
'
:
unittest
.
main
()
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