Skip to content

Commit 9472f7f

Browse files
committed
Add TRNBuild class and make TRNSYS 18 the default
The TRNBuild class can be used to create view factor matrix file and shading matrix file from a TRNBuild file (.b18)
1 parent dc3c69e commit 9472f7f

File tree

1 file changed

+61
-10
lines changed

1 file changed

+61
-10
lines changed

trnpy/core.py

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class TRNExe():
6464
"""
6565

6666
def __init__(self,
67-
path_TRNExe=r'C:\Trnsys17\Exe\TRNExe.exe',
67+
path_TRNExe=r'C:\Trnsys18\Exe\TRNExe.exe',
6868
mode_trnsys_hidden=False,
6969
mode_exec_parallel=False,
7070
n_cores=0,
@@ -1823,18 +1823,10 @@ class SimStudio():
18231823
/d create deck file
18241824
/r run simulation
18251825
/q quit
1826-
1827-
Other useful command line features of TRNSYS (not implemented):
1828-
1829-
TRNBuild: Create VFM from command line
1830-
subprocess.call(r'"C:\TRNSYS18\Building\TRNBuild.exe" "file.b18" /N /vfm')
1831-
1832-
TRNBuild: Create SHM/ISM from command line
1833-
subprocess.call(r'"C:\TRNSYS18\Building\TRNBuild.exe" "file.b18" /N /masks')
18341826
"""
18351827

18361828
def __init__(self,
1837-
path_Studio=r'C:\Trnsys17\Studio\Exe\Studio.exe',
1829+
path_Studio=r'C:\Trnsys18\Studio\Exe\Studio.exe',
18381830
):
18391831
"""Initialize a Simulation Studio object.
18401832
@@ -1882,3 +1874,62 @@ def create_dck_from_tpf(self, tpf, create=True, run=False, close=True,
18821874
if ret != 0 and not silence_errors:
18831875
raise ValueError("Simulation Studio returned error")
18841876
return ret
1877+
1878+
1879+
class TRNBuild():
1880+
r"""Define the TRNBuild class.
1881+
1882+
Can be used to create view factor matrix file and shading matrix file
1883+
from a TRNBuild file (.b18).
1884+
"""
1885+
1886+
def __init__(self,
1887+
path_TRNBuild=r'C:\TRNSYS18\Building\TRNBuild.exe',
1888+
):
1889+
"""Initialize a TRNBuild object.
1890+
1891+
Args:
1892+
path_TRNBuild (str, optional): Path to TRNBuild executable
1893+
1894+
Returns:
1895+
None
1896+
"""
1897+
self.path_TRNBuild = path_TRNBuild
1898+
1899+
def create_vfm_from_b18(self, b18, silence_errors=False):
1900+
"""Create a view factor matrix file from a .b18 TRNBuild file.
1901+
1902+
Args:
1903+
b18 (str): Path to a TRNBuild file.
1904+
1905+
Returns:
1906+
ret (int): A return value of 0 indicates success
1907+
1908+
"""
1909+
args = [self.path_TRNBuild, os.path.abspath(b18), '/n', '/vfm']
1910+
1911+
logger.info("Calling TRNBuild with command '%s'",
1912+
' '.join(args))
1913+
ret = subprocess.call(args)
1914+
if ret != 0 and not silence_errors:
1915+
raise ValueError("TRNBuild returned error")
1916+
return ret
1917+
1918+
def create_masks_from_b18(self, b18, silence_errors=False):
1919+
"""Create a shading matrix file from a .b18 TRNBuild file.
1920+
1921+
Args:
1922+
b18 (str): Path to a TRNBuild file.
1923+
1924+
Returns:
1925+
ret (int): A return value of 0 indicates success
1926+
1927+
"""
1928+
args = [self.path_TRNBuild, os.path.abspath(b18), '/n', '/masks']
1929+
1930+
logger.info("Calling TRNBuild with command '%s'",
1931+
' '.join(args))
1932+
ret = subprocess.call(args)
1933+
if ret != 0 and not silence_errors:
1934+
raise ValueError("TRNBuild returned error")
1935+
return ret

0 commit comments

Comments
 (0)