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
4cf2dd9e
Commit
4cf2dd9e
authored
9 years ago
by
Van Herck, Walter
Browse files
Options
Downloads
Patches
Plain Diff
Replaced shared_ptr with scoped_ptr in LayerSpecularInfo
parent
d2dbb75f
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/Algorithms/inc/LayerSpecularInfo.h
+3
-3
3 additions, 3 deletions
Core/Algorithms/inc/LayerSpecularInfo.h
Core/Algorithms/src/SpecularSimulation.cpp
+82
-111
82 additions, 111 deletions
Core/Algorithms/src/SpecularSimulation.cpp
with
85 additions
and
114 deletions
Core/Algorithms/inc/LayerSpecularInfo.h
+
3
−
3
View file @
4cf2dd9e
...
...
@@ -21,7 +21,7 @@
#include
"ILayerRTCoefficients.h"
#include
"ISpecularInfoMap.h"
#include
<boost/s
har
ed_ptr.hpp>
#include
<boost/s
cop
ed_ptr.hpp>
//! @class LayerSpecularInfo
...
...
@@ -56,8 +56,8 @@ public:
return
mP_in_coeffs
.
get
();
}
private
:
boost
::
s
har
ed_ptr
<
ISpecularInfoMap
>
mP_out_coeff_map
;
boost
::
s
har
ed_ptr
<
ILayerRTCoefficients
>
mP_in_coeffs
;
boost
::
s
cop
ed_ptr
<
ISpecularInfoMap
>
mP_out_coeff_map
;
boost
::
s
cop
ed_ptr
<
ILayerRTCoefficients
>
mP_in_coeffs
;
};
...
...
This diff is collapsed.
Click to expand it.
Core/Algorithms/src/SpecularSimulation.cpp
+
82
−
111
View file @
4cf2dd9e
...
...
@@ -19,57 +19,42 @@
#include
"Units.h"
#include
<iostream>
SpecularSimulation
::
SpecularSimulation
()
:
IParameterized
(
"SpecularSimulation"
)
,
m_sample
(
0
)
,
m_alpha_i_axis
(
0
)
,
m_z_axis
(
0
)
,
m_lambda
(
0.0
)
:
IParameterized
(
"SpecularSimulation"
),
m_sample
(
0
),
m_alpha_i_axis
(
0
),
m_z_axis
(
0
),
m_lambda
(
0.0
)
{
init_parameters
();
}
SpecularSimulation
::
SpecularSimulation
(
const
ISample
&
sample
)
:
IParameterized
(
"SpecularSimulation"
)
,
m_sample
(
sample
.
clone
())
,
m_alpha_i_axis
(
0
)
,
m_z_axis
(
0
)
,
m_lambda
(
0.0
)
SpecularSimulation
::
SpecularSimulation
(
const
ISample
&
sample
)
:
IParameterized
(
"SpecularSimulation"
),
m_sample
(
sample
.
clone
()),
m_alpha_i_axis
(
0
),
m_z_axis
(
0
),
m_lambda
(
0.0
)
{
init_parameters
();
}
SpecularSimulation
::
SpecularSimulation
(
SampleBuilder_t
sample_builder
)
:
IParameterized
(
"SpecularSimulation"
)
,
m_sample
(
0
)
,
m_sample_builder
(
sample_builder
)
,
m_alpha_i_axis
(
0
)
,
m_z_axis
(
0
)
,
m_lambda
(
0.0
)
:
IParameterized
(
"SpecularSimulation"
),
m_sample
(
0
),
m_sample_builder
(
sample_builder
),
m_alpha_i_axis
(
0
),
m_z_axis
(
0
),
m_lambda
(
0.0
)
{
init_parameters
();
}
SpecularSimulation
::
SpecularSimulation
(
const
SpecularSimulation
&
other
)
:
ICloneable
(),
IParameterized
(
other
)
,
m_sample
(
0
)
,
m_sample_builder
(
other
.
m_sample_builder
)
,
m_alpha_i_axis
(
0
)
,
m_z_axis
(
0
)
,
m_lambda
(
other
.
m_lambda
)
SpecularSimulation
::
SpecularSimulation
(
const
SpecularSimulation
&
other
)
:
ICloneable
(),
IParameterized
(
other
),
m_sample
(
0
),
m_sample_builder
(
other
.
m_sample_builder
),
m_alpha_i_axis
(
0
),
m_z_axis
(
0
),
m_lambda
(
other
.
m_lambda
)
{
if
(
other
.
m_sample
)
m_sample
=
other
.
m_sample
->
clone
();
if
(
other
.
m_alpha_i_axis
)
m_alpha_i_axis
=
other
.
m_alpha_i_axis
->
clone
();
if
(
other
.
m_z_axis
)
m_z_axis
=
other
.
m_z_axis
->
clone
();
if
(
other
.
m_sample
)
m_sample
=
other
.
m_sample
->
clone
();
if
(
other
.
m_alpha_i_axis
)
m_alpha_i_axis
=
other
.
m_alpha_i_axis
->
clone
();
if
(
other
.
m_z_axis
)
m_z_axis
=
other
.
m_z_axis
->
clone
();
m_data
.
copyFrom
(
other
.
m_data
);
m_ewave_intensity
.
copyFrom
(
other
.
m_ewave_intensity
);
init_parameters
();
}
SpecularSimulation
::~
SpecularSimulation
()
{
delete
m_sample
;
...
...
@@ -77,93 +62,85 @@ SpecularSimulation::~SpecularSimulation()
delete
m_z_axis
;
}
SpecularSimulation
*
SpecularSimulation
::
clone
()
const
SpecularSimulation
*
SpecularSimulation
::
clone
()
const
{
return
new
SpecularSimulation
(
*
this
);
}
void
SpecularSimulation
::
setSample
(
const
ISample
&
sample
)
{
delete
m_sample
;
m_sample
=
sample
.
clone
();
}
ISample
*
SpecularSimulation
::
getSample
()
const
{
return
m_sample
;
}
void
SpecularSimulation
::
setSampleBuilder
(
SampleBuilder_t
sample_builder
)
{
if
(
!
sample_builder
.
get
()
)
throw
NullPointerException
(
"SpecularSimulation::setSampleBuilder() -> "
"Error! Attempt to set null sample builder."
);
if
(
!
sample_builder
.
get
())
throw
NullPointerException
(
"SpecularSimulation::setSampleBuilder() -> "
"Error! Attempt to set null sample builder."
);
m_sample_builder
=
sample_builder
;
delete
m_sample
;
m_sample
=
0
;
}
SampleBuilder_t
SpecularSimulation
::
getSampleBuilder
()
const
{
return
m_sample_builder
;
}
void
SpecularSimulation
::
prepareSimulation
()
{
updateSample
();
if
(
!
m_alpha_i_axis
||
m_alpha_i_axis
->
getSize
()
<
1
)
{
throw
ClassInitializationException
(
"SpecularSimulation::checkSimulation() "
"-> Error. Incoming alpha range not configured."
);
if
(
!
m_alpha_i_axis
||
m_alpha_i_axis
->
getSize
()
<
1
)
{
throw
ClassInitializationException
(
"SpecularSimulation::checkSimulation() "
"-> Error. Incoming alpha range not configured."
);
}
if
(
m_lambda
<=
0.0
)
{
throw
ClassInitializationException
(
"SpecularSimulation::checkSimulation() "
"-> Error. Incoming wavelength <= 0."
);
if
(
m_lambda
<=
0.0
)
{
throw
ClassInitializationException
(
"SpecularSimulation::checkSimulation() "
"-> Error. Incoming wavelength <= 0."
);
}
if
(
!
m_sample
)
throw
ClassInitializationException
(
"SpecularSimulation::checkSimulation() -> Error. No sample set"
);
if
(
!
m_sample
)
throw
ClassInitializationException
(
"SpecularSimulation::checkSimulation() -> Error. No sample set"
);
updateCoefficientDataAxes
();
}
//OutputData<double> *SpecularSimulation::getEvanescentWaveIntensity() const
// OutputData<double> *SpecularSimulation::getEvanescentWaveIntensity() const
//{
// if(m_ewave_intensity.getAllocatedSize() == 1)
// throw ClassInitializationException("SpecularSimulation::getEvanescentWaveIntensity() -> Error. No evanescent wave calculations have been performed. Set corresponding axis with Simulation::setEvanescentWaveAxis.");
// throw ClassInitializationException("SpecularSimulation::getEvanescentWaveIntensity() ->
// Error. No evanescent wave calculations have been performed. Set corresponding axis with
// Simulation::setEvanescentWaveAxis.");
// return m_ewave_intensity.clone();
//}
void
SpecularSimulation
::
runSimulation
()
{
prepareSimulation
();
MultiLayer
*
multilayer
=
dynamic_cast
<
MultiLayer
*>
(
m_sample
);
if
(
!
multilayer
)
throw
NullPointerException
(
"SpecularSimulation::runSimulation() -> Error. Not a MultiLayer"
);
if
(
!
multilayer
)
throw
NullPointerException
(
"SpecularSimulation::runSimulation() -> Error. Not a MultiLayer"
);
if
(
multilayer
->
requiresMatrixRTCoefficients
())
{
if
(
multilayer
->
requiresMatrixRTCoefficients
())
{
collectRTCoefficientsMatrix
(
multilayer
);
}
else
{
collectRTCoefficientsScalar
(
multilayer
);
// calculateEvanescentWaveIntensity();
// calculateEvanescentWaveIntensity();
}
}
void
SpecularSimulation
::
setBeamParameters
(
double
lambda
,
const
IAxis
&
alpha_axis
)
{
delete
m_alpha_i_axis
;
...
...
@@ -171,8 +148,8 @@ void SpecularSimulation::setBeamParameters(double lambda, const IAxis &alpha_axi
m_lambda
=
lambda
;
}
void
SpecularSimulation
::
setBeamParameters
(
double
lambda
,
int
nbins
,
double
alpha_i_min
,
double
alpha_i_max
)
void
SpecularSimulation
::
setBeamParameters
(
double
lambda
,
int
nbins
,
double
alpha_i_min
,
double
alpha_i_max
)
{
FixedBinAxis
axis
(
"alpha_i"
,
nbins
,
alpha_i_min
,
alpha_i_max
);
setBeamParameters
(
lambda
,
axis
);
...
...
@@ -190,75 +167,68 @@ void SpecularSimulation::setEvanescentWaveAxis(int nbins, double z_min, double z
setEvanescentWaveAxis
(
axis
);
}
const
IAxis
*
SpecularSimulation
::
getAlphaAxis
()
const
{
return
m_alpha_i_axis
;
}
std
::
vector
<
complex_t
>
SpecularSimulation
::
getScalarR
(
size_t
i_layer
)
const
std
::
vector
<
complex_t
>
SpecularSimulation
::
getScalarR
(
size_t
i_layer
)
const
{
checkCoefficients
(
i_layer
);
std
::
vector
<
complex_t
>
result
;
std
::
vector
<
complex_t
>
result
;
result
.
resize
(
m_data
.
getAllocatedSize
());
for
(
size_t
i
=
0
;
i
<
m_data
.
getAllocatedSize
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
m_data
.
getAllocatedSize
();
++
i
)
{
result
[
i
]
=
m_data
[
i
][
i_layer
]
->
getScalarR
();
}
return
result
;
}
std
::
vector
<
complex_t
>
SpecularSimulation
::
getScalarT
(
size_t
i_layer
)
const
std
::
vector
<
complex_t
>
SpecularSimulation
::
getScalarT
(
size_t
i_layer
)
const
{
checkCoefficients
(
i_layer
);
std
::
vector
<
complex_t
>
result
;
std
::
vector
<
complex_t
>
result
;
result
.
resize
(
m_data
.
getAllocatedSize
());
for
(
size_t
i
=
0
;
i
<
m_data
.
getAllocatedSize
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
m_data
.
getAllocatedSize
();
++
i
)
{
result
[
i
]
=
m_data
[
i
][
i_layer
]
->
getScalarT
();
}
return
result
;
}
std
::
vector
<
complex_t
>
SpecularSimulation
::
getScalarKz
(
size_t
i_layer
)
const
{
checkCoefficients
(
i_layer
);
std
::
vector
<
complex_t
>
result
;
std
::
vector
<
complex_t
>
result
;
result
.
resize
(
m_data
.
getAllocatedSize
());
for
(
size_t
i
=
0
;
i
<
m_data
.
getAllocatedSize
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
m_data
.
getAllocatedSize
();
++
i
)
{
result
[
i
]
=
m_data
[
i
][
i_layer
]
->
getScalarKz
();
}
return
result
;
}
SpecularSimulation
::
LayerRTCoefficients_t
SpecularSimulation
::
getLayerRTCoefficients
(
size_t
i_alpha
,
size_t
i_layer
)
const
SpecularSimulation
::
LayerRTCoefficients_t
SpecularSimulation
::
getLayerRTCoefficients
(
size_t
i_alpha
,
size_t
i_layer
)
const
{
if
(
i_alpha
>=
m_data
.
getAllocatedSize
())
throw
RuntimeErrorException
(
"SpecularSimulation::getLayerRTCoefficients() -> Error. Wrong i_alpha."
);
if
(
i_alpha
>=
m_data
.
getAllocatedSize
())
throw
RuntimeErrorException
(
"SpecularSimulation::getLayerRTCoefficients() -> Error. Wrong i_alpha."
);
if
(
i_layer
>=
m_data
[
i_alpha
].
size
())
throw
RuntimeErrorException
(
"SpecularSimulation::getLayerRTCoefficients() -> Error. Wrong layer index."
);
if
(
i_layer
>=
m_data
[
i_alpha
].
size
())
throw
RuntimeErrorException
(
"SpecularSimulation::getLayerRTCoefficients() -> Error. Wrong layer index."
);
return
m_data
[
i_alpha
][
i_layer
];
}
void
SpecularSimulation
::
init_parameters
()
{
}
void
SpecularSimulation
::
updateSample
()
{
if
(
m_sample_builder
.
get
())
{
ISample
*
new_sample
=
m_sample_builder
->
buildSample
();
std
::
string
builder_type
=
typeid
(
*
m_sample_builder
).
name
();
if
(
builder_type
.
find
(
"ISampleBuilder_wrapper"
)
!=
std
::
string
::
npos
)
{
if
(
builder_type
.
find
(
"ISampleBuilder_wrapper"
)
!=
std
::
string
::
npos
)
{
setSample
(
*
new_sample
);
}
else
{
delete
m_sample
;
...
...
@@ -267,12 +237,11 @@ void SpecularSimulation::updateSample()
}
}
void
SpecularSimulation
::
collectRTCoefficientsScalar
(
const
MultiLayer
*
multilayer
)
{
OutputData
<
MultiLayerRTCoefficients_t
>::
iterator
it
=
m_data
.
begin
();
while
(
it
!=
m_data
.
end
())
{
double
alpha_i
=
m_data
.
getValueOfAxis
(
0
,
it
.
getIndex
());
double
alpha_i
=
m_data
.
getValueOfAxis
(
0
,
it
.
getIndex
());
kvector_t
kvec
;
kvec
.
setLambdaAlphaPhi
(
m_lambda
,
-
alpha_i
,
0.0
);
...
...
@@ -282,7 +251,7 @@ void SpecularSimulation::collectRTCoefficientsScalar(const MultiLayer *multilaye
MultiLayerRTCoefficients_t
ml_coeffs
;
ml_coeffs
.
resize
(
coeffs
.
size
());
for
(
size_t
i_layer
=
0
;
i_layer
<
coeffs
.
size
();
++
i_layer
)
{
for
(
size_t
i_layer
=
0
;
i_layer
<
coeffs
.
size
();
++
i_layer
)
{
ml_coeffs
[
i_layer
]
=
LayerRTCoefficients_t
(
new
ScalarRTCoefficients
(
coeffs
[
i_layer
]));
}
...
...
@@ -292,14 +261,13 @@ void SpecularSimulation::collectRTCoefficientsScalar(const MultiLayer *multilaye
}
// alpha_i
}
void
SpecularSimulation
::
collectRTCoefficientsMatrix
(
const
MultiLayer
*
/*multilayer*/
)
{
throw
NotImplementedException
(
"SpecularSimulation::collectRTCoefficientsMatrix() -> Error. Not implemented."
);
throw
NotImplementedException
(
"SpecularSimulation::collectRTCoefficientsMatrix() -> Error. Not implemented."
);
}
//void SpecularSimulation::calculateEvanescentWaveIntensity()
// void SpecularSimulation::calculateEvanescentWaveIntensity()
//{
// if(!m_z_axis) return;
...
...
@@ -307,7 +275,6 @@ void SpecularSimulation::collectRTCoefficientsMatrix(const MultiLayer * /*multil
// const IAxis *alpha_axis = m_ewave_intensity.getAxis(0);
// const IAxis *z_axis = m_ewave_intensity.getAxis(1);
// OutputData<double>::iterator it = m_ewave_intensity.begin();
// while (it != m_ewave_intensity.end()) {
// std::vector<int> indices =
...
...
@@ -321,37 +288,41 @@ void SpecularSimulation::collectRTCoefficientsMatrix(const MultiLayer * /*multil
// int i_layer = multilayer->zToLayerIndex(z_axis_value);
// double depth = multilayer->getLayerThickness(i_layer) - (z_axis_value-multilayer->getLayerBottomZ(i_layer));
// double depth = multilayer->getLayerThickness(i_layer) -
// (z_axis_value-multilayer->getLayerBottomZ(i_layer));
//// std::cout << "alpha_axis_value:" << alpha_axis_value << " z_axis_value:" << z_axis_value << " i_layer:" << i_layer << " depth:" << depth<< std::endl;
//// std::cout << "alpha_axis_value:" << alpha_axis_value << " z_axis_value:" << z_axis_value
///<< " i_layer:" << i_layer << " depth:" << depth<< std::endl;
// LayerRTCoefficients_t rtcoeff = getLayerRTCoefficients(alpha_index, i_layer);
//// complex_t cvalue = rtcoeff->getScalarT()*std::exp(rtcoeff->getScalarKz()*depth) + rtcoeff->getScalarR()*std::exp(rtcoeff->getScalarKz()*depth);
//// complex_t cvalue = rtcoeff->getScalarT()*std::exp(std::imag(rtcoeff->getScalarKz())*depth) + rtcoeff->getScalarR()*std::exp(std::imag(rtcoeff->getScalarKz())*depth);
//// complex_t cvalue = rtcoeff->getScalarT()*std::exp(rtcoeff->getScalarKz()*depth) +
///rtcoeff->getScalarR()*std::exp(rtcoeff->getScalarKz()*depth);
//// complex_t cvalue =
///rtcoeff->getScalarT()*std::exp(std::imag(rtcoeff->getScalarKz())*depth) +
///rtcoeff->getScalarR()*std::exp(std::imag(rtcoeff->getScalarKz())*depth);
//// *it = std::abs(cvalue);
// double value = 1.0 + std::abs(rtcoeff->getScalarT())*std::exp(std::imag(rtcoeff->getScalarKz())*depth*Units::angstrom);
// double value = 1.0 +
// std::abs(rtcoeff->getScalarT())*std::exp(std::imag(rtcoeff->getScalarKz())*depth*Units::angstrom);
// *it = value;
// ++it;
// }
//}
void
SpecularSimulation
::
checkCoefficients
(
size_t
i_layer
)
const
{
if
(
m_data
.
getAllocatedSize
()
==
1
||
m_data
[
0
].
size
()
==
0
)
throw
ClassInitializationException
(
"SpecularSimulation::checkCoefficients() "
"-> Error. No coefficients found, check that (1) you have set beam parameters (2) you have run your simulation."
);
if
(
m_data
.
getAllocatedSize
()
==
1
||
m_data
[
0
].
size
()
==
0
)
throw
ClassInitializationException
(
"SpecularSimulation::checkCoefficients() "
"-> Error. No coefficients found, check that (1) you "
"have set beam parameters (2) you have run your "
"simulation."
);
if
(
i_layer
>=
m_data
[
0
].
size
())
{
if
(
i_layer
>=
m_data
[
0
].
size
())
{
std
::
ostringstream
message
;
message
<<
"SpecularSimulation::checkCoefficients() -> Error. Requested layer index "
<<
i_layer
<<
" is large than or equal to the total number of layers "
<<
m_data
[
0
].
size
()
<<
std
::
endl
;
<<
i_layer
<<
" is large than or equal to the total number of layers "
<<
m_data
[
0
].
size
()
<<
std
::
endl
;
throw
OutOfBoundsException
(
message
.
str
());
}
}
...
...
@@ -361,7 +332,7 @@ void SpecularSimulation::updateCoefficientDataAxes()
m_data
.
clear
();
m_data
.
addAxis
(
*
m_alpha_i_axis
);
if
(
m_z_axis
)
{
if
(
m_z_axis
)
{
m_ewave_intensity
.
clear
();
m_ewave_intensity
.
addAxis
(
*
m_alpha_i_axis
);
m_ewave_intensity
.
addAxis
(
*
m_z_axis
);
...
...
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