Skip to content
This repository has been archived by the owner on Feb 12, 2020. It is now read-only.

Commit

Permalink
Add *_ref.opt files and copy FMUs to cross-check
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed Feb 24, 2019
1 parent e4dee65 commit ce40604
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 3 deletions.
4 changes: 4 additions & 0 deletions BouncingBall/BouncingBall_ref.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
StartTime, 0
StopTime, 3
StepSize, 0
RelTol, 1e-5
4 changes: 4 additions & 0 deletions Dahlquist/Dahlquist_ref.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
StartTime, 0
StopTime, 10
StepSize, 0
RelTol, 1e-5
4 changes: 4 additions & 0 deletions Feedthrough/Feedthrough_ref.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
StartTime, 0
StopTime, 2
StepSize, 0
RelTol, 1e-5
4 changes: 4 additions & 0 deletions LinearTransform/LinearTransform_ref.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
StartTime, 0
StopTime, 10
StepSize, 0
RelTol, 1e-5
4 changes: 4 additions & 0 deletions Resource/Resource_ref.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
StartTime, 0
StopTime, 1
StepSize, 0
RelTol, 1e-5
4 changes: 4 additions & 0 deletions Stair/Stair_ref.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
StartTime, 0
StopTime, 10
StepSize, 0
RelTol, 1e-5
4 changes: 4 additions & 0 deletions VanDerPol/VanDerPol_ref.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
StartTime, 0
StopTime, 20
StepSize, 0
RelTol, 1e-5
33 changes: 30 additions & 3 deletions test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import os
import shutil


fmus_dir = None # /path/to/fmi-cross-check/fmus

try:
from fmpy import simulate_fmu
fmpy_available = True
Expand Down Expand Up @@ -33,6 +36,21 @@
generator = 'Unix Makefiles'


def copy_to_cross_check(build_dir, model_names, fmi_version, fmi_types):

if fmus_dir is None:
return

for fmi_type in fmi_types:
for model in model_names:
target_dir = os.path.join(fmus_dir, fmi_version, fmi_type, fmpy.platform, 'Test-FMUs', '0.0.0', model)
if not os.path.exists(target_dir):
os.makedirs(target_dir)
shutil.copy(os.path.join(build_dir, 'dist', model + '.fmu'), target_dir)
shutil.copy(os.path.join(test_fmus_dir, model, model + '_ref.csv'), target_dir)
shutil.copy(os.path.join(test_fmus_dir, model, model + '_ref.opt'), target_dir)


class BuildTest(unittest.TestCase):
""" Build all variants of the Test FMUs and simulate the default experiment """

Expand Down Expand Up @@ -87,11 +105,14 @@ def test_fmi1_me(self):
subprocess.call(['cmake', '-G', generator, '-DFMI_VERSION=1', '-DFMI_TYPE=ME', '..'], cwd=build_dir)
subprocess.call(['cmake', '--build', '.', '--config', 'Release'], cwd=build_dir)

model_names = ['BouncingBall', 'Dahlquist', 'Stair', 'VanDerPol']

if fmpy_available:
self.validate(build_dir,
fmi_types=['ModelExchange'],
models=['BouncingBall', 'Dahlquist', 'Stair', 'VanDerPol']
)
models=model_names)

copy_to_cross_check(build_dir=build_dir, model_names=model_names, fmi_version='1.0', fmi_types=['me'])

def test_fmi1_cs(self):

Expand All @@ -103,10 +124,14 @@ def test_fmi1_cs(self):
subprocess.call(['cmake', '-G', generator, '-DFMI_VERSION=1', '-DFMI_TYPE=CS', '..'], cwd=build_dir)
subprocess.call(['cmake', '--build', '.', '--config', 'Release'], cwd=build_dir)

model_names = ['BouncingBall', 'Dahlquist', 'Resource', 'Stair', 'VanDerPol']

if fmpy_available:
self.validate(build_dir,
fmi_types=['CoSimulation'],
models=['BouncingBall', 'Dahlquist', 'Resource', 'Stair', 'VanDerPol'])
models=model_names)

copy_to_cross_check(build_dir=build_dir, model_names=model_names, fmi_version='1.0', fmi_types=['cs'])

def test_fmi2(self):

Expand All @@ -121,6 +146,8 @@ def test_fmi2(self):
if fmpy_available:
self.validate(build_dir)

copy_to_cross_check(build_dir=build_dir, model_names=models, fmi_version='2.0', fmi_types=['cs', 'me'])

def test_fmi3(self):

print('FMI 3.0')
Expand Down

0 comments on commit ce40604

Please sign in to comment.