Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,46 @@ def set_output_variables(idf: IDF, sim_settings: EnergyPlusSimSettings):
"Surface Window Net Heat Transfer Rate",
Reporting_Frequency="Hourly",
)
idf.newidfobject(
"OUTPUT:VARIABLE",
Variable_Name="Site Solar Azimuth Angle",
Reporting_Frequency="Hourly",
)
idf.newidfobject(
"OUTPUT:VARIABLE",
Variable_Name="Site Solar Altitude Angle",
Reporting_Frequency="Hourly",
)
idf.newidfobject(
"OUTPUT:VARIABLE",
Variable_Name="Site Diffuse Solar Radiation Rate per Area",
Reporting_Frequency="Hourly",
)
idf.newidfobject(
"OUTPUT:VARIABLE",
Variable_Name="Site Direct Solar Radiation Rate per Area",
Reporting_Frequency="Hourly",
)
idf.newidfobject(
"OUTPUT:VARIABLE",
Variable_Name="Site Ground Reflected Solar Radiation Rate per Area[W / m2]",
Reporting_Frequency="Hourly",
)
idf.newidfobject(
"OUTPUT:VARIABLE",
Variable_Name="Site Total Sky Cover",
Reporting_Frequency="Hourly",
)
idf.newidfobject(
"OUTPUT:VARIABLE",
Variable_Name="Surface Window Transmitted Solar Radiation Rate",
Reporting_Frequency="Hourly",
)
idf.newidfobject(
"OUTPUT:VARIABLE",
Variable_Name="Surface Inside Face Solar Radiation Heat Gain Rate per Area",
Reporting_Frequency="Hourly",
)
idf.newidfobject("OUTPUT:DIAGNOSTICS",
Key_1="DisplayAdvancedReportVariables",
Key_2="DisplayExtraWarnings")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,48 @@ fvDOMCoeffs

}

solarLoadCoeffs
{

reflecting
{

nPhi 10;

nTheta 10;

}

sunDirectionModel constant;

sunDirection (0 -1 -1);

spectralDistribution (1);

sunLoadModel constant;

directSolarRad 100;

diffuseSolarRad 0;

solidCoupled false;

wallCoupled true;

useReflectedRays true;

}


useSolarLoad false;

radiation on;

radiationModel fvDOM;

solverFreq 10;


constantAbsorptionEmissionCoeffs
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

#### Request the memory you need for your job.
##SBATCH --mem-per-cpu=2600M
#SBATCH --output=logJOBNAME.txt

### Request processes & nodes
COMP_ACCOUNT
SET_COMP_ACCOUNT
#SBATCH --nodes=NNODES
#SBATCH --ntasks=NPROCS

### Load the required module files
module load GCC/11.3.0
module load OpenMPI/4.1.4
module load OpenFOAM/v2206
LOAD_OPENFOAM_VERSION

### start the OpenFOAM binary in parallel, cf.
blockMesh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

#### Request the memory you need for your job.
##SBATCH --mem-per-cpu=2600M
#SBATCH --output=logJOBNAME.txt

### Request & nodes
COMP_ACCOUNT
SET_COMP_ACCOUNT
#SBATCH --nodes=NNODES
#SBATCH --ntasks=NPROCS

### Load the required module files
module load GCC/11.3.0
module load OpenMPI/4.1.4
module load OpenFOAM/v2206
LOAD_OPENFOAM_VERSION

### start the OpenFOAM binary in parallel, cf.
blockMesh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

#### Request the memory you need for your job.
##SBATCH --mem-per-cpu=2600M
#SBATCH --output=logJOBNAME.txt

### Request & nodes
COMP_ACCOUNT
SET_COMP_ACCOUNT
#SBATCH --nodes=NNODES
#SBATCH --ntasks=NPROCS

### Load the required module files
module load GCC/11.3.0
module load OpenMPI/4.1.4
module load OpenFOAM/v2206
LOAD_OPENFOAM_VERSION

### start the OpenFOAM binary in parallel, cf.
decomposePar -force
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import tempfile
from pathlib import Path

import bim2sim
from bim2sim import Project, run_project, ConsoleDecisionHandler
from bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam import OpenFOAMSimSettings
from bim2sim.project import add_config_section
from bim2sim.kernel.decision.decisionhandler import DebugDecisionHandler
from bim2sim.utilities.types import IFCDomain

def run_example_19():
"""
Prepare an OpenFOAM case with a radiator and solar radiation.

This example runs a BPS with the EnergyPlus backend and a CFD simulation
with the OpenFOAM backend. It specifies project
directory and location of the IFC file. Then, it creates a bim2sim
project with the EnergyPlus backend. Simulation settings are specified
(EnergyPlus location needs to be specified according to your system,
other settings are set to default if not specified otherwise),
before the project is executed with the previously specified settings.

The EnergyPlus simulation is followed by the setup of the OpenFOAM
CFD use case, which bases on the same IFC input as the previously set
up EnergyPlus use case.
"""
# Create a temp directory for the project, feel free to use a "normal"
# directory
project_path = Path(
tempfile.TemporaryDirectory(prefix='bim2sim_openfoam19_').name)

# download additional test resources for arch domain, you might want to set
# force_new to True to update your test resources
# Set the ifc path to use and define which domain the IFC belongs to
ifc_paths = {
IFCDomain.arch:
Path(bim2sim.__file__).parent.parent /
'test/resources/arch/ifc/AC20-FZK-Haus.ifc',
}
project = Project.create(project_path, ifc_paths, 'openfoam')
project.sim_settings.weather_file_path = (
Path(bim2sim.__file__).parent.parent /
'test/resources/weather_files/DEU_NW_Aachen.105010_TMYx.epw')

# Set the install path to your EnergyPlus installation according to your
# system requirements
# project.sim_settings.ep_install_path = 'C://EnergyPlusV9-4-0/'

# Set other simulation settings, otherwise all settings are set to default
project.sim_settings.run_full_simulation = True
project.sim_settings.cfd_export = True
# project.sim_settings.select_space_guid = '3GmoJyFk9FvAnea6mogixJ'
project.sim_settings.select_space_guid = '2RSCzLOBz4FAK$_wE8VckM'
project.sim_settings.simulation_time = 12
project.sim_settings.simulation_date = '01/14'
project.sim_settings.building_rotation_overwrite = 180
project.sim_settings.add_heating = True
project.sim_settings.fixed_faces = []

project.sim_settings.total_iterations = 6000
project.sim_settings.n_procs = 48
project.sim_settings.radiation_model = 'fvDOM'
project.sim_settings.cluster_max_runtime_simulation = "03:59:00"

project.sim_settings.add_solar_radiation = False
project.sim_settings.set_openfoam_source = 'Modified'
project.sim_settings.cluster_jobname = "solar_radiation"

answers = ('Autodesk Revit','Autodesk Revit', *(None,)*13,
*('HVAC-AirTerminal',)*3,
*(None,)*2, 2015)
# Run the project with the ConsoleDecisionHandler. This allows interactive
# input to answer upcoming questions regarding the imported IFC.
run_project(project, DebugDecisionHandler(answers))
# run_project(project, ConsoleDecisionHandler())


if __name__ == '__main__':
run_example_19()
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,13 @@ def __init__(self, playground):
self.internal_gains = None
self.n_procs = playground.sim_settings.n_procs
self.floor_area = None
self.add_solar_radiation = playground.sim_settings.add_solar_radiation
self.building_rotation = (
playground.sim_settings.building_rotation_overwrite)
self.solar_azimuth_angle = None
self.solar_altitude_angle = None
self.solar_hour_angle = None
self.direct_solar_rad = None
self.diffuse_solar_rad = None
self.fixed_faces = playground.sim_settings.fixed_faces
self.timestep_df = None
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@


class StlBound(OpenFOAMBaseBoundaryFields, OpenFOAMBaseElement):
def __init__(self, bound, radiation_model):
def __init__(self, bound, radiation_model, add_solar_radiation, fixed_faces):
super().__init__()
self.radiation_model = radiation_model
self.add_solar_radiation = add_solar_radiation
self.fixed_faces = fixed_faces
self.bound = bound
self.guid = bound.guid
self.bound_element_type = (
Expand Down Expand Up @@ -69,7 +71,8 @@ def set_patch_info_type(self):
else:
pass

def read_boundary_conditions(self, timestep_df, default_temp):
def read_boundary_conditions(self, timestep_df, default_temp,
solar_radiation):
res_key = self.guid.upper() + ':'
if not self.bound.physical:
self.heat_flux = 0
Expand All @@ -94,24 +97,40 @@ def read_boundary_conditions(self, timestep_df, default_temp):
'Rate per Area [W/m2]('
'Hourly)')]
self.heat_flux = prev_heat_flux
if self.add_solar_radiation:
# add load radiation contribution to wall heat fluxes if
# solar radiation is active
self.power += timestep_df[res_key + (
'Surface Inside Face Solar Radiation Heat Gain Rate per '
'Area [W/m2](Hourly)')] * self.bound_area
self.heat_flux += timestep_df[res_key + (
'Surface Inside Face Solar Radiation Heat Gain Rate per Area [W/m2](Hourly)')]
else:
self.heat_flux = (timestep_df[res_key + (
'Surface Window Net Heat Transfer '
'Rate [W](Hourly)')] /
self.bound_area)
self.power = timestep_df[res_key + (
'Surface Window Net Heat Transfer '
'Rate [W](Hourly)')]
# This is the heat flux based on conduction and solar
# radiation. If the transmitted solar radiation part is not
# removed, the window acts as a heat source substituting the
# sun. It is therefore, to get realistic surface temperatures,
# subtracted.
self.power -= timestep_df[res_key + ('Surface Window '
'Transmitted Solar '
'Radiation Rate [W]('
'Hourly)')]
Comment thread
veronikarichter marked this conversation as resolved.
self.heat_flux = (self.power / self.bound_area)

def set_boundary_conditions(self, no_heatloss=False):
if self.radiation_model == 'none':
qr = 'none'
else:
qr = 'qr'
fixed_faces = self.fixed_faces
if not self.add_solar_radiation and 'FLOOR' not in fixed_faces:
fixed_faces.append('FLOOR')
if no_heatloss:
pass
elif any(i for i in ["INNER", "FLOOR"] if i in self.solid_name.upper()):
# else: #
elif any(i for i in fixed_faces if i in self.solid_name.upper()):
self.T = {
'type': 'fixedValue',
'value': f'uniform '
Expand Down
39 changes: 37 additions & 2 deletions bim2sim/plugins/PluginOpenFOAM/bim2sim_openfoam/sim_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ def __init__(self):
'radiation for fvDOM radiation',
for_frontend=True
)
add_solar_radiation=BooleanSetting(
value=True,
add_solar_radiation = BooleanSetting(
value=False,
description='Add solar radiation. Requires fvDOM as radiation model.',
for_frontend=True
)
Expand Down Expand Up @@ -347,3 +347,38 @@ def __init__(self):
description='Number of physical cores per node.',
for_frontend=True
)
set_openfoam_source = ChoiceSetting(
value="Standard",
choices={"Standard": "Use a preinstalled version from the Compute "
"Cluster.",
"Modified": "Use a modified version saved to the rwth1588 "
"account.",
"Custom": "Leaves a dummy path in the run-files which must "
"be replaced manually."},
description='Specify which OpenFOAM version to use, either by choice '
'or by a path.',
for_frontend=True,
any_string=True
)

set_openfoam_version = ChoiceSetting(
value="v2206",
choices={"v2206": "OpenFOAM v2206",
"v2306": "OpenFOAM v2306",
"v2406": "OpenFOAM v2406"},
description='Specify which OpenFOAM version to use.',
for_frontend=True,
)

fixed_faces = ChoiceSetting(
value=['INNER'],
# value=['office', 'meeting', 'canteen', 'sanitary', 'kitchen'],
choices={'': 'No faces have a fixed temperature', 'INNER': 'Inner '
'walls are fixed', 'OUTER': 'Outer walls are fixed',
'FLOOR': 'Floor is fixed', 'CEILING': 'Ceiling is fixed'},
description='Choose faces that have a fixed temperature boundary '
'condition in the OpenFOAM simulation',
multiple_choice=True,
any_string=True,
for_frontend=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ def init_zone(openfoam_case, elements, openfoam_elements,
# remove 2b
openfoam_case.current_bounds += openfoam_case.current_zone.space_boundaries_2B
for bound in openfoam_case.current_bounds:
new_stl_bound = StlBound(bound, openfoam_case.radiation_model)
new_stl_bound = StlBound(bound, openfoam_case.radiation_model,
openfoam_case.add_solar_radiation,
openfoam_case.fixed_faces)
openfoam_elements[new_stl_bound.solid_name] = new_stl_bound
# openfoam_case.stl_bounds.append(new_stl_bound)

Expand Down
Loading