# baseURI: http://smartlab.elis.ugent.be/aimontologies/NBNS01-400-1:2008/rules20091028

# --------------------------------------------------------------------------------------------------------------------------
# Belgische Norm NBN S 01-400-1
# -----------------------------
# Akoestische criteria voor woongebouwen 
# --------------------------------------------------------------------------------------------------------------------------
#
# Bureau voor Normalisatie, Brabançonnelaan 29, B-1000 Brussel, België
# --------------------------------------------------------------------------------------------------------------------------

@prefix NBNS014001_rules: <http://smartlab.elis.ugent.be/aimontologies/NBNS01-400-1:2008/rules20091028#> .
@prefix EN12354:        <http://smartlab.elis.ugent.be/aimontologies/EN-12354-3:2000/ontology20091028#> .
@prefix NBNS014001: <http://smartlab.elis.ugent.be/aimontologies/NBNS01-400-1:2008/ontology20091028#> .
@prefix math: <http://www.w3.org/2000/10/swap/math#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix list: <http://www.co-ode.org/ontologies/lists/2008/09/11/list.owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> . 
@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#> .

# Input:
# ------

# La = 0
# RoadCorner = 0
# m = 0

# Infer Input:
# ------------

  {
       # Find Required Input 
       ?BE a EN12354:BoundaryElement
  }
  =>
  {
       ?BE a NBNS014001:Gevelelement
  }.
  
  {
       # Find Required Input 
       ?RB a EN12354:RoomBoundary
  }
  =>
  {
       ?RB a NBNS014001:Gevelvlak
  }.

  {
       # Find Required Input 
       ?BE EN12354:partOfRoomBoundary ?RB .
       ?BE a EN12354:BoundaryElement .
       ?RB a EN12354:RoomBoundary
  }
  =>
  {
       ?BE NBNS014001:deelVanGevelvlak ?RB
  }.
  
  
  # Calculate Snetto
  {
        # Find Required Input 
        ?RB a NBNS014001:Gevelvlak .
        (?SCOPE 1) e:findall 
            (
                ?BEarea 
                {
                    ?BE a NBNS014001:Gevelelement .
                    ?BE NBNS014001:Ratr ?i1 .
                    ?i1 math:greaterThan 48 .
                    ?i1 EN12354:elementSurfaceArea ?i2 .
                } 
                ?BEareaList
            ) .
        ?BEareaList math:sum ?i .
  }
  =>
  {
       ?RB NBNS014001:Snetto ?i
  }.

# Calculate:
# ----------

  # Calculate Datr  
  {
       # Find Required Input 
       ?x EN12354:standardizedSoundLevelDifference_63Hz ?D63 .
       ?x EN12354:standardizedSoundLevelDifference_125Hz ?D125 .
       ?x EN12354:standardizedSoundLevelDifference_250Hz ?D250 .
       ?x EN12354:standardizedSoundLevelDifference_500Hz ?D500 .
       ?x EN12354:standardizedSoundLevelDifference_1000Hz ?D1000 .
       ?x EN12354:standardizedSoundLevelDifference_2000Hz ?D2000 .
       ?x EN12354:standardizedSoundLevelDifference_4000Hz ?D4000 .
       
       (-14 ?D125) math:difference ?i_1 .
       (?i_1 10) math:quotient ?j_1 .
       (10 ?j_1) math:exponentiation ?k_1 .
       (-10 ?D250) math:difference ?i_2 .
       (?i_2 10) math:quotient ?j_2 .
       (10 ?j_2) math:exponentiation ?k_2 .
       (-7 ?D500) math:difference ?i_3 .
       (?i_3 10) math:quotient ?j_3 .
       (10 ?j_3) math:exponentiation ?k_3 .
       (-4 ?D1000) math:difference ?i_4 .
       (?i_4 10) math:quotient ?j_4 .
       (10 ?j_4) math:exponentiation ?k_4 .
       (-6 ?D2000) math:difference ?i_5 .
       (?i_5 10) math:quotient ?j_5 .
       (10 ?j_5) math:exponentiation ?k_5 .
       
       (?k_1 ?k_2 ?k_3 ?k_4 ?k_5) math:sum ?l .
       (10 ?m) math:exponentiation ?l .
       (-10 ?m) math:product ?n
  }
  =>
  {
       ?x NBNS014001:Datr ?n
  }.

# Calculate Ratr
  {
        # Find Required Input 
        ?x EN12354:soundReductionIndex_125Hz ?R125 .
        ?x EN12354:soundReductionIndex_250Hz ?R250 .
        ?x EN12354:soundReductionIndex_500Hz ?R500 .
        ?x EN12354:soundReductionIndex_1000Hz ?R1000 .
        ?x EN12354:soundReductionIndex_2000Hz ?R2000 .
       
       (-14 ?R125) math:difference ?i_1 .
       (?i_1 10) math:quotient ?j_1 .
       (10 ?j_1) math:exponentiation ?k_1 .
       (-10 ?R250) math:difference ?i_2 .
       (?i_2 10) math:quotient ?j_2 .
       (10 ?j_2) math:exponentiation ?k_2 .
       (-7 ?R500) math:difference ?i_3 .
       (?i_3 10) math:quotient ?j_3 .
       (10 ?j_3) math:exponentiation ?k_3 .
       (-4 ?R1000) math:difference ?i_4 .
       (?i_4 10) math:quotient ?j_4 .
       (10 ?j_4) math:exponentiation ?k_4 .
       (-6 ?R2000) math:difference ?i_5 .
       (?i_5 10) math:quotient ?j_5 .
       (10 ?j_5) math:exponentiation ?k_5 .
       
       (?k_1 ?k_2 ?k_3 ?k_4 ?k_5) math:sum ?l .
       (10 ?m) math:exponentiation ?l .
       (-10 ?m) math:product ?n
  }
  =>
  {
       ?x NBNS014001:Ratr ?n
  }.

# Calculate Dneatr
  {
        # Find Required Input 
        ?x EN12354:elementNormalizedSoundLevelDifference_125Hz ?D125 .
        ?x EN12354:elementNormalizedSoundLevelDifference_250Hz ?D250 .
        ?x EN12354:elementNormalizedSoundLevelDifference_500Hz ?D500 .
        ?x EN12354:elementNormalizedSoundLevelDifference_1000Hz ?D1000 .
        ?x EN12354:elementNormalizedSoundLevelDifference_2000Hz ?D2000 .
       
       (-14 ?D125) math:difference ?i_1 .
       (?i_1 10) math:quotient ?j_1 .
       (10 ?j_1) math:exponentiation ?k_1 .
       (-10 ?D250) math:difference ?i_2 .
       (?i_2 10) math:quotient ?j_2 .
       (10 ?j_2) math:exponentiation ?k_2 .
       (-7 ?D500) math:difference ?i_3 .
       (?i_3 10) math:quotient ?j_3 .
       (10 ?j_3) math:exponentiation ?k_3 .
       (-4 ?D1000) math:difference ?i_4 .
       (?i_4 10) math:quotient ?j_4 .
       (10 ?j_4) math:exponentiation ?k_4 .
       (-6 ?D2000) math:difference ?i_5 .
       (?i_5 10) math:quotient ?j_5 .
       (10 ?j_5) math:exponentiation ?k_5 .
       
       (?k_1 ?k_2 ?k_3 ?k_4 ?k_5) math:sum ?l .
       (10 ?m) math:exponentiation ?l .
       (-10 ?m) math:product ?n
  }
  =>
  {
       ?x NBNS014001:Dneatr ?n
  }.
  
  #Calculate VoldoetAanNBNEis
  {
        # Find Required Input 
        ?BE a NBNS014001:Gevelelement .
        ?BE NBNS014001:Ratr ?i1 .
        ?BE NBNS014001:deelVanGevelvlak ?RB .
        ?RB a NBNS014001:Gevelvlak .
        ?RB NBNS014001:Datr ?i2 .
        ?RB NBNS014001:Snetto ?i3 .
        ?RB EN12354:boundaryOfRoom ?R .
        ?R EN12354:volume ?i4 .
        
        #Calculate
        (3 ?i3) math:product ?j1 .
        (?j1 ?i4) math:quotient ?j2 .
        (10 ?j3) math:exponentiation ?j2 .
        (10 ?j3) math:product ?j4 .
        (?i2 3 ?j4) math:sum ?j5 .
        
        ?i1 math:lessThan ?j5 .
  }
  =>
  {
       ?BE NBNS014001:Voldoet "false"^^xsd:boolean
  }.
  
  
  {
        # Find Required Input 
        ?BE a NBNS014001:Gevelelement .
        ?BE NBNS014001:Ratr ?i1 .
        ?BE NBNS014001:deelVanGevelvlak ?RB .
        ?RB a NBNS014001:Gevelvlak .
        ?RB NBNS014001:Datr ?i2 .
        ?RB NBNS014001:Snetto ?i3 .
        ?RB EN12354:boundaryOfRoom ?R .
        ?R EN12354:volume ?i4 .
        
        #Calculate
        (3 ?i3) math:product ?j1 .
        (?j1 ?i4) math:quotient ?j2 .
        (10 ?j3) math:exponentiation ?j2 .
        (10 ?j3) math:product ?j4 .
        (?i2 3 ?j4) math:sum ?j5 .
        
        ?i1 math:notLessThan ?j5 .
  }
  =>
  {
       ?BE NBNS014001:Voldoet "true"^^xsd:boolean
  }.
  
  
  
  
  
  {
        # Find Required Input 
        ?RB a NBNS014001:Gevelvlak .
        ?RB NBNS014001:Datr ?i1 .
        ?RB NBNS014001:La ?i2 .
        ?RB NBNS014001:m-value ?i3 .
        
        #Calculate
        (?i2 -34 ?i3) math:sum ?j1 .
        ?i1 math:notGreaterThan ?j1 .
  }
  =>
  {
       ?RB NBNS014001:ComfortLevel "onvoldoende"^^xsd:string
  }.
  
  {
        # Find Required Input 
        ?RB a NBNS014001:Gevelvlak .
        ?RB NBNS014001:Datr ?i1 .
        ?RB NBNS014001:La ?i2 .
        ?RB NBNS014001:m-value ?i3 .
        
        #Calculate
        (?i2 -34 ?i3) math:sum ?j1 .
        ?i1 math:notGreaterThan 26 .
  }
  =>
  {
       ?RB NBNS014001:ComfortLevel "onvoldoende"^^xsd:string
  }.
  
  
  
  {
        # Find Required Input 
        ?RB a NBNS014001:Gevelvlak .
        ?RB NBNS014001:Datr ?i1 .
        ?RB NBNS014001:La ?i2 .
        ?RB NBNS014001:m-value ?i3 .
        
        #Calculate
        (?i2 -34 ?i3) math:sum ?j1 .
        ?i1 math:notLessThan 26 .
        ?i1 math:notLessThan ?j1 .
  }
  =>
  {
       ?RB NBNS014001:ComfortLevel "normaal"^^xsd:string
  }.
  
  
  {
        # Find Required Input 
        ?RB a NBNS014001:Gevelvlak .
        ?RB NBNS014001:Datr ?i1 .
        ?RB NBNS014001:La ?i2 .
        ?RB NBNS014001:m-value ?i3 .
        
        #Calculate
        (?i2 -30 ?i3) math:sum ?j1 .
        ?i1 math:notLessThan 30 .
        ?i1 math:notLessThan ?j1 .
  }
  =>
  {
       ?RB NBNS014001:ComfortLevel "verhoogd"^^xsd:string
  }.
  

              
              
# ComfortLevel: onvoldoende - normaal - verhoogd
   