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
ef23e146
Commit
ef23e146
authored
8 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
RTTest: + SplitBilayers. Passes.
parent
c5cae822
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/UnitTests/Core/Sample/RTTest.h
+42
-3
42 additions, 3 deletions
Tests/UnitTests/Core/Sample/RTTest.h
with
42 additions
and
3 deletions
Tests/UnitTests/Core/Sample/RTTest.h
+
42
−
3
View file @
ef23e146
...
@@ -11,13 +11,13 @@
...
@@ -11,13 +11,13 @@
#include
"ParticleLayout.h"
#include
"ParticleLayout.h"
#include
"SpecularMatrix.h"
#include
"SpecularMatrix.h"
#include
<iostream>
//
TODO remove when stable
#include
<iostream>
//
for debug phases
class
RTTest
:
public
::
testing
::
Test
class
RTTest
:
public
::
testing
::
Test
{
{
protected:
protected:
RTTest
()
{}
RTTest
()
{}
void
printCoeffs
(
const
std
::
vector
<
ScalarRTCoefficients
>&
coeffs
)
{
void
printCoeffs
(
const
std
::
vector
<
ScalarRTCoefficients
>&
coeffs
)
{
// for debug phases
for
(
size_t
i
=
0
;
i
<
coeffs
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
coeffs
.
size
();
++
i
)
{
const
ScalarRTCoefficients
&
coeff
=
coeffs
[
i
];
const
ScalarRTCoefficients
&
coeff
=
coeffs
[
i
];
std
::
cout
<<
i
<<
" "
<<
coeff
.
t_r
(
0
)
<<
" "
<<
coeff
.
t_r
(
1
)
<<
"
\n
"
;
std
::
cout
<<
i
<<
" "
<<
coeff
.
t_r
(
0
)
<<
" "
<<
coeff
.
t_r
(
1
)
<<
"
\n
"
;
...
@@ -33,7 +33,7 @@ protected:
...
@@ -33,7 +33,7 @@ protected:
}
}
const
HomogeneousMaterial
air
{
"air"
,
1e-8
,
1e-8
};
const
HomogeneousMaterial
air
{
"air"
,
1e-8
,
1e-8
};
const
HomogeneousMaterial
amat
{
"material A"
,
2e-6
,
8e-7
};
const
HomogeneousMaterial
amat
{
"material A"
,
2e-6
,
8e-7
};
const
HomogeneousMaterial
bmat
{
"material B (high absorption)"
,
3e-
6
,
2e-4
};
const
HomogeneousMaterial
bmat
{
"material B (high absorption)"
,
3e-
5
,
2e-4
};
const
HomogeneousMaterial
stone
{
"substrate material"
,
1e-6
,
1e-7
};
const
HomogeneousMaterial
stone
{
"substrate material"
,
1e-6
,
1e-7
};
const
Layer
topLayer
{
air
,
0
};
const
Layer
topLayer
{
air
,
0
};
const
Layer
substrate
{
stone
,
0
};
const
Layer
substrate
{
stone
,
0
};
...
@@ -66,3 +66,42 @@ TEST_F(RTTest, SplitLayer)
...
@@ -66,3 +66,42 @@ TEST_F(RTTest, SplitLayer)
compareCoeffs
(
coeffs1
[
1
],
coeffs2
[
1
]);
compareCoeffs
(
coeffs1
[
1
],
coeffs2
[
1
]);
compareCoeffs
(
coeffs1
.
back
(),
coeffs2
.
back
());
compareCoeffs
(
coeffs1
.
back
(),
coeffs2
.
back
());
}
}
TEST_F
(
RTTest
,
SplitBilayers
)
{
// With exaggerated values of #layers, layer thickness, and absorption
// so that we also test correct handling of floating-point overflow.
const
int
n
=
400
;
sample1
.
addLayer
(
topLayer
);
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
sample1
.
addLayer
(
Layer
(
amat
,
100
)
);
sample1
.
addLayer
(
Layer
(
bmat
,
200
)
);
}
sample1
.
addLayer
(
substrate
);
sample2
.
addLayer
(
topLayer
);
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
sample2
.
addLayer
(
Layer
(
amat
,
100
)
);
sample2
.
addLayer
(
Layer
(
bmat
,
100
)
);
sample2
.
addLayer
(
Layer
(
amat
,
0
)
);
sample2
.
addLayer
(
Layer
(
bmat
,
100
)
);
}
sample2
.
addLayer
(
substrate
);
SpecularMatrix
::
execute
(
sample1
,
k
,
coeffs1
);
SpecularMatrix
::
execute
(
sample2
,
k
,
coeffs2
);
// printCoeffs( coeffs1 );
// printCoeffs( coeffs2 );
compareCoeffs
(
coeffs1
[
0
],
coeffs2
[
0
]);
compareCoeffs
(
coeffs1
[
1
],
coeffs2
[
1
]);
// If floating-point overflow is handled correctly, amplitudes at bottom must be strictly zero.
EXPECT_EQ
(
complex_t
(),
coeffs1
[
coeffs1
.
size
()
-
2
].
t_r
(
0
));
EXPECT_EQ
(
complex_t
(),
coeffs1
[
coeffs1
.
size
()
-
2
].
t_r
(
1
));
EXPECT_EQ
(
complex_t
(),
coeffs2
[
coeffs2
.
size
()
-
2
].
t_r
(
0
));
EXPECT_EQ
(
complex_t
(),
coeffs2
[
coeffs2
.
size
()
-
2
].
t_r
(
1
));
}
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