9 Star 46 Fork 4

Junruoyu-Zheng / Ligral

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Ligral

LOGO

Ligral是一个基于文本的仿真语言,旨在替代 Simulink 进行仿真,通过与框图等效的文本语言描述仿真对象,并解释/编译而后求解。

star

安装

目前发布了v0.2.2 预览版,您也可以克隆本项目到本地编译。

git clone https://gitee.com/junruoyu-zheng/ligral.git
cd ligral
dotnet build
./bin/Debug/netcoreapp3.1/ligral

详细安装方法请参考快速开始

使用

运行仿真工程需要给出仿真工程文件作为第一个位置参数,该命令支持以下参数:

参数 作用
[ProjectFileName] 仿真工程文件,一般是.lig.lig.json文件
-s, --step-size [StepSize] 设置仿真步长,仅在定步长求解器中生效
-t, --stop-time [StopTime] 设置仿真时长
-j, --json [bool]? 指定输入.lig.json文件,默认为输入.lig文件
-o, --output [Folder] 仿真输出重定向至给定文件夹

Ligral 目前支持的命令包括doctrimlinexm,可以通过ligral [command] --help查看使用说明。

依赖

如果启用内部绘图工具(InnerPlotter),绘图模块ScopePhaseDiagram需要 python 3 支持,且需要numpy、matplotlib、pandas包。

示例

以下是一个弹簧阻尼质量块系统的仿真(代码)。

# 定义一个路由 MassSpringDamper
route MassSpringDamper(m, k, d, x0, v0; F; x, v)
    F-k*x-d*v -> Gain{value:1/m} -> Integrator{initial:v0} -> v;
    v -> Integrator{initial:x0} -> x;
end

# 定义一个 Step 信号
Step[F]{start:3, level:5};

# 实例化一个 MassSpringDamper 对象
MassSpringDamper[sys]{m:0.1, k:10, d:0.3, x0:1, v0: 0};

# 连接模块
F -> sys;
sys:x[position] -> Scope;
(sys:x, sys:v[velocity]) -> PhaseDiagram;

# 设置定步长仿真配置参数
conf step_size = 0.001;
conf stop_time = 10;

# 设置输出文件夹
conf output_folder = 'out';

plots!!

更多例子参见examples

语法

语法参见用户指引,目前已编写完成的文档如下:

开发

目前开发文档还在努力编撰中。

如有 bug 反馈或其他建议,请提交 issue

开发计划:

  • 增加单元测试
  • 增加科学计算语法,进行仿真前处理、后处理
  • 统一数据格式为矩阵
  • 修复 bugs
  • ...
MIT License Copyright (C) 2019-2021 Junruoyu Zheng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Ligral是一个基于文本的仿真语言,旨在替代 Simulink 进行仿真,通过与框图等效的文本语言描述仿真对象,并解释/编译而后求解。 展开 收起
MIT
取消

发行版 (5)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/junruoyu-zheng/ligral.git
git@gitee.com:junruoyu-zheng/ligral.git
junruoyu-zheng
ligral
Ligral
dev

搜索帮助