BIM2SIM / bim2sim

A python tool to create simulation models for different domains based on BIM IFC models.
https://bim2sim.github.io/bim2sim/
GNU Lesser General Public License v3.0
42 stars 7 forks source link

understanding the structure of bim2sim #640

Open Cudok opened 3 months ago

Cudok commented 3 months ago

therefore some pictures were generated

Cudok commented 3 months ago

Process for teaser plugin e1 example

flowchart TB

    subgraph PL["`**Plugin**`"]
        default_tasks
        sim_settings
    end

    subgraph IP["`**Configuration**`"]
        X[ifc_paths]
        Y[project directory]

        style X text-align:left
    end

    cPro("Project.create(Configuration, 'teaser')")

    subgraph Init["`**bim2sim __init__.py**`"]
      ex1("run_project() opens playground \n&nbsp&nbsp which runs tasks sequencally \n&nbsp&nbsp part of project.py")
      ex2("def run_project(): &nbsp&nbsp
           handler.handle(project.run(), project.loaded_decisions))
          ")
    end

    subgraph PR["`**bim2sim project.py - run**`"]
      ex5("def run():")
    end

    IP -.-o|input| cPro
    PL-.-o|input| cPro
    cPro -->|create| Init --> PR
    PR -->|default run| PJ
    PR -->|interactive run| PJ

    subgraph PJ["`**Project**`"]
      rd("run_default(): \n&nbsp&nbsp for task in plugin.default_tasks:\n&nbsp&nbsp&nbsp&nbsp      playground.run_task()")
      style rd text-align:left
    end

    subgraph PG["`**Playground**`"]
        C["run_task ()"]
        S[(state)]
        exPG("is Class
              in base.py")
    end

    subgraph TA["`**Tasks**`"]
      D{{Task 1}}
      E{{Task 2}}
      F{{Task n}}

      ex3("tasks to run are defined in
          __init__.py of the plugin
          like
          /plugins/PluginTEASER/
          bim2sim_teaser/__init__.py")
    end

        rd --> C
    C -->|run| D
    D <-.-> |data exchange| S
    C -->|run| E
    E <-.-> |data exchange| S
    C -->|run| F
    F <-.-> |data exchange| S
    D-->E-->F
    S --> |load data|R
    F --> R(Task Export)

    User <---> |decisions| rd
Cudok commented 3 months ago

task create elements of the teaser plugin

flowchart TB
cE("common.CreateElements;
part of plugin __init__")
cEr("playground calls
     CreateElements.run()")
pF("prepare Filter
    - Typefilter (type_filter.run)
    - Textfiler")
aF("apply Filter on all ifc elements")
cLoE("create a list of elements
      one generic element: factory.create()")
eL(element_lst)
uEO("Update Elements dictionary
    elements.update({inst.guid: inst for inst in element_lst}
    line 116)
")
ifc("ifc data; read in an privious task ")
cE --> cEr --> pF --> aF --> cLoE --> eL --> uEO
ifc --> aF
Cudok commented 3 months ago

generic structure

flowchart TB
Sifc("source: ifc file")
req(requirements)
enr("enrichment")
ETeaserDB("Statitic Infos,
           eg. TEASER")
Filter("Filter by requirements")
get_att("attribute.get_value() >
         see attribute system")

elifc("ifc-elements")
enel("enriched elements")
cR1("required + not available")
req --> Filter

%% general flow
Sifc --> Filter --> get_att --> elifc --> cR1 --> enr  --> enel
ETeaserDB --> enr
elifc --> enel

%% TEASER Simulation
cRTEASER("required + not available")
deciTEASER("decision: User Input")
deciInputTEASER("User Input")
felSimTEASER("final-elements TEASER")
simTEASER(sim TEASER)
enel --> cRTEASER -->deciTEASER -->felSimTEASER -->simTEASER
deciInputTEASER --> deciTEASER
enel --> felSimTEASER

%% EnergyPlus Simulation
cREnergyPlus("required + not available")
deciEnergyPlus("decision: User Input")
deciInputEnergyPlus("User Input")
felSimEnergyPlus("final-elements EnergyPlus")
simEnergyPlus(sim EnergyPlus)
enel --> cREnergyPlus -->deciEnergyPlus -->felSimEnergyPlus -->simEnergyPlus
deciInputEnergyPlus --> deciEnergyPlus
enel --> felSimEnergyPlus

%% CFD Simulation
cRCFD("required + not available")
deciCFD("decision: User Input")
deciInputCFD("User Input")
felSimCFD("final-elements CFD")
simCFD(sim CFD)
enel --> cRCFD -->deciCFD -->felSimCFD -->simCFD
deciInputCFD --> deciCFD
enel --> felSimCFD
Cudok commented 3 months ago

structure elements and attributes

graph LR
  eles(elements)
  el1(element 1)
  atMa(attributeManager 1)
  at1(attribute 1.1)
  at2(attribute 1.2)
  at3(attribute 1.3)
  at4(attribute 1.n)
  eles --- el1 --- atMa
  atMa --- at1
  atMa --- at2
  atMa --- at3
  atMa --- at4

  el2(element 2)
  atMa2(attributeManager 2)
  at21(attribute 2.1)
  at22(attribute 2.2)
  at23(attribute 2.3)
  at2n(attribute 2.n)
  eles --- el2 --- atMa2
  atMa2 --- at21
  atMa2 --- at22
  atMa2 --- at23
  atMa2 --- at2n

  eln(element n)
  atMan(attributeManager n)
  atn1(attribute n.1)
  atn2(attribute n.2)
  atn3(attribute n.3)
  atnn(attribute n.n)
  eles --- eln --- atMan
  atMan --- atn1
  atMan --- atn2
  atMan --- atn3
  atMan --- atnn
Cudok commented 3 months ago

Flowchart attribute system (discussion version)

flowchart TB
gv["_get_value()"]

subgraph "default ifc attribute name"
  da{ifc.attr_name}
  ex_da("look into default ifc attribute name
         and process to raw value")
end

subgraph "default property set"
  ps{default_ps}
  ex_ps("look into default property set
         (get_from_default_propertyset)
         and process to raw value")
end

subgraph "default association"
  as{default_association}
  ex_as("look into default association
         get value via associated names/feature
         (get_from_default_assocation)
         and process to raw value")
end

subgraph "tool specific properties (finder)"
  fi{finder}
  ex_fi("search element object via keywords
         (get_from_finder)
         and process to raw value")
end

subgraph "custom properties by patterns"
  pt{patterns}
  ex_pt("Get value from non default property sets matching patterns
         (get_from_finder >
          select_from_potential_properties)
         and process to raw value")
end

subgraph "custom functions"
  ft{functions}
  ex_ft("call function including specific
         instructions to get the value
         (get_from_functions)
         and process to raw value")
end

subgraph "default value"
  de{default}
  ex_de("get default value, given for every attribute,
         default_value: this value hardcoded in bim2sim
         and process to raw value")
end

re[return value]

gv --> da -->|Value not existing| ps -->|Value not existing| as -->|Value not existing| fi -->|Value not existing| pt -->|Value not existing| ft -->|Value not existing| de

da -->|Value exists| re
ps -->|Value exists| re
as -->|Value exists| re
fi -->|Value exists| re
pt -->|Value exists| re
ft -->|Value exists| re
de --> re
Cudok commented 3 months ago

Teaser Task Structure (date 2024-01-24)

flowchart TB

subgraph "task LoadIFC"
  tli["common.LoadIFC"]
  subgraph reads & touches
    direction LR
    rli[/"None"/]
    toli[\"ifc_files"\]
  end
  extli("reads the IFC files of one or
         multiple domains inside bim2sim")
end

subgraph "task CheckIfc"
  tci["common.CheckIfc"]
  subgraph reads & touches
    direction LR
    rci[/"ifc_files"/]
    toci[\"None"\]
  end
  extci("Check an IFC file, for a number of conditions
         (missing information, incorrect information, etc)
         that could lead on future tasks to fatal errors.
        ")
end

subgraph "task CreateElements"
  tce["common.CreateElements"]
  subgraph reads & touches
    direction LR
    rce[/"ifc_files"/]
    toce[\"ifc_files, elements"\]
  end
  extce("Create bim2sim elements based
         on information in IFC.
        ")
end

subgraph "task CreateSpaceBoundaries"
  tcs["bps.CreateSpaceBoundaries"]
  subgraph reads & touches
    direction LR
    rcs[/"ifc_files, elements"/]
    tocs[\"space_boundaries"\]
  end
  extcs("Create space boundary elements from ifc.
        ")
end

subgraph "task FilterTZ"
  tftz["bps.FilterTZ"]
  subgraph reads & touches
    direction LR
    rftz[/"elements"/]
    toftz[\"tz_elements"\]
  end
  extftz("Filters the thermal zones for later usage and stores them in state.
        ")
end

subgraph "task ProcessSlabsRoofs"
  tpsr["bps.ProcessSlabsRoofs"]
  subgraph reads & touches
    direction LR
    rpsr[/"elements"/]
    topsr[\"elements"\]
  end
  extpsr("Handles decomposed roofs and wrong slab elements.
        ")
end

subgraph "task BindStoreys"
  tbs["common.BindStoreys"]
  subgraph reads & touches
    direction LR
    rbs[/"elements"/]
    tobs[\"elements"\]
  end
  extbs("Bind thermal_zones and elements to
          each floor/storey and vice versa
        ")
end

subgraph "task EnrichUseConditions"
  teuc["bps.EnrichUseConditions"]
  subgraph reads & touches
    direction LR
    reuc[/"tz_elements"/]
    toeuc[\"enriched_tz"\]
  end
  exteuc("Enriches Use Conditions of thermal zones
          based on decisions and translation of zone names
        ")
end

subgraph "task VerifyLayersMaterials"
  tvlm["bps.VerifyLayersMaterials"]
  subgraph reads & touches
    direction LR
    rvlm[/"elements"/]
    tovlm[\"invalid"\]
  end
  extvlm("Verifies if layers and materials and their properties are meaningful.
        ")
end

subgraph "task EnrichMaterial"
  tem["bps.EnrichMaterial"]
  subgraph reads & touches
    direction LR
    rem[/"elements, invalid"/]
    toem[\"elements"\]
  end
  extem("Enriches material properties that were recognized as invalid
         LOD.layers = Medium & Full
        ")
end

subgraph "task DisaggregationCreation"
  tdc["bps.DisaggregationCreation"]
  subgraph reads & touches
    direction LR
    rdc[/"elements"/]
    todc[\"disaggregations"\]
  end
  extdc("Disaggregates building elements based on their space boundaries.

         This task is needed to allow the later combination for thermal zones. If two
         thermal zones are combined to one, we might need to cut/disaggregate
         elements like walls into pieces that belong to the different zones.
        ")
end

subgraph "task CombineThermalZones"
  tctz[" bps.CombineThermalZones"]
  subgraph reads & touches
    direction LR
    rctz[/"tz_elements, elements"/]
    toctz[\"bounded_tz"\]
  end
  extctz("Combine thermal zones to reduce the amount of thermal zones.

          As the zoning of simulation models is a time-consuming task we decided to
          automate it with the tasks.
          This task will combine multiple thermal zones into one zone based on the
          criteria selected in the simulation type settings and the decisions made.
          We do this by giving the user multiple criteria to select from:
           * External/Internal
           * Orientation
           * Usage
           * Window to wall ratio
       ")
end

subgraph "task Weather"
  tw["common.Weather"]
  subgraph reads & touches
    direction LR
    rw[/"elements"/]
    tow[\"weather_file"\]
  end
  extw("Task to get the weather file for later simulation.
       ")
end

subgraph "task LoadLibrariesTEASER"
  tllt["LoadLibrariesTEASER"]
  subgraph reads & touches
    direction LR
    rllt[/"None"/]
    tollt[\"libraries"\]
  end
  extllt("Load AixLib library for export.
       ")
end

subgraph "task CreateTEASER"
  tct["teaser_task.CreateTEASER"]
  subgraph reads & touches
    direction LR
    rct[/"libraries, elements, weather_file"/]
    toct[\"teaser_prj, bldg_names, orig_heat_loads, orig_cool_loads, tz_mapping"\]
  end
  extct("Creates a TEASER project by using the found information from IFC.
       ")
end

subgraph "task ExportTEASER"
  tet["teaser_task.ExportTEASER"]
  subgraph reads & touches
    direction LR
    ret[/"teaser_prj"/]
    toet[\"teaser_prj"\]
  end
  extet("Exports the previous created TEASER project to Modelica.
       ")
end

subgraph "task SimulateModelEBCPy"
  tsme["teaser_task.SimulateModelEBCPy"]
  subgraph reads & touches
    direction LR
    rsme[/"bldg_names"/]
    tosme[\"teaser_mat_result_paths, sim_results_path"\]
  end
  extsme("None
       ")
end

subgraph "task CreateResultDF"
  tcrdf["teaser_task.CreateResultDF"]
  subgraph reads & touches
    direction LR
    rcrdf[/"teaser_mat_result_paths, sim_results_path, tz_mapping"/]
    tocrdf[\"df_finals"\]
  end
  extcrdf("This ITask creates a result dataframe for TEASER BEPS simulations.

    Args:
        teaser_mat_result_paths: path to simulation result file
        tz_mapping: dict with mapping between IFC space GUIDs and rooms/zones
    Returns:
        df_final: final dataframe that holds only relevant data, with generic
        `bim2sim` names and index in form of MM/DD-hh:mm:ss
       ")
end

subgraph "task PlotBEPSResults"
  tpbepsr["bps.PlotBEPSResults"]
  subgraph reads & touches
    direction LR
    rpbepsr[/"df_finals, sim_results_path, ifc_files"/]
    topbepsr[\"None"\]
  end
  extpbepsr("Plots the results for BEPS simulations.

     This holds pre configured functions to plot the results of the BEPS
     simulations with EnergyPlus or TEASER.

     Args:
         df_finals: dict of final results where key is the building name and
          value is the dataframe holding the results for this building
         sim_results_path: path where to store the plots (currently with
          simulation results, maybe change this? #TODO
         ifc_files: bim2sim IfcFileClass holding the ifcopenshell ifc instance
       ")
end

tli --> tci --> tce --> tcs --> tftz --> tpsr --> tbs --> teuc --> tvlm --> tem --> tdc --> tctz --> tw --> tllt --> tct --> tet --> tsme --> tcrdf --> tpbepsr
DaJansenGit commented 2 weeks ago

see #652