Skip to content

Commit

Permalink
Merge branch 'release/1.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelduchesne committed Feb 12, 2021
2 parents 65384df + a689882 commit 85df83f
Show file tree
Hide file tree
Showing 60 changed files with 1,045 additions and 806 deletions.
4 changes: 4 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
template: |
## What’s Changed
$CHANGES
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ target/

.idea/
/docs/reference/

test.dck

test_deck.txt
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ pip install trnsystor

## Usage

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:
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).

From the xml file of a type proforma, simply create a TrnsysModel object by invoking the
Expand Down Expand Up @@ -91,9 +91,9 @@ 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 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:
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.
Expand Down Expand Up @@ -149,8 +149,8 @@ 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. trnsystor implements many of those
*Statements* with a series of Statement objects.
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:
Expand All @@ -171,3 +171,20 @@ LIMITS 25 10 25 ! Max iterations Max warnings Trace limit
EQSOLVER 0 ! EQUATION SOLVER statement
```

### Selecting elements of components

Inputs, Outputs, Parameters, Derivatives, SpecialCards and ExternalFiles can be accessed
via their attribute in any TrnsysModel component. They are accessed via their position as
for in a list. It is also possible to `slice` the collection to retrieved more than one
element. In this case a list is returned:

```python
>>> from trnsystor.trnsysmodel import TrnsysModel
>>> pipe = TrnsysModel.from_xml("tests/input_files/Type951.xml")
>>> pipe.inputs[0:2] # getting the first 2 inputs
[Inlet Fluid Temperature - Pipe 1; units=C; value=15.0 °C
The temperature of the fluid flowing into the first buried horizontal pipe., Inlet Fluid Flowrate - Pipe 1; units=(kg)/(hr); value=0.0 kg/hr
The flowrate of fluid into the first buried horizontal pipe.]

```

6 changes: 4 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Docs module."""
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand All @@ -13,6 +14,8 @@
import os
import sys

from trnsystor import __version__

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

Expand All @@ -23,9 +26,8 @@
author = "Samuel Letellier-Duchesne"

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

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

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

Expand Down
9 changes: 8 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ description-file = README.md
max-line-length = 88
extend-ignore =
# See https://github.com/PyCQA/pycodestyle/issues/373
E203,
E203, E501
docstring-convention=google
exclude =
.git,
__pycache__,
docs/conf.py,
tests
setup.py
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Setup/install the package."""
# Always prefer setuptools over distutils
import codecs
import os
import re
from os import path

from setuptools import setup, find_packages
from setuptools import find_packages, setup

here = os.getcwd()

Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Testing module."""
Binary file added tests/input_files/Type25c.bmp
Binary file not shown.
248 changes: 248 additions & 0 deletions tests/input_files/Type25c.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
<?xml version="1.0" encoding="UTF-8"?>
<TrnsysModel>
<object>Printer - No units printed to output file</object>
<author>See the list of contributors in the main manual</author>
<organization>Solar Energy Laboratory, University of Wisconsin-Madison</organization>
<editor>SEL and TESS</editor>
<creationDate>TRNSYS v7.5</creationDate>
<modifictionDate>February 2016</modifictionDate>
<mode>4</mode>
<validation>32</validation>
<icon>C:\software\pyTrnsysType\tests\input_files\Type25c.bmp</icon>
<type>25</type>
<maxInstance>9999</maxInstance>
<keywords/>
<details>The printer component is used to output (or print) selected system variables at specified (even) intervals
of time. In this mode, unit descriptors (kJ/hr, degC, W, etc.) are NOT printed to the output file with each
column heading. Output can be printed in even time intervals starting relative to the simulation start time or
can be printed in absolute time. If relative printing is chosen with a one hour print interval and the
simulation starts at time 0.5, values will be printed at times 0.5, 1.5, 2.5, etc. If absolute printing is
selected, for the same simulation, values will be printed at times 0.5, 1.0, 2.0, 3.0, etc. Type25 is also able
to print simulation information as a header to the output file (name of input file, and time of simulation run).
It is further able to append new data to an existing file or can be set to overwrite the existing file.
</details>
<variables>
<variable><!--input-1-->
<order>1</order>
<name>Input to be printed</name>
<role>input</role>
<dimension>any</dimension>
<unit>any</unit>
<type>string</type>
<min>-Inf</min>
<max>+Inf</max>
<boundaries>[ ; ]</boundaries>
<default>label</default>
<symbol>SN</symbol>
<definition>Input to be printed</definition>
</variable>
<variable><!--parameter-1-->
<order>2</order>
<name>Printing interval</name>
<role>parameter</role>
<dimension>Time</dimension>
<unit>hr</unit>
<type>real</type>
<min>-12</min>
<max>+Inf</max>
<boundaries>[ ; ]</boundaries>
<default>STEP</default>
<symbol>SN</symbol>
<definition>The time interval at which printing is to occur. If the time interval is less than zero, then
the print interval will be measured in the absolute value of this parameter expressed in months.
Examples:
1: print every hour
-1: print every month
The default value (STEP) is a TRNSYS parameter equal to the simulation time step
</definition>
</variable>
<variable><!--parameter-2-->
<order>3</order>
<name>Start time</name>
<role>parameter</role>
<dimension>Time</dimension>
<unit>hr</unit>
<type>real</type>
<min>0</min>
<max>+Inf</max>
<boundaries>[ ; ]</boundaries>
<default>START</default>
<symbol>SN</symbol>
<definition>The time of the year in hours at which printing is to start.
The default value (START) is a TRNSYS parameter equal to the simulation start time
</definition>
</variable>
<variable><!--parameter-3-->
<order>4</order>
<name>Stop time</name>
<role>parameter</role>
<dimension>Time</dimension>
<unit>hr</unit>
<type>real</type>
<min>0</min>
<max>+Inf</max>
<boundaries>[ ; ]</boundaries>
<default>STOP</default>
<symbol>SN</symbol>
<definition>The time of the year in hours at which printing is to stop.
The default value (STOP) is a TRNSYS parameter equal to the simulation stop time
</definition>
</variable>
<variable><!--parameter-4-->
<order>5</order>
<name>Logical unit</name>
<role>parameter</role>
<dimension>Dimensionless</dimension>
<unit>-</unit>
<type>integer</type>
<min>30</min>
<max>999</max>
<boundaries>[ ; ]</boundaries>
<default>30</default>
<symbol>SN</symbol>
<definition>This parameter sets the Fortran Logical Unit (File reference number) of the output file. It is
used internally by TRNSYS to refer to the file. This parameter will automatically be assigned to a
unique value by the TRNSYS Studio
</definition>
</variable>
<variable><!--parameter-5-->
<order>6</order>
<name>Units printing mode</name>
<role>parameter</role>
<dimension>Dimensionless</dimension>
<unit>-</unit>
<type>integer</type>
<min>0</min>
<max>0</max>
<boundaries>[ ; ]</boundaries>
<default>0</default>
<symbol>SN</symbol>
<definition>This parameter is set to 0, so no units are printed to the output file</definition>
</variable>
<variable><!--parameter-6-->
<order>7</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 print intervals are relative or absolute
0: print at time intervals relative to the simulation start time
1: print at absolute time intervals
For example, if the simulation start time is 0.5, the simulation time step is 0.25 and the printing time
step is 1:
If this parameter is set to 0, printing will occur at 0.5, 1.5, 2.5, etc.
If this parameter is set to 1, printing will occur at 1, 2, 3, etc.
</definition>
</variable>
<variable><!--parameter-7-->
<order>8</order>
<name>Overwrite or Append</name>
<role>parameter</role>
<dimension>Dimensionless</dimension>
<unit>-</unit>
<type>integer</type>
<min>-1</min>
<max>1</max>
<boundaries>[ ; ]</boundaries>
<default>-1</default>
<symbol>SN</symbol>
<definition>This parameter decides whether the file is appended to or overwritten:
-1: Overwrite the output file
1: Append to the output file
</definition>
</variable>
<variable><!--parameter-8-->
<order>9</order>
<name>Print header</name>
<role>parameter</role>
<dimension>Dimensionless</dimension>
<unit>-</unit>
<type>integer</type>
<min>-1</min>
<max>1</max>
<boundaries>[ ; ]</boundaries>
<default>-1</default>
<symbol>SN</symbol>
<definition>This parameters decides whether or not a header with input file information will be printed to
the output file or not
-1: Do not print header
1: Print header
</definition>
</variable>
<variable><!--parameter-9-->
<order>10</order>
<name>Delimiter</name>
<role>parameter</role>
<dimension>Dimensionless</dimension>
<unit>-</unit>
<type>integer</type>
<min>0</min>
<max>2</max>
<boundaries>[ ; ]</boundaries>
<default>0</default>
<symbol>SN</symbol>
<definition>This parameter controls the delimiter used in the output file:
0: use tabs to delimit columns
1: use spaces to delimit columns
2: use commas to delimit columns
</definition>
</variable>
<variable><!--parameter-10-->
<order>11</order>
<name>Print labels</name>
<role>parameter</role>
<dimension>Dimensionless</dimension>
<unit>-</unit>
<type>integer</type>
<min>-1</min>
<max>1</max>
<boundaries>[ ; ]</boundaries>
<default>1</default>
<symbol>SN</symbol>
<definition>This parameter decides whether or not labels (variable descriptors) should be printed as column
headers:
-1: Do not print descriptors
1: Print descriptors
</definition>
</variable>
</variables>
<cycles>
<cycle>
<role>input</role>
<firstRow>1</firstRow>
<lastRow>1</lastRow>
<cycles>
<cycle>
<role>input</role>
<firstRow>1</firstRow>
<lastRow>1</lastRow>
<cycles/>
<question>How many variables are to be printed by this component?</question>
<minSize>1</minSize>
<maxSize>100</maxSize>
</cycle>
</cycles>
<minSize>1</minSize>
<maxSize>50</maxSize>
</cycle>
</cycles>
<externalFiles>
<externalFile>
<question>Output file for printed results</question>
<answer>***.out</answer>
<answers>
<answer>***.out</answer>
</answers>
<parameter>Logical unit</parameter>
<designate>no</designate>
</externalFile>
</externalFiles>
<compileCommand>df /c</compileCommand>
<source>.\SourceCode\Types\Type25.f90</source>
</TrnsysModel>
5 changes: 3 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test utils module."""
import pytest

from trnsystor import redistribute_vertices
from trnsystor.utils import redistribute_vertices


class TestRedistributeVertices:
Expand Down Expand Up @@ -30,7 +31,7 @@ def test_redistribute_vertices(self, line):
assert newline.length == line.length

def test_redistribute_vertices_wrongtype(self, ring):
"""Tests unsupported geometry"""
"""Tests unsupported geometry."""
with pytest.raises(TypeError):
assert redistribute_vertices(ring, 10)

Expand Down

0 comments on commit 85df83f

Please sign in to comment.