diff --git a/dragonfly_grasshopper/json/DF_Run_Modelica_DES.json b/dragonfly_grasshopper/json/DF_Run_Modelica_DES.json index 2a61ca5..53b044e 100644 --- a/dragonfly_grasshopper/json/DF_Run_Modelica_DES.json +++ b/dragonfly_grasshopper/json/DF_Run_Modelica_DES.json @@ -1,5 +1,5 @@ { - "version": "1.8.2", + "version": "1.8.3", "nickname": "RunDES", "outputs": [ [ @@ -57,7 +57,7 @@ } ], "subcategory": "5 :: District Thermal", - "code": "\nimport os\nimport subprocess\n\ntry:\n from ladybug.futil import nukedir\n from ladybug.config import folders as lb_folders\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry:\n from honeybee.config import folders\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the dragonfly_energy dependencies\n from dragonfly_energy.config import folders as df_folders\n from dragonfly_energy.run import run_des_sys_param, run_des_modelica, \\\n run_modelica_docker\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.download import download_file_by_name\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, give_warning\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\nUO_GMT_VERSION = '0.8.0'\nUO_TN_VERSION = '0.3.0'\nMBL_VERSION = '10.0.0'\n\n\nif all_required_inputs(ghenv.Component) and _write:\n # set up the custom python environment\n custom_env = os.environ.copy()\n custom_env['PYTHONHOME'] = ''\n\n # set global values\n ext = '.exe' if os.name == 'nt' else ''\n executor_path = os.path.join(\n lb_folders.ladybug_tools_folder, '{{plugin}}',\n 'ladybug_{{plugin}}_dotnet', 'Ladybug.Executor.exe')\n\n # check to see if the geojson-modelica-translator is installed\n uo_gmt = '{}/uo_des{}'.format(folders.python_scripts_path, ext)\n uo_gmt_pack = '{}/geojson_modelica_translator-{}.dist-info'.format(\n folders.python_package_path, UO_GMT_VERSION)\n if not os.path.isfile(uo_gmt) or not os.path.isdir(uo_gmt_pack):\n install_cmd = 'pip install geojson-modelica-translator=={}'.format(UO_GMT_VERSION)\n if os.name == 'nt' and os.path.isfile(executor_path) and \\\n 'Program Files' in executor_path:\n pip_cmd = [\n executor_path, folders.python_exe_path, '-m {}'.format(install_cmd)\n ]\n else:\n pip_cmd = '\"{py_exe}\" -m {uo_cmd}'.format(\n py_exe=folders.python_exe_path, uo_cmd=install_cmd)\n shell = True if os.name == 'nt' else False\n process = subprocess.Popen(\n pip_cmd, stderr=subprocess.PIPE, shell=shell, env=custom_env)\n stderr = process.communicate()\n\n # check to see if the ThermalNetwork package is installed\n uo_tn = '{}/thermalnetwork{}'.format(folders.python_scripts_path, ext)\n uo_tn_pack = '{}/ThermalNetwork-{}.dist-info'.format(\n folders.python_package_path, UO_TN_VERSION)\n if not os.path.isfile(uo_tn) or not os.path.isdir(uo_tn_pack):\n install_cmd = 'pip install thermalnetwork=={}'.format(UO_TN_VERSION)\n if os.name == 'nt' and os.path.isfile(executor_path) and \\\n 'Program Files' in executor_path:\n pip_cmd = [\n executor_path, folders.python_exe_path, '-m {}'.format(install_cmd)\n ]\n else:\n pip_cmd = '\"{py_exe}\" -m {uo_cmd}'.format(\n py_exe=folders.python_exe_path, uo_cmd=install_cmd)\n shell = True if os.name == 'nt' else False\n process = subprocess.Popen(\n pip_cmd, stderr=subprocess.PIPE, shell=shell, env=custom_env)\n stderr = process.communicate()\n\n # check to see if the Modelica Buildings Library is installed\n install_directory = os.path.join(lb_folders.ladybug_tools_folder, 'resources')\n final_dir = os.path.join(install_directory, 'mbl')\n version_file = os.path.join(final_dir, 'version.txt')\n already_installed = False\n if os.path.isdir(final_dir) and os.path.isfile(version_file):\n with open(version_file, 'r') as vf:\n install_version = vf.read()\n if install_version == MBL_VERSION:\n already_installed = True\n else:\n nukedir(final_dir, True)\n if not already_installed:\n install_cmd = 'dragonfly_energy install mbl --version {}'.format(MBL_VERSION)\n if os.name == 'nt' and os.path.isfile(executor_path) and \\\n 'Program Files' in executor_path:\n pip_cmd = [\n executor_path, folders.python_exe_path, '-m {}'.format(install_cmd)\n ]\n else:\n pip_cmd = '\"{py_exe}\" -m {uo_cmd}'.format(\n py_exe=folders.python_exe_path, uo_cmd=install_cmd)\n shell = True if os.name == 'nt' else False\n process = subprocess.Popen(\n pip_cmd, stderr=subprocess.PIPE, shell=shell, env=custom_env)\n stderr = process.communicate()\n\n # run the command that adds the building loads to the system parameters\n sys_param = run_des_sys_param(_geojson, _scenario)\n\n # run the command that generates the modelica files\n modelica = run_des_modelica(sys_param, _geojson, _scenario)\n\n # execute the modelica files in URBANopt\n if run_:\n if df_folders.docker_version_str is not None:\n results = run_modelica_docker(modelica)\n else:\n docker_url = 'https://www.docker.com/products/docker-desktop/'\n msg = 'No Docker installation was found on this machine.\\n' \\\n 'This is needed to execute Modelica simulations.\\n' \\\n 'Download Docker Desktop from: {}'.format(docker_url)\n print(msg)\n give_warning(ghenv.Component, msg)\n", + "code": "\nimport os\nimport subprocess\n\ntry:\n from ladybug.futil import nukedir\n from ladybug.config import folders as lb_folders\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry:\n from honeybee.config import folders\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the dragonfly_energy dependencies\n from dragonfly_energy.config import folders as df_folders\n from dragonfly_energy.run import run_des_sys_param, run_des_modelica, \\\n run_modelica_docker\nexcept ImportError as e:\n raise ImportError('\\nFailed to import dragonfly_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.download import download_file_by_name\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, give_warning\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\nUO_GMT_VERSION = '0.8.0'\nUO_TN_VERSION = '0.1.dev194+gddad013'\nMBL_VERSION = '10.0.0'\n\n\nif all_required_inputs(ghenv.Component) and _write:\n # set up the custom python environment\n custom_env = os.environ.copy()\n custom_env['PYTHONHOME'] = ''\n\n # set global values\n ext = '.exe' if os.name == 'nt' else ''\n executor_path = os.path.join(\n lb_folders.ladybug_tools_folder, '{{plugin}}',\n 'ladybug_{{plugin}}_dotnet', 'Ladybug.Executor.exe')\n\n # check to see if the geojson-modelica-translator is installed\n uo_gmt = '{}/uo_des{}'.format(folders.python_scripts_path, ext)\n uo_gmt_pack = '{}/geojson_modelica_translator-{}.dist-info'.format(\n folders.python_package_path, UO_GMT_VERSION)\n if not os.path.isfile(uo_gmt) or not os.path.isdir(uo_gmt_pack):\n install_cmd = 'pip install geojson-modelica-translator=={}'.format(UO_GMT_VERSION)\n if os.name == 'nt' and os.path.isfile(executor_path) and \\\n 'Program Files' in executor_path:\n pip_cmd = [\n executor_path, folders.python_exe_path, '-m {}'.format(install_cmd)\n ]\n else:\n pip_cmd = '\"{py_exe}\" -m {uo_cmd}'.format(\n py_exe=folders.python_exe_path, uo_cmd=install_cmd)\n shell = True if os.name == 'nt' else False\n process = subprocess.Popen(\n pip_cmd, stderr=subprocess.PIPE, shell=shell, env=custom_env)\n stderr = process.communicate()\n\n # check to see if the ThermalNetwork package is installed\n uo_tn = '{}/thermalnetwork{}'.format(folders.python_scripts_path, ext)\n uo_tn_pack = '{}/ThermalNetwork-{}.dist-info'.format(\n folders.python_package_path, UO_TN_VERSION)\n if not os.path.isfile(uo_tn) or not os.path.isdir(uo_tn_pack):\n # install_cmd = 'pip install thermalnetwork=={}'.format(UO_TN_VERSION)\n install_cmd = 'pip install git+https://github.com/chriswmackey/ThermalNetwork'\n if os.name == 'nt' and os.path.isfile(executor_path) and \\\n 'Program Files' in executor_path:\n pip_cmd = [\n executor_path, folders.python_exe_path, '-m {}'.format(install_cmd)\n ]\n else:\n pip_cmd = '\"{py_exe}\" -m {uo_cmd}'.format(\n py_exe=folders.python_exe_path, uo_cmd=install_cmd)\n shell = True if os.name == 'nt' else False\n process = subprocess.Popen(\n pip_cmd, stderr=subprocess.PIPE, shell=shell, env=custom_env)\n stderr = process.communicate()\n\n # check to see if the Modelica Buildings Library is installed\n install_directory = os.path.join(lb_folders.ladybug_tools_folder, 'resources')\n final_dir = os.path.join(install_directory, 'mbl')\n version_file = os.path.join(final_dir, 'version.txt')\n already_installed = False\n if os.path.isdir(final_dir) and os.path.isfile(version_file):\n with open(version_file, 'r') as vf:\n install_version = vf.read()\n if install_version == MBL_VERSION:\n already_installed = True\n else:\n nukedir(final_dir, True)\n if not already_installed:\n install_cmd = 'dragonfly_energy install mbl --version {}'.format(MBL_VERSION)\n if os.name == 'nt' and os.path.isfile(executor_path) and \\\n 'Program Files' in executor_path:\n pip_cmd = [\n executor_path, folders.python_exe_path, '-m {}'.format(install_cmd)\n ]\n else:\n pip_cmd = '\"{py_exe}\" -m {uo_cmd}'.format(\n py_exe=folders.python_exe_path, uo_cmd=install_cmd)\n shell = True if os.name == 'nt' else False\n process = subprocess.Popen(\n pip_cmd, stderr=subprocess.PIPE, shell=shell, env=custom_env)\n stderr = process.communicate()\n\n # run the command that adds the building loads to the system parameters\n sys_param = run_des_sys_param(_geojson, _scenario)\n\n # run the command that generates the modelica files\n modelica = run_des_modelica(sys_param, _geojson, _scenario)\n\n # execute the modelica files in URBANopt\n if run_:\n if df_folders.docker_version_str is not None:\n results = run_modelica_docker(modelica)\n else:\n docker_url = 'https://www.docker.com/products/docker-desktop/'\n msg = 'No Docker installation was found on this machine.\\n' \\\n 'This is needed to execute Modelica simulations.\\n' \\\n 'Download Docker Desktop from: {}'.format(docker_url)\n print(msg)\n give_warning(ghenv.Component, msg)\n", "category": "Dragonfly", "name": "DF Run Modelica DES", "description": "Run a an URBANopt geoJSON and scenario through Modelica Distric Energy System\n(DES) simulation.\n_\nThe geoJSON must have a valid DES Loop assigned to it in order to run correctly\nthrough Modelica DES simulation.\n-" diff --git a/dragonfly_grasshopper/src/DF Run Modelica DES.py b/dragonfly_grasshopper/src/DF Run Modelica DES.py index fd7a98e..10c0139 100644 --- a/dragonfly_grasshopper/src/DF Run Modelica DES.py +++ b/dragonfly_grasshopper/src/DF Run Modelica DES.py @@ -40,7 +40,7 @@ ghenv.Component.Name = 'DF Run Modelica DES' ghenv.Component.NickName = 'RunDES' -ghenv.Component.Message = '1.8.2' +ghenv.Component.Message = '1.8.3' ghenv.Component.Category = 'Dragonfly' ghenv.Component.SubCategory = '5 :: District Thermal' ghenv.Component.AdditionalHelpFromDocStrings = '1' @@ -73,7 +73,7 @@ raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) UO_GMT_VERSION = '0.8.0' -UO_TN_VERSION = '0.3.0' +UO_TN_VERSION = '0.1.dev194+gddad013' MBL_VERSION = '10.0.0' @@ -112,7 +112,8 @@ uo_tn_pack = '{}/ThermalNetwork-{}.dist-info'.format( folders.python_package_path, UO_TN_VERSION) if not os.path.isfile(uo_tn) or not os.path.isdir(uo_tn_pack): - install_cmd = 'pip install thermalnetwork=={}'.format(UO_TN_VERSION) + # install_cmd = 'pip install thermalnetwork=={}'.format(UO_TN_VERSION) + install_cmd = 'pip install git+https://github.com/chriswmackey/ThermalNetwork' if os.name == 'nt' and os.path.isfile(executor_path) and \ 'Program Files' in executor_path: pip_cmd = [ diff --git a/dragonfly_grasshopper/user_objects/DF Run Modelica DES.ghuser b/dragonfly_grasshopper/user_objects/DF Run Modelica DES.ghuser index a579087..84aa620 100644 Binary files a/dragonfly_grasshopper/user_objects/DF Run Modelica DES.ghuser and b/dragonfly_grasshopper/user_objects/DF Run Modelica DES.ghuser differ diff --git a/samples/ghe_example.gh b/samples/ghe_example.gh index b299343..3731b29 100644 Binary files a/samples/ghe_example.gh and b/samples/ghe_example.gh differ diff --git a/samples/ghe_multiple_example.gh b/samples/ghe_multiple_example.gh new file mode 100644 index 0000000..35ae388 Binary files /dev/null and b/samples/ghe_multiple_example.gh differ