{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Tutorial - What you can do" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Author(s):** Santosh Philip" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We am using this tutorial/documentation as a way of identifying alformed API and gaps in the software. When eppy was developed, writing the user documentation forced us to rewrite the software. This documentation is written with the same intent. It is a little easier in the case of eppy3000, since we are trying to mimic eppy using it as a starting point.\n", "\n", "Any places where the word TODO occurs is where we find some recoding has to be done. An issue has to be opened and then resolved." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Quick Start\n", "\n", "Here is a short EPJ file that I’ll be using as an example to start us off\n", "\n" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "::\n", "\n", " {\n", " \"Version\": {\n", " \"Version 1\": {\n", " \"version_identifier\": \"9.3\",\n", " \"idf_order\": 1\n", " }\n", " },\n", " \"SimulationControl\": {\n", " \"SimulationControl 1\": {\n", " \"do_zone_sizing_calculation\": \"Yes\",\n", " \"do_system_sizing_calculation\": \"Yes\",\n", " \"do_plant_sizing_calculation\": \"Yes\",\n", " \"run_simulation_for_sizing_periods\": \"No\",\n", " \"run_simulation_for_weather_file_run_periods\": \"Yes\",\n", " \"idf_order\": 2\n", " }\n", " },\n", " \"Building\": {\n", " \"Empire State Building\": {\n", " \"north_axis\": 30,\n", " \"terrain\": \"City\",\n", " \"loads_convergence_tolerance_value\": 0.04,\n", " \"temperature_convergence_tolerance_value\": 0.4,\n", " \"solar_distribution\": \"FullExterior\",\n", " \"maximum_number_of_warmup_days\": 25,\n", " \"minimum_number_of_warmup_days\": 6,\n", " \"idf_order\": 3\n", " }\n", " },\n", " \"Site:Location\": {\n", " \"CHICAGO_IL_USA TMY2-94846\": {\n", " \"latitude\": 41.78,\n", " \"longitude\": -87.75,\n", " \"time_zone\": -6,\n", " \"elevation\": 190,\n", " \"idf_order\": 4\n", " }\n", " }\n", " }" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To use eppy3000 to look at this model, we have to run a little code first:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# you would normaly install eppy3000 by doing\n", "# python setup.py install\n", "# or\n", "# pip install eppy3000\n", "# or\n", "# easy_install eppy3000\n", "\n", "# if you have not done so, uncomment the following three lines\n", "import sys\n", "# pathnameto_eppy = 'c:/eppy3000'\n", "pathnameto_eppy3000 = '../'\n", "sys.path.append(pathnameto_eppy3000)\n", "\n", "from eppy3000.modelmaker import EPJ\n", "schema_file = \"../eppy3000/resources/schema/V9_3/Energy+.schema.epJSON\"\n", "ep_file = \"../eppy3000/resources/epJSON/V9_3/smallfile.epJSON\"" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "epj = EPJ(epjname=ep_file, epschemaname=schema_file)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Version !- EP_KEY # use .eppykey\n", " Version 1 !- EPJOBJECT_NAME # use .eppyname\n", " 9.3 !- version_identifier\n", " 1 !- idf_order\n", "\n", "SimulationControl !- EP_KEY # use .eppykey\n", " SimulationControl 1 !- EPJOBJECT_NAME # use .eppyname\n", " Yes !- do_zone_sizing_calculation\n", " Yes !- do_system_sizing_calculation\n", " Yes !- do_plant_sizing_calculation\n", " No !- run_simulation_for_sizing_periods\n", " Yes !- run_simulation_for_weather_file_run_periods\n", " 2 !- idf_order\n", "\n", "Building !- EP_KEY # use .eppykey\n", " Empire State Building !- EPJOBJECT_NAME # use .eppyname\n", " 30 !- north_axis\n", " City !- terrain\n", " 0.04 !- loads_convergence_tolerance_value\n", " 0.4 !- temperature_convergence_tolerance_value\n", " FullExterior !- solar_distribution\n", " 25 !- maximum_number_of_warmup_days\n", " 6 !- minimum_number_of_warmup_days\n", " 3 !- idf_order\n", "\n", "Site:Location !- EP_KEY # use .eppykey\n", " CHICAGO_IL_USA TMY2-94846 !- EPJOBJECT_NAME # use .eppyname\n", " 41.78 !- latitude\n", " -87.75 !- longitude\n", " -6 !- time_zone\n", " 190 !- elevation\n", " 4 !- idf_order\n" ] } ], "source": [ "print(epj)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Looks like the same file as before, except that it is written in the idf format\n", "\n", "As you can see, this file has four objects:\n", "\n", "- Version\n", "- SimulationControl\n", "- Building\n", "- Site:Location\n", "\n", "You may notice some weird fields like ``EP_KEY`` and ``EPJOBJECT_NAME``\n", "\n", "Let us look at the ``Version`` object and tease out what is going on" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The ``EPjson`` for ``version`` object looks like this:" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "::\n", "\n", " {\n", " \"Version\": {\n", " \"Version 1\": {\n", " \"version_identifier\": \"9.3\",\n", " \"idf_order\": 1\n", " }\n", " },\n", "\n", " ... ...\n", " More objects below\n", " }" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "But ``eppy3000`` prints it like this" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "::\n", "\n", " Version !- EP_KEY # use .eppykey\n", " Version 1 !- EPJOBJECT_NAME # use .eppyname\n", " 9.3 !- version_identifier\n", " 1 !- idf_order\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "E+ and ``eppy3000`` see the E+ objects slightly differently.\n", "\n", "- Eppy3000 sees each object as having fields\n", "- E+ and EPjson see each object as key-value pairs\n", "\n", "If you stare at the above representation in ``EPjson`` and ``eppy3000`` you will see how they are different and how they work.\n", "\n", "Let us play with the ``eppy3000`` version\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Version !- EP_KEY # use .eppykey\n", " Version 1 !- EPJOBJECT_NAME # use .eppyname\n", " 9.3 !- version_identifier\n", " 1 !- idf_order\n" ] } ], "source": [ "versions = epj.epobjects[\"Version\"]\n", "version = versions[0]\n", "print(version)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Version\n" ] } ], "source": [ "print(version.eppykey)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Version 1\n" ] } ], "source": [ "print(version.eppyname)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "9.3\n" ] } ], "source": [ "print(version.version_identifier)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1\n" ] } ], "source": [ "print(version.idf_order)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "TODO: test what happens when user changes ``eppykey`` and ``eppyname``" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us do the same with the ``EPjson`` object. Let us treat it as a pure ``json`` object" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " {\n", " \"Version\": {\n", " \"Version 1\": {\n", " \"version_identifier\": \"9.3\",\n", " \"idf_order\": 1\n", " }\n", " }\n", "\n", " }\n" ] } ], "source": [ "import json\n", "\n", "jsonstr = \"\"\" {\n", " \"Version\": {\n", " \"Version 1\": {\n", " \"version_identifier\": \"9.3\",\n", " \"idf_order\": 1\n", " }\n", " }\n", "\n", " }\"\"\"\n", "\n", "print(jsonstr)" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'Version': {'Version 1': {'version_identifier': '9.3', 'idf_order': 1}}}\n" ] } ], "source": [ "epjson = json.loads(jsonstr)\n", "print(epjson)" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'Version 1': {'version_identifier': '9.3', 'idf_order': 1}}\n" ] } ], "source": [ "ep_versions = epjson[\"Version\"]\n", "print(ep_versions)" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'version_identifier': '9.3', 'idf_order': 1}\n" ] } ], "source": [ "ep_version = ep_versions[\"Version 1\"]\n", "print(ep_version)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "9.3\n" ] } ], "source": [ "print(ep_version[\"version_identifier\"])" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1\n" ] } ], "source": [ "print(ep_version[\"idf_order\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Do you notice how much easier it is to operate with the ``eppy3000`` than direclty with the ``json`` structure of ``EPjson``" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So, let us look take a closer look at the BUILDING object. We can do this using this command:" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "print(epjfile.epobjects['OBJECTNAME'])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[\n", "Building !- EP_KEY # use .eppykey\n", " Empire State Building !- EPJOBJECT_NAME # use .eppyname\n", " 30 !- north_axis\n", " City !- terrain\n", " 0.04 !- loads_convergence_tolerance_value\n", " 0.4 !- temperature_convergence_tolerance_value\n", " FullExterior !- solar_distribution\n", " 25 !- maximum_number_of_warmup_days\n", " 6 !- minimum_number_of_warmup_days\n", " 3 !- idf_order]\n" ] } ], "source": [ "print(epj.epobjects['Building']) # put the name of the object you'd like to look at in brackets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also zoom in on the object and look just at its individual parts.\n", "\n", "For example, let us look at the name of the building.\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "building = epj.epobjects['Building'][0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we can do this:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Empire State Building'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "building.eppyname" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that we’ve isolated the building name, we can change it." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "building.eppyname = \"Taj Mahal\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Did this actually change the name in the model ? Let us print the entire model and see." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Version !- EP_KEY # use .eppykey\n", " Version 1 !- EPJOBJECT_NAME # use .eppyname\n", " 9.3 !- version_identifier\n", " 1 !- idf_order\n", "\n", "SimulationControl !- EP_KEY # use .eppykey\n", " SimulationControl 1 !- EPJOBJECT_NAME # use .eppyname\n", " Yes !- do_zone_sizing_calculation\n", " Yes !- do_system_sizing_calculation\n", " Yes !- do_plant_sizing_calculation\n", " No !- run_simulation_for_sizing_periods\n", " Yes !- run_simulation_for_weather_file_run_periods\n", " 2 !- idf_order\n", "\n", "Building !- EP_KEY # use .eppykey\n", " Taj Mahal !- EPJOBJECT_NAME # use .eppyname\n", " 30 !- north_axis\n", " City !- terrain\n", " 0.04 !- loads_convergence_tolerance_value\n", " 0.4 !- temperature_convergence_tolerance_value\n", " FullExterior !- solar_distribution\n", " 25 !- maximum_number_of_warmup_days\n", " 6 !- minimum_number_of_warmup_days\n", " 3 !- idf_order\n", "\n", "Site:Location !- EP_KEY # use .eppykey\n", " CHICAGO_IL_USA TMY2-94846 !- EPJOBJECT_NAME # use .eppyname\n", " 41.78 !- latitude\n", " -87.75 !- longitude\n", " -6 !- time_zone\n", " 190 !- elevation\n", " 4 !- idf_order\n" ] } ], "source": [ "print(epj)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Yes! It did. So now you have a taste of what eppy can do. Let’s get started!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Modifying EPJ Fields" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "That was just a quick example – we were showing off. Let’s look a little closer.\n", "\n", "As you might have guessed, changing an EPJ field follows this structure:" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "``object.fieldname = \"New Field Name\"``" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plugging the object name (building), the field name (Name) and our new field name (“Empire State Building”) into this command gave us this:" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "``object.fieldname = \"New Field Name\"``" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "But how did we know that “Name” is one of the fields in the object “building”?\n", "\n", "Are there other fields?\n", "\n", "What are they called?" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "# TODO: need to implement the function fieldnames()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Python lesson 1: lists\n", "\n", "do this later ?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## How many items in the list\n", "\n", "Do this later" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Saving an epj file\n", "\n", "This is easy:" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "::\n", "\n", " epj.save()\n", " # OR\n", " epj.saveas(\"newname.epJSON\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Working with E+ objects\n", "\n", "Let us open a small epj file that has only “CONSTRUCTION” and “MATERIAL” objects in it. You can go into “../eppy3000/resources/epJSON/V9_3/constructions.epJSON” and take a look at the file. We are not printing it here because it is too big.\n", "\n", "So let us open it using the idfreader -" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "from eppy3000 import modelmaker\n", "from eppy3000.modelmaker import EPJ\n", "\n", "\n", "fname = \"../eppy3000/resources/epJSON/V9_3/constructions.epJSON\"\n", "epschemaname =\"../eppy3000/resources/schema/V9_0/Energy+.schema.epJSON\"\n", "\n", "\n", "epj = EPJ(fname, epschemaname)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us print all the “MATERIAL” objects in this model." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[\n", "Material !- EP_KEY # use .eppykey\n", " F08 Metal surface !- EPJOBJECT_NAME # use .eppyname\n", " Smooth !- roughness\n", " 0.0008 !- thickness\n", " 45.28 !- conductivity\n", " 7824 !- density\n", " 500 !- specific_heat\n", " 2 !- idf_order, \n", "Material !- EP_KEY # use .eppykey\n", " I01 25mm insulation board !- EPJOBJECT_NAME # use .eppyname\n", " MediumRough !- roughness\n", " 0.0254 !- thickness\n", " 0.03 !- conductivity\n", " 43 !- density\n", " 1210 !- specific_heat\n", " 3 !- idf_order, \n", "Material !- EP_KEY # use .eppykey\n", " I02 50mm insulation board !- EPJOBJECT_NAME # use .eppyname\n", " MediumRough !- roughness\n", " 0.0508 !- thickness\n", " 0.03 !- conductivity\n", " 43 !- density\n", " 1210 !- specific_heat\n", " 4 !- idf_order, \n", "Material !- EP_KEY # use .eppykey\n", " G01a 19mm gypsum board !- EPJOBJECT_NAME # use .eppyname\n", " MediumSmooth !- roughness\n", " 0.019 !- thickness\n", " 0.16 !- conductivity\n", " 800 !- density\n", " 1090 !- specific_heat\n", " 5 !- idf_order, \n", "Material !- EP_KEY # use .eppykey\n", " M11 100mm lightweight concrete !- EPJOBJECT_NAME # use .eppyname\n", " MediumRough !- roughness\n", " 0.1016 !- thickness\n", " 0.53 !- conductivity\n", " 1280 !- density\n", " 840 !- specific_heat\n", " 6 !- idf_order, \n", "Material !- EP_KEY # use .eppykey\n", " F16 Acoustic tile !- EPJOBJECT_NAME # use .eppyname\n", " MediumSmooth !- roughness\n", " 0.0191 !- thickness\n", " 0.06 !- conductivity\n", " 368 !- density\n", " 590 !- specific_heat\n", " 7 !- idf_order, \n", "Material !- EP_KEY # use .eppykey\n", " M01 100mm brick !- EPJOBJECT_NAME # use .eppyname\n", " MediumRough !- roughness\n", " 0.1016 !- thickness\n", " 0.89 !- conductivity\n", " 1920 !- density\n", " 790 !- specific_heat\n", " 8 !- idf_order, \n", "Material !- EP_KEY # use .eppykey\n", " M15 200mm heavyweight concrete !- EPJOBJECT_NAME # use .eppyname\n", " MediumRough !- roughness\n", " 0.2032 !- thickness\n", " 1.95 !- conductivity\n", " 2240 !- density\n", " 900 !- specific_heat\n", " 9 !- idf_order, \n", "Material !- EP_KEY # use .eppykey\n", " M05 200mm concrete block !- EPJOBJECT_NAME # use .eppyname\n", " MediumRough !- roughness\n", " 0.2032 !- thickness\n", " 1.11 !- conductivity\n", " 800 !- density\n", " 920 !- specific_heat\n", " 10 !- idf_order, \n", "Material !- EP_KEY # use .eppykey\n", " G05 25mm wood !- EPJOBJECT_NAME # use .eppyname\n", " MediumSmooth !- roughness\n", " 0.0254 !- thickness\n", " 0.15 !- conductivity\n", " 608 !- density\n", " 1630 !- specific_heat\n", " 11 !- idf_order]\n" ] } ], "source": [ "materials = epj.epobjects[\"Material\"]\n", "print(materials)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As you can see, there are many material objects in this epj file.\n", "\n", "The variable “materials” now contains a list of “MATERIAL” objects.\n", "\n", "You already know a little about lists, so let us take a look at the items in this list." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "firstmaterial = materials[0]\n", "secondmaterial = materials[1]" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Material !- EP_KEY # use .eppykey\n", " F08 Metal surface !- EPJOBJECT_NAME # use .eppyname\n", " Smooth !- roughness\n", " 0.0008 !- thickness\n", " 45.28 !- conductivity\n", " 7824 !- density\n", " 500 !- specific_heat\n", " 2 !- idf_order\n" ] } ], "source": [ "print(firstmaterial)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us print secondmaterial" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Material !- EP_KEY\n", " I01 25mm insulation board !- EPJOBJECT_NAME\n", " MediumRough !- roughness\n", " 0.0254 !- thickness\n", " 0.03 !- conductivity\n", " 43 !- density\n", " 1210 !- specific_heat\n", " 3 !- idf_order\n" ] } ], "source": [ "print(secondmaterial)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is awesome!! Why?\n", "\n", "To understand what you can do with your objects organized as lists, you’ll have to learn a little more about lists." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Python lesson 2: more about lists" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### More ways to access items in a list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Do this later" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Continuing to work with E+ objects" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us get those “MATERIAL” objects again" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "materials = epj.epobjects[\"Material\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With our newfound knowledge of lists, we can do a lot of things.\n", "\n", "Let us get the last material:" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Material !- EP_KEY\n", " G05 25mm wood !- EPJOBJECT_NAME\n", " MediumSmooth !- roughness\n", " 0.0254 !- thickness\n", " 0.15 !- conductivity\n", " 608 !- density\n", " 1630 !- specific_heat\n", " 11 !- idf_order\n" ] } ], "source": [ "print(materials[-1])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "How about the last two?" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[\n", "Material !- EP_KEY\n", " M05 200mm concrete block !- EPJOBJECT_NAME\n", " MediumRough !- roughness\n", " 0.2032 !- thickness\n", " 1.11 !- conductivity\n", " 800 !- density\n", " 920 !- specific_heat\n", " 10 !- idf_order, \n", "Material !- EP_KEY\n", " G05 25mm wood !- EPJOBJECT_NAME\n", " MediumSmooth !- roughness\n", " 0.0254 !- thickness\n", " 0.15 !- conductivity\n", " 608 !- density\n", " 1630 !- specific_heat\n", " 11 !- idf_order]\n" ] } ], "source": [ "print(materials[-2:])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "More stuff to do later" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Python lesson 3: indentation and looping through lists" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Do later" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Looping through E+ objects" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you have read the python explanation of loops, you are now masters of using loops.\n", "\n", "Let us use the loops with E+ objects.\n", "\n", "We’ll continue to work with the materials list." ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "F08 Metal surface\n", "I01 25mm insulation board\n", "I02 50mm insulation board\n", "G01a 19mm gypsum board\n", "M11 100mm lightweight concrete\n", "F16 Acoustic tile\n", "M01 100mm brick\n", "M15 200mm heavyweight concrete\n", "M05 200mm concrete block\n", "G05 25mm wood\n" ] } ], "source": [ "for material in materials:\n", " print(material.eppyname)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['F08 Metal surface',\n", " 'I01 25mm insulation board',\n", " 'I02 50mm insulation board',\n", " 'G01a 19mm gypsum board',\n", " 'M11 100mm lightweight concrete',\n", " 'F16 Acoustic tile',\n", " 'M01 100mm brick',\n", " 'M15 200mm heavyweight concrete',\n", " 'M05 200mm concrete block',\n", " 'G05 25mm wood']" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[material.eppyname for material in materials]" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Smooth',\n", " 'MediumRough',\n", " 'MediumRough',\n", " 'MediumSmooth',\n", " 'MediumRough',\n", " 'MediumSmooth',\n", " 'MediumRough',\n", " 'MediumRough',\n", " 'MediumRough',\n", " 'MediumSmooth']" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[material.roughness for material in materials]" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[0.1016, 0.1016, 0.2032, 0.2032]" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[material.thickness for material in materials if material.thickness > 0.1]" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['M11 100mm lightweight concrete',\n", " 'M01 100mm brick',\n", " 'M15 200mm heavyweight concrete',\n", " 'M05 200mm concrete block']" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[material.eppyname for material in materials if material.thickness > 0.1]\n" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "thick_materials = [material for material in materials if material.thickness > 0.1]" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[\n", " Material !- EP_KEY\n", " M11 100mm lightweight concrete !- EPJOBJECT_NAME\n", " MediumRough !- roughness\n", " 0.1016 !- thickness\n", " 0.53 !- conductivity\n", " 1280 !- density\n", " 840 !- specific_heat\n", " 6 !- idf_order,\n", " \n", " Material !- EP_KEY\n", " M01 100mm brick !- EPJOBJECT_NAME\n", " MediumRough !- roughness\n", " 0.1016 !- thickness\n", " 0.89 !- conductivity\n", " 1920 !- density\n", " 790 !- specific_heat\n", " 8 !- idf_order,\n", " \n", " Material !- EP_KEY\n", " M15 200mm heavyweight concrete !- EPJOBJECT_NAME\n", " MediumRough !- roughness\n", " 0.2032 !- thickness\n", " 1.95 !- conductivity\n", " 2240 !- density\n", " 900 !- specific_heat\n", " 9 !- idf_order,\n", " \n", " Material !- EP_KEY\n", " M05 200mm concrete block !- EPJOBJECT_NAME\n", " MediumRough !- roughness\n", " 0.2032 !- thickness\n", " 1.11 !- conductivity\n", " 800 !- density\n", " 920 !- specific_heat\n", " 10 !- idf_order]" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "thick_materials" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "# change the names of the thick materials\n", "for material in thick_materials:\n", " material.eppyname = \"THICK \" + material.eppyname" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[\n", " Material !- EP_KEY\n", " THICK M11 100mm lightweight concrete !- EPJOBJECT_NAME\n", " MediumRough !- roughness\n", " 0.1016 !- thickness\n", " 0.53 !- conductivity\n", " 1280 !- density\n", " 840 !- specific_heat\n", " 6 !- idf_order,\n", " \n", " Material !- EP_KEY\n", " THICK M01 100mm brick !- EPJOBJECT_NAME\n", " MediumRough !- roughness\n", " 0.1016 !- thickness\n", " 0.89 !- conductivity\n", " 1920 !- density\n", " 790 !- specific_heat\n", " 8 !- idf_order,\n", " \n", " Material !- EP_KEY\n", " THICK M15 200mm heavyweight concrete !- EPJOBJECT_NAME\n", " MediumRough !- roughness\n", " 0.2032 !- thickness\n", " 1.95 !- conductivity\n", " 2240 !- density\n", " 900 !- specific_heat\n", " 9 !- idf_order,\n", " \n", " Material !- EP_KEY\n", " THICK M05 200mm concrete block !- EPJOBJECT_NAME\n", " MediumRough !- roughness\n", " 0.2032 !- thickness\n", " 1.11 !- conductivity\n", " 800 !- density\n", " 920 !- specific_heat\n", " 10 !- idf_order]" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "thick_materials" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Do the rest later" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Geometry functions in eppy3000" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "No geometry functions yet in eppy3000\n", "\n", "TODO: Add geometry functions" ] } ], "metadata": { "celltoolbar": "Raw Cell Format", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 4 }