Skip to main content

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.

原始的 MATLAB/Simulink 模型

安装

从源码构建

确保你已经安装了 Rust, CMake 和 Python 3.10 及以上版本。

使用 uv 进行构建

  1. 克隆仓库:

    git clone https://github.com/WindLX/pyf16.git
    cd pyf16
    
  2. 运行测试用例:

    uv run examples/example1.py
    

不使用 uv 进行构建

  1. 克隆仓库:

    git clone https://github.com/WindLX/pyf16.git
    cd pyf16
    
  2. 使用 maturin 构建并安装:

    python -m venv .venv
    source ./.venv/bin/activate
    pip install maturin
    maturin develop
    
  3. (可选)手动构建 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_modelAerodynamicModelinstall 方法的 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

许可证

Release files for pyf16 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pyf16 0.1.1
File Interpreter ABI Platform
pyf16-0.1.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
pyf16-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details

Total release size: 1.2 MB

Release files / pyf16-0.1.1-cp39-abi3-win_amd64.whl

Download URL pyf16-0.1.1-cp39-abi3-win_amd64.whl
Size 484.7 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2d3e1d24e4a072063f5c007a1b9e8273bcd505bcb8f6cb97701830456c4c459f
BLAKE2b-256 checksum
How to use checksums
352be35fa64f2ca57fa0d4c081854fbae15ed3e68fc4fbb5450e36dfb58dd3d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.29

Release files / pyf16-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyf16-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 677.9 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
465576ae0cc7419c573bce44adba1006d4866a16b1206c99b6700c145f74569a
BLAKE2b-256 checksum
How to use checksums
a2b5b513d89f2df74bba0e6c4bfb0d315a102b5777d29e51f386412ad15fc08c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.9

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page