Coder Social home page Coder Social logo

lbl-srg / buildingspy Goto Github PK

View Code? Open in Web Editor NEW
78.0 21.0 45.0 3.83 MB

Python modules for automating Modelica simulations and for running unit test for the Buildings library

Makefile 0.60% Python 93.02% Modelica 1.42% Shell 1.48% HTML 3.39% C 0.03% Motoko 0.06%
python

buildingspy's Introduction

BuildingsPy

https://travis-ci.com/lbl-srg/BuildingsPy.svg?branch=master

BuildingsPy is a Python package that can be used to

  • run Modelica simulation using Dymola, OpenModelica or OPTIMICA,
  • process *.mat output files that were generated by Dymola, OPTIMICA or OpenModelica, and
  • run unit tests and automate other workflows as part of Modelica library development.

The package provides functions to extract data series from the output file for further use in the python packages matplotlib for plotting and SciPy for scientific computing.

Documentation is available at http://simulationresearch.lbl.gov/modelica/buildingspy/

The license is at buildingspy/license.txt

buildingspy's People

Contributors

antoinegautier avatar dependabot[bot] avatar giplessis avatar ilab3e avatar jayhulbl avatar massimocimmino avatar mathadon avatar mbonvini avatar mrosemeier avatar mwetter avatar rpatureau avatar saroele avatar srouchier avatar thorade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

buildingspy's Issues

TypeError when handling exception

When a simulation fails, the following error message may be generated, which is due to wrong parsing of the exception:

File "/usr/local/lib/python2.7/dist-packages/buildingspy/simulate/Simulator.py", line 447, in simulate
    + "   You need to delete the directory manually.")
TypeError: cannot concatenate 'str' and 'exceptions.ImportError' objects

Add regression test for FMU export

Add a module that exports all examples as an FMU for ME, 2.0, and simulates them in Ptolemy II.

Note that to handle strings, use

Advanced.AllowStringParameters = true

Excluding files from merger

In IDEAS we have created a 'weatherbus' connector that contains many more signals and parameters than the Annex 60 version. This causes problems (open-ideas/IDEAS#414) when connecting components from A60 such as IDEAS.Fluid.Sources.Outside_CpLowRise.

The cleanest way to deal with this seems to provide the option exclude some files from being overwritten. This way we can develop our own bus connector, without it being overwritten when merging.

An added functionality may be to include the 'original' A60 code in the bus connector, but to comment it, such that it is easy to compare the two code versions when problems would arise after a merge.

Does this seem to be a good solution to our problem?

Add test for presence of stateGraphRoot

If inner Modelica.StateGraph.StateGraphRoot stateGraphRoot is not present in a model that uses StateGraph, then Dymola issues the following warning:

Note: A "stateGraphRoot" component was automatically introduced.

Such a check needs to be added to the regression tests.

refactor.py also finds commented types

refactor.py finds type declarations in comments and adds them to the package.order

within BuildingSystems.HAM.ConvectiveHeatTransfer;
package Gaps "Functions for convective heat transfer within gaps or parallel surfaces"
  extends Modelica.Icons.VariantsPackage;
  // type Gas = enumeration(air, argon, krypton);
  // Gas gas = Gas.air  "gas: air, argon or krypton";

end Gaps;

Also see UdK-VPT/BuildingSystems#9

These comments will be deleted some time soon in our library,
not sure whether it is worth changing BuildingsPy,
feel free to just close as won't fix.

Installation instructions for linux

You need tidylib in order to be able to run buildingspy. In fact you need tidylib and its python wrapper. It took me a while to figure this out (again) when reinstalling my system. I propose to add some hints to this in the installation instructions on this page
http://simulationresearch.lbl.gov/modelica/buildingspy/install.html

Install instructions can be found here:
http://countergram.com/open-source/pytidylib/docs/index.html

To summarise, I had to run:

sudo pip install pytidylib
sudo apt-get install tidy

to get it to run!

add translation statistics to reference results

Add the translation statistics to the reference results.
Entries could be

statistics/dynamics
          /initialization
                         /linear_systems
                         /nonlinear_systems
                         /numerical_Jacobian

These statistics will be after the symbolic manipulation.

refactor.py write_package_order in recursive mode

When calling write_package_order with recursive=True it will go into all sub-directories, but it forgets about the top level. This means, the top level package.order will not be re-written. Instead, the version as copied from Annex60 is kept.

merger.py on Windows: newline and directory separator in path

To get merger.py to work (on Windows) I changed the code

        previouslyCopiedFiles = list()
        if os.path.isfile(copFilPat):
            roo = self._target_home.split(self._new_library_name)[0]
            with open(copFilPat,'r') as fp:
                files = fp.read().splitlines()
                for fil in files:
                    if not fil.startswith('#'):
                        absFil = os.path.join(roo, fil)
                        if os.path.isfile(absFil):
                            previouslyCopiedFiles.append(fil)

to this

        previouslyCopiedFiles = list()
        if os.path.isfile(copFilPat):
            roo = self._target_home.split(self._new_library_name)[0]
            # print("roo is " + roo)
            # print("Reading in previously copied files from: " + copFilPat)
            with open(copFilPat,'r') as fp:
                files = fp.read().splitlines()
                for fil in files:
                    fil = os.path.normpath(fil.rstrip())
                    if not fil.startswith('#'):
                        absFil = os.path.join(roo, fil)
                        # print(str(os.path.isfile(absFil)) + " " + absFil)
                        if os.path.isfile(absFil):
                            previouslyCopiedFiles.append(fil)

It removes the newlines at the end of the line and it converts directory separators.
Otherwise the list of previouslyCopiedFiles was always empty, because isfile was returning False.
I can send a pull request for this one if you want.
I have not yet tested whether this breaks the Linux version.

Correct rst syntax.

On the branch annex60, the file regressiontest.py has invalid documentation. See for example the method test_JModelica.

Error when making case error in setSinglePackage

When using

tester.setSinglePackage("IDEAS.AirFlow")

instead of

tester.setSinglePackage("IDEAS.Airflow")

(notice the capital F), Buildingspy accepts this, starts looking for unit tests in the designated path and apparently does find the .mos files even though the path is not exact. However this ultimately results in the following error:

Traceback (most recent call last):
  File "RunUnitTests.py", line 40, in <module>
    tester.run()
  File "/usr/local/lib/python2.7/dist-packages/buildingspy-1.4.0-py2.7.egg/buildingspy/development/regressiontest.py", line 2142, in run
    self._write_runscripts()
  File "/usr/local/lib/python2.7/dist-packages/buildingspy-1.4.0-py2.7.egg/buildingspy/development/regressiontest.py", line 1880, in _write_runscripts
    "checkCommand": self._getModelCheckCommand(absMosFilNam).replace("\\","/"),
  File "/usr/local/lib/python2.7/dist-packages/buildingspy-1.4.0-py2.7.egg/buildingspy/development/regressiontest.py", line 1721, in _getModelCheckCommand
    fil = open(mosFilNam, "r+")
IOError: [Errno 2] No such file or directory: '/tmp/tmp-IDEAS-0-44EFE4/IDEAS/Resources/Scripts/Dymola/AirFlow/AHU/Validation/AdsolairDatasheetSummer.mos'

because the path does not exist after copying all files to directory Airflow instead of AirFlow.

I suppose that this is user error but this could be caught using a check too. However I completely understand if this is not high on the priority list =)

verify that all variables are processed if a line break exists in the .mos plot command

Verify that all variables are processed if the .mos file has the following syntax:

simulateModel("Anergy.SubStations.VaporCompression.Validation.HeatingCoolingHotwaterTimeSeries_dT", stopTime=864000, method="dassl", resultFile="HeatingCoolingHotwaterTimeSeries_dT");
createPlot(id=3, position={55, 50, 1639, 1211}, y={"subSta.QCoo_flow", "subSta.QHea_flow", "subSta.QHotWat_flow"}, range={0.0, 880000.0, -400000.0, 1000000.0}, grid=true, filename="HeatingCoolingHotwaterTimeSeries_dT.mat", colors={{28,108,200}, {238,46,47}, {0,140,72}});
createPlot(id=3, position={55, 50, 1639, 299}, y={"subSta.staHea_a2.T", "subSta.staHea_b2.T", "subSta.staHotWat_a2.T", 
"subSta.staHotWat_b2.T"}, range={0.0, 880000.0, 7.0, 13.0}, grid=true, subPlot=2, colors={{28,108,200}, {238,46,47}, {0,140,72}, {180,56,148}});
createPlot(id=3, position={55, 50, 1639, 298}, y={"subSta.staCoo_a1.T", "subSta.staCoo_b1.T"}, range={0.0, 880000.0, 9.8, 11.4}, grid=true, subPlot=3, colors={{28,108,200}, {238,46,47}});
createPlot(id=3, position={55, 50, 1639, 298}, y={"subSta.weaBus.TDryBul"}, range={0.0, 880000.0, 2.0, 18.0}, grid=true, subPlot=4, colors={{28,108,200}});

single line html documentation

When checking the following code with BuildingsPy and HTML tidy it returns
Warning: discarding unexpected </html>

record OakWood =
    BuildingSystems.HAM.Data.MaterialProperties.BaseClasses.MaterialThermalGeneral (
    id=7,
    name="Oak wood",
    lambda=0.18,
    c=1600,
    rho=740) "Oak wood"
    annotation(Documentation(info="<html>source: www.masea-ensan.de</html>"));

But the following does not generate a warning:

record OakWood =
    BuildingSystems.HAM.Data.MaterialProperties.BaseClasses.MaterialThermalGeneral (
    id=7,
    name="Oak wood",
    lambda=0.18,
    c=1600,
    rho=740) "Oak wood"
    annotation(Documentation(info="<html>source: www.masea-ensan.de
</html>"));

Bug when using other executable than 'dymola'

I have two dymola installations. When trying to use an old version, using:

tester=r.Tester(executable='dymola_old') 

I get the following error:

Traceback (most recent call last):
  File "RunUnitTests.py", line 40, in <module>
    tester.run()
  File "/usr/local/lib/python2.7/dist-packages/buildingspy-1.4.0-py2.7.egg/buildingspy/development/regressiontest.py", line 2137, in run
    self._write_runscripts()
  File "/usr/local/lib/python2.7/dist-packages/buildingspy-1.4.0-py2.7.egg/buildingspy/development/regressiontest.py", line 1875, in _write_runscripts
    "checkCommand": self._getModelCheckCommand(absMosFilNam).replace("\\","/"),
AttributeError: 'NoneType' object has no attribute 'replace

is this a bug?

Several build failures

Having hit my head against Modelica's Mat file standard for enough hours, I decided to give your library a try.

But I'm striking at out getting it to install.

FYI it would be great if you could put BuildingsPy on PyPI. That would simplify things. Also, have you thought about doing unit tests using Travis? Travis integrates nicely with github. And can sanity check releases as well.

Several different methods of installation fail:

Py 2.7, windows, more info on request.

From the zip file:

C:\Users\Belli\Downloads\buildingspy-1.3.0\buildingspy-1.3.0>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    long_description = read('README.rst'),
  File "setup.py", line 7, in read
    return open(os.path.join(os.path.dirname(__file__), fname)).read()
IOError: [Errno 2] No such file or directory: 'README.rst'

Using pip

C:\Users\Belli>pip install http://simulationresearch.lbl.gov/modelica/releases/python/buildingspy-1.3.0.tar.gz
Downloading/unpacking http://simulationresearch.lbl.gov/modelica/releases/python/buildingspy-1.3.0.tar.gz
  Downloading buildingspy-1.3.0.tar.gz (894Kb): 894Kb downloaded
  Running setup.py egg_info for package from http://simulationresearch.lbl.gov/modelica/releases/python/buildingspy-1.3.0.tar.gz
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "c:\users\belli\appdata\local\temp\pip-oxr1xm-build\setup.py", line 15, in <module>
        long_description = read('README.rst'),
      File "c:\users\belli\appdata\local\temp\pip-oxr1xm-build\setup.py", line 7, in read
        return open(os.path.join(os.path.dirname(__file__), fname)).read()
    IOError: [Errno 2] No such file or directory: 'c:\\users\\belli\\appdata\\local\\temp\\pip-oxr1xm-build\\README.rst'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "c:\users\belli\appdata\local\temp\pip-oxr1xm-build\setup.py", line 15, in <module>

    long_description = read('README.rst'),

  File "c:\users\belli\appdata\local\temp\pip-oxr1xm-build\setup.py", line 7, in read

    return open(os.path.join(os.path.dirname(__file__), fname)).read()

IOError: [Errno 2] No such file or directory: 'c:\\users\\belli\\appdata\\local\\temp\\pip-oxr1xm-build\\README.rst'

----------------------------------------
Command python setup.py egg_info failed with error code 1 in c:\users\belli\appdata\local\temp\pip-oxr1xm-build
Storing complete log in C:\Users\Belli\AppData\Roaming\pip\pip.log

Seems like a file is missing?

Test for dynamic state selection and modifiers with subscript

Add a test to the regression suite that searches for

Dynamically selected continuous time states

Modifiers cannot have subscripts

conflicting start values

Redeclaration of non-replaceable requires type equivalence

and issues an error when this occurs in any of the examples.

Non-ascii characters in files

When a .mo file contains a non-ascii character the merger crashes:

  File "mergeIdeasScript.py", line 23, in <module>
    mer.merge()
  File "/Library/Python/2.7/site-packages/buildingspy-1.4.0-py2.7.egg/buildingspy/development/merger.py", line 203, in merge
    self._copy_mo_and_mos(srcFil, desFil)
  File "/Library/Python/2.7/site-packages/buildingspy-1.4.0-py2.7.egg/buildingspy/development/merger.py", line 96, in _copy_mo_and_mos
    lin = string.replace(lin, ori, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/string.py", line 521, in replace
    return s.replace(old, new, maxreplace)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb7 in position 103: ordinal not in range(128)

in some cases these non-ascii codes are introduced by weird characters at position zero in the file, but they can also be functional, for instance the ö in Göteborg.

We can either

  1. replace the non-ascii characters using a code snippet like:
    nonAsciiString = "".join(i for i in asciiString if ord(i)<128)
  2. configure the script to use UTF8:
import sys
reload(sys)
sys.setdefaultencoding('UTF8')

code from http://stackoverflow.com/questions/2276200/changing-default-encoding-of-python
?

also install dependencies

After installing BuildingsPy using pip install -U buildingspy I got a warning because tidylib was missing, so I had to run pip install -U pytidylib (because that package contains tidylib).

Can you specify depencies on PyPi, so that pip will automatically install pytidylib when installing buildingspy?
Alternatively, one could just add a notice to the BuildingsPy installation instructions.

Of course, one also has to install the tidylib executable from http://tidy.sourceforge.net/

no fmi built

It seems that the fmi function is not built using the setup.py.

On windows I get an error when calling def _check_fmu_statistics(self, ans): saying that no file fmi exists.

add test for type equivalance and other warnings in regression testing

Add a test for the following string to the unit tests:

Warning: Redeclaration of non-replaceable requires type equivalence
 But attempting to increase variability of component per

The above string is in simulator.log.

To reproduce, run

checkModel("Buildings.Fluid.Movers.Validation.Pump_stratos");

on the branch openmodelica, commit bb3d050eea378bfb68b509b4649e29a47ca78456


Add test for

Warning: Failed to interpret experiment annotation

Add test for

Warning: Command 'Simulate and plot' in model 'Buildings.Airflow.Multizone.BaseClasses.Examples.WindPressureLowRise',
 specified file modelica://Buildings/Resources/Scripts/Dymola/Airflow/Multizone/BaseClasses/Examples/windPressureLowRise.mos which was not found.

adding custom dymola commands

It would be nice if we could add Dymola commands prior to running the unit tests,
for instance I need Advanced.CompileWith64=True since only 64 bit binaries are available for the software that I use and therefore the compiler should use 64 bit.

I put it in setup.mos for now, but it would be a nice feature to have this option in Buildingspy.

Another example, that I cannot fix with setup.mos, is that for my own library I'd like to generate reference results with Evaluate=true.

more prominent place for license

Just a minor enhancement: The license is currently located at doc/source/legal.rst and maybe it is a good idea to either move it to the top level and rename it LICENSE.rst or LICENSE.md(that is what github recommends) or alternatively add a link to the README.rst that points to the license.

merger.py expects lib name and dir name to be different

Line 159 of merger.py reads (or closeby)

roo = self._target_home.split(self._new_library_name)[0]

Not 100% sure, but I believe this is causing problems if the library name and the above directory name are identical, e.g. a path to the main package.mo like this one

C:\Users\mthorade\Documents\Dymola\BuildingSystems\BuildingSystems\package.mo

will be split at the wrong location.
Correct me if I am wrong and feel free to close this as won't fix, as there is an easy workaround (just rename the directory).

Refactor for JModelica

JModelica needs more support points for verification. This issue is to refactor BuildingsPy to write reference results with more supports points.

Simulator processes vectors of parameter values wrong

Daniele Basciotti reported:

I found a small bug in the buildingspy when trying to use arrays of parameters. See the following python code:

s.addParameters({'heat_setting' : {1,0,0,0}})
s.addParameters({'weather_setting' : {1,0}})

This is translated in a mos file as:

modelInstance="Model(Tnet=333.15,weather_setting=[0, 1],heat_setting=set([0, 1]))";

Which is totally wrong for the syntax and the values in the vectors. The correct syntax should be:

modelInstance="Model(Tnet=333.15,heat_setting={1,0,0,0}, weather_setting={1, 0})";

Please let me know if you can easily fix it or if I use wrongly the command addParameters

Python 3 compatibility

It would be nice to make BuildingsPy compatible to Python 3.5+ (without breaking Python 2.7.9+).
The basic idea is that these versions have a sufficient common subset (which is not available in 2.6 or 3.0, e.g. PEP414).

An end-of-support timeline for the various Python versions is here:
https://docs.python.org/devguide/#status-of-python-branches
or, in visual form, here:
http://www.python3statement.org/#sections40-timeline

Helpful resources for porting:

Tasks for makinge the code Py3 compatible:

Then, once the code is Py3 compatible:

  • develop new code in Python3 and import from future to make it work with Python 2.7.x.
    Porting from 3 to 2 is usually easy, because Py3 is usually stricter than Py2.
  • alternatively, when developing new code in Py2, do not forget to import from future to enforce at least some of the Py3 strictness
  • use Python 2 with flags -3 -Werror at least once
  • use Python 3 with flags -bb at least once

Change variable name in template

This issue is to rename the variable line in regression.py so it does not cause the unit tests to fail. This variable is written in the mos file. This causes a name clash for instances of models which have the name line. This happens for instance in the model Buildings.Electrical.DC.Lines.Examples.DCLinesLinearized.

improve html check

Search documentation for

<span style=\"font-family: Sans Serif;\">

which is introduced by Dymola, and report a warning.

missing .mos script warning not processed

If a .mo file references a .mos file for the simulate and plot command but this file is missing, Dymola writes a warning. The regression tests do not parse the log for this warning.

See Annex60 library, commit 4ec3cb556f740eb537b8c12fd26b73f4d4f7a06d
and ibpsa/modelica-ibpsa#313

The warning message is

Check of Annex60.Utilities.Psychrometrics.Examples.Density_pTX:

 Command 'Simulate and plot' in model 'Annex60.Utilities.Psychrometrics.Examples.Density_pTX',
 specified file modelica://Annex60/Resources/Scripts/Dymola/Utilities/Psychrometrics/Examples/Density_pTX.mos which was not found.

check for differentiation warnings

Check in the regression tests for differentiation warnings, such as

Translation of Annex60.Fluid.Actuators.Dampers.Examples.Damper:

The DAE has 70 scalar unknowns and 70 scalar equations.

Differentiating (if noEvent(m_flow > m_flow_turbulent) then (m_flow/k)^2 else (if noEvent(m_flow < -m_flow_turbulent) then -(m_flow/k)^2 else 0.5*(m_flow_turbulent*m_flow+ m_flow^3/m_flow_turbulent)/k^2))
under the assumption that it is continuous at switching.

This can be reproduced with the Annex60 library, commit 73db3de

add refactor module

Create a module development.refactor that aids in

  • renaming Modelica classes, including the associated *.mos scripts, reference results, hyperlinks and images,
  • updating package.order

Declaration of string parameters in Simulator

There seems to be an issue with how BuildingsPy handles the declaration of string parameters.

For example, calling the model in Buildings.Fluid.Examples.SimpleHouse but changing the weather data file like so:

import buildingspy.simulate.Simulator as si

def main():
    model = 'Buildings.Fluid.Examples.SimpleHouse'
    s = si.Simulator(model, 'dymola')
    weatherFile = 'modelica://Buildings/Resources/weatherdata/USA_CA_San.Francisco.Intl.AP.724940_TMY3.mos'
    s.addParameters({'weaDat.filNam' : weatherFile})
    s.setTimeOut(60)
    
    try:
        s.simulate()
    except:
        with open('simulator.log') as f:
            print f.read()
    
# Main function
if __name__ == '__main__':
    main()

leads to a failed simulation with the simulation log:

RunScript("d:/program files (x86)/dymola 2017/insert/dymola.mos", true);
 = true
 = true
RunScript("C:/Users/massi/AppData/Roaming/Dynasim/setup.mos", true);
 = true
RunScript("c:\\users\\massi\\appdata\\local\\temp\\tmp-simulator-massi-mxj0ct\\pyHeatPump\\run.mos");

// File autogenerated by _get_dymola_commands
// Do not edit.
cd("c:\users\massi\appdata\local\temp\tmp-simulator-massi-mxj0ct\pyHeatPump");
C:/users/massi/appdata/local/temp/tmp-simulator-massi-mxj0ct/pyHeatPump
 = true
Modelica.Utilities.Files.remove("simulator.log");
openModel("package.mo");
 = true
OutputCPUtime:=true;
modelInstance="Buildings.Fluid.Examples.SimpleHouse(weaDat.filNam='modelica://Buildings/Resources/weatherdata/USA_CA_San.Francisco.Intl.AP.724940_TMY3.mos')";
Declaring variable: String modelInstance ;

simulateModel(modelInstance, startTime=0, stopTime=1, method="radau", tolerance=1e-06, resultFile="SimpleHouse");
 = false
savelog("simulator.log");

The problem comes from the use of repr(arg) when declaring string parameters, which produces single quotes (') instead of double quotes (").
The following line:
modelInstance="Buildings.Fluid.Examples.SimpleHouse(weaDat.filNam='modelica://Buildings/Resources/weatherdata/USA_CA_San.Francisco.Intl.AP.724940_TMY3.mos')";
Should properly be:
modelInstance="Buildings.Fluid.Examples.SimpleHouse(weaDat.filNam=\"modelica://Buildings/Resources/weatherdata/USA_CA_San.Francisco.Intl.AP.724940_TMY3.mos\")";

Changing the check for strings in Simulator._declare_parameters.to_modelica seems to fix this issue.
Current implementation:

if isinstance(arg, str):
    return repr(arg)

Modified implementation:

if isinstance(arg, str):
    return '\\"' + arg + '\\"'

Regression tests may fail if OS or compiler are different

Some regression tests fail as they produce slightly different results on Windows and Linux, and possibly also if different compilers are used.

This issue should

  • analysis these cases,
  • write respective test cases that should pass and should fail and include them in the BuildingsPy regression tests, and
  • update the tolerance check.

Maybe adding a relative test in addition to an absolute test may help.

64 bit dymola - exec format error

Hi,

since installing Dymola2015 (64 bit - linux) the regression tests no longer work for me:

Traceback (most recent call last):
  File "RunUnitTests.py", line 39, in <module>
    tester.run()
  File "/usr/local/lib/python2.7/dist-packages/buildingspy-1.4.0-py2.7.egg/buildingspy/development/regressiontest.py", line 1616, in run
    runSimulation(os.path.join(self._temDir[0], libNam), cmd)
  File "/usr/local/lib/python2.7/dist-packages/buildingspy-1.4.0-py2.7.egg/buildingspy/development/regressiontest.py", line 33, in runSimulation
    cwd=worDir)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1308, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error

Is this a known issue or is it machine-dependent?

2 problems with using MODELICAPATH in buildingspy.simulate.Simulator

I am trying to use the buildingspy simulator from current master to simulate a model that uses more than one library other than the MSL. I am using Dymola 2015 on Windows 7. I specify the library which contains the model to simulate via the packagePath variable:

s = si.Simulator(model, 'dymola', saveAtPath, packagePath = PathOfMyLibrary)

MyLibrary contains a uses-statement to the other libraries needed, which Dymola finds in MODELICAPATH. This works in some cases, yet I am experiencing 2 problems when using MODELICAPATH instead of the packagePath:

  • Dymola 2015 and buildingsPy seem to use different definitions for the MODELICAPATH. Let the path of my buildings library clone be ...\modelica-buildings\Buildings\package.mo. While buildingsPy seems to require the directory that contains the package.mo (e.g. MODELICAPATH = ...\modelica-buildings\Buildings), Dymola seems to require the path to lead one directory higher (e.g. MODELICAPATH = ...\modelica-buildings).
  • Dymola accepts more than one path in MODELICAPATH, separated by semi-colons, e.g. ...\library1 and ...\library2 as ...\library1;...\library2. In buildingsPy, this leads to a Value Error "Argument packagePath= ...\library1;...\library2 does not exist."

Bug in regressiontest under windows

the file regressiontest gives an error under Windows due to the use of json library: all the path needs to be given with double escape (\\) or forward slash /. Otherwise its give an escape error.

There is also an error with loading the file statistics.json. The path should also only contain double escape. I do not understand why but I could not replace the single escape between ..\Temp\tmp... to a double one using the command replace. I had to use replace("Temp\tmp","Temp\\tmp").

I will issue a pull request which works for me in Windows. I do not, however, if this will be compatible with Linux system.

I also had to use chech_html=False as libtidy also gave some errors. I have tried many things but so far unsuccesfully.

overwrite reference results when merging

Currently reference results are not overwritten when merging files. This is based on code excerpt:

# Only copy reference results if no such file exists.
                    # If a reference file already exists, then don't change it.
                    # This requires to replace
                    # the name of the library in names of the result file
                    elif desFil.startswith(ref_res):
                        dir_name = os.path.dirname(desFil)
                        base_name = os.path.basename(desFil)
                        new_file = os.path.join(dir_name,
                                                base_name.replace("Annex60",
                                                                  self._new_library_name))
                        if not os.path.isfile(new_file):
                            copiedFiles.append(new_file)
                            shutil.copy2(srcFil, new_file)

I would prefer it if they are updated, or if there would exist a way of overriding this default setting. This way I don't have to go through all changed unit test results for models that are imported from Annex60. Can this be changed?

[ubuntu] buildingspy simulations in linux screens crash when bash is closed

Dear developers,
first of all, thanks so much for making this awesome tool available to us Dymola users!
I am experiencing a problem though when using buildingspy 1.5.0 to run Dymola 2015FD01 simulations on a linux machine with ubuntu, to which I connect on my local laptop via SSH.

What I want to do is: run multiple Dymola simulations, managed by Python scripts via buildingspy, in linux screens so that I can detach from the screens and disconnect my laptop from the network while the simulations continue to run. This works as long as I keep the bash/login shell open (which of course requires me to stay in the network). However, even after detaching from the screen, closing the bash/login shell will lead to simulation aborts.

The symptoms are as follows:
[case 1] when Dymola is still loading or translating, closing the login shell leads to an immediate crash
[case 2] when Dymola is already simulating, it seems that buildingspy is deleting the temporary directory and I receive the same error message about the missing log file (see below), but Dymola continues to execute the simulation and to write into the already-deleted directory. After the simulation is finished, the Dymola process stops, but buildingspy cannot find the result and log files because the directory is already removed.

So it appears that buildingspy stays connected to something outside the screen, even though Dymola's core simulation process is detached from the bash and continues to run. Do you have an idea what could be the cause of this, or how I could work around this?

Thanks a bunch,
Konstantin

Error message in both cases:
error1_when_dymol_is_loading translating

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.