mabuseif commited on
Commit
9fbcca7
·
verified ·
1 Parent(s): 1030edf

Update app/internal_loads.py

Browse files
Files changed (1) hide show
  1. app/internal_loads.py +14 -30
app/internal_loads.py CHANGED
@@ -308,29 +308,13 @@ def display_lighting_tab():
308
  help="Lighting power density in watts per square meter."
309
  )
310
 
311
- # Heat fractions
312
- st.write("**Heat Distribution:**")
313
- col_rad, col_conv = st.columns(2)
314
-
315
- with col_rad:
316
- radiative_fraction = st.number_input(
317
- "Radiative Fraction",
318
- min_value=0.0,
319
- max_value=1.0,
320
- value=float(editor_state.get("radiative_fraction", 0.4)),
321
- format="%.2f",
322
- help="Fraction of heat released as radiation."
323
- )
324
-
325
- with col_conv:
326
- convective_fraction = st.number_input(
327
- "Convective Fraction",
328
- min_value=0.0,
329
- max_value=1.0,
330
- value=float(editor_state.get("convective_fraction", 0.6)),
331
- format="%.2f",
332
- help="Fraction of heat released as convection."
333
- )
334
 
335
  # Schedule selection
336
  available_schedules = list(st.session_state.project_data["internal_loads"]["schedules"].keys())
@@ -356,15 +340,15 @@ def display_lighting_tab():
356
  if not name.strip():
357
  st.error("System name is required.")
358
  return
359
- if abs(radiative_fraction + convective_fraction - 1.0) > 0.01:
360
- st.error("Radiative and convective fractions must sum to 1.0")
361
- return
362
  # Check for unique name
363
  existing_names = [system["name"] for system in lighting_systems if not (is_edit and system["name"] == editor_state.get("name"))]
364
  if name.strip() in existing_names:
365
  st.error("System name must be unique.")
366
  return
367
 
 
 
 
368
  # Create lighting system data
369
  lighting_data = {
370
  "id": str(uuid.uuid4()),
@@ -372,8 +356,9 @@ def display_lighting_tab():
372
  "area": area,
373
  "lpd": lpd,
374
  "total_power": area * lpd,
375
- "radiative_fraction": radiative_fraction,
376
- "convective_fraction": convective_fraction,
 
377
  "schedule": schedule
378
  }
379
 
@@ -1016,8 +1001,7 @@ def display_lighting_table(lighting_systems: List[Dict[str, Any]]):
1016
  "name": system.get("name", ""),
1017
  "area": system.get("area", 100.0),
1018
  "lpd": system.get("lpd", 12.0),
1019
- "radiative_fraction": system.get("radiative_fraction", 0.4),
1020
- "convective_fraction": system.get("convective_fraction", 0.6),
1021
  "schedule": system.get("schedule", "Continuous"),
1022
  "is_edit": True
1023
  }
 
308
  help="Lighting power density in watts per square meter."
309
  )
310
 
311
+ # Lighting type
312
+ lighting_type = st.selectbox(
313
+ "Lighting Type",
314
+ list(LIGHTING_FIXTURE_TYPES.keys()),
315
+ index=list(LIGHTING_FIXTURE_TYPES.keys()).index(editor_state.get("lighting_type", list(LIGHTING_FIXTURE_TYPES.keys())[0])) if editor_state.get("lighting_type") in LIGHTING_FIXTURE_TYPES else 0,
316
+ help="Select the type of lighting fixture."
317
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
 
319
  # Schedule selection
320
  available_schedules = list(st.session_state.project_data["internal_loads"]["schedules"].keys())
 
340
  if not name.strip():
341
  st.error("System name is required.")
342
  return
 
 
 
343
  # Check for unique name
344
  existing_names = [system["name"] for system in lighting_systems if not (is_edit and system["name"] == editor_state.get("name"))]
345
  if name.strip() in existing_names:
346
  st.error("System name must be unique.")
347
  return
348
 
349
+ # Get lighting fixture data
350
+ fixture_data = LIGHTING_FIXTURE_TYPES[lighting_type]
351
+
352
  # Create lighting system data
353
  lighting_data = {
354
  "id": str(uuid.uuid4()),
 
356
  "area": area,
357
  "lpd": lpd,
358
  "total_power": area * lpd,
359
+ "lighting_type": lighting_type,
360
+ "radiative_fraction": fixture_data["radiative"] / 100.0,
361
+ "convective_fraction": fixture_data["convective"] / 100.0,
362
  "schedule": schedule
363
  }
364
 
 
1001
  "name": system.get("name", ""),
1002
  "area": system.get("area", 100.0),
1003
  "lpd": system.get("lpd", 12.0),
1004
+ "lighting_type": system.get("lighting_type", list(LIGHTING_FIXTURE_TYPES.keys())[0]),
 
1005
  "schedule": system.get("schedule", "Continuous"),
1006
  "is_edit": True
1007
  }