pystormflow 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pystormflow-0.2.0/CHANGELOG.md +11 -0
- {pystormflow-0.1.0 → pystormflow-0.2.0}/Cargo.lock +36 -70
- {pystormflow-0.1.0 → pystormflow-0.2.0}/Cargo.toml +4 -4
- {pystormflow-0.1.0 → pystormflow-0.2.0}/PKG-INFO +64 -64
- {pystormflow-0.1.0 → pystormflow-0.2.0}/README.md +63 -63
- {pystormflow-0.1.0 → pystormflow-0.2.0}/pyproject.toml +37 -37
- {pystormflow-0.1.0 → pystormflow-0.2.0}/pystormflow/__init__.py +17 -17
- {pystormflow-0.1.0 → pystormflow-0.2.0}/pystormflow/__init__.pyi +89 -89
- {pystormflow-0.1.0 → pystormflow-0.2.0}/src/result_structs.rs +2 -2
- {pystormflow-0.1.0 → pystormflow-0.2.0}/src/simulation.rs +86 -86
- {pystormflow-0.1.0 → pystormflow-0.2.0}/.gitignore +0 -0
- {pystormflow-0.1.0 → pystormflow-0.2.0}/LICENSE +0 -0
- {pystormflow-0.1.0 → pystormflow-0.2.0}/src/lib.rs +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change log pystormflow
|
|
2
|
+
|
|
3
|
+
This file contains an overview of the changes made to pystormflow, the Python interface to the Stormflow CFD solver. See the [Stormflow change log](../../stormflow/CHANGELOG.md) for changes to the solver, and the [Stormbird change log](../../stormbird/CHANGELOG.md) for changes to the actuator line model.
|
|
4
|
+
|
|
5
|
+
## 0.2.0 - 2026-10-23
|
|
6
|
+
### Breaking changes
|
|
7
|
+
- Depends on Stormflow 0.2.0, Stormbird 0.11.0 and Stormath 0.4.0. The input format for the Stormbird models has changed in Stormbird 0.11.0, so setup files may need to be updated.
|
|
8
|
+
- The `gyroscopic` property of the `SectionalForces` class is renamed to `gyroscopic_moment`, as the gyroscopic effect is now a pure moment in Stormbird. The `gyroscopic` property of the `IntegratedValues` class is unchanged.
|
|
9
|
+
|
|
10
|
+
## 0.1.0
|
|
11
|
+
The first version.
|
|
@@ -156,6 +156,17 @@ version = "0.2.2"
|
|
|
156
156
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
157
157
|
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
|
|
158
158
|
|
|
159
|
+
[[package]]
|
|
160
|
+
name = "chacha20"
|
|
161
|
+
version = "0.10.2"
|
|
162
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
163
|
+
checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
|
|
164
|
+
dependencies = [
|
|
165
|
+
"cfg-if",
|
|
166
|
+
"cpufeatures",
|
|
167
|
+
"rand_core",
|
|
168
|
+
]
|
|
169
|
+
|
|
159
170
|
[[package]]
|
|
160
171
|
name = "clap"
|
|
161
172
|
version = "4.6.6"
|
|
@@ -226,6 +237,15 @@ dependencies = [
|
|
|
226
237
|
"windows-sys 0.59.0",
|
|
227
238
|
]
|
|
228
239
|
|
|
240
|
+
[[package]]
|
|
241
|
+
name = "cpufeatures"
|
|
242
|
+
version = "0.3.1"
|
|
243
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
244
|
+
checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
|
|
245
|
+
dependencies = [
|
|
246
|
+
"libc",
|
|
247
|
+
]
|
|
248
|
+
|
|
229
249
|
[[package]]
|
|
230
250
|
name = "crossbeam-deque"
|
|
231
251
|
version = "0.8.7"
|
|
@@ -370,18 +390,6 @@ dependencies = [
|
|
|
370
390
|
"tempfile",
|
|
371
391
|
]
|
|
372
392
|
|
|
373
|
-
[[package]]
|
|
374
|
-
name = "getrandom"
|
|
375
|
-
version = "0.3.4"
|
|
376
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
377
|
-
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
|
|
378
|
-
dependencies = [
|
|
379
|
-
"cfg-if",
|
|
380
|
-
"libc",
|
|
381
|
-
"r-efi 5.3.0",
|
|
382
|
-
"wasip2",
|
|
383
|
-
]
|
|
384
|
-
|
|
385
393
|
[[package]]
|
|
386
394
|
name = "getrandom"
|
|
387
395
|
version = "0.4.3"
|
|
@@ -390,7 +398,8 @@ checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
|
|
|
390
398
|
dependencies = [
|
|
391
399
|
"cfg-if",
|
|
392
400
|
"libc",
|
|
393
|
-
"r-efi
|
|
401
|
+
"r-efi",
|
|
402
|
+
"rand_core",
|
|
394
403
|
]
|
|
395
404
|
|
|
396
405
|
[[package]]
|
|
@@ -830,15 +839,6 @@ dependencies = [
|
|
|
830
839
|
"portable-atomic",
|
|
831
840
|
]
|
|
832
841
|
|
|
833
|
-
[[package]]
|
|
834
|
-
name = "ppv-lite86"
|
|
835
|
-
version = "0.2.21"
|
|
836
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
837
|
-
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
|
838
|
-
dependencies = [
|
|
839
|
-
"zerocopy",
|
|
840
|
-
]
|
|
841
|
-
|
|
842
842
|
[[package]]
|
|
843
843
|
name = "presser"
|
|
844
844
|
version = "0.3.1"
|
|
@@ -919,7 +919,7 @@ dependencies = [
|
|
|
919
919
|
|
|
920
920
|
[[package]]
|
|
921
921
|
name = "pystormflow"
|
|
922
|
-
version = "0.
|
|
922
|
+
version = "0.2.0"
|
|
923
923
|
dependencies = [
|
|
924
924
|
"pyo3",
|
|
925
925
|
"stormath",
|
|
@@ -936,12 +936,6 @@ dependencies = [
|
|
|
936
936
|
"proc-macro2",
|
|
937
937
|
]
|
|
938
938
|
|
|
939
|
-
[[package]]
|
|
940
|
-
name = "r-efi"
|
|
941
|
-
version = "5.3.0"
|
|
942
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
943
|
-
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
|
944
|
-
|
|
945
939
|
[[package]]
|
|
946
940
|
name = "r-efi"
|
|
947
941
|
version = "6.0.0"
|
|
@@ -950,32 +944,20 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
|
|
950
944
|
|
|
951
945
|
[[package]]
|
|
952
946
|
name = "rand"
|
|
953
|
-
version = "0.
|
|
947
|
+
version = "0.10.3"
|
|
954
948
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
955
|
-
checksum = "
|
|
949
|
+
checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"
|
|
956
950
|
dependencies = [
|
|
957
|
-
"
|
|
958
|
-
"
|
|
959
|
-
]
|
|
960
|
-
|
|
961
|
-
[[package]]
|
|
962
|
-
name = "rand_chacha"
|
|
963
|
-
version = "0.9.0"
|
|
964
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
965
|
-
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
|
966
|
-
dependencies = [
|
|
967
|
-
"ppv-lite86",
|
|
951
|
+
"chacha20",
|
|
952
|
+
"getrandom",
|
|
968
953
|
"rand_core",
|
|
969
954
|
]
|
|
970
955
|
|
|
971
956
|
[[package]]
|
|
972
957
|
name = "rand_core"
|
|
973
|
-
version = "0.
|
|
958
|
+
version = "0.10.1"
|
|
974
959
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
975
|
-
checksum = "
|
|
976
|
-
dependencies = [
|
|
977
|
-
"getrandom 0.3.4",
|
|
978
|
-
]
|
|
960
|
+
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
|
|
979
961
|
|
|
980
962
|
[[package]]
|
|
981
963
|
name = "range-alloc"
|
|
@@ -1148,9 +1130,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|
|
1148
1130
|
|
|
1149
1131
|
[[package]]
|
|
1150
1132
|
name = "stormath"
|
|
1151
|
-
version = "0.
|
|
1133
|
+
version = "0.4.0"
|
|
1152
1134
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1153
|
-
checksum = "
|
|
1135
|
+
checksum = "fad970e17409e0e32b7cf29c1663d94c38130858ec6c4b86cdf8f26fccb4ea54"
|
|
1154
1136
|
dependencies = [
|
|
1155
1137
|
"rand",
|
|
1156
1138
|
"rayon",
|
|
@@ -1159,11 +1141,10 @@ dependencies = [
|
|
|
1159
1141
|
|
|
1160
1142
|
[[package]]
|
|
1161
1143
|
name = "stormbird"
|
|
1162
|
-
version = "0.
|
|
1144
|
+
version = "0.11.0"
|
|
1163
1145
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1164
|
-
checksum = "
|
|
1146
|
+
checksum = "53d22ec67a0ed1406b1e8b7ca8270c97bd86e278a88a9136b7fb23cff5f83566"
|
|
1165
1147
|
dependencies = [
|
|
1166
|
-
"rand",
|
|
1167
1148
|
"serde",
|
|
1168
1149
|
"serde_json",
|
|
1169
1150
|
"stormath",
|
|
@@ -1171,9 +1152,9 @@ dependencies = [
|
|
|
1171
1152
|
|
|
1172
1153
|
[[package]]
|
|
1173
1154
|
name = "stormflow"
|
|
1174
|
-
version = "0.
|
|
1155
|
+
version = "0.2.0"
|
|
1175
1156
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1176
|
-
checksum = "
|
|
1157
|
+
checksum = "dd005f180b04dd0a2d9451cbb3da8f4832c4d56c19936867e01a03c6efbc9d17"
|
|
1177
1158
|
dependencies = [
|
|
1178
1159
|
"bytemuck",
|
|
1179
1160
|
"clap",
|
|
@@ -1229,7 +1210,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
1229
1210
|
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
|
1230
1211
|
dependencies = [
|
|
1231
1212
|
"fastrand",
|
|
1232
|
-
"getrandom
|
|
1213
|
+
"getrandom",
|
|
1233
1214
|
"once_cell",
|
|
1234
1215
|
"rustix",
|
|
1235
1216
|
"windows-sys 0.61.2",
|
|
@@ -1308,15 +1289,6 @@ version = "0.9.5"
|
|
|
1308
1289
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1309
1290
|
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
|
1310
1291
|
|
|
1311
|
-
[[package]]
|
|
1312
|
-
name = "wasip2"
|
|
1313
|
-
version = "1.0.4+wasi-0.2.12"
|
|
1314
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1315
|
-
checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"
|
|
1316
|
-
dependencies = [
|
|
1317
|
-
"wit-bindgen",
|
|
1318
|
-
]
|
|
1319
|
-
|
|
1320
1292
|
[[package]]
|
|
1321
1293
|
name = "wasm-bindgen"
|
|
1322
1294
|
version = "0.2.127"
|
|
@@ -1790,12 +1762,6 @@ version = "0.52.6"
|
|
|
1790
1762
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1791
1763
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
|
1792
1764
|
|
|
1793
|
-
[[package]]
|
|
1794
|
-
name = "wit-bindgen"
|
|
1795
|
-
version = "0.57.1"
|
|
1796
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1797
|
-
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
|
|
1798
|
-
|
|
1799
1765
|
[[package]]
|
|
1800
1766
|
name = "xml-rs"
|
|
1801
1767
|
version = "0.8.29"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "pystormflow"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
authors = ["Jarle Kramer <jarle.kramer@gmail.com>"]
|
|
5
5
|
description = "Python interface to the Stormflow CFD solver."
|
|
6
6
|
homepage = "https://github.com/NTNU-IMT/stormbird"
|
|
@@ -15,9 +15,9 @@ crate-type = ["cdylib"]
|
|
|
15
15
|
|
|
16
16
|
[dependencies]
|
|
17
17
|
pyo3 = "0.29.0"
|
|
18
|
-
stormath = {version = "0.
|
|
19
|
-
stormbird = { version="0.
|
|
20
|
-
stormflow = { version="0.
|
|
18
|
+
stormath = {version = "0.4.0", features=["single_precision"]}
|
|
19
|
+
stormbird = { version="0.11.0", features=["single_precision"]}
|
|
20
|
+
stormflow = { version="0.2.0" }
|
|
21
21
|
|
|
22
22
|
[profile.release]
|
|
23
23
|
opt-level = 3
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pystormflow
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Classifier: Development Status :: 3 - Alpha
|
|
5
5
|
Classifier: Intended Audience :: Science/Research
|
|
6
6
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
@@ -24,67 +24,67 @@ Project-URL: Documentation, https://jarlekramer.github.io/stormbird_book_pages/
|
|
|
24
24
|
Project-URL: Homepage, https://github.com/NTNU-IMT/stormbird
|
|
25
25
|
Project-URL: Repository, https://github.com/NTNU-IMT/stormbird
|
|
26
26
|
|
|
27
|
-
# pystormflow
|
|
28
|
-
|
|
29
|
-
A Python interface to Stormflow, a CFD solver specialized for actuator line simulations of lifting surfaces with the Stormbird library.
|
|
30
|
-
|
|
31
|
-
## Requirements
|
|
32
|
-
|
|
33
|
-
> **⚠️ Rust Toolchain Required**
|
|
34
|
-
>
|
|
35
|
-
> This package is distributed as source only and must be compiled during installation.
|
|
36
|
-
> You **must** have the Rust toolchain installed before installing this package.
|
|
37
|
-
>
|
|
38
|
-
> **Install Rust:** Visit [https://rust-lang.org/](https://rust-lang.org/)
|
|
39
|
-
|
|
40
|
-
Stormflow can run parts of the solver on the GPU through [wgpu](https://wgpu.rs/), which requires up-to-date graphics drivers with support for Vulkan, Metal or DirectX 12.
|
|
41
|
-
|
|
42
|
-
## Installation
|
|
43
|
-
|
|
44
|
-
Once Rust is installed, install pystormflow with pip:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
pip install pystormflow
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Or install from source:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
git clone https://github.com/NTNU-IMT/stormbird.git
|
|
54
|
-
cd stormbird/interfaces/pystormflow
|
|
55
|
-
pip install .
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Use Cases
|
|
59
|
-
|
|
60
|
-
- Running actuator line simulations with Stormflow through Python scripting
|
|
61
|
-
- Post-processing of flow fields and sectional forces directly in Python
|
|
62
|
-
|
|
63
|
-
## Implementation Details
|
|
64
|
-
|
|
65
|
-
The interface is made using [PyO3](https://pyo3.rs/). A simulation is set up from a JSON string, which can be created using Python's built-in `json` module for dictionaries, or using the [stormbird_setup](https://github.com/NTNU-IMT/stormbird/tree/main/interfaces/stormbird_setup) helper package. See the [Stormflow README](https://github.com/NTNU-IMT/stormbird/tree/main/stormflow) for a description of the solver and its settings.
|
|
66
|
-
|
|
67
|
-
```python
|
|
68
|
-
from pystormflow import Simulation
|
|
69
|
-
|
|
70
|
-
with open("setup.json") as f:
|
|
71
|
-
simulation = Simulation(f.read())
|
|
72
|
-
|
|
73
|
-
simulation.do_steps_until_end_time(end_time=10.0, courant_number=0.5)
|
|
74
|
-
|
|
75
|
-
simulation.export_fields_as_vtk("fields.vtk", binary=True)
|
|
76
|
-
result = simulation.get_stormbird_simulation_result()
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Development
|
|
80
|
-
|
|
81
|
-
For a test build using cargo:
|
|
82
|
-
```bash
|
|
83
|
-
cargo build
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
To build a distributable source package:
|
|
87
|
-
```bash
|
|
88
|
-
maturin sdist
|
|
89
|
-
```
|
|
27
|
+
# pystormflow
|
|
28
|
+
|
|
29
|
+
A Python interface to Stormflow, a CFD solver specialized for actuator line simulations of lifting surfaces with the Stormbird library.
|
|
30
|
+
|
|
31
|
+
## Requirements
|
|
32
|
+
|
|
33
|
+
> **⚠️ Rust Toolchain Required**
|
|
34
|
+
>
|
|
35
|
+
> This package is distributed as source only and must be compiled during installation.
|
|
36
|
+
> You **must** have the Rust toolchain installed before installing this package.
|
|
37
|
+
>
|
|
38
|
+
> **Install Rust:** Visit [https://rust-lang.org/](https://rust-lang.org/)
|
|
39
|
+
|
|
40
|
+
Stormflow can run parts of the solver on the GPU through [wgpu](https://wgpu.rs/), which requires up-to-date graphics drivers with support for Vulkan, Metal or DirectX 12.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
Once Rust is installed, install pystormflow with pip:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install pystormflow
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or install from source:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/NTNU-IMT/stormbird.git
|
|
54
|
+
cd stormbird/interfaces/pystormflow
|
|
55
|
+
pip install .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Use Cases
|
|
59
|
+
|
|
60
|
+
- Running actuator line simulations with Stormflow through Python scripting
|
|
61
|
+
- Post-processing of flow fields and sectional forces directly in Python
|
|
62
|
+
|
|
63
|
+
## Implementation Details
|
|
64
|
+
|
|
65
|
+
The interface is made using [PyO3](https://pyo3.rs/). A simulation is set up from a JSON string, which can be created using Python's built-in `json` module for dictionaries, or using the [stormbird_setup](https://github.com/NTNU-IMT/stormbird/tree/main/interfaces/stormbird_setup) helper package. See the [Stormflow README](https://github.com/NTNU-IMT/stormbird/tree/main/stormflow) for a description of the solver and its settings.
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from pystormflow import Simulation
|
|
69
|
+
|
|
70
|
+
with open("setup.json") as f:
|
|
71
|
+
simulation = Simulation(f.read())
|
|
72
|
+
|
|
73
|
+
simulation.do_steps_until_end_time(end_time=10.0, courant_number=0.5)
|
|
74
|
+
|
|
75
|
+
simulation.export_fields_as_vtk("fields.vtk", binary=True)
|
|
76
|
+
result = simulation.get_stormbird_simulation_result()
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Development
|
|
80
|
+
|
|
81
|
+
For a test build using cargo:
|
|
82
|
+
```bash
|
|
83
|
+
cargo build
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
To build a distributable source package:
|
|
87
|
+
```bash
|
|
88
|
+
maturin sdist
|
|
89
|
+
```
|
|
90
90
|
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# pystormflow
|
|
2
|
-
|
|
3
|
-
A Python interface to Stormflow, a CFD solver specialized for actuator line simulations of lifting surfaces with the Stormbird library.
|
|
4
|
-
|
|
5
|
-
## Requirements
|
|
6
|
-
|
|
7
|
-
> **⚠️ Rust Toolchain Required**
|
|
8
|
-
>
|
|
9
|
-
> This package is distributed as source only and must be compiled during installation.
|
|
10
|
-
> You **must** have the Rust toolchain installed before installing this package.
|
|
11
|
-
>
|
|
12
|
-
> **Install Rust:** Visit [https://rust-lang.org/](https://rust-lang.org/)
|
|
13
|
-
|
|
14
|
-
Stormflow can run parts of the solver on the GPU through [wgpu](https://wgpu.rs/), which requires up-to-date graphics drivers with support for Vulkan, Metal or DirectX 12.
|
|
15
|
-
|
|
16
|
-
## Installation
|
|
17
|
-
|
|
18
|
-
Once Rust is installed, install pystormflow with pip:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
pip install pystormflow
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Or install from source:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
git clone https://github.com/NTNU-IMT/stormbird.git
|
|
28
|
-
cd stormbird/interfaces/pystormflow
|
|
29
|
-
pip install .
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Use Cases
|
|
33
|
-
|
|
34
|
-
- Running actuator line simulations with Stormflow through Python scripting
|
|
35
|
-
- Post-processing of flow fields and sectional forces directly in Python
|
|
36
|
-
|
|
37
|
-
## Implementation Details
|
|
38
|
-
|
|
39
|
-
The interface is made using [PyO3](https://pyo3.rs/). A simulation is set up from a JSON string, which can be created using Python's built-in `json` module for dictionaries, or using the [stormbird_setup](https://github.com/NTNU-IMT/stormbird/tree/main/interfaces/stormbird_setup) helper package. See the [Stormflow README](https://github.com/NTNU-IMT/stormbird/tree/main/stormflow) for a description of the solver and its settings.
|
|
40
|
-
|
|
41
|
-
```python
|
|
42
|
-
from pystormflow import Simulation
|
|
43
|
-
|
|
44
|
-
with open("setup.json") as f:
|
|
45
|
-
simulation = Simulation(f.read())
|
|
46
|
-
|
|
47
|
-
simulation.do_steps_until_end_time(end_time=10.0, courant_number=0.5)
|
|
48
|
-
|
|
49
|
-
simulation.export_fields_as_vtk("fields.vtk", binary=True)
|
|
50
|
-
result = simulation.get_stormbird_simulation_result()
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Development
|
|
54
|
-
|
|
55
|
-
For a test build using cargo:
|
|
56
|
-
```bash
|
|
57
|
-
cargo build
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
To build a distributable source package:
|
|
61
|
-
```bash
|
|
62
|
-
maturin sdist
|
|
63
|
-
```
|
|
1
|
+
# pystormflow
|
|
2
|
+
|
|
3
|
+
A Python interface to Stormflow, a CFD solver specialized for actuator line simulations of lifting surfaces with the Stormbird library.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
> **⚠️ Rust Toolchain Required**
|
|
8
|
+
>
|
|
9
|
+
> This package is distributed as source only and must be compiled during installation.
|
|
10
|
+
> You **must** have the Rust toolchain installed before installing this package.
|
|
11
|
+
>
|
|
12
|
+
> **Install Rust:** Visit [https://rust-lang.org/](https://rust-lang.org/)
|
|
13
|
+
|
|
14
|
+
Stormflow can run parts of the solver on the GPU through [wgpu](https://wgpu.rs/), which requires up-to-date graphics drivers with support for Vulkan, Metal or DirectX 12.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Once Rust is installed, install pystormflow with pip:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install pystormflow
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or install from source:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/NTNU-IMT/stormbird.git
|
|
28
|
+
cd stormbird/interfaces/pystormflow
|
|
29
|
+
pip install .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Use Cases
|
|
33
|
+
|
|
34
|
+
- Running actuator line simulations with Stormflow through Python scripting
|
|
35
|
+
- Post-processing of flow fields and sectional forces directly in Python
|
|
36
|
+
|
|
37
|
+
## Implementation Details
|
|
38
|
+
|
|
39
|
+
The interface is made using [PyO3](https://pyo3.rs/). A simulation is set up from a JSON string, which can be created using Python's built-in `json` module for dictionaries, or using the [stormbird_setup](https://github.com/NTNU-IMT/stormbird/tree/main/interfaces/stormbird_setup) helper package. See the [Stormflow README](https://github.com/NTNU-IMT/stormbird/tree/main/stormflow) for a description of the solver and its settings.
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from pystormflow import Simulation
|
|
43
|
+
|
|
44
|
+
with open("setup.json") as f:
|
|
45
|
+
simulation = Simulation(f.read())
|
|
46
|
+
|
|
47
|
+
simulation.do_steps_until_end_time(end_time=10.0, courant_number=0.5)
|
|
48
|
+
|
|
49
|
+
simulation.export_fields_as_vtk("fields.vtk", binary=True)
|
|
50
|
+
result = simulation.get_stormbird_simulation_result()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Development
|
|
54
|
+
|
|
55
|
+
For a test build using cargo:
|
|
56
|
+
```bash
|
|
57
|
+
cargo build
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
To build a distributable source package:
|
|
61
|
+
```bash
|
|
62
|
+
maturin sdist
|
|
63
|
+
```
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["maturin>=1.15,<2.0"]
|
|
3
|
-
build-backend = "maturin"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "pystormflow"
|
|
7
|
-
dynamic = ["version"]
|
|
8
|
-
description = "Python interface to Stormflow, a CFD solver specialized for actuator line simulations with Stormbird."
|
|
9
|
-
authors = [{ name = "Jarle Kramer", email = "jarle.kramer@gmail.com" }]
|
|
10
|
-
readme = "README.md"
|
|
11
|
-
license = { text = "GPL-3.0-only" }
|
|
12
|
-
requires-python = ">=3.12"
|
|
13
|
-
keywords = ["wind propulsion", "actuator line", "CFD", "aerodynamics"]
|
|
14
|
-
classifiers = [
|
|
15
|
-
"Development Status :: 3 - Alpha",
|
|
16
|
-
"Intended Audience :: Science/Research",
|
|
17
|
-
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
18
|
-
"Operating System :: OS Independent",
|
|
19
|
-
"Programming Language :: Python :: 3",
|
|
20
|
-
"Programming Language :: Python :: 3.12",
|
|
21
|
-
"Programming Language :: Python :: 3.13",
|
|
22
|
-
"Programming Language :: Python :: 3.14",
|
|
23
|
-
"Programming Language :: Rust",
|
|
24
|
-
"Programming Language :: Python :: Implementation :: CPython",
|
|
25
|
-
"Topic :: Scientific/Engineering",
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
[project.urls]
|
|
29
|
-
Homepage = "https://github.com/NTNU-IMT/stormbird"
|
|
30
|
-
Repository = "https://github.com/NTNU-IMT/stormbird"
|
|
31
|
-
Documentation = "https://jarlekramer.github.io/stormbird_book_pages/"
|
|
32
|
-
|
|
33
|
-
[tool.maturin]
|
|
34
|
-
module-name = "pystormflow._native"
|
|
35
|
-
python-source = "."
|
|
36
|
-
features = ["pyo3/extension-module"]
|
|
37
|
-
profile = "release"
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.15,<2.0"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pystormflow"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Python interface to Stormflow, a CFD solver specialized for actuator line simulations with Stormbird."
|
|
9
|
+
authors = [{ name = "Jarle Kramer", email = "jarle.kramer@gmail.com" }]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = { text = "GPL-3.0-only" }
|
|
12
|
+
requires-python = ">=3.12"
|
|
13
|
+
keywords = ["wind propulsion", "actuator line", "CFD", "aerodynamics"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Science/Research",
|
|
17
|
+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Programming Language :: Rust",
|
|
24
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
25
|
+
"Topic :: Scientific/Engineering",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://github.com/NTNU-IMT/stormbird"
|
|
30
|
+
Repository = "https://github.com/NTNU-IMT/stormbird"
|
|
31
|
+
Documentation = "https://jarlekramer.github.io/stormbird_book_pages/"
|
|
32
|
+
|
|
33
|
+
[tool.maturin]
|
|
34
|
+
module-name = "pystormflow._native"
|
|
35
|
+
python-source = "."
|
|
36
|
+
features = ["pyo3/extension-module"]
|
|
37
|
+
profile = "release"
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"""Pystormflow - Python interface to run CFD simulations with Stormflow."""
|
|
2
|
-
|
|
3
|
-
from pystormflow._native import (
|
|
4
|
-
SectionalForcesInput,
|
|
5
|
-
SectionalForces,
|
|
6
|
-
IntegratedValues,
|
|
7
|
-
SimulationResult,
|
|
8
|
-
Simulation,
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
__all__ = [
|
|
12
|
-
"SectionalForcesInput",
|
|
13
|
-
"SectionalForces",
|
|
14
|
-
"IntegratedValues",
|
|
15
|
-
"SimulationResult",
|
|
16
|
-
"Simulation",
|
|
17
|
-
]
|
|
1
|
+
"""Pystormflow - Python interface to run CFD simulations with Stormflow."""
|
|
2
|
+
|
|
3
|
+
from pystormflow._native import (
|
|
4
|
+
SectionalForcesInput,
|
|
5
|
+
SectionalForces,
|
|
6
|
+
IntegratedValues,
|
|
7
|
+
SimulationResult,
|
|
8
|
+
Simulation,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"SectionalForcesInput",
|
|
13
|
+
"SectionalForces",
|
|
14
|
+
"IntegratedValues",
|
|
15
|
+
"SimulationResult",
|
|
16
|
+
"Simulation",
|
|
17
|
+
]
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
"""Type stubs for pystormflow."""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class SectionalForcesInput:
|
|
5
|
-
@property
|
|
6
|
-
def circulation_strength(self) -> list[float]: ...
|
|
7
|
-
@property
|
|
8
|
-
def velocity(self) -> list[list[float]]: ...
|
|
9
|
-
@property
|
|
10
|
-
def angles_of_attack(self) -> list[float]: ...
|
|
11
|
-
@property
|
|
12
|
-
def acceleration(self) -> list[list[float]]: ...
|
|
13
|
-
@property
|
|
14
|
-
def rotation_velocity(self) -> list[float]: ...
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class SectionalForces:
|
|
18
|
-
@property
|
|
19
|
-
def circulatory(self) -> list[list[float]]: ...
|
|
20
|
-
@property
|
|
21
|
-
def sectional_drag(self) -> list[list[float]]: ...
|
|
22
|
-
@property
|
|
23
|
-
def added_mass(self) -> list[list[float]]: ...
|
|
24
|
-
@property
|
|
25
|
-
def
|
|
26
|
-
@property
|
|
27
|
-
def total(self) -> list[list[float]]: ...
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class IntegratedValues:
|
|
31
|
-
@property
|
|
32
|
-
def circulatory(self) -> list[float]: ...
|
|
33
|
-
@property
|
|
34
|
-
def sectional_drag(self) -> list[float]: ...
|
|
35
|
-
@property
|
|
36
|
-
def added_mass(self) -> list[float]: ...
|
|
37
|
-
@property
|
|
38
|
-
def gyroscopic(self) -> list[float]: ...
|
|
39
|
-
@property
|
|
40
|
-
def total(self) -> list[float]: ...
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class SimulationResult:
|
|
44
|
-
@classmethod
|
|
45
|
-
def from_json_file(cls, file_path: str) -> "SimulationResult": ...
|
|
46
|
-
@classmethod
|
|
47
|
-
def result_history_from_file(cls, file_path: str) -> list["SimulationResult"]: ...
|
|
48
|
-
|
|
49
|
-
@property
|
|
50
|
-
def ctrl_points(self) -> list[list[float]]: ...
|
|
51
|
-
@property
|
|
52
|
-
def force_input(self) -> SectionalForcesInput: ...
|
|
53
|
-
@property
|
|
54
|
-
def sectional_forces(self) -> SectionalForces: ...
|
|
55
|
-
@property
|
|
56
|
-
def integrated_forces(self) -> list[IntegratedValues]: ...
|
|
57
|
-
@property
|
|
58
|
-
def integrated_moments(self) -> list[IntegratedValues]: ...
|
|
59
|
-
@property
|
|
60
|
-
def input_power(self) -> list[float]: ...
|
|
61
|
-
@property
|
|
62
|
-
def iterations(self) -> int: ...
|
|
63
|
-
@property
|
|
64
|
-
def residual(self) -> float: ...
|
|
65
|
-
@property
|
|
66
|
-
def wing_indices(self) -> list[list[int]]: ...
|
|
67
|
-
|
|
68
|
-
def integrated_forces_sum(self) -> list[float]: ...
|
|
69
|
-
def integrated_moments_sum(self) -> list[float]: ...
|
|
70
|
-
def input_power_sum(self) -> float: ...
|
|
71
|
-
def write_to_file(self, file_path: str) -> None: ...
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
class Simulation:
|
|
75
|
-
def __init__(self, setup_string: str) -> None: ...
|
|
76
|
-
|
|
77
|
-
def time_step_from_courant_number(self, courant_number: float) -> float: ...
|
|
78
|
-
def do_step(self, time: float, time_step: float) -> None: ...
|
|
79
|
-
def nr_limited_velocity_values(self) -> int:
|
|
80
|
-
"""
|
|
81
|
-
The number of velocity components that were clipped by the velocity limiter during the
|
|
82
|
-
last time step, summed over all the inner iterations. Always zero if the limiter is not
|
|
83
|
-
used (see `max_velocity_factor` in the velocity solver settings).
|
|
84
|
-
"""
|
|
85
|
-
...
|
|
86
|
-
def do_steps_until_end_time(self, end_time: float, courant_number: float) -> None: ...
|
|
87
|
-
def export_fields_as_vtk(self, file_path: str, binary: bool) -> None: ...
|
|
88
|
-
def fields_as_vtk(self, binary: bool) -> bytes: ...
|
|
89
|
-
def get_stormbird_simulation_result(self) -> SimulationResult | None: ...
|
|
1
|
+
"""Type stubs for pystormflow."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SectionalForcesInput:
|
|
5
|
+
@property
|
|
6
|
+
def circulation_strength(self) -> list[float]: ...
|
|
7
|
+
@property
|
|
8
|
+
def velocity(self) -> list[list[float]]: ...
|
|
9
|
+
@property
|
|
10
|
+
def angles_of_attack(self) -> list[float]: ...
|
|
11
|
+
@property
|
|
12
|
+
def acceleration(self) -> list[list[float]]: ...
|
|
13
|
+
@property
|
|
14
|
+
def rotation_velocity(self) -> list[float]: ...
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SectionalForces:
|
|
18
|
+
@property
|
|
19
|
+
def circulatory(self) -> list[list[float]]: ...
|
|
20
|
+
@property
|
|
21
|
+
def sectional_drag(self) -> list[list[float]]: ...
|
|
22
|
+
@property
|
|
23
|
+
def added_mass(self) -> list[list[float]]: ...
|
|
24
|
+
@property
|
|
25
|
+
def gyroscopic_moment(self) -> list[list[float]]: ...
|
|
26
|
+
@property
|
|
27
|
+
def total(self) -> list[list[float]]: ...
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class IntegratedValues:
|
|
31
|
+
@property
|
|
32
|
+
def circulatory(self) -> list[float]: ...
|
|
33
|
+
@property
|
|
34
|
+
def sectional_drag(self) -> list[float]: ...
|
|
35
|
+
@property
|
|
36
|
+
def added_mass(self) -> list[float]: ...
|
|
37
|
+
@property
|
|
38
|
+
def gyroscopic(self) -> list[float]: ...
|
|
39
|
+
@property
|
|
40
|
+
def total(self) -> list[float]: ...
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class SimulationResult:
|
|
44
|
+
@classmethod
|
|
45
|
+
def from_json_file(cls, file_path: str) -> "SimulationResult": ...
|
|
46
|
+
@classmethod
|
|
47
|
+
def result_history_from_file(cls, file_path: str) -> list["SimulationResult"]: ...
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def ctrl_points(self) -> list[list[float]]: ...
|
|
51
|
+
@property
|
|
52
|
+
def force_input(self) -> SectionalForcesInput: ...
|
|
53
|
+
@property
|
|
54
|
+
def sectional_forces(self) -> SectionalForces: ...
|
|
55
|
+
@property
|
|
56
|
+
def integrated_forces(self) -> list[IntegratedValues]: ...
|
|
57
|
+
@property
|
|
58
|
+
def integrated_moments(self) -> list[IntegratedValues]: ...
|
|
59
|
+
@property
|
|
60
|
+
def input_power(self) -> list[float]: ...
|
|
61
|
+
@property
|
|
62
|
+
def iterations(self) -> int: ...
|
|
63
|
+
@property
|
|
64
|
+
def residual(self) -> float: ...
|
|
65
|
+
@property
|
|
66
|
+
def wing_indices(self) -> list[list[int]]: ...
|
|
67
|
+
|
|
68
|
+
def integrated_forces_sum(self) -> list[float]: ...
|
|
69
|
+
def integrated_moments_sum(self) -> list[float]: ...
|
|
70
|
+
def input_power_sum(self) -> float: ...
|
|
71
|
+
def write_to_file(self, file_path: str) -> None: ...
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class Simulation:
|
|
75
|
+
def __init__(self, setup_string: str) -> None: ...
|
|
76
|
+
|
|
77
|
+
def time_step_from_courant_number(self, courant_number: float) -> float: ...
|
|
78
|
+
def do_step(self, time: float, time_step: float) -> None: ...
|
|
79
|
+
def nr_limited_velocity_values(self) -> int:
|
|
80
|
+
"""
|
|
81
|
+
The number of velocity components that were clipped by the velocity limiter during the
|
|
82
|
+
last time step, summed over all the inner iterations. Always zero if the limiter is not
|
|
83
|
+
used (see `max_velocity_factor` in the velocity solver settings).
|
|
84
|
+
"""
|
|
85
|
+
...
|
|
86
|
+
def do_steps_until_end_time(self, end_time: float, courant_number: float) -> None: ...
|
|
87
|
+
def export_fields_as_vtk(self, file_path: str, binary: bool) -> None: ...
|
|
88
|
+
def fields_as_vtk(self, binary: bool) -> bytes: ...
|
|
89
|
+
def get_stormbird_simulation_result(self) -> SimulationResult | None: ...
|
|
@@ -70,8 +70,8 @@ impl SectionalForces {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
#[getter]
|
|
73
|
-
pub fn
|
|
74
|
-
self.data.
|
|
73
|
+
pub fn gyroscopic_moment(&self) -> Vec<[Float; 3]> {
|
|
74
|
+
self.data.gyroscopic_moment.iter().map(|v| v.0).collect()
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
#[getter]
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
use pyo3::prelude::*;
|
|
3
|
-
use pyo3::types::PyBytes;
|
|
4
|
-
|
|
5
|
-
use stormath::type_aliases::Float;
|
|
6
|
-
use stormflow::simulation::Simulation as SimulationRust;
|
|
7
|
-
|
|
8
|
-
use crate::result_structs::SimulationResult;
|
|
9
|
-
|
|
10
|
-
#[pyclass]
|
|
11
|
-
pub struct Simulation {
|
|
12
|
-
data: SimulationRust
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
#[pymethods]
|
|
16
|
-
impl Simulation {
|
|
17
|
-
#[new]
|
|
18
|
-
pub fn new(setup_string: String) -> Self {
|
|
19
|
-
Self {
|
|
20
|
-
data: SimulationRust::new_from_string(&setup_string).unwrap()
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
pub fn time_step_from_courant_number(&self, courant_number: Float) -> Float {
|
|
25
|
-
self.data.time_step_from_courant_number(courant_number)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
pub fn do_step(&mut self, time: Float, time_step: Float) {
|
|
29
|
-
self.data.do_step(time, time_step);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/// The number of velocity components that were clipped by the velocity limiter during the
|
|
33
|
-
/// last time step, summed over all the inner iterations. Always zero if the limiter is not
|
|
34
|
-
/// used (see `max_velocity_factor` in the velocity solver settings).
|
|
35
|
-
pub fn nr_limited_velocity_values(&self) -> usize {
|
|
36
|
-
self.data.nr_limited_velocity_values()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
pub fn do_steps_until_end_time(&mut self, end_time: Float, courant_number: Float) {
|
|
40
|
-
self.data.do_steps_until_end_time(end_time, courant_number);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
pub fn export_fields_as_vtk(&self, file_path: String, binary: bool) {
|
|
44
|
-
self.data.export_fields_as_vtk(&file_path, binary);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/// Return the VTK legacy file content for the current fields as raw bytes,
|
|
48
|
-
/// without touching the disk.
|
|
49
|
-
///
|
|
50
|
-
/// The `binary` switch selects between the ASCII and BINARY variants of the
|
|
51
|
-
/// VTK legacy format. The returned `bytes` can be fed straight into a VTK
|
|
52
|
-
/// reader to build a mesh in memory, e.g. with pyvista:
|
|
53
|
-
///
|
|
54
|
-
/// import vtk
|
|
55
|
-
/// import pyvista as pv
|
|
56
|
-
///
|
|
57
|
-
/// data = simulation.fields_as_vtk(binary=True)
|
|
58
|
-
///
|
|
59
|
-
/// reader = vtk.vtkStructuredGridReader()
|
|
60
|
-
/// reader.ReadFromInputStringOn()
|
|
61
|
-
/// reader.SetBinaryInputString(data, len(data)) # use SetInputString for ASCII
|
|
62
|
-
/// reader.ReadAllScalarsOn()
|
|
63
|
-
/// reader.ReadAllVectorsOn()
|
|
64
|
-
/// reader.Update()
|
|
65
|
-
///
|
|
66
|
-
/// grid = pv.wrap(reader.GetOutput())
|
|
67
|
-
pub fn fields_as_vtk<'py>(&self, py: Python<'py>, binary: bool) -> Bound<'py, PyBytes> {
|
|
68
|
-
let content = self.data.fields_as_vtk(binary);
|
|
69
|
-
PyBytes::new(py, &content)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
pub fn get_stormbird_simulation_result(&self) -> Option<SimulationResult> {
|
|
73
|
-
if let Some(actuator_line) = &self.data.actuator_line {
|
|
74
|
-
if let Some(result) = &actuator_line.model.simulation_result {
|
|
75
|
-
Some(
|
|
76
|
-
SimulationResult{
|
|
77
|
-
data: result.clone()
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
} else {
|
|
81
|
-
None
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
None
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
|
|
2
|
+
use pyo3::prelude::*;
|
|
3
|
+
use pyo3::types::PyBytes;
|
|
4
|
+
|
|
5
|
+
use stormath::type_aliases::Float;
|
|
6
|
+
use stormflow::simulation::Simulation as SimulationRust;
|
|
7
|
+
|
|
8
|
+
use crate::result_structs::SimulationResult;
|
|
9
|
+
|
|
10
|
+
#[pyclass]
|
|
11
|
+
pub struct Simulation {
|
|
12
|
+
data: SimulationRust
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#[pymethods]
|
|
16
|
+
impl Simulation {
|
|
17
|
+
#[new]
|
|
18
|
+
pub fn new(setup_string: String) -> Self {
|
|
19
|
+
Self {
|
|
20
|
+
data: SimulationRust::new_from_string(&setup_string).unwrap()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
pub fn time_step_from_courant_number(&self, courant_number: Float) -> Float {
|
|
25
|
+
self.data.time_step_from_courant_number(courant_number)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
pub fn do_step(&mut self, time: Float, time_step: Float) {
|
|
29
|
+
self.data.do_step(time, time_step);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/// The number of velocity components that were clipped by the velocity limiter during the
|
|
33
|
+
/// last time step, summed over all the inner iterations. Always zero if the limiter is not
|
|
34
|
+
/// used (see `max_velocity_factor` in the velocity solver settings).
|
|
35
|
+
pub fn nr_limited_velocity_values(&self) -> usize {
|
|
36
|
+
self.data.nr_limited_velocity_values()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
pub fn do_steps_until_end_time(&mut self, end_time: Float, courant_number: Float) {
|
|
40
|
+
self.data.do_steps_until_end_time(end_time, courant_number);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
pub fn export_fields_as_vtk(&self, file_path: String, binary: bool) {
|
|
44
|
+
self.data.export_fields_as_vtk(&file_path, binary);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// Return the VTK legacy file content for the current fields as raw bytes,
|
|
48
|
+
/// without touching the disk.
|
|
49
|
+
///
|
|
50
|
+
/// The `binary` switch selects between the ASCII and BINARY variants of the
|
|
51
|
+
/// VTK legacy format. The returned `bytes` can be fed straight into a VTK
|
|
52
|
+
/// reader to build a mesh in memory, e.g. with pyvista:
|
|
53
|
+
///
|
|
54
|
+
/// import vtk
|
|
55
|
+
/// import pyvista as pv
|
|
56
|
+
///
|
|
57
|
+
/// data = simulation.fields_as_vtk(binary=True)
|
|
58
|
+
///
|
|
59
|
+
/// reader = vtk.vtkStructuredGridReader()
|
|
60
|
+
/// reader.ReadFromInputStringOn()
|
|
61
|
+
/// reader.SetBinaryInputString(data, len(data)) # use SetInputString for ASCII
|
|
62
|
+
/// reader.ReadAllScalarsOn()
|
|
63
|
+
/// reader.ReadAllVectorsOn()
|
|
64
|
+
/// reader.Update()
|
|
65
|
+
///
|
|
66
|
+
/// grid = pv.wrap(reader.GetOutput())
|
|
67
|
+
pub fn fields_as_vtk<'py>(&self, py: Python<'py>, binary: bool) -> Bound<'py, PyBytes> {
|
|
68
|
+
let content = self.data.fields_as_vtk(binary);
|
|
69
|
+
PyBytes::new(py, &content)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
pub fn get_stormbird_simulation_result(&self) -> Option<SimulationResult> {
|
|
73
|
+
if let Some(actuator_line) = &self.data.actuator_line {
|
|
74
|
+
if let Some(result) = &actuator_line.model.simulation_result {
|
|
75
|
+
Some(
|
|
76
|
+
SimulationResult{
|
|
77
|
+
data: result.clone()
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
} else {
|
|
81
|
+
None
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
None
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
87
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|