commit 285fbf8ec1c4ad2ea1db707af6dc15e3269be7b6
parent 469270448ee13a25d7919554124b141d5e4e417c
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Tue, 7 Mar 2017 17:22:36 +0100
Add some tests with know analytical results.
Add to relax conformance predicate, though.
Diffstat:
17 files changed, 280 insertions(+), 1 deletion(-)
diff --git a/cmake/test_model/CMakeLists.txt b/cmake/test_model/CMakeLists.txt
@@ -46,6 +46,11 @@ add_executable(test_model ${TESTMODEL_FILES_SRC})
################################################################################
if(NOT NO_TEST)
add_test(test_beam_down test_model beam_down)
+ add_test(test_01 test_model test01)
+ add_test(test_02 test_model test02)
+ add_test(test_03 test_model test03)
+ add_test(test_04 test_model test04)
+ add_test(test_05 test_model test05)
rcmake_copy_runtime_libraries(test_model)
diff --git a/src/test_model/test_model.c b/src/test_model/test_model.c
@@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <rsys/rsys.h>
+#include <rsys/math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -123,6 +124,7 @@ is_compatible_with
const double test_E,
const double test_SE)
{
+ double SE;
ASSERT(POSITIVE_OR_M_ONE(ref_E) && POSITIVE_OR_M_ONE(ref_SE)
&& POSITIVE_OR_M_ONE(test_E) && POSITIVE_OR_M_ONE(test_SE));
if (ref_E == -1) {
@@ -130,7 +132,8 @@ is_compatible_with
return (test_E == -1 && test_SE == -1);
}
ASSERT(ref_SE != -1);
- return (fabs(ref_E - test_E) <= 2 * ref_SE && test_SE <= 2 * ref_SE);
+ SE = ref_SE > 0 ? 2 * ref_SE : (ref_E > 0 ? ref_E * 1e-6 : 1e-6);
+ return (fabs(ref_E - test_E) <= SE && test_SE <= SE);
}
static res_T
diff --git a/yaml/test01.ref b/yaml/test01.ref
@@ -0,0 +1,5 @@
+#--- Sun direction: -6.12323e-17 -0 -1
+1 10000
+square_receiver 2 -1 -1 1 0 -1 -1 0 0 -1 -1 0 0 -1 -1 0 0 -1 -1 1 0
+0 0
+0 0
diff --git a/yaml/test01.yaml b/yaml/test01.yaml
@@ -0,0 +1,50 @@
+- sun: &sun
+ dni: 1
+ spectrum: [{wavelength: 1, data: 1}]
+
+- material: &specular
+ front:
+ mirror: { reflectivity: 1, roughness: 0 }
+ back:
+ mirror: { reflectivity: 1, roughness: 0 }
+
+
+- geometry: &small_square
+ - material: *specular
+ plane:
+ clip:
+ - operation: AND
+ vertices:
+ - [-0.50, -0.50]
+ - [-0.50, 0.50]
+ - [0.50, 0.50]
+ - [0.50, -0.50]
+
+- geometry: &big_square
+ - material: { virtual: }
+ plane:
+ clip:
+ - operation: AND
+ vertices:
+ - [-5.00, -5.00]
+ - [-5.00, 5.00]
+ - [5.00, 5.00]
+ - [5.00, -5.00]
+
+
+- entity:
+ name: "reflector"
+ primary: 1
+ transform: { rotation: [0, 0, 0], translation: [0, 0, 0] }
+ geometry: *small_square
+
+
+
+- entity:
+ name: "square_receiver"
+ primary: 0
+ transform: { rotation: [0, 0, 0], translation: [0, 0, 2] }
+ geometry: *big_square
+
+
+
diff --git a/yaml/test01_receiver.yaml b/yaml/test01_receiver.yaml
@@ -0,0 +1 @@
+- { name: "square_receiver", side: BACK }
diff --git a/yaml/test02.ref b/yaml/test02.ref
@@ -0,0 +1,5 @@
+#--- Sun direction: -6.12323e-17 -0 -1
+1 100000
+square_receiver 2 -1 -1 1 0.0313065 -1 -1 0 0 -1 -1 0 0 -1 -1 0 0 -1 -1 0.01003 0.000315109
+0 0
+99 0.0313065
diff --git a/yaml/test02.yaml b/yaml/test02.yaml
@@ -0,0 +1,47 @@
+- sun: &sun
+ dni: 1
+ spectrum: [{wavelength: 1, data: 1}]
+
+- material: &specular
+ mirror: { reflectivity: 1, roughness: 0 }
+
+
+- geometry: &small_square
+ - material: { virtual: }
+ plane:
+ clip:
+ - operation: AND
+ vertices:
+ - [-0.50, -0.50]
+ - [-0.50, 0.50]
+ - [0.50, 0.50]
+ - [0.50, -0.50]
+
+- geometry: &big_square
+ - material: *specular
+ plane:
+ clip:
+ - operation: AND
+ vertices:
+ - [-5.00, -5.00]
+ - [-5.00, 5.00]
+ - [5.00, 5.00]
+ - [5.00, -5.00]
+
+
+- entity:
+ name: "reflector"
+ primary: 1
+ transform: { rotation: [0, 0, 0], translation: [0, 0, 0] }
+ geometry: *big_square
+
+
+
+- entity:
+ name: "square_receiver"
+ primary: 0
+ transform: { rotation: [0, 0, 0], translation: [0, 0, 2] }
+ geometry: *small_square
+
+
+
diff --git a/yaml/test02_receiver.yaml b/yaml/test02_receiver.yaml
@@ -0,0 +1 @@
+- { name: "square_receiver", side: BACK }
diff --git a/yaml/test03.ref b/yaml/test03.ref
@@ -0,0 +1,5 @@
+#--- Sun direction: -0.707107 -0 -0.707107
+1 10000
+square_receiver 2 -1 -1 0.707107 0 -1 -1 0 0 -1 -1 0 0 -1 -1 0.292893 0 -1 -1 0.707107 0
+0 0
+0 0
diff --git a/yaml/test03.yaml b/yaml/test03.yaml
@@ -0,0 +1,49 @@
+- sun: &sun
+ dni: 1
+ spectrum: [{wavelength: 1, data: 1}]
+
+- material: &specular
+ front:
+ mirror: { reflectivity: 1, roughness: 0 }
+ back:
+ mirror: { reflectivity: 1, roughness: 0 }
+
+- geometry: &small_square
+ - material: *specular
+ plane:
+ clip:
+ - operation: AND
+ vertices:
+ - [-0.50, -0.50]
+ - [-0.50, 0.50]
+ - [0.50, 0.50]
+ - [0.50, -0.50]
+
+- geometry: &big_square
+ - material: { virtual: }
+ plane:
+ clip:
+ - operation: AND
+ vertices:
+ - [-5.00, -5.00]
+ - [-5.00, 5.00]
+ - [5.00, 5.00]
+ - [5.00, -5.00]
+
+
+- entity:
+ name: "reflector"
+ primary: 1
+ transform: { rotation: [0, 0, 0], translation: [0, 0, 0] }
+ geometry: *small_square
+
+
+
+- entity:
+ name: "square_receiver"
+ primary: 0
+ transform: { rotation: [0, 0, 0], translation: [-2, 0, 2] }
+ geometry: *big_square
+
+
+
diff --git a/yaml/test03_receiver.yaml b/yaml/test03_receiver.yaml
@@ -0,0 +1 @@
+- { name: "square_receiver", side: BACK }
diff --git a/yaml/test04.ref b/yaml/test04.ref
@@ -0,0 +1,4 @@
+#--- Sun direction: -0.707107 -0 -0.707107
+1 10000
+square_receiver 2 0 0 0.707107 0 0 0 0 0 0 0 0 0 0 0 0.292893 0 0 0 0.707107 0
+0 0
diff --git a/yaml/test04.yaml b/yaml/test04.yaml
@@ -0,0 +1,52 @@
+- sun: &sun
+ dni: 1
+ spectrum: [{wavelength: 1, data: 1}]
+
+- material: &specular
+ front:
+ mirror: { reflectivity: 1, roughness: 0 }
+ back:
+ mirror: { reflectivity: 1, roughness: 0 }
+
+- material: &black
+ matte: { reflectivity: 0 }
+
+- geometry: &small_square
+ - material: *specular
+ plane:
+ clip:
+ - operation: AND
+ vertices:
+ - [-0.50, -0.50]
+ - [-0.50, 0.50]
+ - [0.50, 0.50]
+ - [0.50, -0.50]
+
+- geometry: &big_square
+ - material: { virtual: }
+ plane:
+ clip:
+ - operation: AND
+ vertices:
+ - [-5.00, -5.00]
+ - [-5.00, 5.00]
+ - [5.00, 5.00]
+ - [5.00, -5.00]
+
+
+- entity:
+ name: "reflector"
+ primary: 1
+ transform: { rotation: [0, 0, 0], translation: [0, 0, 0] }
+ geometry: *small_square
+
+
+
+- entity:
+ name: "square_receiver"
+ primary: 0
+ transform: { rotation: [0, -45, 0], translation: [-2, 0, 2] }
+ geometry: *big_square
+
+
+
diff --git a/yaml/test04_receiver.yaml b/yaml/test04_receiver.yaml
@@ -0,0 +1 @@
+- { name: "square_receiver", side: FRONT_AND_BACK }
diff --git a/yaml/test05.ref b/yaml/test05.ref
@@ -0,0 +1,5 @@
+#--- Sun direction: -6.12323e-17 -0 -1
+1 10000
+spherical_receiver 2 -1 -1 1 0 -1 -1 0 0 -1 -1 0 0 -1 -1 0 0 -1 -1 1 0
+0 0
+0 0
diff --git a/yaml/test05.yaml b/yaml/test05.yaml
@@ -0,0 +1,44 @@
+- sun: &sun
+ dni: 1
+ spectrum: [{wavelength: 1, data: 1}]
+
+- material: &lambertian
+ front:
+ matte: { reflectivity: 1 }
+ back:
+ matte: { reflectivity: 1 }
+
+- geometry: &small_square
+ - material: *lambertian
+ plane:
+ clip:
+ - operation: AND
+ vertices:
+ - [-0.50, -0.50]
+ - [-0.50, 0.50]
+ - [0.50, 0.50]
+ - [0.50, -0.50]
+
+- geometry: &big_sphere
+ - material: { virtual: }
+ sphere:
+ radius: 2.0
+ slices: 128
+
+
+- entity:
+ name: "reflector"
+ primary: 1
+ transform: { rotation: [0, 0, 0], translation: [0, 0, 0] }
+ geometry: *small_square
+
+
+
+- entity:
+ name: "spherical_receiver"
+ primary: 0
+ transform: { rotation: [0, 0, 0], translation: [0, 0, 0] }
+ geometry: *big_sphere
+
+
+
diff --git a/yaml/test05_receiver.yaml b/yaml/test05_receiver.yaml
@@ -0,0 +1 @@
+- { name: "spherical_receiver", side: BACK }