Skip to content

Commit 92e7f86

Browse files
authored
Merge pull request #15 from openfedem/run-fmu-fix
Installation guide update and new versions
2 parents 7dd300a + 64ca10e commit 92e7f86

File tree

7 files changed

+65
-47
lines changed

7 files changed

+65
-47
lines changed

docs/examples/digital_twins.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ my_model.edit_triad(t3, load={'Tz' : my_model.make_function('Wheel force', tag='
116116
# Ouput sensors
117117
my_model.make_sensor('Damper force', (s1, d1), FmVar.FORCE, tag='damper_force')
118118
my_model.make_sensor('Damper deformation', s1, FmVar.DEFLECTION, tag='damper_deformation')
119-
my_model.make_sensor('Steering pin deflection', t0, FmVar.POS, FmDof.TZ, tag='pin_deflection')
119+
my_model.make_sensor('Steering pin deflection', t0, FmVar.POS, FmDof.TZ, 'pin_deflection')
120120

121121
my_model.fm_solver_setup(t_inc=0.005, t_end=2.5, t_quasi=-1.0)
122122
my_model.fm_solver_tol(1.0e-6,1.0e-6,1.0e-6)
@@ -142,7 +142,7 @@ You find this in the *File* menu (*File --> Export --> Export Digital Twin...*).
142142

143143
This dialog box shows three alternative ways of exporting the model,
144144
but only the **FMU** option is relevant here. So enable that toggle.
145-
Then use the **Browse...** button to selected the name for the fmu-file.
145+
Then use the **Browse...** button to select the name for the fmu-file.
146146
In the right side of the dialog, you find a list of the input- and output
147147
indicators in the model, corresponding to the external functions
148148
and output sensors defined in the modelling script.
@@ -232,9 +232,10 @@ Use this as a template for more advanced co-simulation tasks with FEDEM FMUs.
232232
[Download...](linked_files/run_fedem_fmu.py)
233233

234234
```python
235-
from fmpy import fmi2, read_model_description, extract
236-
from pandas import read_csv
237235
from sys import argv
236+
from os import path
237+
from pandas import read_csv
238+
from fmpy import fmi2, read_model_description, extract
238239

239240

240241
def run(fmu_file, input_file=None, instance_name="my instance"):
@@ -249,6 +250,11 @@ def run(fmu_file, input_file=None, instance_name="my instance"):
249250
print("Extracting", fmu_file, "...")
250251
unzipdir = extract(fmu_file)
251252

253+
# Get absolute path of input_file because the fmu.instantiate() call
254+
# will change the working directory
255+
if input_file is not None:
256+
input_file = path.abspath(input_file)
257+
252258
# Setup the FMU
253259
print("Setup the FMU", model.coSimulation.modelIdentifier)
254260
fmu = fmi2.FMU2Slave(guid=model.guid, unzipDirectory=unzipdir,
@@ -263,16 +269,15 @@ def run(fmu_file, input_file=None, instance_name="my instance"):
263269
num_inputs = num_params[0] # Number of input sensors
264270
num_output = num_params[1] # Number of output sensors
265271

266-
# Read the input values into a Dataframe
267-
if input_file is None:
268-
inputs = None
269-
elif num_inputs > 0:
270-
inputs = read_csv(input_file, sep="\t")
272+
if input_file is None or num_inputs < 1:
273+
inputs = None # All inputs are assumed defined internally in the model
274+
else: # Read the input values into a Dataframe
275+
inputs = read_csv(input_file, sep=",")
271276

272277
# List of external function indices
273-
inpIdx = range(num_inputs)
278+
inp_idx = range(num_inputs)
274279
# List of output sensor indices
275-
outIdx = range(num_inputs,num_inputs+num_output)
280+
out_idx = range(num_inputs, num_inputs+num_output)
276281

277282
# Time loop, this will run through the FEDEM simulation
278283
# using the time domain setup of the model file used to export the FMU.
@@ -282,13 +287,13 @@ def run(fmu_file, input_file=None, instance_name="my instance"):
282287
while not fmu.getBooleanStatus(fmi2.fmi2Terminated):
283288
if inputs is not None: # Set external function values for next step
284289
# First column of inputs is not used, assuming it contains the time
285-
fmu.setReal([*inpIdx], inputs.iloc[step].tolist()[1:])
290+
fmu.setReal([*inp_idx], inputs.iloc[step].tolist()[1:])
286291

287292
fmu.doStep(0.0, 0.0) # Advance the simulation on step
288293

289294
step += 1
290295
time = fmu.getRealStatus(fmi2.fmi2LastSuccessfulTime)
291-
output = fmu.getReal([*outIdx])
296+
output = fmu.getReal([*out_idx])
292297
print(f"Here are the outputs at step={step} time={time}:", output)
293298

294299
# Finished, close down

docs/examples/linked_files/loader_modeling_and_solving.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737

3838
# Load the FE parts
3939
parts = [my_model.make_fe_part(f) for f in FILES]
40+
if any(p < 0 for p in parts):
41+
print("Failed to load FE parts")
42+
exit(1)
4043

4144
# Edit some part properties
4245
my_model.edit_part(parts, alpha2=0.00286, component_modes=0, consistent_mass=True)
@@ -130,7 +133,8 @@
130133
constraints={'Rz' : FmDofStat.SPRING},
131134
spring={'Rz' : 1.0e9},
132135
length={'Rz' : f3})
133-
[my_model.edit_joint(j, Rx=90) for j in [j03, j04, j05, j06, j07, j08, j09, j10]]
136+
for j in [j03, j04, j05, j06, j07, j08, j09, j10]:
137+
my_model.edit_joint(j, Rx=90)
134138

135139
my_model.fm_solver_setup(t_inc=0.01, t_end=1.6)
136140
my_model.close(True, True)

docs/examples/linked_files/run_fedem_fmu.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
Usage: python -m run_fedem_fmu <fmu-file> <input-file>
99
"""
1010

11-
from fmpy import fmi2, read_model_description, extract
12-
from pandas import read_csv
1311
from sys import argv
12+
from os import path
13+
from pandas import read_csv
14+
from fmpy import fmi2, read_model_description, extract
1415

1516

1617
def run(fmu_file, input_file=None, instance_name="my instance"):
@@ -25,6 +26,11 @@ def run(fmu_file, input_file=None, instance_name="my instance"):
2526
print("Extracting", fmu_file, "...")
2627
unzipdir = extract(fmu_file)
2728

29+
# Get absolute path of input_file because the fmu.instantiate() call
30+
# will change the working directory
31+
if input_file is not None:
32+
input_file = path.abspath(input_file)
33+
2834
# Setup the FMU
2935
print("Setup the FMU", model.coSimulation.modelIdentifier)
3036
fmu = fmi2.FMU2Slave(guid=model.guid, unzipDirectory=unzipdir,
@@ -39,16 +45,15 @@ def run(fmu_file, input_file=None, instance_name="my instance"):
3945
num_inputs = num_params[0] # Number of input sensors
4046
num_output = num_params[1] # Number of output sensors
4147

42-
# Read the input values into a Dataframe
43-
if input_file is None:
44-
inputs = None
45-
elif num_inputs > 0:
48+
if input_file is None or num_inputs < 1:
49+
inputs = None # All inputs are assumed defined internally in the model
50+
else: # Read the input values into a Dataframe
4651
inputs = read_csv(input_file, sep=",")
4752

4853
# List of external function indices
49-
inpIdx = range(num_inputs)
54+
inp_idx = range(num_inputs)
5055
# List of output sensor indices
51-
outIdx = range(num_inputs,num_inputs+num_output)
56+
out_idx = range(num_inputs, num_inputs+num_output)
5257

5358
# Time loop, this will run through the FEDEM simulation
5459
# using the time domain setup of the model file used to export the FMU.
@@ -58,13 +63,13 @@ def run(fmu_file, input_file=None, instance_name="my instance"):
5863
while not fmu.getBooleanStatus(fmi2.fmi2Terminated):
5964
if inputs is not None: # Set external function values for next step
6065
# First column of inputs is not used, assuming it contains the time
61-
fmu.setReal([*inpIdx], inputs.iloc[step].tolist()[1:])
66+
fmu.setReal([*inp_idx], inputs.iloc[step].tolist()[1:])
6267

6368
fmu.doStep(0.0, 0.0) # Advance the simulation on step
6469

6570
step += 1
6671
time = fmu.getRealStatus(fmi2.fmi2LastSuccessfulTime)
67-
output = fmu.getReal([*outIdx])
72+
output = fmu.getReal([*out_idx])
6873
print(f"Here are the outputs at step={step} time={time}:", output)
6974

7075
# Finished, close down
224 Bytes
Binary file not shown.

docs/examples/linked_files/sla_modeling.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
lca = my_model.make_fe_part(PARTS_PATH + 'lca.nas')
3131
knuckle = my_model.make_fe_part(PARTS_PATH + 'knuckle.nas')
3232
uca = my_model.make_fe_part(PARTS_PATH + 'uca.nas')
33+
if any(p < 0 for p in [lca, knuckle, uca]):
34+
print("Loading FE parts failed")
35+
exit(1)
3336

3437
# Lower control arm joints to ground
3538
j1 = my_model.make_joint('Fix 1', FmType.BALL_JOINT,

docs/installation_guide.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ the latest built release, and run some of the example models provided.
55

66
## Installation
77

8-
64-bit binaries are now provided for both Windows and Linux (Ubuntu 22.04).
8+
64-bit binaries are provided for Windows and Linux (Ubuntu 22.04) platform.
99
To install the latest Windows release, proceed as follows:
1010

11-
* Go to the [Releases](https://github.com/openfedem/fedem-gui/releases) page
12-
on the [fedem-gui](https://github.com/openfedem/fedem-gui) repository on github,
13-
and download the most recent zip-file `FedemInstaller-*.zip`.
14-
* Alternatively, you may download the latest Windows installer
15-
from the **Download** menu in the left pane.
16-
* Unzip this file at arbitrary location on your PC.
11+
* Go to the **Download** menu in the left pane and choose **Windows installer (zip)**.
12+
This will download a zip-file `FedemInstaller-*.zip` with the latest installation.
13+
You may also go to the [Releases](https://github.com/openfedem/fedem-gui/releases)
14+
page of the [fedem-gui](https://github.com/openfedem/fedem-gui) repository
15+
on github if you need to download some of the earlier releases.
16+
* Unzip the downloaded file at arbitrary location on your PC.
1717
* Execute the `INSTALL.bat` file as administrator.
1818
This will (by default) install the software in the folder "C:\Program Files\FEDEM"
1919
on your PC, set the file association for FEDEM model files to the GUI executable
@@ -26,12 +26,12 @@ To install the latest Windows release, proceed as follows:
2626
That is, download the file [vc_redist.x64.exe](https://aka.ms/vs/17/release/vc_redist.x64.exe)
2727
and execute it as administrator.
2828

29-
To install the latest Linux release,
30-
download the most recent `Fedem-*_Ubuntu-22.04.tar.gz` file
31-
from the [Releases](https://github.com/openfedem/fedem-gui/releases) page
32-
(it is also available from the **Download** menu in the left pane).
29+
To install the latest Linux release, choose **Linux installation (tar.gz)**
30+
from the **Downlad** menu in the left pane. This will download a compressed tar-file
31+
`Fedem-*_Ubuntu-22.04.tar.gz` with the latest Linux installation. You will also find this
32+
and earlier versions on the [Releases](https://github.com/openfedem/fedem-gui/releases) page.
3333

34-
Unpack this file in the location where you want to have Fedem installed, e.g.:
34+
Unpack the downloaded file in the location where you want to have Fedem installed, e.g.:
3535

3636
$ cd /usr/local
3737
$ sudo tar zxfv ~/Downloads/Fedem-R8.1.1_Ubuntu-22.04.tar.gz

mkdocs.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ repo_url: https://github.com/openfedem/fedem-gui/
88
nav:
99
- Welcome: index.md
1010
- Getting started:
11-
- Installation Guide: installation_guide.md
12-
- Development Setup: development_setup.md
11+
- Installation guide: installation_guide.md
12+
- Development setup: development_setup.md
1313
- Python API (fedempy): python_api.md
1414
- Download:
15-
- Windows installer (zip): https://github.com/openfedem/fedem-gui/releases/download/fedem-8.1.1/FedemInstaller-R8.1.1.zip
16-
- Linux installation (tar.gz): https://github.com/openfedem/fedem-gui/releases/download/fedem-8.1.1/Fedem-R8.1.1_Ubuntu-22.04.tar.gz
17-
- Linux solvers (tar.gz): https://github.com/openfedem/fedem-solvers/releases/download/fedem-8.1.1/fedem-solvers-4.1.1_linux64.tar.gz
18-
- fedempy package (tar.gz): https://github.com/openfedem/fedem-solvers/releases/download/fedem-8.1.1/fedempy-4.1.1.tar.gz
15+
- Windows installer (zip): https://github.com/openfedem/fedem-gui/releases/download/fedem-8.1.2/FedemInstaller-R8.1.2.zip
16+
- Linux installation (tar.gz): https://github.com/openfedem/fedem-gui/releases/download/fedem-8.1.2/Fedem-R8.1.2_Ubuntu-22.04.tar.gz
17+
- Windows solvers (zip): https://github.com/openfedem/fedem-solvers/releases/download/fedem-8.1.1.3/fedem-solvers-4.1.3_win64.zip
18+
- Linux solvers (tar.gz): https://github.com/openfedem/fedem-solvers/releases/download/fedem-8.1.1.3/fedem-solvers-4.1.3_linux64.tar.gz
19+
- fedempy package (tar.gz): https://github.com/openfedem/fedem-solvers/releases/download/fmu-8.1.2/fedempy-4.2.1.tar.gz
1920
- Documentation:
20-
- User Guide (PDF): https://github.com/openfedem/fedem-docs/releases/download/fedem-8.1.1/FedemUsersGuide.pdf
21-
- Theory Guide (PDF): https://github.com/openfedem/fedem-docs/releases/download/fedem-8.1.1/FedemTheoryGuide.pdf
21+
- User guide (PDF): https://github.com/openfedem/fedem-docs/releases/download/fedem-8.1.1/FedemUsersGuide.pdf
22+
- Theory guide (PDF): https://github.com/openfedem/fedem-docs/releases/download/fedem-8.1.1/FedemTheoryGuide.pdf
2223
- Python API (fedempy): https://openfedem.github.io/fedem-solvers/fedempy/
2324
- Solver source code: https://openfedem.github.io/fedem-solvers/solver/
2425
- Tutorials: tutorials.md
25-
- YouTube videos: youtube_videos.md
2626
- Discussions: discussions.md
27-
- Issues (Bugs): issues.md
27+
- Issues (bugs): issues.md
2828
- Examples:
2929
- Introduction: examples/introduction.md
3030
- The Loader: examples/loader.md
@@ -33,10 +33,11 @@ nav:
3333
#- Model imports: examples/C_imports.md
3434
#- Industrial applications: examples/D_industrial_applications.md
3535
#- Simulators: examples/E_simulators.md
36-
- Digital Twins: examples/digital_twins.md
3736
#- Benchmarks: examples/G_case_studies.md
3837
#- Physics cases: examples/H_physics.md
3938
#- API: examples/I_api.md
39+
- Digital twins: examples/digital_twins.md
40+
- Training videos: youtube_videos.md
4041
- Developer area: developer_area.md
4142
- Partner area: partner_area.md
4243

0 commit comments

Comments
 (0)