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
d3bdc09f
Commit
d3bdc09f
authored
3 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
make fct local
parent
8d031b2d
No related branches found
No related tags found
1 merge request
!154
further simplification of ProcessedSample
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sample/Processed/ProcessedSample.cpp
+68
-63
68 additions, 63 deletions
Sample/Processed/ProcessedSample.cpp
Sample/Processed/ProcessedSample.h
+0
-1
0 additions, 1 deletion
Sample/Processed/ProcessedSample.h
with
68 additions
and
64 deletions
Sample/Processed/ProcessedSample.cpp
+
68
−
63
View file @
d3bdc09f
...
...
@@ -32,14 +32,80 @@
#include
"Sample/Specular/SpecularStrategyBuilder.h"
#include
<functional>
//! Returns a SliceStack that refines the layer structure of sample,
//! taking into account the average SLD of layer material and particle decoration.
namespace
{
SliceStack
slicify
(
const
MultiLayer
&
sample
,
const
SimulationOptions
&
options
)
{
SliceStack
result
;
if
(
sample
.
numberOfLayers
()
==
0
)
return
result
;
const
bool
use_slicing
=
options
.
useAvgMaterials
()
&&
sample
.
numberOfLayers
()
>
1
;
const
auto
layer_limits
=
SampleUtils
::
Preprocessor
::
particleRegions
(
sample
,
use_slicing
);
for
(
size_t
i
=
0
;
i
<
sample
.
numberOfLayers
();
++
i
)
{
const
Layer
*
const
layer
=
sample
.
layer
(
i
);
const
size_t
N
=
layer
->
numberOfSlices
();
if
(
N
==
0
)
throw
std
::
runtime_error
(
"Cannot process layer with numberOfSlices=0"
);
const
ZLimits
&
slice_limits
=
layer_limits
[
i
];
double
tl
=
layer
->
thickness
();
const
Material
*
const
material
=
layer
->
material
();
const
LayerRoughness
*
roughness
=
SampleUtils
::
Multilayer
::
LayerTopRoughness
(
sample
,
i
);
if
(
roughness
&&
roughness
->
getSigma
()
<=
0
)
roughness
=
nullptr
;
// if no slicing is needed, create single slice for the layer
if
(
!
slice_limits
.
isFinite
()
||
N
==
0
)
{
if
(
i
==
sample
.
numberOfLayers
()
-
1
)
tl
=
0.0
;
if
(
i
==
0
)
result
.
addTopSlice
(
tl
,
*
material
);
else
result
.
addSlice
(
tl
,
*
material
,
roughness
);
continue
;
}
const
double
top
=
slice_limits
.
zTop
();
const
double
bottom
=
slice_limits
.
zBottom
();
// top layer
if
(
i
==
0
)
{
if
(
top
<=
0
)
throw
std
::
runtime_error
(
"ProcessedSample::ProcessedSample: "
"top limit for top layer must be > 0."
);
result
.
addTopSlice
(
top
,
*
material
);
// semiinfinite top slice
result
.
addNSlices
(
N
,
top
-
bottom
,
*
material
);
if
(
bottom
>
0
)
result
.
addSlice
(
bottom
,
*
material
);
}
// middle or bottom layer
else
{
if
(
top
<
0
)
{
result
.
addSlice
(
-
top
,
*
material
,
roughness
);
result
.
addNSlices
(
N
,
top
-
bottom
,
*
material
);
}
else
{
result
.
addNSlices
(
N
,
top
-
bottom
,
*
material
,
roughness
);
}
// middle layer
if
(
i
<
sample
.
numberOfLayers
()
-
1
&&
bottom
>
-
tl
)
result
.
addSlice
(
bottom
+
tl
,
*
material
);
// bottom layer
if
(
i
==
sample
.
numberOfLayers
()
-
1
)
result
.
addSlice
(
0.0
,
*
material
);
// semiinfinite bottom slice
}
}
return
result
;
}
}
// namespace
ProcessedSample
::
ProcessedSample
(
const
MultiLayer
&
sample
,
const
SimulationOptions
&
options
,
bool
forcePolarized
)
:
m_slices
{}
:
m_slices
{
slicify
(
sample
,
options
)
}
,
m_polarized
{
forcePolarized
||
sample
.
isMagnetic
()}
,
m_crossCorrLength
{
sample
.
crossCorrLength
()}
,
m_ext_field
{
sample
.
externalField
()}
{
initSlices
(
sample
,
options
);
// set m_slices
initBFields
();
// set B field in all slices.
initLayouts
(
sample
);
// set m_layouts and m_region_map
...
...
@@ -144,67 +210,6 @@ double ProcessedSample::crossCorrSpectralFun(const kvector_t kvec, size_t j, siz
*
std
::
exp
(
-
1
*
std
::
abs
(
z_j
-
z_k
)
/
m_crossCorrLength
);
}
//! Creates a array of slices with the correct thickness, roughness and material.
//!
//! Sets m_slices (through addSlice).
void
ProcessedSample
::
initSlices
(
const
MultiLayer
&
sample
,
const
SimulationOptions
&
options
)
{
if
(
sample
.
numberOfLayers
()
==
0
)
return
;
const
bool
use_slicing
=
options
.
useAvgMaterials
()
&&
sample
.
numberOfLayers
()
>
1
;
const
auto
layer_limits
=
SampleUtils
::
Preprocessor
::
particleRegions
(
sample
,
use_slicing
);
for
(
size_t
i
=
0
;
i
<
sample
.
numberOfLayers
();
++
i
)
{
const
Layer
*
const
layer
=
sample
.
layer
(
i
);
const
size_t
N
=
layer
->
numberOfSlices
();
if
(
N
==
0
)
throw
std
::
runtime_error
(
"Cannot process layer with numberOfSlices=0"
);
const
ZLimits
&
slice_limits
=
layer_limits
[
i
];
double
tl
=
layer
->
thickness
();
const
Material
*
const
material
=
layer
->
material
();
const
LayerRoughness
*
roughness
=
SampleUtils
::
Multilayer
::
LayerTopRoughness
(
sample
,
i
);
if
(
roughness
&&
roughness
->
getSigma
()
<=
0
)
roughness
=
nullptr
;
// if no slicing is needed, create single slice for the layer
if
(
!
slice_limits
.
isFinite
()
||
N
==
0
)
{
if
(
i
==
sample
.
numberOfLayers
()
-
1
)
tl
=
0.0
;
if
(
i
==
0
)
m_slices
.
addTopSlice
(
tl
,
*
material
);
else
m_slices
.
addSlice
(
tl
,
*
material
,
roughness
);
continue
;
}
const
double
top
=
slice_limits
.
zTop
();
const
double
bottom
=
slice_limits
.
zBottom
();
// top layer
if
(
i
==
0
)
{
if
(
top
<=
0
)
throw
std
::
runtime_error
(
"ProcessedSample::ProcessedSample: "
"top limit for top layer must be > 0."
);
m_slices
.
addTopSlice
(
top
,
*
material
);
// semiinfinite top slice
m_slices
.
addNSlices
(
N
,
top
-
bottom
,
*
material
);
if
(
bottom
>
0
)
m_slices
.
addSlice
(
bottom
,
*
material
);
}
// middle or bottom layer
else
{
if
(
top
<
0
)
{
m_slices
.
addSlice
(
-
top
,
*
material
,
roughness
);
m_slices
.
addNSlices
(
N
,
top
-
bottom
,
*
material
);
}
else
{
m_slices
.
addNSlices
(
N
,
top
-
bottom
,
*
material
,
roughness
);
}
// middle layer
if
(
i
<
sample
.
numberOfLayers
()
-
1
&&
bottom
>
-
tl
)
m_slices
.
addSlice
(
bottom
+
tl
,
*
material
);
// bottom layer
if
(
i
==
sample
.
numberOfLayers
()
-
1
)
m_slices
.
addSlice
(
0.0
,
*
material
);
// semiinfinite bottom slice
}
}
}
//! Modifies m_region_map.
void
ProcessedSample
::
mergeRegionMap
(
...
...
This diff is collapsed.
Click to expand it.
Sample/Processed/ProcessedSample.h
+
0
−
1
View file @
d3bdc09f
...
...
@@ -64,7 +64,6 @@ public:
double
crossCorrSpectralFun
(
const
kvector_t
kvec
,
size_t
j
,
size_t
k
)
const
;
private:
void
initSlices
(
const
MultiLayer
&
sample
,
const
SimulationOptions
&
options
);
void
mergeRegionMap
(
const
std
::
map
<
size_t
,
std
::
vector
<
HomogeneousRegion
>>&
region_map
);
void
initLayouts
(
const
MultiLayer
&
sample
);
void
initBFields
();
...
...
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