Usage — setup

This page covers what you prepare before simulating: the project layout, the materials file and the global configuration. The steps of a simulation are the Quickstart; they run with real results in Usage — 1D (homogeneous layer stacks) and Usage — 2D (hollow blocks and joist-and-block slabs).

Materials file

Material properties are declared in an .ini file. The material name is the section header, and each material takes three keys: k, the thermal conductivity in W/(m·K); rho, the density in kg/m³; and c, the specific heat in J/(kg·K). The keys are case-sensitive, with no Greek letters. Inline comments (# or ;) are allowed. By default the package looks for materials.ini in the working directory; otherwise set eh.config.file.

The file below defines every material used in these docs (Usage — 1D and Usage — 2D), so you can run all the snippets as-is. The values are typical, for illustration; replace them with your own data:

[Adobe]
k   = 0.58    # Thermal conductivity, W/(m·K)
rho = 1500    # Density, kg/m³
c   = 1480    # Specific heat, J/(kg·K)

[Mortero]     ; cement mortar / render
k   = 0.70
rho = 1800
c   = 1000

[Ladrillo]    ; fired-clay brick
k   = 0.85
rho = 1600
c   = 840

[Concreto]    ; structural concrete (topping, hollow block)
k   = 1.80
rho = 2200
c   = 880

[ConcretoAltaDensidad]   ; high-density structural concrete (joist/rib)
k   = 2.00
rho = 2400
c   = 920

[Bovedilla]   ; lightweight filler block
k   = 0.50
rho = 1200
c   = 900

[Yeso]        ; gypsum plaster
k   = 0.37
rho = 900
c   = 1000

[EPS]         ; expanded polystyrene
k   = 0.04
rho = 15
c   = 1400

[Impermeabilizante]   ; asphaltic waterproofing membrane
k   = 0.17
rho = 1100
c   = 1000

Assigning a missing path to config.file raises FileNotFoundError immediately, and the previously loaded materials (and path) are kept untouched. If the default materials.ini is not present in the working directory when EnerHabitat is imported, materials starts empty ({}); solving then fails because the layer materials cannot be resolved. Set config.file before building systems.

Configuration

You can run everything with the defaults; come back to this section when you need to override them. Two objects hold the parameters: config applies to both 1D and 2D (physics and materials), and config2d only to 2D (mesh and convergence). Changing an attribute takes effect for the computations that follow in your notebook or program; nothing is stored on disk, so a new session always starts from the defaults listed here.

config: physics and materials, 1D and 2D

config is shared by every Location, System and System2D in the session.

Attribute Default Description
file "materials.ini" Path to the .ini file with material properties
La 2.5 m Depth of the indoor air volume
Nx 200 Control volumes across the system thickness
ho 13 W/(m²·K) Outdoor film coefficient
hi 8.1 W/(m²·K) Indoor film coefficient for walls (vertical surfaces)
hi_up 9.4 W/(m²·K) Indoor coefficient for roofs, upward heat flow (Tsi < Ti)
hi_down 6.6 W/(m²·K) Indoor coefficient for roofs, downward heat flow (Tsi > Ti, stable stratification)
hi_flow True Roofs select hi_up/hi_down at every time step from the heat-flow direction; False forces the fixed hi on every orientation
dt 10 s (fixed) Time step; not configurable (assignments are ignored)

The film coefficients are the NOM-008-ENER and NOM-020-ENER values. Walls use hi = 8.1 W/(m²·K). Roofs use 9.4 when the heat flows upward and 6.6 when it flows downward (a hot ceiling over cooler air stratifies, and convection is suppressed). By default (hi_flow = True) a roof picks the coefficient at every time step, comparing the indoor-surface temperature (its mean, in 2D) with the indoor-air temperature. A surface counts as a roof when tilt < 60°, the same limit used by EnergyPlus and ISO 6946 (in 2D only 0 and 90 are allowed anyway). To fix a value: hi_flow = False uses hi on every orientation, and hi_up = hi_down = value fixes roofs while walls keep hi. dt is locked because of the explicit indoor-air coupling; see the numerical method.

eh.config.file = "./materials.ini"
eh.config.La = 2.0
eh.config.ho = 12          # override the NOM defaults if needed
eh.config.hi_flow = False  # force the fixed hi on roofs too (e.g. to compare)
eh.config.reset()          # restore the numeric defaults (La, Nx, ho, hi, hi_up,
                           # hi_down, hi_flow, dt, air); config.file / materials
                           # are user-provided and are kept

config.materials is a read-only dict keyed by material name (eh.config.materials["Adobe"].k, .rho, .c).

config2d: 2D mesh and convergence

The physics (La, ho, hi, dt, air properties) comes from config; config2d holds the parameters that only exist in 2D:

Attribute Default Description
nx 80 mesh nodes across the cell width (adiabatic sides)
ny 160 mesh nodes through the thickness (outside → inside)
tol_inner 1e-8 °C inner-step tolerance (max node update and max equation residual)
tol_day 5e-4 °C day-to-day convergence tolerance
max_days 60 cap on the day-to-day iterations
max_inner 10000 cap on inner sweeps per step (hit → converged = False)
from enerhabitat import config2d
config2d.nx, config2d.ny = 120, 160

Each 2D solve is single-threaded. For volume (many configurations), parallelise at the process level: run independent solve() calls in separate processes (multiprocessing, joblib).