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
aa9548da
Commit
aa9548da
authored
6 years ago
by
Yurov, Dmitry
Browse files
Options
Downloads
Patches
Plain Diff
Implement SpecularSimulation::setBeamParameters overloads for TOF and q-defined reflectometry
parent
1d969ec9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Core/Simulation/SpecularSimulation.cpp
+45
-2
45 additions, 2 deletions
Core/Simulation/SpecularSimulation.cpp
Core/Simulation/SpecularSimulation.h
+3
-0
3 additions, 0 deletions
Core/Simulation/SpecularSimulation.h
with
48 additions
and
2 deletions
Core/Simulation/SpecularSimulation.cpp
+
45
−
2
View file @
aa9548da
...
...
@@ -36,6 +36,10 @@ namespace
std
::
unique_ptr
<
ISpecularDataHandler
>
mangledDataHandler
(
const
ISpecularDataHandler
&
data_handler
,
const
Beam
&
beam
);
// compute qz values for given wavelengths and inclination angle. Sorts
// wavelengths in descending order if it was not done before.
std
::
vector
<
double
>
computeQzValues
(
std
::
vector
<
double
>
wls
,
double
inc_angle
);
const
RealLimits
alpha_limits
=
RealLimits
::
limited
(
0.0
,
M_PI_2
);
const
double
zero_phi_i
=
0.0
;
const
double
zero_alpha_i
=
0.0
;
...
...
@@ -85,8 +89,8 @@ size_t SpecularSimulation::numberOfSimulationElements() const
SimulationResult
SpecularSimulation
::
result
()
const
{
auto
data
=
createIntensityData
();
UnitC
onverter
ConvSpec
converter
(
m_instrument
.
getBeam
(),
*
coordinateAxis
()
);
return
SimulationResult
(
*
data
,
converter
);
auto
c
onverter
=
UnitConverter1D
::
createUnitConverter
(
*
m_data_handler
);
return
SimulationResult
(
*
data
,
*
converter
);
}
void
SpecularSimulation
::
setBeamParameters
(
double
lambda
,
const
IAxis
&
alpha_axis
,
...
...
@@ -130,6 +134,26 @@ void SpecularSimulation::setBeamParameters(double lambda, std::vector<double> in
setBeamParameters
(
lambda
,
axis
,
beam_shape
);
}
void
SpecularSimulation
::
setBeamParameters
(
std
::
vector
<
double
>
wavelength_values
,
double
incident_angle
,
const
IFootprintFactor
*
beam_shape
)
{
auto
qzs
=
computeQzValues
(
wavelength_values
,
incident_angle
);
auto
q_axis
=
std
::
make_unique
<
PointwiseAxis
>
(
"qzs"
,
std
::
move
(
qzs
));
SpecularDetector1D
detector
(
*
q_axis
);
m_instrument
.
setDetector
(
detector
);
m_data_handler
=
std
::
make_unique
<
SpecularDataHandlerTOF
>
(
incident_angle
,
std
::
move
(
q_axis
),
beam_shape
);
}
void
SpecularSimulation
::
setBeamParameters
(
std
::
vector
<
double
>
qz_values
)
{
auto
q_axis
=
std
::
make_unique
<
PointwiseAxis
>
(
"qz"
,
std
::
move
(
qz_values
));
SpecularDetector1D
detector
(
*
q_axis
);
m_instrument
.
setDetector
(
detector
);
m_data_handler
=
std
::
make_unique
<
SpecularDataHandlerQ
>
(
std
::
move
(
q_axis
));
}
const
IAxis
*
SpecularSimulation
::
coordinateAxis
()
const
{
if
(
!
m_data_handler
||
!
m_data_handler
->
coordinateAxis
())
...
...
@@ -323,4 +347,23 @@ std::unique_ptr<ISpecularDataHandler> mangledDataHandler(const ISpecularDataHand
data_handler
.
footprintFactor
());
return
std
::
move
(
result
);
}
std
::
vector
<
double
>
computeQzValues
(
std
::
vector
<
double
>
wls
,
double
inc_angle
)
{
std
::
vector
<
double
>
result
;
result
.
reserve
(
wls
.
size
());
const
auto
begin
=
wls
.
begin
();
const
auto
end
=
wls
.
end
();
if
(
!
std
::
is_sorted
(
begin
,
end
,
std
::
greater
<
double
>
()))
std
::
sort
(
begin
,
end
,
std
::
greater
<
double
>
());
if
(
wls
.
back
()
<=
0.0
)
throw
std
::
runtime_error
(
"Error in computeQzValues: passed vector of wavelengths contains "
"negative or zero values"
);
std
::
transform
(
begin
,
end
,
std
::
back_inserter
(
result
),
[
sin_inc
=
std
::
sin
(
inc_angle
)](
double
value
)
{
return
4.0
*
M_PI
*
sin_inc
/
value
;
});
return
result
;
}
}
This diff is collapsed.
Click to expand it.
Core/Simulation/SpecularSimulation.h
+
3
−
0
View file @
aa9548da
...
...
@@ -58,6 +58,9 @@ public:
const
IFootprintFactor
*
beam_shape
=
nullptr
);
void
setBeamParameters
(
double
lambda
,
std
::
vector
<
double
>
incident_angle_values
,
const
IFootprintFactor
*
beam_shape
=
nullptr
);
void
setBeamParameters
(
std
::
vector
<
double
>
wavelength_values
,
double
incident_angle
,
const
IFootprintFactor
*
beam_shape
=
nullptr
);
void
setBeamParameters
(
std
::
vector
<
double
>
qz_values
);
//! Sets beam parameters for specular simulation. _lambda_ defines the wavelength of incoming
//! beam (in nm), _alpha_axis_ defines the range of incident angles, while _beam_shape_
//! (optional parameter) is required to take footprint effects into account.
...
...
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