Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelduchesne committed Feb 12, 2021
2 parents 66039e8 + 7862d58 commit 9bbe73c
Show file tree
Hide file tree
Showing 82 changed files with 389 additions and 335 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
pytest --cov=trnsystor --cov-report=xml tests/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
31 changes: 31 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# from the environment for the first two.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = pytrnsys
SPHINXPROJ = trnsystor
SOURCEDIR = ./docs
BUILDDIR = _build

Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![image](https://travis-ci.com/samuelduchesne/pytrnsys.svg?branch=develop)](https://travis-ci.com/samuelduchesne/pytrnsys)
[![PyPI version fury.io](https://badge.fury.io/py/trnsystor.svg)](https://pypi.python.org/pypi/trnsystor/)
[![codecov](https://codecov.io/gh/samuelduchesne/trnsystor/branch/master/graph/badge.svg?token=kY9pzjlDZJ)](https://codecov.io/gh/samuelduchesne/trnsystor)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/trnsystor.svg)](https://pypi.python.org/pypi/trnsystor/)

[![image](https://coveralls.io/repos/github/samuelduchesne/pytrnsys/badge.svg?branch=develop)](https://coveralls.io/github/samuelduchesne/pytrnsys?branch=develop)

# pytrnsys
# trnsystor

A python scripting language for TRNSYS.

Expand All @@ -12,12 +12,12 @@ specify parameters, connect components together and more throught python code.
## Installation

```python
pip install pytrnsys
pip install trnsystor
```

## Usage

Since TRNSYS 18, type proformas can be exported to XML schemas. *pytrnsys* builds on
Since TRNSYS 18, type proformas can be exported to XML schemas. *trnsystor* builds on
this easy to read data structure to easily create TrnsysModels using the most popular
scripting language in the data science community:
[Python](https://www.economist.com/graphic-detail/2018/07/26/python-is-becoming-the-worlds-most-popular-coding-language).
Expand All @@ -26,7 +26,7 @@ From the xml file of a type proforma, simply create a TrnsysModel object by invo
`from_xml()` constructor:

```python
>>> from pytrnsys import TrnsysModel
>>> from trnsystor import TrnsysModel
>>> xml = "tests/input_files/Type951.xml"
>>> pipe1 = TrnsysModel.from_xml(xml)
```
Expand Down Expand Up @@ -91,15 +91,15 @@ pipe1.connect_to(pipe2, mapping={0:0, 1:1})
## Equations

In the TRNSYS studio, equations are components holding a list of user-defined expressions.
In pytrnsys a similar approach has been taken: the `Equation` class handles the
In trnsystor a similar approach has been taken: the `Equation` class handles the
creation of equations and the [EquationCollection` class handles the block of equations.
Here's an example:

First, create a series of Equation by invoking the [from_expression` constructor. This
allows you to input the equation as a string.

```python
>>> from pytrnsys import Equation, EquationCollection
>>> from trnsystor import Equation, EquationCollection
>>> equa1 = Equation.from_expression("TdbAmb = [011,001]")
>>> equa2 = Equation.from_expression("rhAmb = [011,007]")
>>> equa3 = Equation.from_expression("Tsky = [011,004]")
Expand Down Expand Up @@ -134,7 +134,7 @@ method `.save()`. The Deck object contains the Simulation Cards and the differen
and saving it to file.

```python
>>> from pytrnsys import Deck, ControlCards
>>> from trnsystor import Deck, ControlCards
>>>
>>> control_card = ControlCards.debug_template(). # Specifies a predefined set of control cards. See section bellow.
>>> cdeck = Deck(name="mydeck", control_cards=control_card, author="jovyan")
Expand All @@ -149,14 +149,14 @@ and saving it to file.
### Simulation Cards

The Simulation Cards is a chuck of code that informs TRNSYS of various simulation controls
such as start time end time and time-step. pytrnsys implements many of those
such as start time end time and time-step. trnsystor implements many of those
*Statements* with a series of Statement objects.

For instance, to create simulation cards using default values, simply call the `all()`
constructor:

```python
>>> from pytrnsys import ControlCards
>>> from trnsystor import ControlCards
>>> cc = ControlCards.all()
>>> print(cc)
*** Control Cards
Expand Down
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
import sys

sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath("pytrnsys"))
sys.path.insert(0, os.path.abspath("trnsystor"))

# -- Project information -----------------------------------------------------

project = "pytrnsys"
project = "trnsystor"
copyright = "2019, Samuel Letellier-Duchesne"
author = "Samuel Letellier-Duchesne"

# The full version, including alpha/beta/rc tags
import pytrnsys
import trnsystor

version = release = pytrnsys.__version__
version = release = trnsystor.__version__

# -- General configuration ---------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytrnsys |version|
trnsystor |version|
======================

.. include:: ../README.rst
Expand All @@ -13,7 +13,7 @@ pytrnsys |version|
Indices and tables
==================

.. py:currentmodule:: pytrnsys
.. py:currentmodule:: trnsystor
* :ref:`genindex`
* :ref:`search`
10 changes: 5 additions & 5 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Reference
Main Classes
------------

.. currentmodule:: pytrnsys
.. currentmodule:: trnsystor
.. autosummary::
:template: autosummary.rst
:nosignatures:
Expand All @@ -25,7 +25,7 @@ Main Classes
Trnsys Statements
-----------------

.. currentmodule:: pytrnsys.statement
.. currentmodule:: trnsystor.statement
.. autosummary::
:template: autosummary.rst
:nosignatures:
Expand All @@ -51,7 +51,7 @@ Trnsys Statements
Helper Classes
--------------

.. currentmodule:: pytrnsys
.. currentmodule:: trnsystor
.. autosummary::
:template: autosummary.rst
:nosignatures:
Expand All @@ -69,7 +69,7 @@ Helper Classes
Collections
-----------

.. currentmodule:: pytrnsys.collections
.. currentmodule:: trnsystor.collections
.. autosummary::
:template: autosummary.rst
:nosignatures:
Expand All @@ -89,7 +89,7 @@ Collections
Utils
-----

.. currentmodule:: pytrnsys.utils
.. currentmodule:: trnsystor.utils
.. autosummary::
:template: autosummary.rst
:nosignatures:
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pytrnsys
name: trnsystor
channels:
- defaults
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if "%SPHINXBUILD%" == "" (
)
set SOURCEDIR=./docs
set BUILDDIR=_build
set SPHINXPROJ=pytrnsys
set SPHINXPROJ=trnsystor

if "%1" == "" goto help

Expand Down
29 changes: 0 additions & 29 deletions pytrnsys/collections/__init__.py

This file was deleted.

45 changes: 0 additions & 45 deletions pytrnsys/statement/__init__.py

This file was deleted.

18 changes: 17 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def find_version(*file_paths):
requirements_lines = f.readlines()
dev_requires = [r.strip() for r in requirements_lines]

package = "pytrnsys"
package = "trnsystor"
setup(
name=package,
version=find_version(package, "__init__.py"),
Expand All @@ -51,4 +51,20 @@ def find_version(*file_paths):
extras_require={"dev": dev_requires},
test_suite="tests",
include_package_data=True,
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 4 - Beta",
# Indicate who your project is intended for
"Intended Audience :: Science/Research",
# Pick your license as you wish (should match "license" above)
"License :: OSI Approved :: MIT License",
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
)
2 changes: 1 addition & 1 deletion tests/input_files/TYPE24.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<TrnsysModel><object>Quantity Integrator</object><author>Contributors are listed in manuals</author><organization>Solar Energy Laboratory, University of Wisconsin-Madison</organization><editor>MKu</editor><creationDate>TRNSYS v7.5</creationDate><modifictionDate>April 2016</modifictionDate><mode>4</mode><validation>8</validation><icon>C:\software\pytrnsys\tests\input_files\Type24.bmp</icon><type>24</type><maxInstance>9999</maxInstance><keywords/><details>This component integrates a series of quantities over a period of time. Each quantity integrator can have up to, but no more than 500 inputs. Type24 is able to reset periodically throughout the simulation either after a specified number of hours or after each month of the year. With the release of TRNSYS 16, Type24 was expanded so that the time between resets could be counted relative to the start time of the simulation or in absolute time. For example, with a 1 hour reset time, relative time resetting, and a simulation start time of 0.5, the integrator will reset at time 1.5, 2.5, 3.5, 4.5, etc. With a 1 hour reset time, absolute time resetting, and a simulation start time of 0.5, the Type24 integrator would reset at time 1.0, 2.0, 3.0, 4.0, etc. Thus the first integration period would not be a full hour.</details><variables><variable><!--parameter-1--><order>1</order><name>Integration period</name><role>parameter</role><dimension>Time</dimension><unit>hr</unit><type>real</type><min>-12</min><max>+Inf</max><boundaries>[ ; ]</boundaries><default>STOP</default><symbol>SN</symbol><definition>The time interval over which the inputs are to be investigated. The outputs are reset to zero after each reset time interval. If the reset time is set to a negative value, then units of months are assumed (if the reset time is set to -2, then the reset time will be two months...)</definition></variable><variable><!--input-1--><order>2</order><name>Input to be integrated</name><role>input</role><dimension>any</dimension><unit>any</unit><type>real</type><min>-Inf</min><max>+Inf</max><boundaries>[ ; ]</boundaries><default>0.0</default><symbol>SN</symbol><definition>Leave the initial value at zero unless you wish to add a constant to the integration results.
<TrnsysModel><object>Quantity Integrator</object><author>Contributors are listed in manuals</author><organization>Solar Energy Laboratory, University of Wisconsin-Madison</organization><editor>MKu</editor><creationDate>TRNSYS v7.5</creationDate><modifictionDate>April 2016</modifictionDate><mode>4</mode><validation>8</validation><icon>C:\software\trnsystor\tests\input_files\Type24.bmp</icon><type>24</type><maxInstance>9999</maxInstance><keywords/><details>This component integrates a series of quantities over a period of time. Each quantity integrator can have up to, but no more than 500 inputs. Type24 is able to reset periodically throughout the simulation either after a specified number of hours or after each month of the year. With the release of TRNSYS 16, Type24 was expanded so that the time between resets could be counted relative to the start time of the simulation or in absolute time. For example, with a 1 hour reset time, relative time resetting, and a simulation start time of 0.5, the integrator will reset at time 1.5, 2.5, 3.5, 4.5, etc. With a 1 hour reset time, absolute time resetting, and a simulation start time of 0.5, the Type24 integrator would reset at time 1.0, 2.0, 3.0, 4.0, etc. Thus the first integration period would not be a full hour.</details><variables><variable><!--parameter-1--><order>1</order><name>Integration period</name><role>parameter</role><dimension>Time</dimension><unit>hr</unit><type>real</type><min>-12</min><max>+Inf</max><boundaries>[ ; ]</boundaries><default>STOP</default><symbol>SN</symbol><definition>The time interval over which the inputs are to be investigated. The outputs are reset to zero after each reset time interval. If the reset time is set to a negative value, then units of months are assumed (if the reset time is set to -2, then the reset time will be two months...)</definition></variable><variable><!--input-1--><order>2</order><name>Input to be integrated</name><role>input</role><dimension>any</dimension><unit>any</unit><type>real</type><min>-Inf</min><max>+Inf</max><boundaries>[ ; ]</boundaries><default>0.0</default><symbol>SN</symbol><definition>Leave the initial value at zero unless you wish to add a constant to the integration results.
The constant added will be the initial value.</definition></variable><variable><!--output-1--><order>3</order><name>Result of integration</name><role>output</role><dimension>any</dimension><unit>any</unit><type>real</type><min>-Inf</min><max>+Inf</max><boundaries>[ ; ]</boundaries><default>0</default><symbol>SN</symbol><definition>The result of the integration of the corresponding input. Output 1will be the result of the integration of Input 1 with respect to time.</definition></variable><variable><!--parameter-2--><order>4</order><name>Relative or absolute start time</name><role>parameter</role><dimension>Dimensionless</dimension><unit>-</unit><type>integer</type><min>0</min><max>1</max><boundaries>[ ; ]</boundaries><default>0</default><symbol>SN</symbol><definition>This parameter controls whether the integration intervals are relative or absolute
0: integrate at time intervals relative to the simulation start time
1: integrate at absolute time intervals
Expand Down

0 comments on commit 9bbe73c

Please sign in to comment.