A Python package for F-16 aircraft simulation.
Project description
pyf16
pyf16 是一个用于模拟 F-16 飞机动力学的 Python 库。
The aerodynamics included in this model come from the NASA Technical Report 1538, Simulator Study of Stall/Post-Stall Characteristics of a Fighter Airplane with Relaxed Longitudinal Static Stability, by Nguyen, Ogburn, Gilbert, Kibler, Brown, and Deal, Dec 1979. The model is based on Aircraft Control and Simulations, by Brian Stevens and Frank Lewis, Wiley Inter-Science, New York, 1992.
安装
从源码构建
确保你已经安装了 Rust, CMake 和 Python 3.10 及以上版本。
使用 uv 进行构建
-
克隆仓库:
git clone https://github.com/WindLX/pyf16.git cd pyf16
-
运行测试用例:
uv run examples/example1.py
不使用 uv 进行构建
-
克隆仓库:
git clone https://github.com/WindLX/pyf16.git cd pyf16
-
使用
maturin构建并安装:python -m venv .venv source ./.venv/bin/activate pip install maturin maturin develop
-
(可选)手动构建 f16_model: 这一过程会由 cargo 的构建脚本
build.rs自动完成,你也可以尝试手动编译气动模型。rm -rf build cd f16_model mkdir build cd build cmake .. make install
在 f16_model 目录下会生成一个 install 文件夹,其中的 f16_model 文件夹为后续加载模型所需的目录。例如:
pyf16.AerodynamicModel(path: str)的path参数需要指向该目录,即/path/to/f16_model,AerodynamicModel的install方法的path参数需要指向该目录下的data目录,即/path/to/f16_model/data。
使用示例
以下是一个简单的使用示例,展示了如何加载气动模型、安装模型、加载控制限制、进行配平计算并创建飞机对象:
import pyf16
aero_model = pyf16.AerodynamicModel("/path/to/f16_model")
aero_model.install("/path/to/f16_model/data")
control_limits = aero_model.load_ctrl_limits()
trim_target = pyf16.TrimTarget(15000, 500, None, None)
trim_init = None
trim_result = pyf16.trim(aero_model, trim_target, control_limits, trim_init).to_core_init()
f16 = pyf16.PlaneBlock(
pyf16.SolverType.RK4,
0.01,
aero_model,
trim_result.to_core_init(),
[0, 0, 0],
control_limits,
)
core_output = f16.update(
pyf16.Control(thrust=100, elevator=0, aileron=0, rudder=0), 0.1
)
print(core_output.state.to_list())
f16.delete_model()
aero_model.uninstall()
API
见 API 文档
TODO
- 更详细的文档
- 可变的 ODE 求解器
LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyf16-0.1.1-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: pyf16-0.1.1-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 484.7 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d3e1d24e4a072063f5c007a1b9e8273bcd505bcb8f6cb97701830456c4c459f
|
|
| MD5 |
f39f7b0d8fc61159da0c98c5617a3da7
|
|
| BLAKE2b-256 |
352be35fa64f2ca57fa0d4c081854fbae15ed3e68fc4fbb5450e36dfb58dd3d8
|
File details
Details for the file pyf16-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyf16-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 677.9 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
465576ae0cc7419c573bce44adba1006d4866a16b1206c99b6700c145f74569a
|
|
| MD5 |
0a6675275cf5faa98db94cee8a945a98
|
|
| BLAKE2b-256 |
a2b5b513d89f2df74bba0e6c4bfb0d315a102b5777d29e51f386412ad15fc08c
|