Skip to content

Commit

Permalink
Merge branch 'release/v0.0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed Oct 13, 2017
2 parents c28f34f + 09ad5ed commit 0b70b28
Show file tree
Hide file tree
Showing 32 changed files with 1,525 additions and 967 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
build/
dist/
MANIFEST
*.egg-info

# PyCharm project
.idea/
Expand Down
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: python

python:
- "2.7"
- 2.7
- 3.6

install: "pip install -r requirements.txt"
install:
- pip install -r requirements.txt

script:
- pip install .
Expand All @@ -16,4 +18,5 @@ deploy:
user: t-sommer
password:
secure: H4EFw/NtTmmFLOB2yjP8d3uqsPDCzG4WV7RbeEu3rRwz39cZxKkBEvBokKYVPo7tLRwWTQjYGbrwOaLME3hBNo0Mjc9d99Ivcy6UTeE4T6AUln//STDOjy2geJnkBCStZ5I21N+bVom6lzT0Oe0EUnJNBQWnJza7EuMSoTdaH3us5Obtc3F1dqbUensdvaUUvZw9Px7lIQ2C1drwgZvh3yArXX8rVAtxq9wpa601G6tKtrwRcgS4v1jAK8p7MJdFVA/9i5ZAXB/L4waE3pv+k52bjFJ9lcaYOwYcxBedqriKYV78q0+VmBn1TfMK0oNEDgg7abVjZwnx17oGvm389BeEFzN7GXX3RsoNNUlcMFXEEaFVuCWwXNG3Sx6HHsz9zyOE6jbhMt1ag4VHZsCoWO/UoXL7jbd46kBIOuixVgkPZlQSP6FA0/jch85940tYtPQXBxldOiwjYyFFUxv/47iTaB0aAt6Elm+2c/dxgDd0jS/FwmGdChrYcjLU8qjy2/ApMps1C2u00nxN6P/OxqbY0fIqgBFHQOsEgEoSe6sGDzPTOtQrsp/3pP3At1KR8czBkTUxWb+5Xa+ObM/qc4Jcy3QAoLRlGIyId9frOpViI/VgM4RpT+i0chaOwY4yFAexkWwGtWST58VKgvnzYTtnTQ/g+fRgFal3NtkEWUo=
distributions: sdist bdist_wheel
skip_cleanup: true
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [0.0.9] - 2017-10-13

### Fixed
- set start values of type String

### Added
- CVode variable-step solver
- cross-check API for external tools

## [0.0.8] - 2017-09-10

### Fixed
Expand Down
80 changes: 80 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
FMPy
====

Copyright (c) 2017 Dassault Systemes. All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -26,3 +29,80 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



SUNDIALS
========

FMPy contains a compiled version of the CVODE solver that is part of SUNDIALS
available from http://computation.llnl.gov/projects/sundials and subject to
the following licence.


Copyright (c) 2002-2016, Lawrence Livermore National Security.
Produced at the Lawrence Livermore National Laboratory.
Written by A.C. Hindmarsh, D.R. Reynolds, R. Serban, C.S. Woodward,
S.D. Cohen, A.G. Taylor, S. Peles, L.E. Banks, and D. Shumaker.
LLNL-CODE-667205 (ARKODE)
UCRL-CODE-155951 (CVODE)
UCRL-CODE-155950 (CVODES)
UCRL-CODE-155952 (IDA)
UCRL-CODE-237203 (IDAS)
LLNL-CODE-665877 (KINSOL)
All rights reserved.

This file is part of SUNDIALS. For details,
see http://computation.llnl.gov/projects/sundials

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the disclaimer below.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the disclaimer (as noted below)
in the documentation and/or other materials provided with the
distribution.

3. Neither the name of the LLNS/LLNL nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF
ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Additional BSD Notice
---------------------
1. This notice is required to be provided under our contract with
the U.S. Department of Energy (DOE). This work was produced at
Lawrence Livermore National Laboratory under Contract
No. DE-AC52-07NA27344 with the DOE.

2. Neither the United States Government nor Lawrence Livermore
National Security, LLC nor any of their employees, makes any warranty,
express or implied, or assumes any liability or responsibility for the
accuracy, completeness, or usefulness of any information, apparatus,
product, or process disclosed, or represents that its use would not
infringe privately-owned rights.

3. Also, reference herein to any specific commercial products, process,
or services by trade name, trademark, manufacturer or otherwise does
not necessarily constitute or imply its endorsement, recommendation,
or favoring by the United States Government or Lawrence Livermore
National Security, LLC. The views and opinions of authors expressed
herein do not necessarily state or reflect those of the United States
Government or Lawrence Livermore National Security, LLC, and shall
not be used for advertising or product endorsement purposes.
29 changes: 18 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
FMPy
====

FMPy is a Python library to simulate `Functional Mockup Units (FMUs) <http://fmi-standard.org/>`_ that...
FMPy is a free Python library to simulate `Functional Mockup Units (FMUs) <http://fmi-standard.org/>`_ that...

- supports FMI 1.0 and 2.0
- supports Co-Simulation and Model Exchange
- runs on Windows, Linux and macOS
- can validate FMUs
- provides fixed and variable-step solvers
- is pure Python (with ctypes)


Expand All @@ -31,21 +32,27 @@ or, to install the latest development version::
Simulate an FMU on the command line
-----------------------------------

To simulate CoupledClutches.fmu and plot the results download the FMU for your platform
To simulate Rectifier.fmu and plot the results download the FMU for your platform
and run the following command in the folder where you downloaded the FMU::

python -m fmpy.simulate CoupledClutches.fmu
python -m fmpy.simulate Rectifier.fmu --show-plot


+---------------------+---------------------+---------------------+-------------------+-------------------+--------+
| CoupledClutches.fmu | `Windows (32-bit)`_ | `Windows (64-bit)`_ | `Linux (32-bit)`_ | `Linux (64-bit)`_ | macOS_ |
+---------------------+---------------------+---------------------+-------------------+-------------------+--------+
+---------------+---------------------+---------------------+-------------------+-------------------+--------+
| Rectifier.fmu | `Windows (32-bit)`_ | `Windows (64-bit)`_ | `Linux (32-bit)`_ | `Linux (64-bit)`_ | macOS_ |
+---------------+---------------------+---------------------+-------------------+-------------------+--------+

.. _Windows (32-bit): https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_2.0/CoSimulation/win32/MapleSim/2016.2/CoupledClutches/CoupledClutches.fmu
.. _Windows (64-bit): https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_2.0/CoSimulation/win64/MapleSim/2016.2/CoupledClutches/CoupledClutches.fmu
.. _Linux (32-bit): https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_2.0/CoSimulation/linux32/MapleSim/2016.2/CoupledClutches/CoupledClutches.fmu
.. _Linux (64-bit): https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_2.0/CoSimulation/linux64/MapleSim/2016.2/CoupledClutches/CoupledClutches.fmu
.. _macOS: https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_2.0/CoSimulation/darwin64/MapleSim/2016.2/CoupledClutches/CoupledClutches.fmu
.. _Windows (32-bit): https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_2.0/CoSimulation/win32/MapleSim/2016.2/Rectifier/Rectifier.fmu
.. _Windows (64-bit): https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_2.0/CoSimulation/win64/MapleSim/2016.2/Rectifier/Rectifier.fmu
.. _Linux (32-bit): https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_2.0/CoSimulation/linux32/MapleSim/2016.2/Rectifier/Rectifier.fmu
.. _Linux (64-bit): https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_2.0/CoSimulation/linux64/MapleSim/2016.2/Rectifier/Rectifier.fmu
.. _macOS: https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_2.0/CoSimulation/darwin64/MapleSim/2016.2/Rectifier/Rectifier.fmu

.. image:: Rectifier_result.png

To get more information about the available options type::

python -m fmpy.simulate --help


Simulate an FMU in Python
Expand Down
Binary file added Rectifier_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ environment:
MINICONDA: C:\Miniconda35-x64

init:
- "echo %PYTHON_VERSION% %MINICONDA%"
- echo %PYTHON_VERSION% %MINICONDA%

install:
- git submodule update --init --recursive
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%"
- set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- "conda create -q -n test-env python=%PYTHON_VERSION% numpy lxml pathlib requests pywin32"
- conda create -q -n test-env python=%PYTHON_VERSION% numpy lxml pathlib requests pywin32
- activate test-env

test_script:
Expand Down
34 changes: 31 additions & 3 deletions fmpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
""" Simulate Functional Mockup Units (FMUs) in Python """

# noinspection PyPep8

import sys
import os
from ctypes import *
import _ctypes
import zipfile
from tempfile import mkdtemp

__version__ = '0.0.8'
__version__ = '0.0.9'


# determine the platform
Expand Down Expand Up @@ -151,6 +149,36 @@ def extract(filename):
return unzipdir


def download_test_file(fmi_version, fmi_type, tool_name, tool_version, model_name, filename):
""" Download a file from the Test FMUs repository to the current directory """

import requests

# download the FMU and input file
url = 'https://trac.fmi-standard.org/export/HEAD/branches/public/Test_FMUs/FMI_' + fmi_version
url = '/'.join([url, fmi_type, platform, tool_name, tool_version, model_name, filename])

print('Downloading ' + url)

status_code = -1

# try to download the file three times
try:
for _ in range(3):
if status_code != 200:
response = requests.get(url)
status_code = response.status_code
except:
pass

if status_code != 200:
raise Exception("Failed to download %s (status code: %d)" % (url, status_code))

# write the file
with open(filename, 'wb') as f:
f.write(response.content)


# make the functions available in the fmpy module
from .model_description import read_model_description
from .simulation import simulate_fmu
Loading

0 comments on commit 0b70b28

Please sign in to comment.