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
55536c65
Commit
55536c65
authored
2 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
split off ISimulation::initDistributionHandler
parent
ba3a62ad
No related branches found
No related tags found
1 merge request
!923
ISimulation no longer knows about beam and detector; DepthProbeSimulation now inherits from ISimulation2D
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sim/Simulation/ISimulation.cpp
+26
-21
26 additions, 21 deletions
Sim/Simulation/ISimulation.cpp
Sim/Simulation/ISimulation.h
+2
-0
2 additions, 0 deletions
Sim/Simulation/ISimulation.h
with
28 additions
and
21 deletions
Sim/Simulation/ISimulation.cpp
+
26
−
21
View file @
55536c65
...
...
@@ -193,27 +193,7 @@ SimulationResult ISimulation::simulate()
if
(
param_combinations
==
1
)
runSingleSimulation
(
re_sample
,
batch_start
,
batch_size
,
1.
);
else
{
// init callbacks for setting the parameter values
for
(
const
auto
&
distribution
:
m_distribution_handler
.
getDistributions
())
{
const
auto
*
dc
=
const_cast
<
ParameterDistribution
*>
(
&
distribution
);
switch
(
dc
->
whichParameter
())
{
case
ParameterDistribution
::
BeamAzimuthalAngle
:
m_distribution_handler
.
defineCallbackForDistribution
(
dc
,
[
&
](
double
d
)
{
beam
().
setAzimuthalAngleGuarded
(
d
);
});
break
;
case
ParameterDistribution
::
BeamInclinationAngle
:
m_distribution_handler
.
defineCallbackForDistribution
(
dc
,
[
&
](
double
d
)
{
beam
().
setInclinationAngleGuarded
(
d
);
});
break
;
case
ParameterDistribution
::
BeamWavelength
:
m_distribution_handler
.
defineCallbackForDistribution
(
dc
,
[
&
](
double
d
)
{
beam
().
setWavelengthGuarded
(
d
);
});
break
;
default
:
throw
std
::
runtime_error
(
"ISimulation::simulate() missing implementation"
);
}
}
initDistributionHandler
();
for
(
size_t
index
=
0
;
index
<
param_combinations
;
++
index
)
{
double
weight
=
m_distribution_handler
.
setParameterValues
(
index
);
runSingleSimulation
(
re_sample
,
batch_start
,
batch_size
,
weight
);
...
...
@@ -223,6 +203,31 @@ SimulationResult ISimulation::simulate()
return
pack_result
();
}
//! init callbacks for setting the parameter values
void
ISimulation
::
initDistributionHandler
()
{
for
(
const
auto
&
distribution
:
m_distribution_handler
.
getDistributions
())
{
const
auto
*
dc
=
const_cast
<
ParameterDistribution
*>
(
&
distribution
);
switch
(
dc
->
whichParameter
())
{
case
ParameterDistribution
::
BeamAzimuthalAngle
:
m_distribution_handler
.
defineCallbackForDistribution
(
dc
,
[
&
](
double
d
)
{
beam
().
setAzimuthalAngleGuarded
(
d
);
});
break
;
case
ParameterDistribution
::
BeamInclinationAngle
:
m_distribution_handler
.
defineCallbackForDistribution
(
dc
,
[
&
](
double
d
)
{
beam
().
setInclinationAngleGuarded
(
d
);
});
break
;
case
ParameterDistribution
::
BeamWavelength
:
m_distribution_handler
.
defineCallbackForDistribution
(
dc
,
[
&
](
double
d
)
{
beam
().
setWavelengthGuarded
(
d
);
});
break
;
default
:
ASSERT
(
0
);
}
}
}
const
MultiLayer
*
ISimulation
::
sample
()
const
{
return
m_sample
.
get
();
...
...
This diff is collapsed.
Click to expand it.
Sim/Simulation/ISimulation.h
+
2
−
0
View file @
55536c65
...
...
@@ -116,6 +116,8 @@ protected:
std
::
unique_ptr
<
Beam
>
m_beam
;
std
::
unique_ptr
<
IDetector
>
m_detector
;
void
initDistributionHandler
();
private
:
void
runSingleSimulation
(
const
reSample
&
re_sample
,
size_t
batch_start
,
size_t
batch_size
,
double
weight
=
1.0
);
...
...
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