solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

commit fd3f022892f49353b2cc04755d66e5f18a8c1f38
parent 23b5166482cf2476a41fa9befe1dfa6cc3222fa3
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 26 Jan 2017 17:00:02 +0100

Fix example in grammar description, and autotest it.

Diffstat:
Mcmake/parser/CMakeLists.txt | 2++
Mdoc/input | 446++++++++++++++++++++++++++++++++++++++++----------------------------------------
2 files changed, 225 insertions(+), 223 deletions(-)

diff --git a/cmake/parser/CMakeLists.txt b/cmake/parser/CMakeLists.txt @@ -68,6 +68,8 @@ if(NOT NO_TEST) endfunction() build_test(test_solparser) + add_test(test_grammar_example test_solparser + ${PROJECT_SOURCE_DIR}/../../doc/input) add_test(test_solparser_ok_0 test_solparser ${SOLPARSER_SOURCE_DIR}/yaml/test_ok_0.yaml) add_test(test_solparser_ok_1 test_solparser diff --git a/doc/input b/doc/input @@ -1,6 +1,6 @@ --------------------------------------------------------------------------------- -1/ Exemple --------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------- +# 1/ Exemple +# -------------------------------------------------------------------------------- # Declare materials - material: &lambertian matte: @@ -25,6 +25,7 @@ vertices: [ [1, 2], [3, 4], [6, 7] ] # Create the solar factory +- sun: { dni: 1, spectrum: [{wavelength: 1, data: 1}] } - entity: name: "entity0" primary: 0 @@ -50,246 +51,245 @@ material: *mirror children: - name: "hop" + primary: 1 transform: { translation: [1, 2, 3 ] } geometry: *cylinders - name: "hop2" + primary: 1 geometry: *parabol children: - - transform: { rotation: [0, 0, 0] } + - name: "child 1" + transform: { rotation: [0, 0, 0] } pivot: point: [0, 0, 0] normal: [0, 1, 0] - + target: { position: [0, 0, 0] } - entity: name: "entity2" - primary: 0 transform: { translation: [4, 5, 6] } children: [ *composition ] - entity: name: "entity3" - primary: 0 transform: { translation: [7, 8, 9] } children: [ *composition ] - entity: name: "entity4" - primary: 1 transform: { translation: [10, 11, 12] } children: [ *composition ] --------------------------------------------------------------------------------- -2/ Grammar --------------------------------------------------------------------------------- -<solar-factory> ::= - <sun> - <items> - -<items> ::= - - <item> -[ - <item> ... ] - -<item> ::= - <geometry> - | <material> - | <entity> - | <template> - ----------------------------------------- -<geometry> ::= - geometry: - - <object> -[ - <object> ... ] - -<object> ::= - <shape> - <material> -[ <transform> ] - -<pivot> ::= - pivot: - point: <real3> - normal: <real3> - <target> - -<target> ::= - target: - anchor: <anchor-identifier> - | direction: <real3> - | position: <real3> - | <sun> - ----------------------------------------- -<shape> ::= - <cuboid> - | <cylinder> - | <obj> - | <parabol> - | <parabolic-cylinder> - | <plane> - | <sphere> - | <stl> - -<cuboid> ::= - cuboid: - size: <real3*+> - -<cylinder> ::= - cylinder: - height: REAL # in ]0, INF) - radius: REAL # in ]0, INF) -[ slices: INTEGER ] # in [4, 4096]. Default 16 - -<obj> ::= - obj: - path: PATH - -<parabol> ::= - parabol: # x^2 + y^2 - 4*focal*z = 0 - focal: REAL # in ]0, INF) - clip: <polyclip-list> - -<parabolic-cylinder> ::= - parabolic-cylinder: # y^2 - 4*focal*z = 0 - focal: REAL # in ]0, INF) - clip: <polyclip-list> - -<plane> ::= - plane: - clip: <polyclip-list> - -<sphere> ::= - sphere: - radius: REAL # in ]0, INF) -[ slices: INTEGER ] # in [4, 4096]. Default 16 - -<stl> ::= - stl: - path: PATH - ----------------------------------------- -<polyclip-list> ::= - - <polyclip> -[ - <polyclip> ... ] - -<polyclip> ::= - operation: <AND|SUB> - vertices: <vertices-list> - -<vertices-list> ::= - - <real2> - - <real2> - - <real2> -[ - <real2> ... ] - ----------------------------------------- -<material> ::= - <material-descriptor> | <double-sided-material> - -<double-sided-material> ::= - front: <material-descriptor> - back: <material-descriptor> - -<material-descriptor> ::= - <mirror> | <matte> | <virtual> - -<mirror> ::= - mirror: - reflectivity: REAL # in [0, 1] - roughness: REAL # in [0, 1] - -<matte> ::= - matte: - reflectivity: REAL # in [0, 1] - -<virtual> ::= - virtual: EMPTY-STRING - ----------------------------------------- -<entity> ::= - entity: - <entity-data> - -<template> ::= - template: - <entity-data> - -<entity-data> ::= - name: STRING -[ <geometry-data> | <pivot> ] -[ <anchors> ] -[ <transform> ] -[ <children> ] - -<geometry-data> ::= - primary: INTEGER # in [0, 1] - <geometry> - -<children> ::= - children: - - <entity-data> -[ - <entity-data> ... ] - -<anchors> ::= - anchors: - - <anchor-data> -[ - <anchor-data> ... ] - -<anchor-data> ::= - name: STRING - position: <real3> - -# "self" references the first level entity -<entity-identifier> ::= - <self|STRING>[.STRING ... ] - -<anchor-identifier> ::= - <entity-identifier>.STRING - ----------------------------------------- -<sun> ::= - sun: - dni: REAL # Direct Normal Irradiance in ]0, INF) - <spectrum> -[ <radial-angular-distribution> ] - -<radial-angular-distribution> ::= - <pillbox> | <buie> - -<buie> ::= - buie: - csr: REAL # in ]0, 1[ - -<pillbox> ::= - pillbox: - aperture: REAL # in ]0, 90] - ----------------------------------------- -<transform> ::= - transform: - translation: <real3> - rotation: <real3> - -<real2> ::= - - REAL - - REAL - -<real3> ::= - - REAL - - REAL - - REAL - -<real3*+> ::= - - REAL # in ]0, inf) - - REAL # in ]0, inf) - - REAL # in ]0, inf) - -<spectrum> ::= - spectrum: - - <spectrum-data> -[ - <spectrum-data> ... ] - -<spectrum-data> ::= - wavelength: REAL # in [0, INF) - data: REAL # in [0, INF) - +# -------------------------------------------------------------------------------- +# 2/ Grammar +# -------------------------------------------------------------------------------- +# <solar-factory> ::= +# <sun> +# <items> +# +# <items> ::= +# - <item> +# [ - <item> ... ] +# +# <item> ::= +# <geometry> +# | <material> +# | <entity> +# | <template> +# +# ---------------------------------------- +# <geometry> ::= +# geometry: +# - <object> +# [ - <object> ... ] +# +# <object> ::= +# <shape> +# <material> +# [ <transform> ] +# +# <pivot> ::= +# pivot: +# point: <real3> +# normal: <real3> +# <target> +# +# <target> ::= +# target: +# anchor: <anchor-identifier> +# | direction: <real3> +# | position: <real3> +# | <sun> +# +# ---------------------------------------- +# <shape> ::= +# <cuboid> +# | <cylinder> +# | <obj> +# | <parabol> +# | <parabolic-cylinder> +# | <plane> +# | <sphere> +# | <stl> +# +# <cuboid> ::= +# cuboid: +# size: <real3*+> +# +# <cylinder> ::= +# cylinder: +# height: REAL # in ]0, INF) +# radius: REAL # in ]0, INF) +# [ slices: INTEGER ] # in [4, 4096]. Default 16 +# +# <obj> ::= +# obj: +# path: PATH +# +# <parabol> ::= +# parabol: # x^2 + y^2 - 4*focal*z = 0 +# focal: REAL # in ]0, INF) +# clip: <polyclip-list> +# +# <parabolic-cylinder> ::= +# parabolic-cylinder: # y^2 - 4*focal*z = 0 +# focal: REAL # in ]0, INF) +# clip: <polyclip-list> +# +# <plane> ::= +# plane: +# clip: <polyclip-list> +# +# <sphere> ::= +# sphere: +# radius: REAL # in ]0, INF) +# [ slices: INTEGER ] # in [4, 4096]. Default 16 +# +# <stl> ::= +# stl: +# path: PATH +# +# ---------------------------------------- +# <polyclip-list> ::= +# - <polyclip> +# [ - <polyclip> ... ] +# +# <polyclip> ::= +# operation: <AND|SUB> +# vertices: <vertices-list> +# +# <vertices-list> ::= +# - <real2> +# - <real2> +# - <real2> +# [ - <real2> ... ] +# +# ---------------------------------------- +# <material> ::= +# <material-descriptor> | <double-sided-material> +# +# <double-sided-material> ::= +# front: <material-descriptor> +# back: <material-descriptor> +# +# <material-descriptor> ::= +# <mirror> | <matte> | <virtual> +# +# <mirror> ::= +# mirror: +# reflectivity: REAL # in [0, 1] +# roughness: REAL # in [0, 1] +# +# <matte> ::= +# matte: +# reflectivity: REAL # in [0, 1] +# +# <virtual> ::= +# virtual: EMPTY-STRING +# +# ---------------------------------------- +# <entity> ::= +# entity: +# <entity-data> +# +# <template> ::= +# template: +# <entity-data> +# +# <entity-data> ::= +# name: STRING +# [ <geometry-data> | <pivot> ] +# [ <anchors> ] +# [ <transform> ] +# [ <children> ] +# +# <geometry-data> ::= +# primary: INTEGER # in [0, 1] +# <geometry> +# +# <children> ::= +# children: +# - <entity-data> +# [ - <entity-data> ... ] +# +# <anchors> ::= +# anchors: +# - <anchor-data> +# [ - <anchor-data> ... ] +# +# <anchor-data> ::= +# name: STRING +# position: <real3> +# +# # "self" references the first level entity +# <entity-identifier> ::= +# <self|STRING>[.STRING ... ] +# +# <anchor-identifier> ::= +# <entity-identifier>.STRING +# +# ---------------------------------------- +# <sun> ::= +# sun: +# dni: REAL # Direct Normal Irradiance in ]0, INF) +# <spectrum> +# [ <radial-angular-distribution> ] +# +# <radial-angular-distribution> ::= +# <pillbox> | <buie> +# +# <buie> ::= +# buie: +# csr: REAL # in ]0, 1[ +# +# <pillbox> ::= +# pillbox: +# aperture: REAL # in ]0, 90] +# +# ---------------------------------------- +# <transform> ::= +# transform: +# translation: <real3> +# rotation: <real3> +# +# <real2> ::= +# - REAL +# - REAL +# +# <real3> ::= +# - REAL +# - REAL +# - REAL +# +# <real3*+> ::= +# - REAL # in ]0, inf) +# - REAL # in ]0, inf) +# - REAL # in ]0, inf) +# +# <spectrum> ::= +# spectrum: +# - <spectrum-data> +# [ - <spectrum-data> ... ] +# +# <spectrum-data> ::= +# wavelength: REAL # in [0, INF) +# data: REAL # in [0, INF)