Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
1

How to add fields to an object in idf file

asked 2023-12-29 10:30:12 -0500

panda rose's avatar

updated 2023-12-29 14:43:22 -0500

I want to add some fields into People, object of a idf file. As I know, eppy can not add fields into an existing object. And, I also tried edit idf file by readline idf file, but filed>

What should I do?

The following is People object

People,
 189.1-2009 - Office - Corridor - CZ4-8 People,    !- Name
 189.1-2009 - Office - Corridor - CZ4-8,    !- Zone or ZoneList or Space or SpaceList Name
 Office Work Occ,          !- Number of People Schedule Name
 People/Area,              !- Number of People Calculation Method
 ,                         !- Number of People
 0.0107639104167097,       !- People per Floor Area
 ,                         !- Floor Area per Person
 0.3,                      !- Fraction Radiant
 ,                         !- Sensible Heat Fraction
 Office Activity;          !- Activity Level Schedule Name

And I want to add some fields after Office Activity; !- Activity Level Schedule Name

 ,                                       !- Carbon Dioxide Generation Rate {m3/s-W},
 ,                                       !- Enable ASHRAE 55 Comfort Warnings,
 ,                                       !- Mean Radiant Temperature Calculation Type
 ,                                       !- Surface Name/Angle Factor List Name,
 ,                                       !- Work Efficiency Schedule Name,
 ,                                       !- Clothing Insulation Calculation Method,
 ,                                       !- Clothing Insulation Calculation Method Schedule Name,
 ,                                       !- Clothing Insulation Schedule Name,
 ,                                       !- Air Velocity Schedule Name,
 Fanger;                             !- Thermal Comfort Model 1 Type

Best Regards;

edit retag flag offensive close merge delete

Comments

I’m sure some one can give a better answer regarding eppy, but if you’re in a pinch I’d search for the idd file in the energyplus directory and add lines to the objects in question, just keep all the formatting straight and you can more or less add as much as you need.

willyJohan's avatar willyJohan  ( 2023-12-31 02:46:01 -0500 )edit

Thank you very much for your comments!

panda rose's avatar panda rose  ( 2024-02-26 19:29:45 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2024-03-06 11:26:06 -0500

santoshphilip's avatar

updated 2024-03-09 11:21:13 -0500

Short answer: eppy CAN add fields into an existing object

Here is some example code on how to do this.

import eppy
from io import StringIO

txt = """
Version, 23.2;

People,
 189.1-2009 - Office - Corridor - CZ4-8 People,    !- Name
 189.1-2009 - Office - Corridor - CZ4-8,    !- Zone or ZoneList or Space or SpaceList Name
 Office Work Occ,          !- Number of People Schedule Name
 People/Area,              !- Number of People Calculation Method
 ,                         !- Number of People
 0.0107639104167097,       !- People per Floor Area
 ,                         !- Floor Area per Person
 0.3,                      !- Fraction Radiant
 ,                         !- Sensible Heat Fraction
 Office Activity;          !- Activity Level Schedule Name"""

idf = eppy.openidf(StringIO(txt))
peoples = idf.idfobjects["people"]
people = peoples[0]
print(people)

## OUTPUT

    People,
        189.1-2009 - Office - Corridor - CZ4-8 People,    !- Name
        189.1-2009 - Office - Corridor - CZ4-8,    !- Zone or ZoneList or Space or SpaceList Name
        Office Work Occ,          !- Number of People Schedule Name
        People/Area,              !- Number of People Calculation Method
        ,                         !- Number of People
        0.0107639104167097,       !- People per Floor Area
        ,                         !- Floor Area per Person
        0.3,                      !- Fraction Radiant
        ,                         !- Sensible Heat Fraction
        Office Activity;          !- Activity Level Schedule Name


# to see all the field names of people
fieldnames = people.fieldnames
for fieldname in fieldnames:
    print(fieldname)

## OUTPUT


    key
    Name
    Zone_or_ZoneList_or_Space_or_SpaceList_Name
    Number_of_People_Schedule_Name
    Number_of_People_Calculation_Method
    Number_of_People
    People_per_Floor_Area
    Floor_Area_per_Person
    Fraction_Radiant
    Sensible_Heat_Fraction
    Activity_Level_Schedule_Name
    Carbon_Dioxide_Generation_Rate
    Enable_ASHRAE_55_Comfort_Warnings
    Mean_Radiant_Temperature_Calculation_Type
    Surface_NameAngle_Factor_List_Name
    Work_Efficiency_Schedule_Name
    Clothing_Insulation_Calculation_Method
    Clothing_Insulation_Calculation_Method_Schedule_Name
    Clothing_Insulation_Schedule_Name
    Air_Velocity_Schedule_Name
    Thermal_Comfort_Model_1_Type
    Thermal_Comfort_Model_2_Type
    Thermal_Comfort_Model_3_Type
    Thermal_Comfort_Model_4_Type
    Thermal_Comfort_Model_5_Type
    Thermal_Comfort_Model_6_Type
    Thermal_Comfort_Model_7_Type
    Ankle_Level_Air_Velocity_Schedule_Name
    Cold_Stress_Temperature_Threshold
    Heat_Stress_Temperature_Threshold


# add a field name, say 'Air_Velocity_Schedule_Name'
people.Air_Velocity_Schedule_Name = "air vel. schedule"

print(people)

## OUTPUT

    People,
        189.1-2009 - Office - Corridor - CZ4-8 People,    !- Name
        189.1-2009 - Office - Corridor - CZ4-8,    !- Zone or ZoneList or Space or SpaceList Name
        Office Work Occ,          !- Number of People Schedule Name
        People/Area,              !- Number of People Calculation Method
        ,                         !- Number of People
        0.0107639104167097,       !- People per Floor Area
        ,                         !- Floor Area per Person
        0.3,                      !- Fraction Radiant
        ,                         !- Sensible Heat Fraction
        Office Activity,          !- Activity Level Schedule Name
        ,                         !- Carbon Dioxide Generation Rate
        ,                         !- Enable ASHRAE 55 Comfort Warnings
        ,                         !- Mean Radiant Temperature Calculation Type
        ,                         !- Surface NameAngle Factor List Name
        ,                         !- Work Efficiency Schedule Name
        ,                         !- Clothing Insulation Calculation Method
        ,                         !- Clothing Insulation Calculation Method Schedule Name
        ,                         !- Clothing Insulation Schedule Name
        air vel. schedule;        !- Air Velocity Schedule Name
edit flag offensive delete link more

Comments

Thank you very much!

panda rose's avatar panda rose  ( 2024-05-20 08:48:38 -0500 )edit
0

answered 2024-03-14 17:24:08 -0500

Hello,

Alternatively, you could use frads, a Python package for EnergyPlus model edits and simulation. You can check out this guide (https://lbnl-eta.github.io/frads/how-...) section 1 and 2 for more details about editing idf.

installation of frads package comes with an installation of the latest EnergyPlus version, so make sure your idf is up-to-date.

!pip install frad

import frads as fr
your_idf_path = "test.idf"
epmodel = fr.load_energyplus_model(your_idf_path)
epmodel.people["name"].number_of_people_schedule_name = schedule_name

save file as json. can use Energyplus -c to convert back to idf if desired.

with open("test.json", "w") as wtr:
    wtr.write(epmodel.model_dump_json(by_alias=True, exclude_none=True))
edit flag offensive delete link more

Comments

Thank you very much !

panda rose's avatar panda rose  ( 2024-05-20 08:48:18 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2023-12-29 10:30:12 -0500

Seen: 510 times

Last updated: Mar 09